From bf60281ffb6f47986fa6ef9ee559689be0075050 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 10 Nov 2013 23:15:02 +0100 Subject: audio/out: reject non-interleaved formats No AO can handle these, so it would be a problem if they get added later, and non-interleaved formats get accepted erroneously. Let them gracefully fall back to other formats. Most AOs actually would fall back, but to an unrelated formats. This is covered by this commit too, and if possible they should pick the interleaved variant if a non-interleaved format is requested. --- audio/out/ao_portaudio.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'audio/out/ao_portaudio.c') diff --git a/audio/out/ao_portaudio.c b/audio/out/ao_portaudio.c index 8b235f8806..d75fad0aca 100644 --- a/audio/out/ao_portaudio.c +++ b/audio/out/ao_portaudio.c @@ -242,6 +242,8 @@ static int init(struct ao *ao) = Pa_GetDeviceInfo(pa_device)->defaultHighOutputLatency, }; + ao->format = af_fmt_from_planar(ao->format); + const struct format_map *fmt = format_maps; while (fmt->pa_format) { if (fmt->mp_format == ao->format) { -- cgit v1.2.3 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_portaudio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'audio/out/ao_portaudio.c') diff --git a/audio/out/ao_portaudio.c b/audio/out/ao_portaudio.c index d75fad0aca..9c0d7804f8 100644 --- a/audio/out/ao_portaudio.c +++ b/audio/out/ao_portaudio.c @@ -280,13 +280,13 @@ error_exit: return -1; } -static int play(struct ao *ao, void *data, int len, int flags) +static int play(struct ao *ao, void **data, int samples, int flags) { struct priv *priv = ao->priv; pthread_mutex_lock(&priv->ring_mutex); - int write_len = mp_ring_write(priv->ring, data, len); + int write_len = mp_ring_write(priv->ring, data[0], samples * ao->sstride); if (flags & AOPLAY_FINAL_CHUNK) priv->play_remaining = true; @@ -295,7 +295,7 @@ static int play(struct ao *ao, void *data, int len, int flags) if (Pa_IsStreamStopped(priv->stream) == 1) check_pa_ret(Pa_StartStream(priv->stream)); - return write_len; + return write_len / ao->sstride; } static int get_space(struct ao *ao) @@ -308,7 +308,7 @@ static int get_space(struct ao *ao) pthread_mutex_unlock(&priv->ring_mutex); - return free; + return free / ao->sstride; } static float get_delay(struct ao *ao) -- cgit v1.2.3