Commit ff42ba90 authored by Felix Paul Kühne's avatar Felix Paul Kühne

AudioQueue: cleanup

parent 01951465
/***************************************************************************** /*****************************************************************************
* audioqueue.c : AudioQueue audio output plugin for vlc * audioqueue.c : AudioQueue audio output plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2010 VideoLAN and AUTHORS * Copyright (C) 2010-2012 VLC authors and VideoLAN
* $Id$
* *
* Authors: Romain Goyet <romain.goyet@likid.org> * Authors: Romain Goyet <romain.goyet@likid.org>
* Felix Paul Kühne <fkuehne@videolan.org> * Felix Paul Kühne <fkuehne@videolan.org>
...@@ -50,32 +51,32 @@ struct aout_sys_t ...@@ -50,32 +51,32 @@ struct aout_sys_t
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * ); static int Open (vlc_object_t *);
static void Close ( vlc_object_t * ); static void Close (vlc_object_t *);
static void Play ( audio_output_t *, block_t * ); static void Play (audio_output_t *, block_t *);
static void Pause ( audio_output_t *p_aout, bool pause, mtime_t date ); static void Pause (audio_output_t *p_aout, bool pause, mtime_t date);
static void Flush ( audio_output_t *p_aout, bool wait ); static void Flush (audio_output_t *p_aout, bool wait);
static int TimeGet ( audio_output_t *aout, mtime_t * ); static int TimeGet (audio_output_t *aout, mtime_t *);
static void AudioQueueCallback (void *, AudioQueueRef, AudioQueueBufferRef); static void AudioQueueCallback (void *, AudioQueueRef, AudioQueueBufferRef);
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
vlc_module_begin () vlc_module_begin ()
set_shortname( "AudioQueue" ) set_shortname("AudioQueue")
set_description( N_("AudioQueue (iOS / Mac OS) audio output") ) set_description(N_("AudioQueue (iOS / Mac OS) audio output"))
set_capability( "audio output", 40 ) set_capability("audio output", 40)
set_category( CAT_AUDIO ) set_category(CAT_AUDIO)
set_subcategory( SUBCAT_AUDIO_AOUT ) set_subcategory(SUBCAT_AUDIO_AOUT)
add_shortcut( "audioqueue" ) add_shortcut("audioqueue")
set_callbacks( Open, Close ) set_callbacks(Open, Close)
vlc_module_end () vlc_module_end ()
/***************************************************************************** /*****************************************************************************
* Start: open the audio device * Start: open the audio device
*****************************************************************************/ *****************************************************************************/
static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt ) static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
{ {
aout_sys_t *p_sys = p_aout->sys; aout_sys_t *p_sys = p_aout->sys;
OSStatus status = 0; OSStatus status = 0;
...@@ -95,7 +96,7 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt ) ...@@ -95,7 +96,7 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
// Create a new output AudioQueue for the device. // Create a new output AudioQueue for the device.
status = AudioQueueNewOutput(&deviceFormat, // Format status = AudioQueueNewOutput(&deviceFormat, // Format
AudioQueueCallback, // Callback AudioQueueCallback, // Callback
NULL, // User data, passed to the callback NULL, // User data, passed to the callback
CFRunLoopGetMain(), // RunLoop CFRunLoopGetMain(), // RunLoop
kCFRunLoopDefaultMode, // RunLoop mode kCFRunLoopDefaultMode, // RunLoop mode
0, // Flags ; must be zero (per documentation)... 0, // Flags ; must be zero (per documentation)...
...@@ -128,7 +129,7 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt ) ...@@ -128,7 +129,7 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
* Stop: close the audio device * Stop: close the audio device
*****************************************************************************/ *****************************************************************************/
static void Stop ( audio_output_t *p_aout ) static void Stop (audio_output_t *p_aout)
{ {
struct aout_sys_t * p_sys = p_aout->sys; struct aout_sys_t * p_sys = p_aout->sys;
...@@ -144,23 +145,23 @@ static void Stop ( audio_output_t *p_aout ) ...@@ -144,23 +145,23 @@ static void Stop ( audio_output_t *p_aout )
static void Play (audio_output_t *p_aout, block_t *p_block) static void Play (audio_output_t *p_aout, block_t *p_block)
{ {
if ( p_block != NULL ) { if (p_block != NULL) {
AudioQueueBufferRef inBuffer = NULL; AudioQueueBufferRef inBuffer = NULL;
OSStatus status; OSStatus status;
status = AudioQueueAllocateBuffer(p_aout->sys->audioQueue, FRAME_SIZE * 2, &inBuffer); status = AudioQueueAllocateBuffer(p_aout->sys->audioQueue, FRAME_SIZE * 2, &inBuffer);
if (status != noErr) { if (status != noErr) {
msg_Err( p_aout, "buffer alloction failed (%i)", status); msg_Err(p_aout, "buffer alloction failed (%i)", status);
return; return;
} }
memcpy( inBuffer->mAudioData, p_block->p_buffer, p_block->i_buffer ); memcpy(inBuffer->mAudioData, p_block->p_buffer, p_block->i_buffer);
inBuffer->mAudioDataByteSize = p_block->i_buffer; inBuffer->mAudioDataByteSize = p_block->i_buffer;
block_Release( p_block ); block_Release(p_block);
status = AudioQueueEnqueueBuffer(p_aout->sys->audioQueue, inBuffer, 0, NULL); status = AudioQueueEnqueueBuffer(p_aout->sys->audioQueue, inBuffer, 0, NULL);
if (status != noErr) if (status != noErr)
msg_Err( p_aout, "enqueuing buffer failed (%i)", status); msg_Err(p_aout, "enqueuing buffer failed (%i)", status);
} }
} }
...@@ -174,27 +175,27 @@ void AudioQueueCallback(void * inUserData, AudioQueueRef inAQ, AudioQueueBufferR ...@@ -174,27 +175,27 @@ void AudioQueueCallback(void * inUserData, AudioQueueRef inAQ, AudioQueueBufferR
static void Pause (audio_output_t *p_aout, bool pause, mtime_t date) static void Pause (audio_output_t *p_aout, bool pause, mtime_t date)
{ {
VLC_UNUSED( date ); VLC_UNUSED(date);
if (pause) if (pause)
AudioQueuePause( p_aout->sys->audioQueue ); AudioQueuePause(p_aout->sys->audioQueue);
else else
AudioQueueStart( p_aout->sys->audioQueue, NULL ); AudioQueueStart(p_aout->sys->audioQueue, NULL);
} }
static void Flush (audio_output_t *p_aout, bool wait) static void Flush (audio_output_t *p_aout, bool wait)
{ {
VLC_UNUSED( wait ); VLC_UNUSED(wait);
AudioQueueFlush( p_aout->sys->audioQueue ); AudioQueueFlush(p_aout->sys->audioQueue);
} }
static int TimeGet (audio_output_t *p_aout, mtime_t *restrict delay) static int TimeGet (audio_output_t *p_aout, mtime_t *restrict delay)
{ {
// TODO // TODO
VLC_UNUSED( p_aout ); VLC_UNUSED(p_aout);
VLC_UNUSED( delay ); VLC_UNUSED(delay);
return -1; return -1;
} }
...@@ -214,7 +215,6 @@ static int Open(vlc_object_t *obj) ...@@ -214,7 +215,6 @@ static int Open(vlc_object_t *obj)
aout->sys = sys; aout->sys = sys;
aout->start = Start; aout->start = Start;
aout->stop = Stop; aout->stop = Stop;
aout->play = Play;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment