diff options
Diffstat (limited to 'audio_hw.c')
-rw-r--r-- | audio_hw.c | 31 |
1 files changed, 28 insertions, 3 deletions
@@ -90,6 +90,8 @@ static int audio_hw_set_voice_volume(struct audio_hw_device *dev, float volume) return -1; if(volume != device->voice_volume) { + pthread_mutex_lock(&device->lock); + if(device->mode == AUDIO_MODE_IN_CALL) { if(device->ril_interface != NULL) device_modem = device->ril_interface->device_current; @@ -106,6 +108,8 @@ static int audio_hw_set_voice_volume(struct audio_hw_device *dev, float volume) } device->voice_volume = volume; + + pthread_mutex_unlock(&device->lock); } return 0; @@ -125,7 +129,9 @@ static int audio_hw_set_master_volume(struct audio_hw_device *dev, float volume) if(device->mixer == NULL) return -1; + pthread_mutex_lock(&device->lock); tinyalsa_mixer_set_master_volume(device->mixer, volume); + pthread_mutex_unlock(&device->lock); return 0; } @@ -145,6 +151,8 @@ static int audio_hw_set_mode(struct audio_hw_device *dev, int mode) device = (struct tinyalsa_audio_device *) dev; if(mode != device->mode) { + pthread_mutex_lock(&device->lock); + if(mode == AUDIO_MODE_IN_CALL) { tinyalsa_mixer_set_modem_state(device->mixer, 1); @@ -187,6 +195,8 @@ static int audio_hw_set_mode(struct audio_hw_device *dev, int mode) } device->mode = mode; + + pthread_mutex_unlock(&device->lock); } return 0; @@ -208,6 +218,8 @@ static int audio_hw_set_mic_mute(struct audio_hw_device *dev, bool state) return -1; if(device->mic_mute != state) { + pthread_mutex_lock(&device->lock); + if(device->mode == AUDIO_MODE_IN_CALL) { if(device->ril_interface != NULL) device_modem = device->ril_interface->device_current; @@ -229,6 +241,8 @@ static int audio_hw_set_mic_mute(struct audio_hw_device *dev, bool state) } device->mic_mute = state; + + pthread_mutex_unlock(&device->lock); } return 0; @@ -279,16 +293,27 @@ static int audio_hw_set_parameters(struct audio_hw_device *dev, value = atoi(value_string); + pthread_mutex_lock(&device->lock); + if(audio_is_output_device((audio_devices_t) value)) { - if(device->stream_out != NULL && device->stream_out->device_current != (audio_devices_t) value) + if(device->stream_out != NULL && device->stream_out->device_current != (audio_devices_t) value) { + pthread_mutex_lock(&device->stream_out->lock); audio_out_set_route(device->stream_out, (audio_devices_t) value); - if(device->ril_interface != NULL && device->ril_interface->device_current != (audio_devices_t) value) + pthread_mutex_unlock(&device->stream_out->lock); + } + if(device->ril_interface != NULL && device->ril_interface->device_current != (audio_devices_t) value) { audio_ril_interface_set_route(device->ril_interface, (audio_devices_t) value); + } } else if(audio_is_input_device((audio_devices_t) value)) { - if(device->stream_in != NULL && device->stream_in->device_current != (audio_devices_t) value) + if(device->stream_in != NULL && device->stream_in->device_current != (audio_devices_t) value) { + pthread_mutex_lock(&device->stream_in->lock); audio_in_set_route(device->stream_in, (audio_devices_t) value); + pthread_mutex_unlock(&device->stream_in->lock); + } } + pthread_mutex_unlock(&device->lock); + str_parms_destroy(parms); return 0; |