OSDN Git Service

change libasound to be a shared library
[android-x86/hardware-alsa_sound.git] / acoustics_default.cpp
1 /* acoustics_default.cpp
2  **
3  ** Copyright 2009 Wind River Systems
4  **
5  ** Licensed under the Apache License, Version 2.0 (the "License");
6  ** you may not use this file except in compliance with the License.
7  ** You may obtain a copy of the License at
8  **
9  **     http://www.apache.org/licenses/LICENSE-2.0
10  **
11  ** Unless required by applicable law or agreed to in writing, software
12  ** distributed under the License is distributed on an "AS IS" BASIS,
13  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  ** See the License for the specific language governing permissions and
15  ** limitations under the License.
16  */
17
18
19 #define LOG_TAG "AudioHardwareALSA"
20 #include <utils/Log.h>
21
22 #include "AudioHardwareALSA.h"
23
24 namespace android
25 {
26     static int s_device_open(const hw_module_t*, const char*, hw_device_t**);
27     static int s_device_close (hw_device_t*);
28     static status_t s_set_acoustics (snd_pcm_t *, AudioSystem::audio_in_acoustics);
29     static ssize_t s_filter (snd_pcm_t *, void *, ssize_t);
30
31     static hw_module_methods_t s_module_methods = {
32         open: s_device_open
33     };
34
35     extern "C" const hw_module_t HAL_MODULE_INFO_SYM = {
36             tag: HARDWARE_MODULE_TAG,
37             version_major: 1,
38             version_minor: 0,
39             id: ACOUSTICS_HARDWARE_MODULE_ID,
40             name: "ALSA acoustics module",
41             author: "Wind River",
42             methods: &s_module_methods,
43             reserved: {}
44     };
45
46     static int s_device_open(const hw_module_t* module,
47                              const char* name,
48                              hw_device_t** device)
49     {
50         acoustic_device_t *dev;
51         dev = (acoustic_device_t *)malloc(sizeof(*dev));
52         if (! dev) return -ENOMEM;
53
54         memset(dev, 0, sizeof(*dev));
55
56         /* initialize the procs */
57         dev->common.tag = HARDWARE_DEVICE_TAG;
58         dev->common.version = 0;
59         dev->common.module = (hw_module_t *)module;
60         dev->common.close = s_device_close;
61         dev->set_acoustics = s_set_acoustics;
62         dev->filter = s_filter;
63
64         *device = &dev->common;
65         return 0;
66     }
67
68     static int s_device_close (hw_device_t* device)
69     {
70         free(device);
71         return 0;
72     }
73
74     static status_t s_set_acoustics (snd_pcm_t *handle, AudioSystem::audio_in_acoustics acoustics)
75     {
76         LOGD("Acoustics set_acoustics stub called with %d.", (int)acoustics);
77         return NO_ERROR;
78     }
79
80     static ssize_t s_filter (snd_pcm_t *handle, void *buffer, ssize_t frames)
81     {
82         // Default acoustics doesn't apply any filtering
83         return frames;
84     }
85 }