Commit 528b7c3f authored by Max Kellermann's avatar Max Kellermann

decoder: automatically flush the output buffer after decoder exits

A decoder_flush() invocation was missing in the FLAC plugin, resulting in casual assertion failures due to a wrong assumption about the last chunk's audio format. It's much easier to remove that decoder_flush() function and make the decoder thread call ob_flush().
parent 74c85811
...@@ -419,8 +419,6 @@ static int aac_stream_decode(struct decoder * mpd_decoder, ...@@ -419,8 +419,6 @@ static int aac_stream_decode(struct decoder * mpd_decoder,
break; break;
} }
decoder_flush(mpd_decoder);
faacDecClose(decoder); faacDecClose(decoder);
if (b.buffer) if (b.buffer)
free(b.buffer); free(b.buffer);
...@@ -556,8 +554,6 @@ static int aac_decode(struct decoder * mpd_decoder, char *path) ...@@ -556,8 +554,6 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
break; break;
} }
decoder_flush(mpd_decoder);
faacDecClose(decoder); faacDecClose(decoder);
if (b.buffer) if (b.buffer)
free(b.buffer); free(b.buffer);
......
...@@ -110,10 +110,7 @@ static int audiofile_decode(struct decoder * decoder, char *path) ...@@ -110,10 +110,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
bitRate, NULL); bitRate, NULL);
} while (decoder_get_command(decoder) != DECODE_COMMAND_STOP); } while (decoder_get_command(decoder) != DECODE_COMMAND_STOP);
decoder_flush(decoder);
afCloseFile(af_fp); afCloseFile(af_fp);
return 0; return 0;
} }
......
...@@ -314,10 +314,7 @@ static int ffmpeg_decode_internal(BasePtrs *base) ...@@ -314,10 +314,7 @@ static int ffmpeg_decode_internal(BasePtrs *base)
} }
} while (decoder_get_command(decoder) != DECODE_COMMAND_STOP); } while (decoder_get_command(decoder) != DECODE_COMMAND_STOP);
decoder_flush(decoder);
DEBUG("decoder finish\n"); DEBUG("decoder finish\n");
return 0; return 0;
} }
......
...@@ -210,8 +210,6 @@ static int mod_decode(struct decoder * decoder, char *path) ...@@ -210,8 +210,6 @@ static int mod_decode(struct decoder * decoder, char *path)
total_time, 0, NULL); total_time, 0, NULL);
} }
decoder_flush(decoder);
mod_close(data); mod_close(data);
MikMod_Exit(); MikMod_Exit();
......
...@@ -1131,9 +1131,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream) ...@@ -1131,9 +1131,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
data.mute_frame == MUTEFRAME_SEEK) data.mute_frame == MUTEFRAME_SEEK)
decoder_command_finished(decoder); decoder_command_finished(decoder);
decoder_flush(decoder);
mp3_data_finish(&data); mp3_data_finish(&data);
return 0; return 0;
} }
......
...@@ -298,8 +298,6 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream) ...@@ -298,8 +298,6 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK && seeking) if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK && seeking)
decoder_command_finished(mpd_decoder); decoder_command_finished(mpd_decoder);
decoder_flush(mpd_decoder);
return 0; return 0;
} }
......
...@@ -231,8 +231,6 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream) ...@@ -231,8 +231,6 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
replayGainInfo); replayGainInfo);
} }
decoder_flush(mpd_decoder);
freeReplayGainInfo(replayGainInfo); freeReplayGainInfo(replayGainInfo);
return 0; return 0;
......
...@@ -326,9 +326,6 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream) ...@@ -326,9 +326,6 @@ oggvorbis_decode(struct decoder *decoder, struct input_stream *inStream)
freeReplayGainInfo(replayGainInfo); freeReplayGainInfo(replayGainInfo);
ov_clear(&vf); ov_clear(&vf);
decoder_flush(decoder);
return 0; return 0;
} }
......
...@@ -206,8 +206,6 @@ static void wavpack_decode(struct decoder * decoder, ...@@ -206,8 +206,6 @@ static void wavpack_decode(struct decoder * decoder,
replayGainInfo); replayGainInfo);
} }
} while (samplesgot == samplesreq); } while (samplesgot == samplesreq);
decoder_flush(decoder);
} }
static char *wavpack_tag(WavpackContext *wpc, char *key) static char *wavpack_tag(WavpackContext *wpc, char *key)
......
...@@ -206,8 +206,3 @@ decoder_data(struct decoder *decoder, ...@@ -206,8 +206,3 @@ decoder_data(struct decoder *decoder,
return DECODE_COMMAND_NONE; return DECODE_COMMAND_NONE;
} }
void decoder_flush(mpd_unused struct decoder *decoder)
{
ob_flush();
}
...@@ -159,6 +159,4 @@ decoder_data(struct decoder *decoder, ...@@ -159,6 +159,4 @@ decoder_data(struct decoder *decoder,
void *data, size_t datalen, float data_time, uint16_t bitRate, void *data, size_t datalen, float data_time, uint16_t bitRate,
ReplayGainInfo * replayGainInfo); ReplayGainInfo * replayGainInfo);
void decoder_flush(struct decoder *decoder);
#endif #endif
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "decoder_control.h" #include "decoder_control.h"
#include "decoder_internal.h" #include "decoder_internal.h"
#include "player_control.h" #include "player_control.h"
#include "outputBuffer.h"
#include "song.h" #include "song.h"
#include "mapper.h" #include "mapper.h"
#include "path.h" #include "path.h"
...@@ -147,6 +148,8 @@ static void decodeStart(void) ...@@ -147,6 +148,8 @@ static void decodeStart(void)
} }
} }
ob_flush();
if (ret < 0 || ret == DECODE_ERROR_UNKTYPE) { if (ret < 0 || ret == DECODE_ERROR_UNKTYPE) {
if (ret != DECODE_ERROR_UNKTYPE) if (ret != DECODE_ERROR_UNKTYPE)
dc.error = DECODE_ERROR_FILE; dc.error = DECODE_ERROR_FILE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment