Commit a6d3ffa1 authored by Jean-Marc Dressler's avatar Jean-Marc Dressler

Fin du remplacement des pthread + ajout du frame rate dans display.c.

Polux
parent 1d620095
......@@ -13,7 +13,6 @@
******************************************************************************/
#include <unistd.h>
#include <pthread.h>
#include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* malloc(), free() */
#include <netinet/in.h> /* ntohl() */
......@@ -23,6 +22,7 @@
#include "common.h"
#include "config.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "debug.h" /* "input_netlist.h" */
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
......@@ -85,8 +85,8 @@ adec_thread_t * adec_CreateThread( input_thread_t * p_input )
*/
/* Initialize the decoder fifo's data lock and conditional variable and set
* its buffer as empty */
pthread_mutex_init( &p_adec->fifo.data_lock, NULL );
pthread_cond_init( &p_adec->fifo.data_wait, NULL );
vlc_mutex_init( &p_adec->fifo.data_lock );
vlc_cond_init( &p_adec->fifo.data_wait );
p_adec->fifo.i_start = 0;
p_adec->fifo.i_end = 0;
/* Initialize the bit stream structure */
......@@ -110,7 +110,7 @@ adec_thread_t * adec_CreateThread( input_thread_t * p_input )
p_adec->p_aout_fifo = NULL;
/* Spawn the audio decoder thread */
if ( pthread_create(&p_adec->thread_id, NULL, (void *)RunThread, (void *)p_adec) )
if ( vlc_thread_create(&p_adec->thread_id, "audio decoder", (vlc_thread_func)RunThread, (void *)p_adec) )
{
intf_ErrMsg("adec error: can't spawn audio decoder thread\n");
free( p_adec );
......@@ -137,13 +137,13 @@ void adec_DestroyThread( adec_thread_t * p_adec )
/* Ask thread to kill itself */
p_adec->b_die = 1;
/* Make sure the decoder thread leaves the GetByte() function */
pthread_mutex_lock( &(p_adec->fifo.data_lock) );
pthread_cond_signal( &(p_adec->fifo.data_wait) );
pthread_mutex_unlock( &(p_adec->fifo.data_lock) );
vlc_mutex_lock( &(p_adec->fifo.data_lock) );
vlc_cond_signal( &(p_adec->fifo.data_wait) );
vlc_mutex_unlock( &(p_adec->fifo.data_lock) );
/* Waiting for the decoder thread to exit */
/* Remove this as soon as the "status" flag is implemented */
pthread_join( p_adec->thread_id, NULL );
vlc_thread_join( p_adec->thread_id );
}
/* Following functions are local */
......@@ -702,14 +702,14 @@ static int InitThread( adec_thread_t * p_adec )
/* Our first job is to initialize the bit stream structure with the
* beginning of the input stream */
pthread_mutex_lock( &p_adec->fifo.data_lock );
vlc_mutex_lock( &p_adec->fifo.data_lock );
while ( DECODER_FIFO_ISEMPTY(p_adec->fifo) )
{
pthread_cond_wait( &p_adec->fifo.data_wait, &p_adec->fifo.data_lock );
vlc_cond_wait( &p_adec->fifo.data_wait, &p_adec->fifo.data_lock );
}
p_adec->bit_stream.p_ts = DECODER_FIFO_START( p_adec->fifo )->p_first_ts;
p_adec->bit_stream.i_byte = p_adec->bit_stream.p_ts->i_payload_start;
pthread_mutex_unlock( &p_adec->fifo.data_lock );
vlc_mutex_unlock( &p_adec->fifo.data_lock );
/* Now we look for an audio frame header in the input stream */
if ( FindHeader(p_adec) )
......@@ -836,7 +836,7 @@ static void RunThread( adec_thread_t * p_adec )
/* Waiting until there is enough free space in the audio output fifo
* in order to store the new decoded frames */
pthread_mutex_lock( &p_adec->p_aout_fifo->data_lock );
vlc_mutex_lock( &p_adec->p_aout_fifo->data_lock );
/* adec_Layer2_Stereo() produces 6 output frames (2*1152/384)...
* If these 6 frames were recorded in the audio output fifo, the
* l_end_frame index would be incremented 6 times. But, if after
......@@ -844,14 +844,14 @@ static void RunThread( adec_thread_t * p_adec )
* it would mean that we had not enough room to store the 6 frames :-P */
while ( (((p_adec->p_aout_fifo->l_end_frame + 6) - p_adec->p_aout_fifo->l_start_frame) & AOUT_FIFO_SIZE) < 6 ) /* !! */
{
pthread_cond_wait( &p_adec->p_aout_fifo->data_wait, &p_adec->p_aout_fifo->data_lock );
vlc_cond_wait( &p_adec->p_aout_fifo->data_wait, &p_adec->p_aout_fifo->data_lock );
}
pthread_mutex_unlock( &p_adec->p_aout_fifo->data_lock );
vlc_mutex_unlock( &p_adec->p_aout_fifo->data_lock );
/* Decoding the frames */
if ( adec_Layer2_Stereo(p_adec) )
{
pthread_mutex_lock( &p_adec->p_aout_fifo->data_lock );
vlc_mutex_lock( &p_adec->p_aout_fifo->data_lock );
/* Frame 1 */
if ( DECODER_FIFO_START(p_adec->fifo)->b_has_pts )
{
......@@ -878,7 +878,7 @@ static void RunThread( adec_thread_t * p_adec )
/* Frame 6 */
p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = LAST_MDATE;
p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
pthread_mutex_unlock( &p_adec->p_aout_fifo->data_lock );
vlc_mutex_unlock( &p_adec->p_aout_fifo->data_lock );
}
}
break;
......@@ -926,7 +926,7 @@ static void ErrorThread( adec_thread_t *p_adec )
{
/* We take the lock, because we are going to read/write the start/end
* indexes of the decoder fifo */
pthread_mutex_lock( &p_adec->fifo.data_lock );
vlc_mutex_lock( &p_adec->fifo.data_lock );
/* Wait until a `die' order is sent */
while( !p_adec->b_die )
......@@ -939,11 +939,11 @@ static void ErrorThread( adec_thread_t *p_adec )
}
/* Waiting for the input thread to put new PES packets in the fifo */
pthread_cond_wait( &p_adec->fifo.data_wait, &p_adec->fifo.data_lock );
vlc_cond_wait( &p_adec->fifo.data_wait, &p_adec->fifo.data_lock );
}
/* We can release the lock before leaving */
pthread_mutex_unlock( &p_adec->fifo.data_lock );
vlc_mutex_unlock( &p_adec->fifo.data_lock );
}
/******************************************************************************
......
......@@ -10,12 +10,12 @@
#include <stdlib.h> /* malloc(), free() */
#include <netinet/in.h> /* ntohl() */
#include <sys/soundcard.h> /* "audio_output.h" */
#include <pthread.h>
#include <sys/uio.h>
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "debug.h"
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
......
......@@ -15,7 +15,6 @@
/******************************************************************************
* Preamble
******************************************************************************/
#include <pthread.h>
#include <fcntl.h> /* open(), O_WRONLY */
#include <sys/ioctl.h> /* ioctl() */
#include <unistd.h> /* write(), close() */
......@@ -24,6 +23,7 @@
#include "common.h" /* boolean_t, byte_t */
#include "mtime.h"
#include "vlc_thread.h"
#include "audio_output.h" /* aout_dsp_t */
#include "audio_dsp.h"
......
......@@ -12,7 +12,7 @@
* chaque boucle
* = Utiliser des tables pour les gros calculs
* - Faire une structure diffrente pour intf/adec fifo
* - Rajouter des pthread_cond_signal ?
* - Rajouter des vlc_cond_signal ?
*
*/
......@@ -21,7 +21,6 @@
******************************************************************************/
#include <unistd.h>
#include <pthread.h>
#include <sys/soundcard.h>
#include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* calloc(), malloc(), free() */
......@@ -29,6 +28,7 @@
#include "common.h"
#include "config.h"
#include "mtime.h" /* mtime_t, mdate(), msleep() */
#include "vlc_thread.h"
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
......@@ -112,13 +112,13 @@ int aout_SpawnThread( aout_thread_t * p_aout )
p_aout->b_die = 0;
/* Initialize the fifos lock */
pthread_mutex_init( &p_aout->fifos_lock, NULL );
vlc_mutex_init( &p_aout->fifos_lock );
/* Initialize audio fifos : set all fifos as empty and initialize locks */
for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
{
p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
pthread_mutex_init( &p_aout->fifo[i_fifo].data_lock, NULL );
pthread_cond_init( &p_aout->fifo[i_fifo].data_wait, NULL );
vlc_mutex_init( &p_aout->fifo[i_fifo].data_lock );
vlc_cond_init( &p_aout->fifo[i_fifo].data_wait );
}
/* Compute the size (in audio units) of the audio output buffer. Although
......@@ -239,7 +239,7 @@ int aout_SpawnThread( aout_thread_t * p_aout )
p_aout->date = mdate();
/* Launch the thread */
if ( pthread_create( &p_aout->thread_id, NULL, aout_thread, p_aout ) )
if ( vlc_thread_create( &p_aout->thread_id, "audio output", (vlc_thread_func)aout_thread, p_aout ) )
{
intf_ErrMsg("aout error: can't spawn audio output thread (%p)\n", p_aout);
free( p_aout->buffer );
......@@ -260,7 +260,7 @@ void aout_CancelThread( aout_thread_t * p_aout )
/* Ask thread to kill itself and wait until it's done */
p_aout->b_die = 1;
pthread_join( p_aout->thread_id, NULL );
vlc_thread_join( p_aout->thread_id );
/* Free the allocated memory */
free( p_aout->buffer );
......@@ -284,7 +284,7 @@ aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo )
int i_fifo;
/* Take the fifos lock */
pthread_mutex_lock( &p_aout->fifos_lock );
vlc_mutex_lock( &p_aout->fifos_lock );
/* Looking for a free fifo structure */
for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
......@@ -297,7 +297,7 @@ aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo )
if ( i_fifo == AOUT_MAX_FIFOS )
{
intf_ErrMsg("aout error: no empty fifo available\n");
pthread_mutex_unlock( &p_aout->fifos_lock );
vlc_mutex_unlock( &p_aout->fifos_lock );
return( NULL );
}
......@@ -333,7 +333,7 @@ aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo )
{
intf_ErrMsg("aout error: not enough memory to create the frames buffer\n");
p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
pthread_mutex_unlock( &p_aout->fifos_lock );
vlc_mutex_unlock( &p_aout->fifos_lock );
return( NULL );
}
......@@ -343,7 +343,7 @@ aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo )
intf_ErrMsg("aout error: not enough memory to create the dates buffer\n");
free( p_aout->fifo[i_fifo].buffer );
p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
pthread_mutex_unlock( &p_aout->fifos_lock );
vlc_mutex_unlock( &p_aout->fifos_lock );
return( NULL );
}
......@@ -365,12 +365,12 @@ aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo )
default:
intf_ErrMsg("aout error: unknown fifo type (%i)\n", p_aout->fifo[i_fifo].i_type);
p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
pthread_mutex_unlock( &p_aout->fifos_lock );
vlc_mutex_unlock( &p_aout->fifos_lock );
return( NULL );
}
/* Release the fifos lock */
pthread_mutex_unlock( &p_aout->fifos_lock );
vlc_mutex_unlock( &p_aout->fifos_lock );
/* Return the pointer to the fifo structure */
intf_DbgMsg("aout debug: audio output fifo (%p) allocated\n", &p_aout->fifo[i_fifo]);
......@@ -431,7 +431,7 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo/*,
long l_units, l_rate;
/* We take the lock */
pthread_mutex_lock( &p_fifo->data_lock );
vlc_mutex_lock( &p_fifo->data_lock );
/* Are we looking for a dated start frame ? */
if ( !p_fifo->b_start_frame )
......@@ -448,7 +448,7 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo/*,
}
if ( p_fifo->l_start_frame == p_fifo->l_end_frame )
{
pthread_mutex_unlock( &p_fifo->data_lock );
vlc_mutex_unlock( &p_fifo->data_lock );
return( -1 );
}
}
......@@ -456,7 +456,7 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo/*,
if ( aout_date < p_fifo->date[p_fifo->l_start_frame] )
{
fprintf(stderr, "+");
pthread_mutex_unlock( &p_fifo->data_lock );
vlc_mutex_unlock( &p_fifo->data_lock );
return( -1 );
}
*/
......@@ -496,7 +496,7 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo/*,
/* p_fifo->b_next_frame = 0; */
p_fifo->l_end_frame = 0;
}
pthread_mutex_unlock( &p_fifo->data_lock );
vlc_mutex_unlock( &p_fifo->data_lock );
return( -1 );
}
......@@ -513,7 +513,7 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo/*,
* p_aout->dsp.l_rate) / l_rate) + 1;
/* We release the lock before leaving */
pthread_mutex_unlock( &p_fifo->data_lock );
vlc_mutex_unlock( &p_fifo->data_lock );
return( 0 );
}
......@@ -549,7 +549,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
* memory to zero and we can immediately jump into the thread's loop */
while ( !p_aout->b_die )
{
pthread_mutex_lock( &p_aout->fifos_lock );
vlc_mutex_lock( &p_aout->fifos_lock );
for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
{
switch ( p_aout->fifo[i_fifo].i_type )
......@@ -674,10 +674,10 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
}
l_units -= p_aout->fifo[i_fifo].l_units;
pthread_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame;
pthread_cond_signal( &p_aout->fifo[i_fifo].data_wait );
pthread_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait );
vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
/* p_aout->fifo[i_fifo].b_start_frame = 1; */
p_aout->fifo[i_fifo].l_next_frame += 1;
......@@ -742,10 +742,10 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
}
l_units -= p_aout->fifo[i_fifo].l_units;
pthread_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame;
pthread_cond_signal( &p_aout->fifo[i_fifo].data_wait );
pthread_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait );
vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
/* p_aout->fifo[i_fifo].b_start_frame = 1; */
p_aout->fifo[i_fifo].l_next_frame += 1;
......@@ -760,7 +760,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
break;
}
}
pthread_mutex_unlock( &p_aout->fifos_lock );
vlc_mutex_unlock( &p_aout->fifos_lock );
l_buffer_limit = p_aout->l_units << 1; /* p_aout->dsp.b_stereo == 1 */
......@@ -790,7 +790,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
UPDATE_INCREMENT( p_aout->date_increment, p_aout->date )
}
pthread_mutex_lock( &p_aout->fifos_lock );
vlc_mutex_lock( &p_aout->fifos_lock );
for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
{
switch ( p_aout->fifo[i_fifo].i_type )
......@@ -817,7 +817,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
break;
}
}
pthread_mutex_unlock( &p_aout->fifos_lock );
vlc_mutex_unlock( &p_aout->fifos_lock );
}
void aout_Thread_U16_Mono( aout_thread_t * p_aout )
......
......@@ -16,7 +16,6 @@
* Preamble
*******************************************************************************/
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
......@@ -28,6 +27,7 @@
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "thread.h"
#include "intf_msg.h"
......@@ -100,7 +100,7 @@ gdec_thread_t * gdec_CreateThread( gdec_cfg_t *p_cfg, input_thread_t *p_input,
p_gdec->b_active = 1;
/* Create thread */
if( pthread_create( &p_gdec->thread_id, NULL, (void *) RunThread, (void *) p_gdec) )
if( vlc_thread_create( &p_gdec->thread_id, "generic decoder", (vlc_thread_func)RunThread, (void *) p_gdec) )
{
intf_ErrMsg("gdec error: %s\n", strerror(ENOMEM));
intf_DbgMsg("failed\n");
......@@ -145,9 +145,9 @@ void gdec_DestroyThread( gdec_thread_t *p_gdec, int *pi_status )
/* Request thread destruction */
p_gdec->b_die = 1;
/* Make sure the decoder thread leaves the GetByte() function */
pthread_mutex_lock( &(p_gdec->fifo.data_lock) );
pthread_cond_signal( &(p_gdec->fifo.data_wait) );
pthread_mutex_unlock( &(p_gdec->fifo.data_lock) );
vlc_mutex_lock( &(p_gdec->fifo.data_lock) );
vlc_cond_signal( &(p_gdec->fifo.data_wait) );
vlc_mutex_unlock( &(p_gdec->fifo.data_lock) );
/* If status is NULL, wait until thread has been destroyed */
if( pi_status )
......
......@@ -10,7 +10,6 @@
* Preamble
******************************************************************************/
#include <errno.h>
#include <pthread.h>
#include <sys/uio.h> /* iovec */
#include <string.h>
......@@ -27,6 +26,7 @@
#include "common.h"
#include "config.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "intf_msg.h"
#include "debug.h"
......@@ -186,13 +186,13 @@ input_thread_t *input_CreateThread( input_cfg_t *p_cfg )
/* Create thread and set locks. */
p_input->b_die = 0;
pthread_mutex_init( &p_input->netlist.lock, NULL );
pthread_mutex_init( &p_input->programs_lock, NULL );
pthread_mutex_init( &p_input->es_lock, NULL );
vlc_mutex_init( &p_input->netlist.lock );
vlc_mutex_init( &p_input->programs_lock );
vlc_mutex_init( &p_input->es_lock );
#ifdef NO_THREAD
input_Thread( p_input );
#else
if( pthread_create(&p_input->thread_id, NULL, (void *) input_Thread,
if( vlc_thread_create(&p_input->thread_id, "input", (vlc_thread_func)input_Thread,
(void *) p_input) )
{
intf_ErrMsg("input error: can't spawn input thread (%s)\n",
......@@ -223,7 +223,7 @@ void input_DestroyThread( input_thread_t *p_input )
p_input->b_die = 1; /* ask thread to kill itself */
/* Remove this as soon as the "status" flag is implemented */
pthread_join( p_input->thread_id, NULL ); /* wait until it's done */
vlc_thread_join( p_input->thread_id ); /* wait until it's done */
}
#if 0
......@@ -304,7 +304,7 @@ static void input_Thread( input_thread_t *p_input )
EndThread( p_input );
intf_DbgMsg("input debug: thread %p destroyed\n", p_input);
pthread_exit( 0 );
vlc_thread_exit( 0 );
}
......@@ -458,7 +458,7 @@ static __inline__ int input_ReadPacket( input_thread_t *p_input )
/* Remove the TS packets we have just filled from the netlist */
#ifdef INPUT_LIFO_TS_NETLIST
/* We need to take a lock here while we're calculating index positions. */
pthread_mutex_lock( &p_input->netlist.lock );
vlc_mutex_lock( &p_input->netlist.lock );
i_meanwhile_released = i_base_index - p_input->netlist.i_ts_index;
if( i_meanwhile_released )
......@@ -498,7 +498,7 @@ static __inline__ int input_ReadPacket( input_thread_t *p_input )
p_input->netlist.i_ts_index = i_current_index;
}
pthread_mutex_unlock( &p_input->netlist.lock );
vlc_mutex_unlock( &p_input->netlist.lock );
#else /* FIFO netlist */
/* & is modulo ; that's where we make the loop. */
......@@ -538,7 +538,7 @@ static __inline__ void input_SortPacket( input_thread_t *p_input,
// i_current_pid, p_ts_packet);
/* Lock current ES state. */
pthread_mutex_lock( &p_input->es_lock );
vlc_mutex_lock( &p_input->es_lock );
/* Verify that we actually want this PID. */
for( i_es_loop = 0; i_es_loop < INPUT_MAX_SELECTED_ES; i_es_loop++ )
......@@ -553,7 +553,7 @@ static __inline__ void input_SortPacket( input_thread_t *p_input,
modified from inside the input_thread (by the PSI
decoder): interface thread is only allowed to modify
the pp_selected_es table */
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
/* We're interested. Pass it to the demultiplexer. */
input_DemuxTS( p_input, p_ts_packet,
......@@ -567,7 +567,7 @@ static __inline__ void input_SortPacket( input_thread_t *p_input,
break;
}
}
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
}
/* We weren't interested in receiving this packet. Give it back to the
......@@ -705,16 +705,6 @@ static __inline__ void input_DemuxTS( input_thread_t *p_input,
intf_DbgMsg("Duplicate packet received by TS demux\n");
b_trash = 1;
}
else if( p_es_descriptor->i_continuity_counter == 0xFF )
{
/* This means that the packet is the first one we receive for this
ES since the continuity counter ranges between 0 and 0x0F
excepts when it has been initialized by the input: Init the
counter to the correct value. */
intf_DbgMsg("First packet for PID %d received by TS demux\n",
p_es_descriptor->i_id);
p_es_descriptor->i_continuity_counter = (p[3] & 0x0f);
}
else
{
/* This can indicate that we missed a packet or that the
......@@ -841,7 +831,7 @@ static __inline__ void input_DemuxPES( input_thread_t *p_input,
so the PES won't be usefull for any decoder. Moreover,
this should never happen so we can trash the packet and
exit roughly without regrets */
intf_DbgMsg("PES packet is too short: trashed\n");
intf_DbgMsg("PES packet too short: trashed\n");
input_NetlistFreePES( p_input, p_pes );
p_pes = NULL;
/* Stats ?? */
......@@ -915,7 +905,7 @@ static __inline__ void input_DemuxPES( input_thread_t *p_input,
pcr_descriptor_t * p_pcr;
p_pcr = p_input->p_pcr;
pthread_mutex_lock( &p_pcr->lock );
vlc_mutex_lock( &p_pcr->lock );
if( p_pcr->delta_clock == 0 )
{
p_pes->b_has_pts = 0;
......@@ -935,7 +925,7 @@ static __inline__ void input_DemuxPES( input_thread_t *p_input,
p_pes->i_pts += p_pcr->delta_decode;
p_pcr->c_pts += 1;
}
pthread_mutex_unlock( &p_pcr->lock );
vlc_mutex_unlock( &p_pcr->lock );
}
break;
}
......@@ -982,7 +972,7 @@ static __inline__ void input_DemuxPES( input_thread_t *p_input,
if( p_fifo != NULL )
{
pthread_mutex_lock( &p_fifo->data_lock );
vlc_mutex_lock( &p_fifo->data_lock );
if( DECODER_FIFO_ISFULL( *p_fifo ) )
{
/* The FIFO is full !!! This should not happen. */
......@@ -1002,9 +992,9 @@ static __inline__ void input_DemuxPES( input_thread_t *p_input,
DECODER_FIFO_INCEND( *p_fifo );
/* Warn the decoder that it's got work to do. */
pthread_cond_signal( &p_fifo->data_wait );
vlc_cond_signal( &p_fifo->data_wait );
}
pthread_mutex_unlock( &p_fifo->data_lock );
vlc_mutex_unlock( &p_fifo->data_lock );
}
else
{
......
......@@ -10,7 +10,6 @@
* Preamble
*******************************************************************************/
#include <errno.h>
#include <pthread.h>
#include <sys/uio.h> /* iovec */
#include <stdlib.h> /* atoi(), malloc(), free() */
#include <string.h>
......@@ -25,6 +24,7 @@
#include "common.h"
#include "config.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "intf_msg.h"
#include "debug.h"
......@@ -56,7 +56,7 @@ int input_AddPgrmElem( input_thread_t *p_input, int i_current_id )
/* Since this function is intended to be called by interface, lock the
* elementary stream structure. */
pthread_mutex_lock( &p_input->es_lock );
vlc_mutex_lock( &p_input->es_lock );
/* Find out which PID we need. */
for( i_es_loop = 0; i_es_loop < INPUT_MAX_ES; i_es_loop++ )
......@@ -66,7 +66,7 @@ int input_AddPgrmElem( input_thread_t *p_input, int i_current_id )
if( p_input->p_es[i_es_loop].p_dec != NULL )
{
/* We already have a decoder for that PID. */
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
intf_ErrMsg("input error: PID %d already selected\n",
i_current_id);
return( -1 );
......@@ -82,7 +82,7 @@ int input_AddPgrmElem( input_thread_t *p_input, int i_current_id )
if( i_selected_es_loop == INPUT_MAX_SELECTED_ES )
{
/* array full */
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
intf_ErrMsg("input error: MAX_SELECTED_ES reached: try increasing it in config.h\n");
return( -1 );
}
......@@ -91,7 +91,7 @@ int input_AddPgrmElem( input_thread_t *p_input, int i_current_id )
if( p_input->p_es[i_es_loop].b_psi )
{
intf_ErrMsg("input_error: trying to decode PID %d which is the one of a PSI\n");
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
return( -1 );
}
else
......@@ -106,7 +106,7 @@ int input_AddPgrmElem( input_thread_t *p_input, int i_current_id )
adec_CreateThread( p_input )) == NULL )
{
intf_ErrMsg("Could not start audio decoder\n");
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
return( -1 );
}
break;
......@@ -119,7 +119,7 @@ int input_AddPgrmElem( input_thread_t *p_input, int i_current_id )
vdec_CreateThread( p_input )) == NULL )
{
intf_ErrMsg("Could not start video decoder\n");
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
return( -1 );
}
break;
......@@ -128,27 +128,27 @@ int input_AddPgrmElem( input_thread_t *p_input, int i_current_id )
/* That should never happen. */
intf_DbgMsg("input error: unknown stream type (%d)\n",
p_input->p_es[i_es_loop].i_type);
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
return( -1 );
break;
}
/* Initialise the demux */
p_input->p_es[i_es_loop].p_pes_packet = NULL;
p_input->p_es[i_es_loop].i_continuity_counter = 0xFF;
p_input->p_es[i_es_loop].i_continuity_counter = 0;
p_input->p_es[i_es_loop].b_random = 0;
/* Mark stream to be demultiplexed. */
intf_DbgMsg("Stream %d added in %d\n", i_current_id, i_selected_es_loop);
p_input->pp_selected_es[i_selected_es_loop] = &p_input->p_es[i_es_loop];
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
return( 0 );
}
}
}
/* We haven't found this PID in the current stream. */
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
intf_ErrMsg("input error: can't find PID %d\n", i_current_id);
return( -1 );
}
......@@ -167,7 +167,7 @@ int input_DelPgrmElem( input_thread_t *p_input, int i_current_id )
/* Since this function is intended to be called by interface, lock the
structure. */
pthread_mutex_lock( &p_input->es_lock );
vlc_mutex_lock( &p_input->es_lock );
/* Find out which PID we need. */
for( i_selected_es_loop = 0; i_selected_es_loop < INPUT_MAX_SELECTED_ES;
......@@ -180,7 +180,7 @@ int input_DelPgrmElem( input_thread_t *p_input, int i_current_id )
if( !(p_input->pp_selected_es[i_selected_es_loop]->p_dec) )
{
/* We don't have a decoder for that PID. */
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
intf_ErrMsg("input error: PID %d already deselected\n",
i_current_id);
return( -1 );
......@@ -217,14 +217,14 @@ int input_DelPgrmElem( input_thread_t *p_input, int i_current_id )
p_input->pp_selected_es[i_last_selected];
p_input->pp_selected_es[i_last_selected] = NULL;
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
return( 0 );
}
}
}
/* We haven't found this PID in the current stream. */
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
intf_ErrMsg("input error: can't find PID %d\n", i_current_id);
return( -1 );
}
......@@ -244,7 +244,7 @@ boolean_t input_IsElemRecv( input_thread_t *p_input, int i_id )
/* Since this function is intended to be called by interface, lock the
structure. */
pthread_mutex_lock( &p_input->es_lock );
vlc_mutex_lock( &p_input->es_lock );
/* Scan the table */
while( i_index < INPUT_MAX_SELECTED_ES && !p_input->pp_selected_es[i_index] )
......@@ -257,7 +257,7 @@ boolean_t input_IsElemRecv( input_thread_t *p_input, int i_id )
}
/* Unlock the structure */
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
return( b_is_recv );
}
......@@ -6,12 +6,12 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include <pthread.h>
#include <sys/uio.h>
#include "common.h"
#include "config.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "input.h"
#include "input_file.h"
......
......@@ -8,7 +8,6 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include <pthread.h>
#include <sys/uio.h>
#include <stdlib.h>
#include <stdio.h>
......@@ -18,6 +17,7 @@
#include "common.h"
#include "config.h"
#include "mtime.h"
#include "vlc_thread.h"