use a local "initialized" flag instead of dc->state
Since we want to hide mpd internals from the decoder plugins, the plugins should not check dc->state whether they have already called decoder_initialized(). Use a local variable to track that.
This commit is contained in:
parent
17e9cc84c5
commit
dc4d774481
@ -298,6 +298,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
|
||||
mpd_uint16 bitRate = 0;
|
||||
AacBuffer b;
|
||||
InputStream inStream;
|
||||
int initialized = 0;
|
||||
|
||||
if ((totalTime = getAacFloatTotalTime(path)) < 0)
|
||||
return -1;
|
||||
@ -364,11 +365,12 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
|
||||
sampleRate = frameInfo.samplerate;
|
||||
#endif
|
||||
|
||||
if (dc.state != DECODE_STATE_DECODE) {
|
||||
if (!initialized) {
|
||||
audio_format.channels = frameInfo.channels;
|
||||
audio_format.sampleRate = sampleRate;
|
||||
decoder_initialized(mpd_decoder, &audio_format,
|
||||
totalTime);
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
advanceAacBuffer(&b, frameInfo.bytesconsumed);
|
||||
@ -401,7 +403,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
|
||||
if (b.buffer)
|
||||
free(b.buffer);
|
||||
|
||||
if (dc.state != DECODE_STATE_DECODE)
|
||||
if (!initialized)
|
||||
return -1;
|
||||
|
||||
if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK) {
|
||||
|
@ -107,6 +107,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
||||
mpd_uint16 bitRate = 0;
|
||||
int seeking = 0;
|
||||
double seek_where = 0;
|
||||
int initialized = 0;
|
||||
|
||||
mp4cb = xmalloc(sizeof(mp4ff_callback_t));
|
||||
mp4cb->read = mp4_inputStreamReadCallback;
|
||||
@ -241,7 +242,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
||||
break;
|
||||
}
|
||||
|
||||
if (dc.state != DECODE_STATE_DECODE) {
|
||||
if (!initialized) {
|
||||
channels = frameInfo.channels;
|
||||
#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
|
||||
scale = frameInfo.samplerate;
|
||||
@ -250,6 +251,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
||||
audio_format.channels = frameInfo.channels;
|
||||
decoder_initialized(mpd_decoder, &audio_format,
|
||||
total_time);
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
if (channels * (unsigned long)(dur + offset) > frameInfo.samples) {
|
||||
@ -282,7 +284,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
||||
mp4ff_close(mp4fh);
|
||||
free(mp4cb);
|
||||
|
||||
if (dc.state != DECODE_STATE_DECODE)
|
||||
if (!initialized)
|
||||
return -1;
|
||||
|
||||
if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK && seeking) {
|
||||
|
@ -228,6 +228,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
|
||||
ReplayGainInfo *replayGainInfo = NULL;
|
||||
char **comments;
|
||||
const char *errorStr;
|
||||
int initialized = 0;
|
||||
|
||||
data.inStream = inStream;
|
||||
data.decoder = decoder;
|
||||
@ -284,12 +285,13 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
|
||||
vorbis_info *vi = ov_info(&vf, -1);
|
||||
audio_format.channels = vi->channels;
|
||||
audio_format.sampleRate = vi->rate;
|
||||
if (dc.state == DECODE_STATE_START) {
|
||||
if (!initialized) {
|
||||
float total_time = ov_time_total(&vf, -1);
|
||||
if (total_time < 0)
|
||||
total_time = 0;
|
||||
decoder_initialized(decoder, &audio_format,
|
||||
total_time);
|
||||
initialized = 1;
|
||||
}
|
||||
comments = ov_comment(&vf, -1)->user_comments;
|
||||
putOggCommentsIntoOutputBuffer(inStream->metaName,
|
||||
|
Loading…
Reference in New Issue
Block a user