aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/wavpack_decoder_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-07-20 21:46:05 +0200
committerMax Kellermann <max@duempel.org>2011-07-20 21:46:05 +0200
commit0ea4c970d794d535ae6efb4d0ae2d3fe37980ae3 (patch)
treed08d18c852febad9d6da94dfbe31545dcf93b5d0 /src/decoder/wavpack_decoder_plugin.c
parent57936a13741c09fa54a33a53ed05ac0d996e4807 (diff)
parent838f7cd210dbd3f071d48d54c168c123c3d20c58 (diff)
downloadmpd-0ea4c970d794d535ae6efb4d0ae2d3fe37980ae3.tar.gz
mpd-0ea4c970d794d535ae6efb4d0ae2d3fe37980ae3.tar.xz
mpd-0ea4c970d794d535ae6efb4d0ae2d3fe37980ae3.zip
Merge branch 'v0.16.x'
Conflicts: src/player_thread.c src/playlist_control.c
Diffstat (limited to '')
-rw-r--r--src/decoder/wavpack_decoder_plugin.c47
1 files changed, 18 insertions, 29 deletions
diff --git a/src/decoder/wavpack_decoder_plugin.c b/src/decoder/wavpack_decoder_plugin.c
index b14a41f93..200bf6455 100644
--- a/src/decoder/wavpack_decoder_plugin.c
+++ b/src/decoder/wavpack_decoder_plugin.c
@@ -34,9 +34,6 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "wavpack"
-/* pick 1020 since its devisible for 8,16,24, and 32-bit audio */
-#define CHUNK_SIZE 1020
-
#define ERRORLEN 80
static struct {
@@ -162,8 +159,6 @@ wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek)
enum sample_format sample_format;
struct audio_format audio_format;
format_samples_t format_samples;
- char chunk[CHUNK_SIZE];
- int samples_requested, samples_got;
float total_time;
int bytes_per_sample, output_sample_size;
@@ -193,12 +188,15 @@ wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek)
output_sample_size = audio_format_frame_size(&audio_format);
/* wavpack gives us all kind of samples in a 32-bit space */
- samples_requested = sizeof(chunk) / (4 * audio_format.channels);
+ int32_t chunk[1024];
+ const uint32_t samples_requested = G_N_ELEMENTS(chunk) /
+ audio_format.channels;
decoder_initialized(decoder, &audio_format, can_seek, total_time);
- do {
- if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) {
+ enum decoder_command cmd = decoder_get_command(decoder);
+ while (cmd != DECODE_COMMAND_STOP) {
+ if (cmd == DECODE_COMMAND_SEEK) {
if (can_seek) {
unsigned where = decoder_seek_where(decoder) *
audio_format.sample_rate;
@@ -213,29 +211,20 @@ wavpack_decode(struct decoder *decoder, WavpackContext *wpc, bool can_seek)
}
}
- if (decoder_get_command(decoder) == DECODE_COMMAND_STOP) {
+ uint32_t samples_got = WavpackUnpackSamples(wpc, chunk,
+ samples_requested);
+ if (samples_got == 0)
break;
- }
- samples_got = WavpackUnpackSamples(
- wpc, (int32_t *)chunk, samples_requested
- );
- if (samples_got > 0) {
- int bitrate = (int)(WavpackGetInstantBitrate(wpc) /
- 1000 + 0.5);
-
- format_samples(
- bytes_per_sample, chunk,
- samples_got * audio_format.channels
- );
-
- decoder_data(
- decoder, NULL, chunk,
- samples_got * output_sample_size,
- bitrate
- );
- }
- } while (samples_got > 0);
+ int bitrate = (int)(WavpackGetInstantBitrate(wpc) / 1000 +
+ 0.5);
+ format_samples(bytes_per_sample, chunk,
+ samples_got * audio_format.channels);
+
+ cmd = decoder_data(decoder, NULL, chunk,
+ samples_got * output_sample_size,
+ bitrate);
+ }
}
/**