summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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)