1 /* acoustics_default.cpp
3 ** Copyright 2009 Wind River Systems
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
9 ** http://www.apache.org/licenses/LICENSE-2.0
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.
18 #define LOG_TAG "AcousticsModule"
19 #include <utils/Log.h>
21 #include "AudioHardwareALSA.h"
26 static int s_device_open(const hw_module_t*, const char*, hw_device_t**);
27 static int s_device_close(hw_device_t*);
29 static status_t s_use_handle(acoustic_device_t *, alsa_handle_t *);
30 static status_t s_cleanup(acoustic_device_t *);
31 static status_t s_set_params(acoustic_device_t *,
32 AudioSystem::audio_in_acoustics, void *params);
34 static hw_module_methods_t s_module_methods = {
38 extern "C" const hw_module_t HAL_MODULE_INFO_SYM = {
39 tag : HARDWARE_MODULE_TAG,
42 id : ACOUSTICS_HARDWARE_MODULE_ID,
43 name : "ALSA acoustics module",
44 author : "Wind River",
45 methods : &s_module_methods,
50 static int s_device_open(const hw_module_t* module, const char* name,
53 acoustic_device_t *dev;
54 dev = (acoustic_device_t *) malloc(sizeof(*dev));
55 if (!dev) return -ENOMEM;
57 memset(dev, 0, sizeof(*dev));
59 /* initialize the procs */
60 dev->common.tag = HARDWARE_DEVICE_TAG;
61 dev->common.version = 0;
62 dev->common.module = (hw_module_t *) module;
63 dev->common.close = s_device_close;
65 // Required methods...
66 dev->use_handle = s_use_handle;
67 dev->cleanup = s_cleanup;
68 dev->set_params = s_set_params;
70 // read, write, and recover are optional methods...
72 *device = &dev->common;
76 static int s_device_close(hw_device_t* device)
82 static status_t s_use_handle(acoustic_device_t *dev, alsa_handle_t *h)
87 static status_t s_cleanup(acoustic_device_t *dev)
89 LOGD("Acoustics close stub called.");
93 static status_t s_set_params(acoustic_device_t *dev,
94 AudioSystem::audio_in_acoustics acoustics, void *params)
96 LOGD("Acoustics set_params stub called with %d.", (int)acoustics);