Commit e071592a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout: pass audio buffer explicitly to pf_play

parent b616e265
...@@ -179,7 +179,7 @@ struct audio_output ...@@ -179,7 +179,7 @@ struct audio_output
aout_fifo_t fifo; aout_fifo_t fifo;
struct aout_sys_t *sys; /**< Output plugin private data */ struct aout_sys_t *sys; /**< Output plugin private data */
void (*pf_play)( audio_output_t * ); /**< Audio buffer callback */ void (*pf_play)(audio_output_t *, block_t *); /**< Audio buffer callback */
void (* pf_pause)( audio_output_t *, bool, mtime_t ); /**< Pause/resume void (* pf_pause)( audio_output_t *, bool, mtime_t ); /**< Pause/resume
callback (optional, may be NULL) */ callback (optional, may be NULL) */
void (* pf_flush)( audio_output_t *, bool ); /**< Flush/drain callback void (* pf_flush)( audio_output_t *, bool ); /**< Flush/drain callback
...@@ -254,6 +254,7 @@ VLC_API const char * aout_FormatPrintChannels( const audio_sample_format_t * ) V ...@@ -254,6 +254,7 @@ VLC_API const char * aout_FormatPrintChannels( const audio_sample_format_t * ) V
VLC_API mtime_t aout_FifoFirstDate( const aout_fifo_t * ) VLC_USED; VLC_API mtime_t aout_FifoFirstDate( const aout_fifo_t * ) VLC_USED;
VLC_API aout_buffer_t *aout_FifoPop( aout_fifo_t * p_fifo ) VLC_USED; VLC_API aout_buffer_t *aout_FifoPop( aout_fifo_t * p_fifo ) VLC_USED;
VLC_API void aout_FifoPush( aout_fifo_t *, block_t * );
VLC_API void aout_VolumeNoneInit( audio_output_t * ); VLC_API void aout_VolumeNoneInit( audio_output_t * );
VLC_API void aout_VolumeSoftInit( audio_output_t * ); VLC_API void aout_VolumeSoftInit( audio_output_t * );
......
...@@ -85,7 +85,7 @@ struct aout_sys_t ...@@ -85,7 +85,7 @@ struct aout_sys_t
*****************************************************************************/ *****************************************************************************/
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 * ); static void Play ( audio_output_t *, block_t * );
static void* ALSAThread ( void * ); static void* ALSAThread ( void * );
static void ALSAFill ( audio_output_t * ); static void ALSAFill ( audio_output_t * );
static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name, static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
...@@ -522,20 +522,21 @@ error: ...@@ -522,20 +522,21 @@ error:
return VLC_EGENERIC; return VLC_EGENERIC;
} }
static void PlayIgnore( audio_output_t *p_aout ) static void PlayIgnore( audio_output_t *p_aout, block_t *block )
{ /* Already playing - nothing to do */ {
(void) p_aout; aout_FifoPush( &p_aout->fifo, block );
} }
/***************************************************************************** /*****************************************************************************
* Play: start playback * Play: start playback
*****************************************************************************/ *****************************************************************************/
static void Play( audio_output_t *p_aout ) static void Play( audio_output_t *p_aout, block_t *block )
{ {
p_aout->pf_play = PlayIgnore; p_aout->pf_play = PlayIgnore;
/* get the playing date of the first aout buffer */ /* get the playing date of the first aout buffer */
p_aout->sys->start_date = aout_FifoFirstDate( &p_aout->fifo ); p_aout->sys->start_date = block->i_pts;
aout_FifoPush( &p_aout->fifo, block );
/* wake up the audio output thread */ /* wake up the audio output thread */
sem_post( &p_aout->sys->wait ); sem_post( &p_aout->sys->wait );
......
...@@ -59,17 +59,13 @@ struct aout_sys_t ...@@ -59,17 +59,13 @@ struct aout_sys_t
void (*cleanup) (void *opaque); void (*cleanup) (void *opaque);
}; };
static void Play (audio_output_t *aout) static void Play (audio_output_t *aout, block_t *block)
{ {
aout_sys_t *sys = aout->sys; aout_sys_t *sys = aout->sys;
block_t *block;
while ((block = aout_FifoPop(&aout->fifo)) != NULL)
{
sys->play (sys->opaque, block->p_buffer, block->i_nb_samples, sys->play (sys->opaque, block->p_buffer, block->i_nb_samples,
block->i_pts); block->i_pts);
block_Release (block); block_Release (block);
}
} }
static int VolumeSet (audio_output_t *aout, float vol, bool mute) static int VolumeSet (audio_output_t *aout, float vol, bool mute)
......
...@@ -54,7 +54,7 @@ struct aout_sys_t ...@@ -54,7 +54,7 @@ struct aout_sys_t
*****************************************************************************/ *****************************************************************************/
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 * ); static void Play ( audio_output_t *, block_t * );
static void AudioQueueCallback (void *, AudioQueueRef, AudioQueueBufferRef); static void AudioQueueCallback (void *, AudioQueueRef, AudioQueueBufferRef);
/***************************************************************************** /*****************************************************************************
...@@ -135,9 +135,9 @@ static int Open ( vlc_object_t *p_this ) ...@@ -135,9 +135,9 @@ static int Open ( vlc_object_t *p_this )
/***************************************************************************** /*****************************************************************************
* Play: play a sound samples buffer * Play: play a sound samples buffer
*****************************************************************************/ *****************************************************************************/
static void Play( audio_output_t * p_aout ) static void Play( audio_output_t * p_aout, block_t *block )
{ {
VLC_UNUSED(p_aout); aout_FifoPush( &p_aout->fifo, block );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -112,7 +112,7 @@ static int OpenAnalog ( audio_output_t * ); ...@@ -112,7 +112,7 @@ static int OpenAnalog ( audio_output_t * );
static int OpenSPDIF ( audio_output_t * ); static int OpenSPDIF ( audio_output_t * );
static void Close ( vlc_object_t * ); static void Close ( vlc_object_t * );
static void Play ( audio_output_t * ); static void Play ( audio_output_t *, block_t * );
static void Probe ( audio_output_t * ); static void Probe ( audio_output_t * );
static int AudioDeviceHasOutput ( AudioDeviceID ); static int AudioDeviceHasOutput ( AudioDeviceID );
...@@ -910,9 +910,9 @@ static void Close( vlc_object_t * p_this ) ...@@ -910,9 +910,9 @@ static void Close( vlc_object_t * p_this )
/***************************************************************************** /*****************************************************************************
* Play: nothing to do * Play: nothing to do
*****************************************************************************/ *****************************************************************************/
static void Play( audio_output_t * p_aout ) static void Play( audio_output_t * p_aout, block_t *block )
{ {
VLC_UNUSED(p_aout); aout_FifoPush( &p_aout->fifo, block );
} }
......
...@@ -94,7 +94,7 @@ struct aout_sys_t ...@@ -94,7 +94,7 @@ struct aout_sys_t
*****************************************************************************/ *****************************************************************************/
static int OpenAudio ( vlc_object_t * ); static int OpenAudio ( vlc_object_t * );
static void CloseAudio ( vlc_object_t * ); static void CloseAudio ( vlc_object_t * );
static void Play ( audio_output_t * ); static void Play ( audio_output_t *, block_t * );
/* local functions */ /* local functions */
static void Probe ( audio_output_t * ); static void Probe ( audio_output_t * );
...@@ -569,29 +569,23 @@ static void Probe( audio_output_t * p_aout ) ...@@ -569,29 +569,23 @@ static void Probe( audio_output_t * p_aout )
* we know the first buffer has been put in the aout fifo and we also * we know the first buffer has been put in the aout fifo and we also
* know its date. * know its date.
*****************************************************************************/ *****************************************************************************/
static void Play( audio_output_t *p_aout ) static void Play( audio_output_t *p_aout, block_t *p_buffer )
{ {
if( !p_aout->sys->b_playing ) if( !p_aout->sys->b_playing )
{ {
aout_buffer_t *p_buffer;
p_aout->sys->b_playing = 1; p_aout->sys->b_playing = 1;
/* get the playing date of the first aout buffer */ /* get the playing date of the first aout buffer */
p_aout->sys->p_notif->start_date = p_aout->sys->p_notif->start_date = p_buffer->i_pts;
aout_FifoFirstDate( &p_aout->fifo );
/* fill in the first samples */ /* fill in the first samples */
for( int i = 0; i < FRAMES_NUM; i++ ) FillBuffer( p_aout, 0, p_buffer );
{
p_buffer = aout_FifoPop( &p_aout->fifo );
if( !p_buffer ) break;
FillBuffer( p_aout, i, p_buffer );
}
/* wake up the audio output thread */ /* wake up the audio output thread */
SetEvent( p_aout->sys->p_notif->event ); SetEvent( p_aout->sys->p_notif->event );
} }
else
aout_FifoPush( &p_aout->fifo, p_buffer );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -73,7 +73,7 @@ static const int pi_channels_maps[CHANNELS_MAX+1] = ...@@ -73,7 +73,7 @@ static const int pi_channels_maps[CHANNELS_MAX+1] =
*****************************************************************************/ *****************************************************************************/
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 * ); static void Play ( audio_output_t *, block_t * );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -316,12 +316,8 @@ static void Close( vlc_object_t * p_this ) ...@@ -316,12 +316,8 @@ static void Close( vlc_object_t * p_this )
/***************************************************************************** /*****************************************************************************
* Play: pretend to play a sound * Play: pretend to play a sound
*****************************************************************************/ *****************************************************************************/
static void Play( audio_output_t * p_aout ) static void Play( audio_output_t * p_aout, block_t *p_buffer )
{ {
aout_buffer_t * p_buffer;
p_buffer = aout_FifoPop( &p_aout->fifo );
if( fwrite( p_buffer->p_buffer, p_buffer->i_buffer, 1, if( fwrite( p_buffer->p_buffer, p_buffer->i_buffer, 1,
p_aout->sys->p_file ) != 1 ) p_aout->sys->p_file ) != 1 )
{ {
......
...@@ -62,7 +62,7 @@ struct aout_sys_t ...@@ -62,7 +62,7 @@ struct aout_sys_t
*****************************************************************************/ *****************************************************************************/
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 * ); static void Play ( audio_output_t *, block_t * );
static int Process ( jack_nframes_t i_frames, void *p_arg ); static int Process ( jack_nframes_t i_frames, void *p_arg );
static int GraphChange ( void *p_arg ); static int GraphChange ( void *p_arg );
...@@ -334,9 +334,9 @@ static int GraphChange( void *p_arg ) ...@@ -334,9 +334,9 @@ static int GraphChange( void *p_arg )
/***************************************************************************** /*****************************************************************************
* Play: nothing to do * Play: nothing to do
*****************************************************************************/ *****************************************************************************/
static void Play( audio_output_t *p_aout ) static void Play( audio_output_t *p_aout, block_t *block )
{ {
VLC_UNUSED( p_aout ); aout_FifoPush( &p_aout->fifo, block );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -75,7 +75,7 @@ typedef SLresult (*slCreateEngine_t)( ...@@ -75,7 +75,7 @@ typedef SLresult (*slCreateEngine_t)(
*****************************************************************************/ *****************************************************************************/
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 * ); static void Play ( audio_output_t *, block_t * );
static void PlayedCallback ( SLAndroidSimpleBufferQueueItf caller, void *pContext); static void PlayedCallback ( SLAndroidSimpleBufferQueueItf caller, void *pContext);
/***************************************************************************** /*****************************************************************************
...@@ -291,16 +291,13 @@ static void Close( vlc_object_t * p_this ) ...@@ -291,16 +291,13 @@ static void Close( vlc_object_t * p_this )
/***************************************************************************** /*****************************************************************************
* Play: play a sound * Play: play a sound
*****************************************************************************/ *****************************************************************************/
static void Play( audio_output_t * p_aout ) static void Play( audio_output_t * p_aout, block_t *p_buffer )
{ {
aout_sys_t * p_sys = p_aout->sys; aout_sys_t * p_sys = p_aout->sys;
aout_buffer_t *p_buffer; aout_buffer_t *p_buffer;
SLresult result; SLresult result;
p_buffer = aout_FifoPop(&p_aout->fifo);
if( p_buffer != NULL )
{
for (;;) for (;;)
{ {
result = (*p_sys->playerBufferQueue)->Enqueue( result = (*p_sys->playerBufferQueue)->Enqueue(
...@@ -324,9 +321,6 @@ static void Play( audio_output_t * p_aout ) ...@@ -324,9 +321,6 @@ static void Play( audio_output_t * p_aout )
p_sys->p_buffer_array[p_sys->i_toappend_buffer] = p_buffer; p_sys->p_buffer_array[p_sys->i_toappend_buffer] = p_buffer;
if( ++p_sys->i_toappend_buffer == BUFF_QUEUE ) if( ++p_sys->i_toappend_buffer == BUFF_QUEUE )
p_sys->i_toappend_buffer = 0; p_sys->i_toappend_buffer = 0;
}
else
msg_Err( p_aout, "nothing to play?" );
} }
static void PlayedCallback (SLAndroidSimpleBufferQueueItf caller, void *pContext ) static void PlayedCallback (SLAndroidSimpleBufferQueueItf caller, void *pContext )
......
...@@ -86,7 +86,7 @@ struct aout_sys_t ...@@ -86,7 +86,7 @@ struct aout_sys_t
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 * ); static void Play ( audio_output_t *, block_t * );
static void* OSSThread ( void * ); static void* OSSThread ( void * );
static mtime_t BufferDuration( audio_output_t * p_aout ); static mtime_t BufferDuration( audio_output_t * p_aout );
...@@ -520,9 +520,9 @@ static int Open( vlc_object_t *p_this ) ...@@ -520,9 +520,9 @@ static int Open( vlc_object_t *p_this )
/***************************************************************************** /*****************************************************************************
* Play: nothing to do * Play: nothing to do
*****************************************************************************/ *****************************************************************************/
static void Play( audio_output_t *p_aout ) static void Play( audio_output_t *p_aout, block_t *block )
{ {
VLC_UNUSED(p_aout); aout_FifoPush( &p_aout->fifo, block );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -95,7 +95,7 @@ static void* PORTAUDIOThread( void * ); ...@@ -95,7 +95,7 @@ static void* PORTAUDIOThread( void * );
*****************************************************************************/ *****************************************************************************/
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 * ); static void Play ( audio_output_t *, block_t * );
static int PAOpenDevice( audio_output_t * ); static int PAOpenDevice( audio_output_t * );
static int PAOpenStream( audio_output_t * ); static int PAOpenStream( audio_output_t * );
...@@ -559,9 +559,9 @@ static int PAOpenStream( audio_output_t *p_aout ) ...@@ -559,9 +559,9 @@ static int PAOpenStream( audio_output_t *p_aout )
/***************************************************************************** /*****************************************************************************
* Play: play sound * Play: play sound
*****************************************************************************/ *****************************************************************************/
static void Play( audio_output_t * p_aout ) static void Play( audio_output_t * p_aout, block_t *block )
{ {
VLC_UNUSED( p_aout ); aout_FifoPush( &p_aout->fifo, block );
} }
#ifdef PORTAUDIO_IS_SERIOUSLY_BROKEN #ifdef PORTAUDIO_IS_SERIOUSLY_BROKEN
......
...@@ -444,15 +444,11 @@ static void *data_convert(block_t **pp) ...@@ -444,15 +444,11 @@ static void *data_convert(block_t **pp)
/** /**
* Queue one audio frame to the playabck stream * Queue one audio frame to the playabck stream
*/ */
static void Play(audio_output_t *aout) static void Play(audio_output_t *aout, block_t *block)
{ {
aout_sys_t *sys = aout->sys; aout_sys_t *sys = aout->sys;
pa_stream *s = sys->stream; pa_stream *s = sys->stream;
/* This function is called exactly once per block in the output FIFO. */
block_t *block = aout_FifoPop(&aout->fifo);
assert (block != NULL);
const void *ptr = data_convert(&block); const void *ptr = data_convert(&block);
if (unlikely(ptr == NULL)) if (unlikely(ptr == NULL))
return; return;
......
...@@ -58,7 +58,7 @@ struct aout_sys_t ...@@ -58,7 +58,7 @@ struct aout_sys_t
*****************************************************************************/ *****************************************************************************/
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 * ); static void Play ( audio_output_t *, block_t * );
static void SDLCallback ( void *, uint8_t *, int ); static void SDLCallback ( void *, uint8_t *, int );
/***************************************************************************** /*****************************************************************************
...@@ -224,9 +224,9 @@ static int Open ( vlc_object_t *p_this ) ...@@ -224,9 +224,9 @@ static int Open ( vlc_object_t *p_this )
/***************************************************************************** /*****************************************************************************
* Play: play a sound samples buffer * Play: play a sound samples buffer
*****************************************************************************/ *****************************************************************************/
static void Play( audio_output_t * p_aout ) static void Play( audio_output_t * p_aout, block_t *block )
{ {
VLC_UNUSED(p_aout); aout_FifoPush( &p_aout->fifo, block );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
*****************************************************************************/ *****************************************************************************/
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 * ); static void Play ( audio_output_t *, block_t * );
/***************************************************************************** /*****************************************************************************
* notification_thread_t: waveOut event thread * notification_thread_t: waveOut event thread
...@@ -473,15 +473,16 @@ static void Probe( audio_output_t * p_aout ) ...@@ -473,15 +473,16 @@ static void Probe( audio_output_t * p_aout )
* This doesn't actually play the buffer. This just stores the buffer so it * This doesn't actually play the buffer. This just stores the buffer so it
* can be played by the callback thread. * can be played by the callback thread.
*****************************************************************************/ *****************************************************************************/
static void Play( audio_output_t *_p_aout ) static void Play( audio_output_t *_p_aout, block_t *block )
{ {
aout_FifoPush( &_p_aout->fifo, block );
if( !_p_aout->sys->b_playing ) if( !_p_aout->sys->b_playing )
{ {
_p_aout->sys->b_playing = 1; _p_aout->sys->b_playing = 1;
/* get the playing date of the first aout buffer */ /* get the playing date of the first aout buffer */
_p_aout->sys->start_date = _p_aout->sys->start_date = block->i_pts;
aout_FifoFirstDate( &_p_aout->fifo );
msg_Dbg( _p_aout, "Wakeup sleeping output thread."); msg_Dbg( _p_aout, "Wakeup sleeping output thread.");
......
...@@ -167,7 +167,7 @@ audio_output_t *aout_New ( vlc_object_t * ); ...@@ -167,7 +167,7 @@ audio_output_t *aout_New ( vlc_object_t * );
void aout_FifoInit( vlc_object_t *, aout_fifo_t *, uint32_t ); void aout_FifoInit( vlc_object_t *, aout_fifo_t *, uint32_t );
#define aout_FifoInit(o, f, r) aout_FifoInit(VLC_OBJECT(o), f, r) #define aout_FifoInit(o, f, r) aout_FifoInit(VLC_OBJECT(o), f, r)
mtime_t aout_FifoNextStart( const aout_fifo_t * ) VLC_USED; mtime_t aout_FifoNextStart( const aout_fifo_t * ) VLC_USED;
void aout_FifoPush( aout_fifo_t *, aout_buffer_t * ); //void aout_FifoPush( aout_fifo_t *, aout_buffer_t * );
void aout_FifoReset( aout_fifo_t * ); void aout_FifoReset( aout_fifo_t * );
void aout_FifoMoveDates( aout_fifo_t *, mtime_t ); void aout_FifoMoveDates( aout_fifo_t *, mtime_t );
void aout_FifoDestroy( aout_fifo_t * p_fifo ); void aout_FifoDestroy( aout_fifo_t * p_fifo );
......
...@@ -250,10 +250,7 @@ void aout_OutputPlay( audio_output_t * p_aout, aout_buffer_t * p_buffer ) ...@@ -250,10 +250,7 @@ void aout_OutputPlay( audio_output_t * p_aout, aout_buffer_t * p_buffer )
aout_FifoPush (&owner->partial, p_buffer ); aout_FifoPush (&owner->partial, p_buffer );
while ((p_buffer = aout_OutputSlice (p_aout, &owner->partial)) != NULL) while ((p_buffer = aout_OutputSlice (p_aout, &owner->partial)) != NULL)
{ p_aout->pf_play (p_aout, p_buffer);
aout_FifoPush( &p_aout->fifo, p_buffer );
p_aout->pf_play( p_aout );
}
} }
/** /**
......
...@@ -15,6 +15,7 @@ aout_CheckChannelReorder ...@@ -15,6 +15,7 @@ aout_CheckChannelReorder
aout_EnableFilter aout_EnableFilter
aout_FifoFirstDate aout_FifoFirstDate
aout_FifoPop aout_FifoPop
aout_FifoPush
aout_filter_RequestVout aout_filter_RequestVout
aout_FormatPrepare aout_FormatPrepare
aout_FormatPrint aout_FormatPrint
......
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