summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2012-10-13 10:50:09 +0200
committerPaul Kocialkowski <contact@paulk.fr>2012-10-13 10:50:09 +0200
commit5c413b14dd589b5d4f8e7f3ec088743988cc9e99 (patch)
tree2bb39b824c2e534d9c9adaa0ba2fcde3dab5310a
parent7656237bb6e6fe676a318e491c60a2337446c722 (diff)
downloadhardware_tinyalsa-audio-5c413b14dd589b5d4f8e7f3ec088743988cc9e99.zip
hardware_tinyalsa-audio-5c413b14dd589b5d4f8e7f3ec088743988cc9e99.tar.gz
hardware_tinyalsa-audio-5c413b14dd589b5d4f8e7f3ec088743988cc9e99.tar.bz2
Init check: check that mixer was correctly started
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--audio_hw.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/audio_hw.c b/audio_hw.c
index 403f6cd..954c6ea 100644
--- a/audio_hw.c
+++ b/audio_hw.c
@@ -53,12 +53,19 @@ static uint32_t audio_hw_get_supported_devices(const struct audio_hw_device *dev
static int audio_hw_init_check(const struct audio_hw_device *dev)
{
+ struct tinyalsa_audio_device *tinyalsa_audio_device;
+
LOGD("%s(%p)", __func__, dev);
- if(dev != NULL)
- return 0;
- else
- return -EINVAL;
+ if(dev == NULL)
+ return -1;
+
+ tinyalsa_audio_device = (struct tinyalsa_audio_device *) dev;
+
+ if(tinyalsa_audio_device->mixer == NULL)
+ return -1;
+
+ return 0;
}
static int audio_hw_set_voice_volume(struct audio_hw_device *dev, float volume)
@@ -194,14 +201,15 @@ 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) {
+ rc = tinyalsa_mixer_open(&tinyalsa_mixer, TINYALSA_MIXER_CONFIG_FILE);
+ if(rc < 0 || 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");
- }
+ goto error_device;
+ }
+
+ 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;
@@ -209,6 +217,12 @@ int audio_hw_open(const hw_module_t *module, const char *name,
*device = &(dev->common);
return 0;
+
+error_device:
+ *device = NULL;
+ free(tinyalsa_audio_device);
+
+ return -1;
}
struct hw_module_methods_t audio_hw_module_methods = {