summaryrefslogtreecommitdiffstats
path: root/audio/out/ao.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-10 23:24:21 +0100
committerwm4 <wm4@nowhere>2013-11-12 23:27:51 +0100
commit380fc765e4ad4e3ff828c9b0bd4a565ea2ba79ed (patch)
tree6cc32f550b219c903a932692f477c8b8b4f8cfc2 /audio/out/ao.c
parentd115fb3b0eed9145817a20bc0070590f7428bddd (diff)
downloadmpv-380fc765e4ad4e3ff828c9b0bd4a565ea2ba79ed.tar.bz2
mpv-380fc765e4ad4e3ff828c9b0bd4a565ea2ba79ed.tar.xz
audio/out: prepare for non-interleaved audio
This comes with two internal AO API changes: 1. ao_driver.play now can take non-interleaved audio. For this purpose, the data pointer is changed to void **data, where data[0] corresponds to the pointer in the old API. Also, the len argument as well as the return value are now in samples, not bytes. "Sample" in this context means the unit of the smallest possible audio frame, i.e. sample_size * channels. 2. ao_driver.get_space now returns samples instead of bytes. (Similar to the play function.) Change all AOs to use the new API. The AO API as exposed to the rest of the player still uses the old API. It's emulated in ao.c. This is purely to split the commits changing all AOs and the commits adding actual support for outputting N-I audio.
Diffstat (limited to 'audio/out/ao.c')
-rw-r--r--audio/out/ao.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/audio/out/ao.c b/audio/out/ao.c
index 55db34becb..fd20270160 100644
--- a/audio/out/ao.c
+++ b/audio/out/ao.c
@@ -159,7 +159,10 @@ static struct ao *ao_create(bool probing, struct mpv_global *global,
talloc_free(chmap);
if (ao->driver->init(ao) < 0)
goto error;
- ao->bps = ao->channels.num * ao->samplerate * af_fmt2bits(ao->format) / 8;
+ ao->sstride = af_fmt2bits(ao->format) / 8;
+ if (!af_fmt_is_planar(ao->format))
+ ao->sstride *= ao->channels.num;
+ ao->bps = ao->samplerate * ao->sstride;
return ao;
error:
talloc_free(ao);
@@ -208,7 +211,8 @@ void ao_uninit(struct ao *ao, bool cut_audio)
int ao_play(struct ao *ao, void *data, int len, int flags)
{
- return ao->driver->play(ao, data, len, flags);
+ int r = ao->driver->play(ao, &data, len / ao->sstride, flags);
+ return r < 0 ? r : r * ao->sstride;
}
int ao_control(struct ao *ao, enum aocontrol cmd, void *arg)
@@ -229,7 +233,7 @@ double ao_get_delay(struct ao *ao)
int ao_get_space(struct ao *ao)
{
- return ao->driver->get_space(ao);
+ return ao->driver->get_space(ao) * ao->sstride;
}
void ao_reset(struct ao *ao)
@@ -254,10 +258,9 @@ int ao_play_silence(struct ao *ao, int samples)
{
if (samples <= 0 || AF_FORMAT_IS_SPECIAL(ao->format))
return 0;
- int s = ao->channels.num * (af_fmt2bits(ao->format) / 8);
- char *p = talloc_size(NULL, samples * s);
- af_fill_silence(p, samples * s, ao->format);
- int r = ao_play(ao, p, samples * s, 0);
+ char *p = talloc_size(NULL, samples * ao->sstride);
+ af_fill_silence(p, samples * ao->sstride, ao->format);
+ int r = ao_play(ao, p, samples * ao->sstride, 0);
talloc_free(p);
return r;
}