diff options
Diffstat (limited to 'src/DecoderInternal.cxx')
-rw-r--r-- | src/DecoderInternal.cxx | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/src/DecoderInternal.cxx b/src/DecoderInternal.cxx index d5f40ad48..b50fee185 100644 --- a/src/DecoderInternal.cxx +++ b/src/DecoderInternal.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -20,6 +20,7 @@ #include "config.h" #include "DecoderInternal.hxx" #include "DecoderControl.hxx" +#include "pcm/PcmConvert.hxx" #include "MusicPipe.hxx" #include "MusicBuffer.hxx" #include "MusicChunk.hxx" @@ -32,6 +33,11 @@ Decoder::~Decoder() /* caller must flush the chunk */ assert(chunk == nullptr); + if (convert != nullptr) { + convert->Close(); + delete convert; + } + delete song_tag; delete stream_tag; delete decoder_tag; @@ -51,24 +57,21 @@ need_chunks(DecoderControl &dc) } struct music_chunk * -decoder_get_chunk(Decoder &decoder) +Decoder::GetChunk() { - DecoderControl &dc = decoder.dc; DecoderCommand cmd; - if (decoder.chunk != nullptr) - return decoder.chunk; + if (chunk != nullptr) + return chunk; do { - decoder.chunk = dc.buffer->Allocate(); - if (decoder.chunk != nullptr) { - decoder.chunk->replay_gain_serial = - decoder.replay_gain_serial; - if (decoder.replay_gain_serial != 0) - decoder.chunk->replay_gain_info = - decoder.replay_gain_info; - - return decoder.chunk; + chunk = dc.buffer->Allocate(); + if (chunk != nullptr) { + chunk->replay_gain_serial = replay_gain_serial; + if (replay_gain_serial != 0) + chunk->replay_gain_info = replay_gain_info; + + return chunk; } dc.Lock(); @@ -80,18 +83,16 @@ decoder_get_chunk(Decoder &decoder) } void -decoder_flush_chunk(Decoder &decoder) +Decoder::FlushChunk() { - DecoderControl &dc = decoder.dc; - - assert(decoder.chunk != nullptr); + assert(chunk != nullptr); - if (decoder.chunk->IsEmpty()) - dc.buffer->Return(decoder.chunk); + if (chunk->IsEmpty()) + dc.buffer->Return(chunk); else - dc.pipe->Push(decoder.chunk); + dc.pipe->Push(chunk); - decoder.chunk = nullptr; + chunk = nullptr; dc.Lock(); if (dc.client_is_waiting) |