aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-10-08 14:46:17 +0200
committerMax Kellermann <max@duempel.org>2011-10-08 14:51:19 +0200
commit8dd83a2cf3c104f30155368b313d06b3d9f96e65 (patch)
treeaf2860c03c627a15708fbd273170b02171c210da
parent49b84f92293e2cfc7966dc0f8b50b24c52061b9d (diff)
downloadmpd-8dd83a2cf3c104f30155368b313d06b3d9f96e65.tar.gz
mpd-8dd83a2cf3c104f30155368b313d06b3d9f96e65.tar.xz
mpd-8dd83a2cf3c104f30155368b313d06b3d9f96e65.zip
output/roar: move code to _use_audio_format()
-rw-r--r--src/output/roar_output_plugin.c65
1 files changed, 38 insertions, 27 deletions
diff --git a/src/output/roar_output_plugin.c b/src/output/roar_output_plugin.c
index d15569fd5..7566834f7 100644
--- a/src/output/roar_output_plugin.c
+++ b/src/output/roar_output_plugin.c
@@ -145,6 +145,43 @@ roar_finish(struct audio_output *ao)
g_free(self);
}
+static void
+roar_use_audio_format(struct roar_audio_info *info,
+ struct audio_format *audio_format)
+{
+ info->rate = audio_format->sample_rate;
+ info->channels = audio_format->channels;
+ info->codec = ROAR_CODEC_PCM_S;
+
+ switch (audio_format->format) {
+ case SAMPLE_FORMAT_UNDEFINED:
+ info->bits = 16;
+ audio_format->format = SAMPLE_FORMAT_S16;
+ break;
+
+ case SAMPLE_FORMAT_S8:
+ info->bits = 8;
+ break;
+
+ case SAMPLE_FORMAT_S16:
+ info->bits = 16;
+ break;
+
+ case SAMPLE_FORMAT_S24:
+ info->bits = 24;
+ break;
+
+ case SAMPLE_FORMAT_S24_P32:
+ info->bits = 32;
+ audio_format->format = SAMPLE_FORMAT_S32;
+ break;
+
+ case SAMPLE_FORMAT_S32:
+ info->bits = 32;
+ break;
+ }
+}
+
static bool
roar_open(struct audio_output *ao, struct audio_format *audio_format, GError **error)
{
@@ -169,33 +206,7 @@ roar_open(struct audio_output *ao, struct audio_format *audio_format, GError **e
return false;
}
- self->info.rate = audio_format->sample_rate;
- self->info.channels = audio_format->channels;
- self->info.codec = ROAR_CODEC_PCM_S;
-
- switch (audio_format->format)
- {
- case SAMPLE_FORMAT_S8:
- self->info.bits = 8;
- break;
- case SAMPLE_FORMAT_S16:
- self->info.bits = 16;
- break;
- case SAMPLE_FORMAT_S24:
- self->info.bits = 24;
- break;
- case SAMPLE_FORMAT_S24_P32:
- self->info.bits = 32;
- audio_format->format = SAMPLE_FORMAT_S32;
- break;
- case SAMPLE_FORMAT_S32:
- self->info.bits = 32;
- break;
- default:
- self->info.bits = 16;
- audio_format->format = SAMPLE_FORMAT_S16;
- }
- audio_format->reverse_endian = 0;
+ roar_use_audio_format(&self->info, audio_format);
if (roar_vs_stream(self->vss, &(self->info), ROAR_DIR_PLAY,
&(self->err)) < 0)