OSDN Git Service

Updates to add acoustics plugin and move lock to parent class.
[android-x86/hardware-alsa_sound.git] / acoustics_default.cpp
1
2 #define LOG_TAG "AudioHardwareALSA"
3 #include <utils/Log.h>
4
5 #include "AudioHardwareALSA.h"
6
7 namespace android
8 {
9     static int s_device_open(const hw_module_t*, const char*, hw_device_t**);
10     static int s_device_close (hw_device_t*);
11     static status_t s_set_acoustics (snd_pcm_t *, AudioSystem::audio_in_acoustics);
12     static ssize_t s_filter (snd_pcm_t *, void *, ssize_t);
13
14     static hw_module_methods_t s_module_methods = {
15         open: s_device_open
16     };
17
18     extern "C" const hw_module_t HAL_MODULE_INFO_SYM = {
19             tag: HARDWARE_MODULE_TAG,
20             version_major: 1,
21             version_minor: 0,
22             id: ACOUSTICS_HARDWARE_MODULE_ID,
23             name: "ALSA acoustics module",
24             author: "Wind River",
25             methods: &s_module_methods,
26             reserved: {}
27     };
28
29     static int s_device_open(const hw_module_t* module,
30                              const char* name,
31                              hw_device_t** device)
32     {
33         acoustic_device_t *dev;
34         dev = (acoustic_device_t *)malloc(sizeof(*dev));
35         if (! dev) return -ENOMEM;
36
37         memset(dev, 0, sizeof(*dev));
38
39         /* initialize the procs */
40         dev->common.tag = HARDWARE_DEVICE_TAG;
41         dev->common.version = 0;
42         dev->common.module = (hw_module_t *)module;
43         dev->common.close = s_device_close;
44         dev->set_acoustics = s_set_acoustics;
45         dev->filter = s_filter;
46
47         *device = &dev->common;
48         return 0;
49     }
50
51     static int s_device_close (hw_device_t* device)
52     {
53         free(device);
54         return 0;
55     }
56
57     static status_t s_set_acoustics (snd_pcm_t *handle, AudioSystem::audio_in_acoustics acoustics)
58     {
59         LOGD("Acoustics set_acoustics stub called with %d.", (int)acoustics);
60         return NO_ERROR;
61     }
62
63     static ssize_t s_filter (snd_pcm_t *handle, void *buffer, ssize_t frames)
64     {
65         // Default acoustics doesn't apply any filtering
66         return frames;
67     }
68 }