diff options
Diffstat (limited to 'audio_hw.c')
-rw-r--r-- | audio_hw.c | 31 |
1 files changed, 28 insertions, 3 deletions
@@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define LOG_TAG "audio_hw" +#define LOG_TAG "TinyALSA-Audio Hardware" #include <errno.h> #include <pthread.h> @@ -28,6 +28,7 @@ #include <cutils/log.h> #include "audio_hw.h" +#include "mixer.h" /* * Functions @@ -141,10 +142,20 @@ static int audio_hw_dump(const audio_hw_device_t *device, int fd) int audio_hw_close(hw_device_t *device) { + struct tinyalsa_audio_device *tinyalsa_audio_device; + LOGD("%s(%p)", __func__, device); - if(device != NULL) + if(device != NULL) { + tinyalsa_audio_device = (struct tinyalsa_audio_device *) device; + + if(tinyalsa_audio_device != NULL && tinyalsa_audio_device->mixer != NULL) { + tinyalsa_mixer_close(tinyalsa_audio_device->mixer); + tinyalsa_audio_device->mixer = NULL; + } + free(device); + } return 0; } @@ -152,8 +163,10 @@ int audio_hw_close(hw_device_t *device) int audio_hw_open(const hw_module_t *module, const char *name, hw_device_t **device) { - struct tinyalsa_audio_device *tinyalsa_audio_device; + struct tinyalsa_audio_device *tinyalsa_audio_device = NULL; + struct tinyalsa_mixer *tinyalsa_mixer = NULL; struct audio_hw_device *dev; + int rc; LOGD("%s(%p, %s, %p)", __func__, module, name, device); @@ -190,6 +203,18 @@ int audio_hw_open(const hw_module_t *module, const char *name, dev->dump = audio_hw_dump; + tinyalsa_mixer_open(&tinyalsa_mixer, TINYALSA_MIXER_CONFIG_FILE); + if(tinyalsa_mixer == NULL) { + LOGE("Failed to open mixer!"); + } else { + rc = tinyalsa_mixer_set_route(tinyalsa_mixer, AUDIO_DEVICE_OUT_DEFAULT, AUDIO_MODE_NORMAL); + if(rc < 0) { + LOGE("Failed to set default mixer route"); + } + } + + tinyalsa_audio_device->mixer = tinyalsa_mixer; + *device = &(dev->common); return 0; |