aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-03-22 00:24:56 +0100
committerMax Kellermann <max@duempel.org>2012-03-22 00:24:56 +0100
commitc10f013fc21205c5c6c06d753066963805de8555 (patch)
tree80eb4526f2dbb121c5014bf3d2711306bf2c931a /src
parent2874d68bdbb3bc9ab10e14d8c3ec43a78b291f00 (diff)
downloadmpd-c10f013fc21205c5c6c06d753066963805de8555.tar.gz
mpd-c10f013fc21205c5c6c06d753066963805de8555.tar.xz
mpd-c10f013fc21205c5c6c06d753066963805de8555.zip
output/alsa: don't pass audio_format to _try_format()
Let the caller configure the audio_format object.
Diffstat (limited to '')
-rw-r--r--src/output/alsa_output_plugin.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/output/alsa_output_plugin.c b/src/output/alsa_output_plugin.c
index 8cc244d4c..202d09b5c 100644
--- a/src/output/alsa_output_plugin.c
+++ b/src/output/alsa_output_plugin.c
@@ -265,19 +265,16 @@ byteswap_bitformat(snd_pcm_format_t fmt)
*/
static int
alsa_output_try_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
- struct audio_format *audio_format,
- bool *reverse_endian_r,
- enum sample_format sample_format)
+ enum sample_format sample_format,
+ bool *reverse_endian_r)
{
snd_pcm_format_t alsa_format = get_bitformat(sample_format);
if (alsa_format == SND_PCM_FORMAT_UNKNOWN)
return -EINVAL;
int err = snd_pcm_hw_params_set_format(pcm, hwparams, alsa_format);
- if (err == 0) {
+ if (err == 0)
*reverse_endian_r = false;
- audio_format->format = sample_format;
- }
if (err != -EINVAL)
return err;
@@ -287,10 +284,8 @@ alsa_output_try_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
return -EINVAL;
err = snd_pcm_hw_params_set_format(pcm, hwparams, alsa_format);
- if (err == 0) {
+ if (err == 0)
*reverse_endian_r = true;
- audio_format->format = sample_format;
- }
return err;
}
@@ -305,9 +300,8 @@ alsa_output_setup_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
{
/* try the input format first */
- int err = alsa_output_try_format(pcm, hwparams, audio_format,
- reverse_endian_r,
- audio_format->format);
+ int err = alsa_output_try_format(pcm, hwparams, audio_format->format,
+ reverse_endian_r);
if (err != -EINVAL)
return err;
@@ -323,12 +317,15 @@ alsa_output_setup_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
};
for (unsigned i = 0; probe_formats[i] != SAMPLE_FORMAT_UNDEFINED; ++i) {
- if (probe_formats[i] == audio_format->format)
+ const enum sample_format mpd_format = probe_formats[i];
+ if (mpd_format == audio_format->format)
continue;
- err = alsa_output_try_format(pcm, hwparams, audio_format,
- reverse_endian_r,
- probe_formats[i]);
+ err = alsa_output_try_format(pcm, hwparams, mpd_format,
+ reverse_endian_r);
+ if (err == 0)
+ audio_format->format = mpd_format;
+
if (err != -EINVAL)
return err;
}