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
aout_fifo_t fifo;
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
callback (optional, may be NULL) */
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
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 void aout_FifoPush( aout_fifo_t *, block_t * );
VLC_API void aout_VolumeNoneInit( audio_output_t * );
VLC_API void aout_VolumeSoftInit( audio_output_t * );
......
......@@ -85,7 +85,7 @@ struct aout_sys_t
*****************************************************************************/
static int Open ( 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 ALSAFill ( audio_output_t * );
static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
......@@ -522,20 +522,21 @@ error:
return VLC_EGENERIC;
}
static void PlayIgnore( audio_output_t *p_aout )
{ /* Already playing - nothing to do */
(void) p_aout;
static void PlayIgnore( audio_output_t *p_aout, block_t *block )
{
aout_FifoPush( &p_aout->fifo, block );
}
/*****************************************************************************
* 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;
/* 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 */
sem_post( &p_aout->sys->wait );
......
......@@ -59,17 +59,13 @@ struct aout_sys_t
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;
block_t *block;
while ((block = aout_FifoPop(&aout->fifo)) != NULL)
{
sys->play (sys->opaque, block->p_buffer, block->i_nb_samples,
block->i_pts);
block_Release (block);
}
sys->play (sys->opaque, block->p_buffer, block->i_nb_samples,
block->i_pts);
block_Release (block);
}
static int VolumeSet (audio_output_t *aout, float vol, bool mute)
......
......@@ -54,7 +54,7 @@ struct aout_sys_t
*****************************************************************************/
static int Open ( 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);
/*****************************************************************************
......@@ -135,9 +135,9 @@ static int Open ( vlc_object_t *p_this )
/*****************************************************************************
* 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 * );
static int OpenSPDIF ( audio_output_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 int AudioDeviceHasOutput ( AudioDeviceID );
......@@ -910,9 +910,9 @@ static void Close( vlc_object_t * p_this )
/*****************************************************************************
* 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
*****************************************************************************/
static int OpenAudio ( 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 */
static void Probe ( audio_output_t * );
......@@ -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
* 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 )
{
aout_buffer_t *p_buffer;
p_aout->sys->b_playing = 1;
/* get the playing date of the first aout buffer */
p_aout->sys->p_notif->start_date =
aout_FifoFirstDate( &p_aout->fifo );
p_aout->sys->p_notif->start_date = p_buffer->i_pts;
/* fill in the first samples */
for( int i = 0; i < FRAMES_NUM; i++ )
{
p_buffer = aout_FifoPop( &p_aout->fifo );
if( !p_buffer ) break;
FillBuffer( p_aout, i, p_buffer );
}
FillBuffer( p_aout, 0, p_buffer );
/* wake up the audio output thread */
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] =
*****************************************************************************/
static int Open ( 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
......@@ -316,12 +316,8 @@ static void Close( vlc_object_t * p_this )
/*****************************************************************************
* 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,
p_aout->sys->p_file ) != 1 )
{
......
......@@ -62,7 +62,7 @@ struct aout_sys_t
*****************************************************************************/
static int Open ( 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 GraphChange ( void *p_arg );
......@@ -334,9 +334,9 @@ static int GraphChange( void *p_arg )
/*****************************************************************************
* 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)(
*****************************************************************************/
static int Open ( 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);
/*****************************************************************************
......@@ -291,42 +291,36 @@ static void Close( vlc_object_t * p_this )
/*****************************************************************************
* 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_buffer_t *p_buffer;
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(
p_sys->playerBufferQueue, p_buffer->p_buffer,
p_buffer->i_buffer );
if( result == SL_RESULT_SUCCESS )
break;
if ( result != SL_RESULT_BUFFER_INSUFFICIENT )
{
msg_Warn( p_aout, "Dropping invalid buffer" );
aout_BufferFree( p_buffer );
return ;
}
msg_Err( p_aout, "write error (%lu)", result );
// Wait a bit to retry. might miss calls to *cancel
// but this is supposed to be rare anyway
msleep(CLOCK_FREQ);
if( result == SL_RESULT_SUCCESS )
break;
if ( result != SL_RESULT_BUFFER_INSUFFICIENT )
{
msg_Warn( p_aout, "Dropping invalid buffer" );
aout_BufferFree( p_buffer );
return ;
}
p_sys->p_buffer_array[p_sys->i_toappend_buffer] = p_buffer;
if( ++p_sys->i_toappend_buffer == BUFF_QUEUE )
p_sys->i_toappend_buffer = 0;
msg_Err( p_aout, "write error (%lu)", result );
// Wait a bit to retry. might miss calls to *cancel
// but this is supposed to be rare anyway
msleep(CLOCK_FREQ);
}
else
msg_Err( p_aout, "nothing to play?" );
p_sys->p_buffer_array[p_sys->i_toappend_buffer] = p_buffer;
if( ++p_sys->i_toappend_buffer == BUFF_QUEUE )
p_sys->i_toappend_buffer = 0;
}
static void PlayedCallback (SLAndroidSimpleBufferQueueItf caller, void *pContext )
......
......@@ -86,7 +86,7 @@ struct aout_sys_t
static int Open ( 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 mtime_t BufferDuration( audio_output_t * p_aout );
......@@ -520,9 +520,9 @@ static int Open( vlc_object_t *p_this )
/*****************************************************************************
* 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 * );
*****************************************************************************/
static int Open ( 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 PAOpenStream( audio_output_t * );
......@@ -559,9 +559,9 @@ static int PAOpenStream( audio_output_t *p_aout )
/*****************************************************************************
* 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
......
......@@ -444,15 +444,11 @@ static void *data_convert(block_t **pp)
/**
* 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;
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);
if (unlikely(ptr == NULL))
return;
......
......@@ -58,7 +58,7 @@ struct aout_sys_t
*****************************************************************************/
static int Open ( 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 );
/*****************************************************************************
......@@ -224,9 +224,9 @@ static int Open ( vlc_object_t *p_this )
/*****************************************************************************
* 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 @@
*****************************************************************************/
static int Open ( 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
......@@ -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
* 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 )
{
_p_aout->sys->b_playing = 1;
/* 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;
msg_Dbg( _p_aout, "Wakeup sleeping output thread.");
......
......@@ -167,7 +167,7 @@ audio_output_t *aout_New ( vlc_object_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)
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_FifoMoveDates( aout_fifo_t *, mtime_t );
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 )
aout_FifoPush (&owner->partial, p_buffer );
while ((p_buffer = aout_OutputSlice (p_aout, &owner->partial)) != NULL)
{
aout_FifoPush( &p_aout->fifo, p_buffer );
p_aout->pf_play( p_aout );
}
p_aout->pf_play (p_aout, p_buffer);
}
/**
......
......@@ -15,6 +15,7 @@ aout_CheckChannelReorder
aout_EnableFilter
aout_FifoFirstDate
aout_FifoPop
aout_FifoPush
aout_filter_RequestVout
aout_FormatPrepare
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