summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-14 23:54:06 +0100
committerwm4 <wm4@nowhere>2013-11-14 23:54:06 +0100
commit8512a08046adf0bcea501ecbf48d0e9f1b8ba6da (patch)
treec1625e9867664e47475d8f73e154627527e216bb /audio
parent4ee51526ae27a4512aafb7611f5d5001fc1407d3 (diff)
downloadmpv-8512a08046adf0bcea501ecbf48d0e9f1b8ba6da.tar.bz2
mpv-8512a08046adf0bcea501ecbf48d0e9f1b8ba6da.tar.xz
ad_spdif: fix regressions
Apparently this was completely broken after commit 22b3f522. Basically, this locked up immediately completely while decoding the first packet. The reason was that the buffer calculations confused bytes and number of samples. Also, EOF reporting was broken (wrong return code). The special-casing of ad_mpg123 and ad_spdif (with DECODE_MAX_UNIT) is a bit annoying, but will eventually be solved in a better way.
Diffstat (limited to 'audio')
-rw-r--r--audio/decode/ad_spdif.c11
-rw-r--r--audio/decode/dec_audio.c7
2 files changed, 9 insertions, 9 deletions
diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c
index a233286c19..e6e94489a6 100644
--- a/audio/decode/ad_spdif.c
+++ b/audio/decode/ad_spdif.c
@@ -193,16 +193,16 @@ static int decode_audio(sh_audio_t *sh, struct mp_audio *buffer, int maxlen)
int sstride = 2 * sh->channels.num;
assert(sstride == buffer->sstride);
- if (maxlen < spdif_ctx->iec61937_packet_size)
+ if (maxlen * sstride < spdif_ctx->iec61937_packet_size)
return 0;
spdif_ctx->out_buffer_len = 0;
- spdif_ctx->out_buffer_size = maxlen;
+ spdif_ctx->out_buffer_size = maxlen * sstride;
spdif_ctx->out_buffer = buffer->planes[0];
struct demux_packet *mpkt = demux_read_packet(sh->gsh);
if (!mpkt)
- return 0;
+ return -1;
AVPacket pkt;
mp_set_av_packet(&pkt, mpkt);
@@ -212,15 +212,14 @@ static int decode_audio(sh_audio_t *sh, struct mp_audio *buffer, int maxlen)
sh->pts = mpkt->pts;
sh->pts_offset = 0;
}
- int out_len = spdif_ctx->out_buffer_len;
int ret = av_write_frame(lavf_ctx, &pkt);
avio_flush(lavf_ctx->pb);
- sh->pts_offset += (spdif_ctx->out_buffer_len - out_len) / sstride;
+ buffer->samples = spdif_ctx->out_buffer_len / sstride;
+ sh->pts_offset += buffer->samples;
talloc_free(mpkt);
if (ret < 0)
return -1;
- buffer->samples = spdif_ctx->out_buffer_len / sstride;
return 0;
}
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index 19b5d8bdeb..c9b116d4ea 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -56,10 +56,11 @@ static const struct ad_functions * const ad_drivers[] = {
NULL
};
-// At least ad_mpg123 needs to be able to decode this many samples at once
-#define DECODE_MAX_UNIT 1152
+// ad_mpg123 needs to be able to decode 1152 samples at once
+// ad_spdif needs up to 8192
+#define DECODE_MAX_UNIT MPMAX(8192, 1152)
-// At least 8192 samples, plus hack for ad_mpg123
+// At least 8192 samples, plus hack for ad_mpg123 and ad_spdif
#define DECODE_BUFFER_SAMPLES (8192 + DECODE_MAX_UNIT)
// Drop audio buffer and reinit it (after format change)