summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/dec_audio.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-07-15 17:59:46 +0000
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-02 04:14:44 +0200
commit5ed772b9cddc4c0de6762e223428b3e36eceefff (patch)
tree338d1623dd003d777b17c3c64c90049b4c9ebd2c /libmpcodecs/dec_audio.c
parent6be6ba40946d333e9d2cf741ba401366e9081c79 (diff)
downloadmpv-5ed772b9cddc4c0de6762e223428b3e36eceefff.tar.bz2
mpv-5ed772b9cddc4c0de6762e223428b3e36eceefff.tar.xz
audio: support parameter changes (e.g. channel count) during playback
Add support for parameter changes (e.g. channel count) during playback. This makes decoding AC3 files that switch between 2 and 6 channels work reasonably well even with -channels 6 and ffac3 decoder. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31737 b3059339-0415-0410-9bf9-f77b7e298cf2 Fix typo in error message: ACC -> AAC git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32473 b3059339-0415-0410-9bf9-f77b7e298cf2 Avoid printing AAC with SBR warning on every decode call, instead print it only after every decoder reconfiguration. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32476 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs/dec_audio.c')
-rw-r--r--libmpcodecs/dec_audio.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/libmpcodecs/dec_audio.c b/libmpcodecs/dec_audio.c
index 218203272d..ade2429dc0 100644
--- a/libmpcodecs/dec_audio.c
+++ b/libmpcodecs/dec_audio.c
@@ -378,13 +378,20 @@ static int filter_n_bytes(sh_audio_t *sh, int len)
int error = 0;
// Decode more bytes if needed
+ int old_samplerate = sh->samplerate;
+ int old_channels = sh->channels;
+ int old_sample_format = sh->sample_format;
while (sh->a_buffer_len < len) {
unsigned char *buf = sh->a_buffer + sh->a_buffer_len;
int minlen = len - sh->a_buffer_len;
int maxlen = sh->a_buffer_size - sh->a_buffer_len;
int ret = sh->ad_driver->decode_audio(sh, buf, minlen, maxlen);
- if (ret <= 0) {
- error = -1;
+ int format_change = sh->samplerate != old_samplerate
+ || sh->channels != old_channels
+ || sh->sample_format != old_sample_format;
+ if (ret <= 0 || format_change) {
+ error = format_change ? -2 : -1;
+ // samples from format-changing call get discarded too
len = sh->a_buffer_len;
break;
}
@@ -467,8 +474,9 @@ int decode_audio(sh_audio_t *sh_audio, int minlen)
/* if this iteration does not fill buffer, we must have lots
* of buffering in filters */
huge_filter_buffer = 1;
- if (filter_n_bytes(sh_audio, declen) < 0)
- return -1;
+ int res = filter_n_bytes(sh_audio, declen);
+ if (res < 0)
+ return res;
}
return 0;
}