diff options
Diffstat (limited to 'audio/out/ao_lavc.c')
-rw-r--r-- | audio/out/ao_lavc.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c index b849f9b2b4..9be3a7b6ae 100644 --- a/audio/out/ao_lavc.c +++ b/audio/out/ao_lavc.c @@ -296,8 +296,6 @@ static void fill_with_padding(void *buf, int cnt, int sz, const void *padding) } // close audio device -static int encode(struct ao *ao, double apts, void *data); -static int play(struct ao *ao, void *data, int len, int flags); static void uninit(struct ao *ao, bool cut_audio) { struct encode_lavc_context *ectx = ao->encode_lavc_ctx; @@ -315,7 +313,7 @@ static int get_space(struct ao *ao) { struct priv *ac = ao->priv; - return ac->aframesize * ac->sample_size * ao->channels.num * ac->framecount; + return ac->aframesize * ac->framecount; } // must get exactly ac->aframesize amount of data @@ -444,10 +442,10 @@ static int encode(struct ao *ao, double apts, void *data) return packet.size; } -// plays 'len' bytes of 'data' +// plays 'samples' samples of 'ni_data[0]' // it should round it down to frame sizes -// return: number of bytes played -static int play(struct ao *ao, void *data, int len, int flags) +// return: number of samples played +static int play(struct ao *ao, void **ni_data, int samples, int flags) { struct priv *ac = ao->priv; struct encode_lavc_context *ectx = ao->encode_lavc_ctx; @@ -457,6 +455,8 @@ static int play(struct ao *ao, void *data, int len, int flags) double nextpts; double pts = ao->pts; double outpts; + void *data = ni_data[0]; + int len = samples * ao->sstride; int bytelen = len; len /= ac->sample_size * ao->channels.num; @@ -477,8 +477,9 @@ static int play(struct ao *ao, void *data, int len, int flags) extralen / ac->sample_size, ac->sample_size, ac->sample_padding); // No danger of recursion, because AOPLAY_FINAL_CHUNK not set - written = play(ao, paddingbuf, bytelen + extralen, 0); - if (written < bytelen) { + written = + play(ao, &paddingbuf, (bytelen + extralen) / ao->sstride, 0); + if (written * ao->sstride < bytelen) { MP_ERR(ao, "did not write enough data at the end\n"); } talloc_free(paddingbuf); @@ -492,7 +493,7 @@ static int play(struct ao *ao, void *data, int len, int flags) while (encode(ao, outpts, NULL) > 0) ; - return FFMIN(written, bytelen); + return (FFMIN(written, bytelen)) / ao->sstride; } if (pts == MP_NOPTS_VALUE) { @@ -559,7 +560,7 @@ static int play(struct ao *ao, void *data, int len, int flags) if (ac->offset_left <= -len) { // skip whole frame ac->offset_left += len; - return len * ac->sample_size * ao->channels.num; + return len; } else { // skip part of this frame, buffer/encode the rest bufpos -= ac->offset_left; @@ -632,7 +633,7 @@ static int play(struct ao *ao, void *data, int len, int flags) ectx->next_in_pts = nextpts; } - return bufpos * ac->sample_size * ao->channels.num; + return bufpos; } const struct ao_driver audio_out_lavc = { |