diff options
author | wm4 <wm4@nowhere> | 2013-11-14 23:54:06 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-14 23:54:06 +0100 |
commit | 8512a08046adf0bcea501ecbf48d0e9f1b8ba6da (patch) | |
tree | c1625e9867664e47475d8f73e154627527e216bb /audio/decode/ad_spdif.c | |
parent | 4ee51526ae27a4512aafb7611f5d5001fc1407d3 (diff) | |
download | mpv-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/decode/ad_spdif.c')
-rw-r--r-- | audio/decode/ad_spdif.c | 11 |
1 files changed, 5 insertions, 6 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; } |