From 8512a08046adf0bcea501ecbf48d0e9f1b8ba6da Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 14 Nov 2013 23:54:06 +0100 Subject: 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. --- audio/decode/ad_spdif.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'audio/decode/ad_spdif.c') 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; } -- cgit v1.2.3