summaryrefslogtreecommitdiffstats
path: root/audio/decode
diff options
context:
space:
mode:
Diffstat (limited to 'audio/decode')
-rw-r--r--audio/decode/ad_mpg123.c5
-rw-r--r--audio/decode/dec_audio.c6
2 files changed, 10 insertions, 1 deletions
diff --git a/audio/decode/ad_mpg123.c b/audio/decode/ad_mpg123.c
index 777c20c2c9..8ea06dd5ab 100644
--- a/audio/decode/ad_mpg123.c
+++ b/audio/decode/ad_mpg123.c
@@ -310,6 +310,11 @@ static int decode_audio(sh_audio_t *sh, struct mp_audio *buffer, int maxlen)
return -1;
}
+ if (sh->samplerate != buffer->rate ||
+ !mp_chmap_equals(&sh->channels, &buffer->channels) ||
+ sh->sample_format != buffer->format)
+ return 0;
+
size_t got_now = 0;
ret = mpg123_replace_buffer(con->handle, buf, maxlen * con->sample_size);
if (ret != MPG123_OK)
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index 0aee681def..c79e4ffc42 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -267,7 +267,6 @@ static int filter_n_bytes(sh_audio_t *sh, struct mp_audio_buffer *outbuf,
// first, and don't signal a format change to the caller yet.
if (mp_audio_buffer_samples(sh->decode_buffer) > 0)
break;
- reinit_audio_buffer(sh);
error = -2;
break;
}
@@ -288,6 +287,11 @@ static int filter_n_bytes(sh_audio_t *sh, struct mp_audio_buffer *outbuf,
// remove processed data from decoder buffer:
mp_audio_buffer_skip(sh->decode_buffer, len);
+ // Assume the filter chain is drained from old data at this point.
+ // (If not, the remaining old data is discarded.)
+ if (error == -2)
+ reinit_audio_buffer(sh);
+
return error;
}