diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2012-10-13 14:55:00 +0200 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2012-10-13 14:55:00 +0200 |
commit | 9ba79ac296c7ae60c742589565b47f4f5c4adc53 (patch) | |
tree | 16cfdd24db3f4d976a03511d998ddbca8c2d7a82 | |
parent | 3df839e5300e148d1fd4f6c4fc93012071b9380b (diff) | |
download | hardware_tinyalsa-audio-9ba79ac296c7ae60c742589565b47f4f5c4adc53.zip hardware_tinyalsa-audio-9ba79ac296c7ae60c742589565b47f4f5c4adc53.tar.gz hardware_tinyalsa-audio-9ba79ac296c7ae60c742589565b47f4f5c4adc53.tar.bz2 |
Output: Set route function and code style change for PCM functions
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r-- | audio_out.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/audio_out.c b/audio_out.c index c5621ba..861db0c 100644 --- a/audio_out.c +++ b/audio_out.c @@ -42,6 +42,9 @@ int audio_out_pcm_open(struct tinyalsa_audio_stream_out *stream_out) struct pcm *pcm = NULL; struct pcm_config pcm_config; + if(stream_out == NULL) + return -1; + memset(&pcm_config, 0, sizeof(pcm_config)); pcm_config.channels = popcount(stream_out->mixer_props->channels); pcm_config.rate = stream_out->mixer_props->rate; @@ -74,10 +77,24 @@ int audio_out_pcm_open(struct tinyalsa_audio_stream_out *stream_out) void audio_out_pcm_close(struct tinyalsa_audio_stream_out *stream_out) { - if(stream_out->pcm != NULL) { - pcm_close(stream_out->pcm); - stream_out->pcm = NULL; - } + if(stream_out->pcm == NULL) + return; + + pcm_close(stream_out->pcm); + stream_out->pcm = NULL; +} + +int audio_out_set_route(struct tinyalsa_audio_stream_out *stream_out, + audio_devices_t device) +{ + if(stream_out == NULL) + return -1; + + stream_out->device_current = device; + tinyalsa_mixer_set_route(stream_out->device->mixer, + stream_out->device_current, stream_out->device->mode); + + return 0; } static uint32_t audio_out_get_sample_rate(const struct audio_stream *stream) @@ -222,11 +239,8 @@ static int audio_out_set_parameters(struct audio_stream *stream, const char *kvp value = atoi(value_string); - if(stream_out->device_current != (audio_devices_t) value) { - stream_out->device_current = (audio_devices_t) value; - tinyalsa_mixer_set_route(stream_out->device->mixer, - stream_out->device_current, stream_out->device->mode); - } + if(stream_out->device_current != (audio_devices_t) value) + audio_out_set_route(stream_out, (audio_devices_t) value); str_parms_destroy(parms); @@ -407,10 +421,7 @@ int audio_hw_open_output_stream(struct audio_hw_device *dev, *channels = (uint32_t) tinyalsa_audio_stream_out->channels; *format = (uint32_t) tinyalsa_audio_stream_out->format; - tinyalsa_audio_stream_out->device_current = devices; - tinyalsa_mixer_set_route(tinyalsa_audio_stream_out->device->mixer, - tinyalsa_audio_stream_out->device_current, - tinyalsa_audio_stream_out->device->mode); + audio_out_set_route(tinyalsa_audio_stream_out, devices); rc = audio_out_pcm_open(tinyalsa_audio_stream_out); if(rc < 0) { |