aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/wavpack_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-11-10 19:01:38 +0100
committerMax Kellermann <max@duempel.org>2009-11-14 00:47:22 +0100
commit719990b1c5db93ccdc21e5f91e98ed9e8540ade1 (patch)
treeef03f58f54767b73c4c8d267e7b0008938863a17 /src/decoder/wavpack_plugin.c
parentf47bb8c1db91b50be95c4d5dd301728e38c57274 (diff)
downloadmpd-719990b1c5db93ccdc21e5f91e98ed9e8540ade1.tar.gz
mpd-719990b1c5db93ccdc21e5f91e98ed9e8540ade1.tar.xz
mpd-719990b1c5db93ccdc21e5f91e98ed9e8540ade1.zip
decoder: use audio_format_init_checked()
Let the audio_check library verify the audio format in all (relevant, i.e. non-hardcoded) plugins.
Diffstat (limited to '')
-rw-r--r--src/decoder/wavpack_plugin.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/decoder/wavpack_plugin.c b/src/decoder/wavpack_plugin.c
index c784d51db..9b32a79f2 100644
--- a/src/decoder/wavpack_plugin.c
+++ b/src/decoder/wavpack_plugin.c
@@ -19,6 +19,7 @@
#include "config.h"
#include "decoder_api.h"
+#include "audio_check.h"
#include "path.h"
#include "utils.h"
@@ -130,6 +131,8 @@ static void
wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek,
struct replay_gain_info *replay_gain_info)
{
+ GError *error = NULL;
+ unsigned bits;
struct audio_format audio_format;
format_samples_t format_samples;
char chunk[CHUNK_SIZE];
@@ -138,24 +141,22 @@ wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek,
int bytes_per_sample, output_sample_size;
int position;
- audio_format_init(&audio_format, WavpackGetSampleRate(wpc),
- WavpackGetBitsPerSample(wpc),
- WavpackGetNumChannels(wpc));
+ bits = WavpackGetBitsPerSample(wpc);
/* round bitwidth to 8-bit units */
- audio_format.bits = (audio_format.bits + 7) & (~7);
+ bits = (bits + 7) & (~7);
/* MPD handles max 32-bit samples */
- if (audio_format.bits > 32)
- audio_format.bits = 32;
+ if (bits > 32)
+ bits = 32;
if ((WavpackGetMode(wpc) & MODE_FLOAT) == MODE_FLOAT)
- audio_format.bits = 24;
+ bits = 24;
- if (!audio_format_valid(&audio_format)) {
- g_warning("Invalid audio format: %u:%u:%u\n",
- audio_format.sample_rate,
- audio_format.bits,
- audio_format.channels);
+ if (!audio_format_init_checked(&audio_format,
+ WavpackGetSampleRate(wpc), bits,
+ WavpackGetNumChannels(wpc), &error)) {
+ g_warning("%s", error->message);
+ g_error_free(error);
return;
}