From 380fc765e4ad4e3ff828c9b0bd4a565ea2ba79ed Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 10 Nov 2013 23:24:21 +0100 Subject: 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. --- audio/out/ao_wasapi.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'audio/out/ao_wasapi.c') diff --git a/audio/out/ao_wasapi.c b/audio/out/ao_wasapi.c index 5d9f33278c..b43bf04753 100644 --- a/audio/out/ao_wasapi.c +++ b/audio/out/ao_wasapi.c @@ -1197,7 +1197,7 @@ static int get_space(struct ao *ao) if (!ao || !ao->priv) return -1; struct wasapi_state *state = (struct wasapi_state *)ao->priv; - return mp_ring_available(state->ringbuff); + return mp_ring_available(state->ringbuff) / ao->sstride; } static void reset_buffers(struct wasapi_state *state) @@ -1339,25 +1339,24 @@ static void reset(struct ao *ao) reset_buffers(state); } -static int play(struct ao *ao, void *data, int len, int flags) +static int play(struct ao *ao, void **data, int samples, int flags) { - int ret = 0; if (!ao || !ao->priv) - return ret; + return 0; struct wasapi_state *state = (struct wasapi_state *)ao->priv; if (WaitForSingleObject(state->fatal_error, 0) == WAIT_OBJECT_0) { /* something bad happened */ - return ret; + return 0; } - ret = mp_ring_write(state->ringbuff, data, len); + int ret = mp_ring_write(state->ringbuff, data[0], samples * ao->sstride); if (!state->is_playing) { /* start playing */ state->is_playing = 1; SetEvent(state->hPlay); } - return ret; + return ret / ao->sstride; } static float get_delay(struct ao *ao) -- cgit v1.2.3