summaryrefslogtreecommitdiffstats
path: root/audio_hw.c
diff options
context:
space:
mode:
Diffstat (limited to 'audio_hw.c')
-rw-r--r--audio_hw.c89
1 files changed, 78 insertions, 11 deletions
diff --git a/audio_hw.c b/audio_hw.c
index 954c6ea..e2cb1c3 100644
--- a/audio_hw.c
+++ b/audio_hw.c
@@ -36,33 +36,33 @@
static uint32_t audio_hw_get_supported_devices(const struct audio_hw_device *dev)
{
- struct tinyalsa_audio_device *tinyalsa_audio_device;
+ struct tinyalsa_audio_device *device;
LOGD("%s(%p)", __func__, dev);
if(dev == NULL)
return -1;
- tinyalsa_audio_device = (struct tinyalsa_audio_device *) dev;
+ device = (struct tinyalsa_audio_device *) dev;
- if(tinyalsa_audio_device->mixer == NULL)
+ if(device->mixer == NULL)
return -1;
- return (uint32_t) tinyalsa_mixer_get_supported_devices(tinyalsa_audio_device->mixer);
+ return (uint32_t) tinyalsa_mixer_get_supported_devices(device->mixer);
}
static int audio_hw_init_check(const struct audio_hw_device *dev)
{
- struct tinyalsa_audio_device *tinyalsa_audio_device;
+ struct tinyalsa_audio_device *device;
LOGD("%s(%p)", __func__, dev);
if(dev == NULL)
return -1;
- tinyalsa_audio_device = (struct tinyalsa_audio_device *) dev;
+ device = (struct tinyalsa_audio_device *) dev;
- if(tinyalsa_audio_device->mixer == NULL)
+ if(device->mixer == NULL)
return -1;
return 0;
@@ -70,37 +70,104 @@ static int audio_hw_init_check(const struct audio_hw_device *dev)
static int audio_hw_set_voice_volume(struct audio_hw_device *dev, float volume)
{
+ struct tinyalsa_audio_device *device;
+
LOGD("%s(%p, %f)", __func__, dev, volume);
- return -ENOSYS;
+ if(dev == NULL)
+ return -1;
+
+ device = (struct tinyalsa_audio_device *) dev;
+
+ if(device->mixer == NULL)
+ return -1;
+
+ if(device->mode == AUDIO_MODE_IN_CALL) {
+ // FIXME: Select the device from ril interface
+ tinyalsa_mixer_set_voice_volume(device->mixer,
+ AUDIO_DEVICE_IN_DEFAULT, device->mode, volume);
+ }
+
+ return 0;
}
static int audio_hw_set_master_volume(struct audio_hw_device *dev, float volume)
{
+ struct tinyalsa_audio_device *device;
+
LOGD("%s(%p, %f)", __func__, dev, volume);
- return -ENOSYS;
+ if(dev == NULL)
+ return -1;
+
+ device = (struct tinyalsa_audio_device *) dev;
+
+ if(device->mixer == NULL)
+ return -1;
+
+ tinyalsa_mixer_set_master_volume(device->mixer, volume);
+
+ return 0;
}
static int audio_hw_set_mode(struct audio_hw_device *dev, int mode)
{
+ struct tinyalsa_audio_device *device;
+
LOGD("%s(%p, %d)", __func__, dev, mode);
+ if(dev == NULL)
+ return -1;
+
+ device = (struct tinyalsa_audio_device *) dev;
+
+ device->mode = mode;
+
+ // TODO: If mode changed, change routing
+
return 0;
}
static int audio_hw_set_mic_mute(struct audio_hw_device *dev, bool state)
{
+ struct tinyalsa_audio_device *device;
+
LOGD("%s(%p, %d)", __func__, dev, state);
- return -ENOSYS;
+ if(dev == NULL)
+ return -1;
+
+ device = (struct tinyalsa_audio_device *) dev;
+
+ if(device->mixer == NULL)
+ return -1;
+
+ if(device->mic_mute != state) {
+ device->mic_mute = state;
+
+ // FIXME: Select the device from input if mode isn't in-call,
+ // select it from ril interface if mode is in-call
+ tinyalsa_mixer_set_mic_mute(device->mixer,
+ AUDIO_DEVICE_IN_DEFAULT, device->mode, state);
+ }
+
+ return 0;
}
static int audio_hw_get_mic_mute(const struct audio_hw_device *dev, bool *state)
{
+ struct tinyalsa_audio_device *device;
+
LOGD("%s(%p, %p)", __func__, dev, state);
- return -ENOSYS;
+ if(dev == NULL)
+ return -1;
+
+ device = (struct tinyalsa_audio_device *) dev;
+
+ *state = device->mic_mute;
+
+ return 0;
}
static int audio_hw_set_parameters(struct audio_hw_device *dev,