Commit eba980c2 authored by Sam Hocevar's avatar Sam Hocevar

  * ./plugins/mpeg_vdec/vpar_headers.c: we no longer crash when the next
    stream doesn't have the same image size as the previous one.
  * ./src/audio_output/aout_pcm.c: another overrun fix; please test.
parent 45733ceb
......@@ -121,8 +121,8 @@
/* Number of audio output frames contained in an audio output fifo.
* (AOUT_FIFO_SIZE + 1) must be a power of 2, in order to optimise the
* %(AOUT_FIFO_SIZE + 1) operation with an &AOUT_FIFO_SIZE.
* With 511 we have at least 511*384/2/48000=2 seconds of sound */
#define AOUT_FIFO_SIZE 511
* With 255 we have at least 255*384/2/48000=1 second of sound */
#define AOUT_FIFO_SIZE 255
/* Maximum number of audio fifos. The value of AOUT_MAX_FIFOS should be a power
* of two, in order to optimize the '/AOUT_MAX_FIFOS' and '*AOUT_MAX_FIFOS'
......@@ -133,7 +133,7 @@
* - short, in order to be able to play a new song very quickly (especially a
* song from the interface)
* - long, in order to perform the buffer calculations as few as possible */
#define AOUT_BUFFER_DURATION 100000
#define AOUT_BUFFER_DURATION 50000
/*****************************************************************************
* Video configuration
......
......@@ -2,7 +2,7 @@
* scope.c : Scope effect module
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: scope.c,v 1.1 2002/02/25 04:30:03 sam Exp $
* $Id: scope.c,v 1.2 2002/02/27 22:57:10 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -52,7 +52,9 @@ static void aout_getfunctions( function_list_t * p_function_list );
*****************************************************************************/
typedef struct aout_sys_s
{
struct aout_fifo_s *p_aout_fifo; /* XXX: unused yet */
struct aout_thread_s aout;
struct aout_fifo_s *p_aout_fifo;
struct vout_thread_s *p_vout;
} aout_sys_t;
......@@ -128,6 +130,10 @@ static int aout_SetFormat( aout_thread_t *p_aout )
p_aout->i_format = AOUT_FMT_U16_LE;
p_aout->i_channels = 2;
p_aout->p_sys->aout.i_format = p_aout->i_format;
p_aout->p_sys->aout.i_channels = p_aout->i_channels;
p_aout->p_sys->aout.i_rate = p_aout->i_rate;
return( 0 );
}
......
......@@ -2,7 +2,7 @@
* vpar_headers.c : headers parsing
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: vpar_headers.c,v 1.14 2002/02/19 00:50:19 sam Exp $
* $Id: vpar_headers.c,v 1.15 2002/02/27 22:57:10 sam Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Stphane Borel <stef@via.ecp.fr>
......@@ -489,6 +489,33 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
/* Spawn a video output if there is none */
vlc_mutex_lock( &p_vout_bank->lock );
if( p_vout_bank->i_count != 0 )
{
/* Take the first video output FIXME: take the best one */
p_vpar->p_vout = p_vout_bank->pp_vout[ 0 ];
if( p_vpar->p_vout->render.i_width != p_vpar->sequence.i_width
|| p_vpar->p_vout->render.i_height != p_vpar->sequence.i_height
|| p_vpar->p_vout->render.i_chroma != ChromaToFourCC( p_vpar->sequence.i_chroma_format )
|| p_vpar->p_vout->render.i_aspect != p_vpar->sequence.i_aspect )
{
p_vout_bank->pp_vout[ 0 ] = NULL;
p_vout_bank->i_count--;
vlc_mutex_unlock( &p_vout_bank->lock );
vout_DestroyThread( p_vpar->p_vout, NULL );
vlc_mutex_lock( &p_vout_bank->lock );
/* XXX: race condition here if p_vout_bank->i_count was updated */
if( p_vout_bank->i_count )
{
vlc_mutex_unlock( &p_vout_bank->lock );
intf_ErrMsg( "vpar error: can't open vout, aborting" );
p_vpar->p_fifo->b_error = 1;
return;
}
}
}
if( p_vout_bank->i_count == 0 )
{
intf_WarnMsg( 1, "vpar: no vout present, spawning one" );
......@@ -514,11 +541,6 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
p_vout_bank->pp_vout[ p_vout_bank->i_count ] = p_vpar->p_vout;
p_vout_bank->i_count++;
}
else
{
/* Take the first video output FIXME: take the best one */
p_vpar->p_vout = p_vout_bank->pp_vout[ 0 ];
}
vlc_mutex_unlock( &p_vout_bank->lock );
}
......
......@@ -2,7 +2,7 @@
* aout_pcm.c: PCM audio output functions
*****************************************************************************
* Copyright (C) 1999-2002 VideoLAN
* $Id: aout_pcm.c,v 1.1 2002/02/24 22:06:50 sam Exp $
* $Id: aout_pcm.c,v 1.2 2002/02/27 22:57:10 sam Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
......@@ -51,7 +51,7 @@ static int NextFrame ( aout_thread_t * p_aout, aout_fifo_t * p_fifo,
void aout_PCMThread( aout_thread_t * p_aout )
{
int i_fifo;
int i_buffer, i_buffer_limit, i_bytes;
int i_buffer, i_buffer_limit, i_units = 0;
/* As the s32_buffer was created with calloc(), we don't have to set this
* memory to zero and we can immediately jump into the thread's loop */
......@@ -118,13 +118,13 @@ void aout_PCMThread( aout_thread_t * p_aout )
break;
}
i_bytes = p_aout->pf_getbufinfo( p_aout, i_buffer_limit );
switch ( p_aout->i_format )
{
case AOUT_FMT_U8:
case AOUT_FMT_S8:
p_aout->date = mdate() + ((((mtime_t)((i_bytes + 4 *
i_units = p_aout->pf_getbufinfo( p_aout, i_buffer_limit );
p_aout->date = mdate() + ((((mtime_t)((i_units + 4 *
p_aout->i_latency) / p_aout->i_channels)) * 1000000) /
((mtime_t)p_aout->i_rate)) + p_main->i_desync;
......@@ -136,7 +136,9 @@ void aout_PCMThread( aout_thread_t * p_aout )
case AOUT_FMT_U16_BE:
case AOUT_FMT_S16_LE:
case AOUT_FMT_S16_BE:
p_aout->date = mdate() + ((((mtime_t)((i_bytes + 4 *
i_units = p_aout->pf_getbufinfo( p_aout, i_buffer_limit * 2 ) / 2;
p_aout->date = mdate() + ((((mtime_t)((i_units + 4 *
p_aout->i_latency) / (2 * p_aout->i_channels))) * 1000000) /
((mtime_t)p_aout->i_rate)) + p_main->i_desync;
......@@ -145,7 +147,7 @@ void aout_PCMThread( aout_thread_t * p_aout )
break;
}
if ( i_bytes > i_buffer_limit )
if ( i_units > i_buffer_limit )
{
msleep( p_aout->i_msleep );
}
......
......@@ -2,7 +2,7 @@
* aout_spdif.c: AC3 passthrough output
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: aout_spdif.c,v 1.23 2002/02/24 22:06:50 sam Exp $
* $Id: aout_spdif.c,v 1.24 2002/02/27 22:57:10 sam Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Stphane Borel <stef@via.ecp.fr>
......@@ -55,9 +55,9 @@ void aout_SpdifThread( aout_thread_t * p_aout )
{
for( i_fifo = 0 ; i_fifo < AOUT_MAX_FIFOS ; i_fifo++ )
{
/* the loop read each fifo so that we can change the stream
/* The loop reads each fifo so that we can change the stream
* on the fly but mulitplexing is not handled yet so
* the sound will be broken is more than one fifo has data */
* the sound will be broken if more than one fifo has data */
/* TODO: write the muliplexer :) */
if( p_aout->fifo[i_fifo].i_format == AOUT_FIFO_SPDIF )
{
......@@ -93,7 +93,7 @@ void aout_SpdifThread( aout_thread_t * p_aout )
vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
/* play spdif frame to the external decoder
/* Play spdif frame to the external decoder
* the kernel driver will sleep until the
* dsp buffer is empty enough to accept the data */
if( m_play > ( mdate() - m_frame_time ) )
......
......@@ -2,7 +2,7 @@
* audio_output.c : audio output thread
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: audio_output.c,v 1.79 2002/02/26 18:25:40 gbazin Exp $
* $Id: audio_output.c,v 1.80 2002/02/27 22:57:10 sam Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
......@@ -193,8 +193,8 @@ static int aout_SpawnThread( aout_thread_t * p_aout )
/* Compute the size (in audio units) of the audio output buffer. Although
* AOUT_BUFFER_DURATION is given in microseconds, the output rate is given
* in Hz, that's why we need to divide by 10^6 microseconds (1 second) */
p_aout->i_units = ((s64)p_aout->i_rate * AOUT_BUFFER_DURATION) / 1000000;
p_aout->i_msleep = AOUT_BUFFER_DURATION / 4;
p_aout->i_units = (s64)p_aout->i_rate * AOUT_BUFFER_DURATION / 1000000;
p_aout->i_msleep = AOUT_BUFFER_DURATION;
/* Make pf_aout_thread point to the right thread function, and compute the
* byte size of the audio output buffer */
......
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