summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-06-20 23:22:56 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-07-22 21:53:17 +0200
commit8cf36cf950942a9805afcbb300c277c6fd031848 (patch)
treef5f4f540ef321a71202b62a6b630a2dccd377343 /audio
parentd427b4fd1cadcd4b7be9267ad1ea0af0bfa1cbb4 (diff)
downloadmpv-8cf36cf950942a9805afcbb300c277c6fd031848.tar.bz2
mpv-8cf36cf950942a9805afcbb300c277c6fd031848.tar.xz
ao_coreaudio: rewrite spdif render callback
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_coreaudio.c59
1 files changed, 20 insertions, 39 deletions
diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c
index 67cba53d66..2ce5b81457 100644
--- a/audio/out/ao_coreaudio.c
+++ b/audio/out/ao_coreaudio.c
@@ -114,6 +114,25 @@ static OSStatus render_cb_lpcm(void *ctx, AudioUnitRenderActionFlags *aflags,
return noErr;
}
+static OSStatus render_cb_digital(
+ AudioDeviceID device, const AudioTimeStamp *ts,
+ const void *in_data, const AudioTimeStamp *in_ts,
+ AudioBufferList *out_data, const AudioTimeStamp *out_ts, void *ctx)
+{
+ struct ao *ao = ctx;
+ struct priv *p = ao->priv;
+ AudioBuffer buf = out_data->mBuffers[p->i_stream_index];
+ int requested = buf.mDataByteSize;
+
+ if (p->b_muted) {
+ mp_ring_drain(p->buffer, requested);
+ } else {
+ buf.mDataByteSize = mp_ring_read(p->buffer, buf.mData, requested);
+ }
+
+ return noErr;
+}
+
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
{
struct priv *p = ao->priv;
@@ -321,13 +340,6 @@ static int AudioStreamSupportsDigital(AudioStreamID i_stream_id);
static int OpenSPDIF(struct ao *ao);
static int AudioStreamChangeFormat(AudioStreamID i_stream_id,
AudioStreamBasicDescription change_format);
-static OSStatus RenderCallbackSPDIF(AudioDeviceID inDevice,
- const AudioTimeStamp *inNow,
- const void *inInputData,
- const AudioTimeStamp *inInputTime,
- AudioBufferList *outOutputData,
- const AudioTimeStamp *inOutputTime,
- void *threadGlobals);
static OSStatus StreamListener(AudioObjectID inObjectID,
UInt32 inNumberAddresses,
const AudioObjectPropertyAddress inAddresses[],
@@ -851,7 +863,7 @@ static int OpenSPDIF(struct ao *ao)
/* Create IOProc callback. */
err = AudioDeviceCreateIOProcID(p->i_selected_dev,
- (AudioDeviceIOProc)RenderCallbackSPDIF,
+ (AudioDeviceIOProc)render_cb_digital,
(void *)ao,
&p->renderCallback);
@@ -1043,37 +1055,6 @@ static int AudioStreamChangeFormat(AudioStreamID i_stream_id,
return CONTROL_TRUE;
}
-/*****************************************************************************
-* RenderCallbackSPDIF: callback for SPDIF audio output
-*****************************************************************************/
-static OSStatus RenderCallbackSPDIF(AudioDeviceID inDevice,
- const AudioTimeStamp *inNow,
- const void *inInputData,
- const AudioTimeStamp *inInputTime,
- AudioBufferList *outOutputData,
- const AudioTimeStamp *inOutputTime,
- void *threadGlobals)
-{
- struct ao *ao = threadGlobals;
- struct priv *p = ao->priv;
- int amt = mp_ring_buffered(p->buffer);
- AudioBuffer ca_buffer = outOutputData->mBuffers[p->i_stream_index];
- int req = ca_buffer.mDataByteSize;
-
- if (amt > req)
- amt = req;
- if (amt) {
- if (p->b_muted) {
- mp_ring_read(p->buffer, NULL, amt);
- } else {
- mp_ring_read(p->buffer, (unsigned char *)ca_buffer.mData, amt);
- }
- }
-
- return noErr;
-}
-
-
static int play(struct ao *ao, void *output_samples, int num_bytes, int flags)
{
struct priv *p = ao->priv;