diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2012-10-12 21:23:29 +0200 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2012-10-12 21:23:29 +0200 |
commit | 4d6c6cc6e65fdfb2f6ed4a66c062bbf7b1706f0b (patch) | |
tree | 3fd6c8807566538469fb0858543c0a8cd64b2f05 /audio_hw.c | |
parent | 005fa70b060726b5b3cac22a4cf8adbe45281104 (diff) | |
download | hardware_tinyalsa-audio-4d6c6cc6e65fdfb2f6ed4a66c062bbf7b1706f0b.zip hardware_tinyalsa-audio-4d6c6cc6e65fdfb2f6ed4a66c062bbf7b1706f0b.tar.gz hardware_tinyalsa-audio-4d6c6cc6e65fdfb2f6ed4a66c062bbf7b1706f0b.tar.bz2 |
Mixer: Initial commit, implements controls handling
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
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; |