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"
#include "intf_msg.h"
#include "debug.h"
#include "input.h"
......
......@@ -8,7 +8,6 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include <pthread.h>
#include <sys/uio.h>
#include <string.h>
#include <stdio.h>
......@@ -24,6 +23,7 @@
#include "common.h"
#include "config.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "netutils.h"
#include "input.h"
......
......@@ -9,7 +9,6 @@
* Preamble
*******************************************************************************/
#include <stdio.h>
#include <pthread.h>
#include <sys/uio.h> /* iovec */
#include <stdlib.h> /* atoi(), malloc(), free() */
#include <netinet/in.h>
......@@ -17,6 +16,7 @@
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "debug.h"
#include "input.h"
#include "intf_msg.h"
......@@ -54,7 +54,7 @@ int input_PcrInit( input_thread_t *p_input )
{
return( -1 );
}
pthread_mutex_init( &p_input->p_pcr->lock, NULL );
vlc_mutex_init( &p_input->p_pcr->lock );
input_PcrReInit(p_input);
return( 0 );
......@@ -81,7 +81,7 @@ void input_PcrDecode( input_thread_t *p_input, es_descriptor_t *p_es,
sys_time = mdate();
delta_clock = sys_time - pcr_time;
pthread_mutex_lock( &p_pcr->lock );
vlc_mutex_lock( &p_pcr->lock );
if( p_es->b_discontinuity ||
( p_pcr->last_pcr != 0 &&
......@@ -106,7 +106,7 @@ void input_PcrDecode( input_thread_t *p_input, es_descriptor_t *p_es,
p_pcr->c_average++;
}
pthread_mutex_unlock( &p_pcr->lock );
vlc_mutex_unlock( &p_pcr->lock );
#ifdef STATS
{
......
......@@ -10,7 +10,6 @@
* Preamble
******************************************************************************/
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <sys/uio.h> /* iovec */
#include <stdlib.h> /* atoi(), malloc(), free() */
......@@ -23,6 +22,7 @@
#include "common.h"
#include "config.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "intf_msg.h"
#include "debug.h"
......@@ -163,7 +163,7 @@ void input_PsiRead( input_thread_t *p_input /* ??? */ )
ASSERT( p_input );
/* Lock the tables, since this method can be called from any thread */
//pthread_mutex_lock()
//vlc_mutex_lock()
/* Check if the table is complete or not */
if( !p_input->p_stream->b_is_PMT_complete )
......@@ -195,7 +195,7 @@ void input_PsiRead( input_thread_t *p_input /* ??? */ )
}
/* Unock the tables */
//pthread_mutex_unlock()
//vlc_mutex_unlock()
}
/******************************************************************************
......@@ -566,7 +566,7 @@ static void DecodePgrmMapSection( u8* p_pms, input_thread_t* p_input )
intf_DbgMsg("ES Type: %d\n", p_pms[i_offset]);
/* Read PID of that ES */
i_es_pid = U16_AT(&p_pms[i_offset+1]) & 0x1FFF;
i_es_pid = U16_AT(&p_pms[i_offset+1]) & 0x1FF;
intf_DbgMsg("ES PID: %d\n", i_es_pid);
/* Add the ES to the program description and reserve a slot in the
......@@ -880,7 +880,7 @@ static int input_AddPsiPID( input_thread_t *p_input, int i_pid )
/* Ask the input thread to demultiplex it: since the interface
can also access the table of selected es, lock the elementary
stream structure */
pthread_mutex_lock( &p_input->es_lock );
vlc_mutex_lock( &p_input->es_lock );
for( i_index = 0; i_index < INPUT_MAX_SELECTED_ES; i_index++ )
{
if( !p_input->pp_selected_es[i_index] )
......@@ -891,7 +891,7 @@ static int input_AddPsiPID( input_thread_t *p_input, int i_pid )
break;
}
}
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
if( i_index >= INPUT_MAX_SELECTED_ES )
{
......@@ -922,7 +922,7 @@ static int input_DelPsiPID( input_thread_t *p_input, int i_pid )
/* Stop to receive the ES. Since the interface can also access the table
of selected es, lock the elementary stream structure */
pthread_mutex_lock( &p_input->es_lock );
vlc_mutex_lock( &p_input->es_lock );
for( i_es_index = 0; i_es_index < INPUT_MAX_SELECTED_ES; i_es_index++ )
{
......@@ -942,7 +942,7 @@ static int input_DelPsiPID( input_thread_t *p_input, int i_pid )
}
}
pthread_mutex_unlock( &p_input->es_lock );
vlc_mutex_unlock( &p_input->es_lock );
#ifdef DEBUG
/* Check if the pp_selected_es table may be corrupted */
......@@ -1167,7 +1167,7 @@ static pgrm_descriptor_t* AddPgrmDescr( stream_descriptor_t* p_stream,
}
/******************************************************************************
* DestroyPgrmDescr: destroy a program descriptor
* AddPgrmDescr: destroy a program descriptor
******************************************************************************
* All ES descriptions referenced in the descriptor will be deleted.
******************************************************************************/
......@@ -1253,7 +1253,6 @@ static es_descriptor_t* AddESDescr(input_thread_t* p_input,
p_es->i_type = 0; /* ??? */
p_es->b_psi = 0;
p_es->b_pcr = 0;
p_es->i_continuity_counter = 0xFF;
p_es->p_pes_packet = NULL;
// p_es->p_next_pes_packet = NULL;
......@@ -1270,7 +1269,7 @@ static es_descriptor_t* AddESDescr(input_thread_t* p_input,
i_es_pid, p_pgrm->i_number );
}
else
intf_DbgMsg( "ES %d not added to the definition of any pgrm\n",
intf_DbgMsg( "Added ES %d not added to the definition of any pgrm\n",
i_es_pid );
}
......
......@@ -29,7 +29,6 @@
* Preamble
*******************************************************************************/
#include <errno.h>
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
......@@ -46,6 +45,7 @@
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "netutils.h"
#include "input.h"
......@@ -172,7 +172,7 @@ int input_VlanMethodInit( input_vlan_method_t *p_method, char *psz_server, int i
}
/* Initialize lock */
pthread_mutex_init( &p_method->lock, NULL );
vlc_mutex_init( &p_method->lock );
intf_Msg("input: vlans input method installed\n", p_method->i_ifaces);
return( 0 );
......@@ -270,7 +270,7 @@ int input_VlanJoin( int i_vlan_id )
}
/* Get lock */
pthread_mutex_lock( &p_method->lock );
vlc_mutex_lock( &p_method->lock );
/* If the interface is in the wished vlan, increase lock counter */
if( p_iface->i_vlan != VLAN_ID_VLAN( i_vlan_id ) )
......@@ -301,7 +301,7 @@ int input_VlanJoin( int i_vlan_id )
}
/* Release lock (if this point is reached, the function succeeded) */
pthread_mutex_unlock( &p_method->lock );
vlc_mutex_unlock( &p_method->lock );
return( i_err );
}
......@@ -327,13 +327,13 @@ void input_VlanLeave( int i_vlan_id )
}
/* Get lock */
pthread_mutex_lock( &p_method->lock );
vlc_mutex_lock( &p_method->lock );
/* Decrease reference counter */
p_method->p_iface[ VLAN_ID_IFACE( i_vlan_id ) ].i_refcount--;
/* Release lock */
pthread_mutex_unlock( &p_method->lock );
vlc_mutex_unlock( &p_method->lock );
}
/*******************************************************************************
......@@ -391,7 +391,7 @@ int input_VlanSynchronize( void )
/* Get lock */
p_method = &p_program_data->input_vlan_method;
pthread_mutex_lock( &p_method->lock );
vlc_mutex_lock( &p_method->lock );
for( i_index = 0; i_index < p_method->i_ifaces; i_index++ )
{
......@@ -431,7 +431,7 @@ int input_VlanSynchronize( void )
}
/* Release lock */
pthread_mutex_unlock( &p_method->lock );
vlc_mutex_unlock( &p_method->lock );
return( 0 );
}
......
......@@ -10,7 +10,6 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include <pthread.h>
#include <stdio.h>
#include <netinet/in.h>
#include <sys/soundcard.h>
......@@ -21,6 +20,7 @@
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "input.h"
#include "input_vlan.h"
......
......@@ -9,7 +9,6 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <netinet/in.h>
......@@ -25,6 +24,7 @@
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "thread.h"
#include "debug.h"
......
......@@ -11,7 +11,6 @@
* Preamble
*******************************************************************************/
#include <errno.h>
#include <pthread.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
......@@ -24,6 +23,7 @@
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "input.h"
#include "input_vlan.h"
......
......@@ -26,7 +26,6 @@
*******************************************************************************/
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
......@@ -41,6 +40,7 @@
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "debug.h"
#include "intf_msg.h"
......
......@@ -15,7 +15,6 @@
* Preamble
*******************************************************************************/
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
......@@ -29,6 +28,7 @@
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "debug.h"
#include "input.h"
......@@ -73,7 +73,7 @@ int intf_InitMsg( interface_msg_t *p_intf_msg )
{
#ifdef INTF_MSG_QUEUE
/* Message queue initialization */
pthread_mutex_init( &p_intf_msg->lock, NULL ); /* intialize lock */
vlc_mutex_init( &p_intf_msg->lock ); /* intialize lock */
p_intf_msg->i_count = 0; /* queue is empty */
#endif
......@@ -241,9 +241,9 @@ void _intf_DbgMsgImm( char *psz_file, char *psz_function, int i_line,
#ifdef INTF_MSG_QUEUE
void intf_FlushMsg( void )
{
pthread_mutex_lock( &p_program_data->intf_msg.lock ); /* get lock */
vlc_mutex_lock( &p_program_data->intf_msg.lock ); /* get lock */
FlushLockedMsg( &p_program_data->intf_msg ); /* flush messages */
pthread_mutex_unlock( &p_program_data->intf_msg.lock ); /* give lock back */
vlc_mutex_unlock( &p_program_data->intf_msg.lock ); /* give lock back */
}
#endif
......@@ -280,7 +280,7 @@ static void QueueMsg(interface_msg_t *p_intf_msg, int i_type, char *psz_format,
* Queue mode: the queue is flushed if it is full, then the message is
* queued. A lock is required on queue to avoid indexes corruption
*/
pthread_mutex_lock( &p_intf_msg->lock ); /* get lock */
vlc_mutex_lock( &p_intf_msg->lock ); /* get lock */
if( p_intf_msg->i_count == INTF_MSG_QSIZE ) /* flush queue if needed */
{
......@@ -297,7 +297,7 @@ static void QueueMsg(interface_msg_t *p_intf_msg, int i_type, char *psz_format,
p_intf_msg->msg[ p_intf_msg->i_count ].date = mdate();
#endif
pthread_mutex_unlock( &p_intf_msg->lock ); /* give lock back */
vlc_mutex_unlock( &p_intf_msg->lock ); /* give lock back */
#else
......@@ -346,7 +346,7 @@ static void QueueDbgMsg(interface_msg_t *p_intf_msg, char *psz_file, char *psz_f
* Queue mode: the queue is flushed if it is full, then the message is
* queued. A lock is required on queue to avoid indexes corruption
*/
pthread_mutex_lock( &p_intf_msg->lock ); /* get lock */
vlc_mutex_lock( &p_intf_msg->lock ); /* get lock */
if( p_intf_msg->i_count == INTF_MSG_QSIZE ) /* flush queue if needed */
{
......@@ -362,7 +362,7 @@ static void QueueDbgMsg(interface_msg_t *p_intf_msg, char *psz_file, char *psz_f
p_intf_msg->msg[ p_intf_msg->i_count ].i_line = i_line;
p_intf_msg->msg[ p_intf_msg->i_count++ ].psz_msg = psz_str;
pthread_mutex_unlock( &p_intf_msg->lock ); /* give lock back */
vlc_mutex_unlock( &p_intf_msg->lock ); /* give lock back */
#else
......
......@@ -11,7 +11,6 @@
*******************************************************************************/
#include <errno.h>
#include <getopt.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
......@@ -25,6 +24,7 @@
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "netutils.h"
#include "debug.h"
......
......@@ -24,7 +24,6 @@
*******************************************************************************/
#include <errno.h>
#include <keysym.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
......@@ -34,6 +33,7 @@
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "xutils.h"
#include "xconsole.h"
......
......@@ -9,7 +9,6 @@
* Preamble
*******************************************************************************/
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
......@@ -21,6 +20,7 @@
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "intf_msg.h"
#include "debug.h" /* ?? temporaire, requis par netlist.h */
......@@ -73,8 +73,8 @@ vdec_thread_t * vdec_CreateThread( /* video_cfg_t *p_cfg, */ input_thread_t *p_i
* Initialize the input properties
*/
/* Initialize the decoder fifo's data lock and conditional variable and set * its buffer as empty */
pthread_mutex_init( &p_vdec->fifo.data_lock, NULL );
pthread_cond_init( &p_vdec->fifo.data_wait, NULL );
vlc_mutex_init( &p_vdec->fifo.data_lock );
vlc_cond_init( &p_vdec->fifo.data_wait );
p_vdec->fifo.i_start = 0;
p_vdec->fifo.i_end = 0;
/* Initialize the bit stream structure */
......@@ -84,7 +84,7 @@ vdec_thread_t * vdec_CreateThread( /* video_cfg_t *p_cfg, */ input_thread_t *p_i
p_vdec->bit_stream.fifo.i_available = 0;
/* Spawn the video decoder thread */
if ( pthread_create(&p_vdec->thread_id, NULL, (void *)RunThread, (void *)p_vdec) )
if ( vlc_thread_create(&p_vdec->thread_id, "video decoder", (vlc_thread_func)RunThread, (void *)p_vdec) )
{
intf_ErrMsg("vdec error: can't spawn video decoder thread\n");
free( p_vdec );
......@@ -109,13 +109,13 @@ void vdec_DestroyThread( vdec_thread_t *p_vdec /*, int *pi_status */ )
/* Ask thread to kill itself */
p_vdec->b_die = 1;
/* Make sure the decoder thread leaves the GetByte() function */
pthread_mutex_lock( &(p_vdec->fifo.data_lock) );
pthread_cond_signal( &(p_vdec->fifo.data_wait) );
pthread_mutex_unlock( &(p_vdec->fifo.data_lock) );
vlc_mutex_lock( &(p_vdec->fifo.data_lock) );
vlc_cond_signal( &(p_vdec->fifo.data_wait) );
vlc_mutex_unlock( &(p_vdec->fifo.data_lock) );
/* Waiting for the decoder thread to exit */
/* Remove this as soon as the "status" flag is implemented */
pthread_join( p_vdec->thread_id, NULL );
vlc_thread_join( p_vdec->thread_id );
}
/* following functions are local */
......@@ -149,14 +149,14 @@ static int InitThread( vdec_thread_t *p_vdec )
/* Our first job is to initialize the bit stream structure with the
* beginning of the input stream */
pthread_mutex_lock( &p_vdec->fifo.data_lock );
vlc_mutex_lock( &p_vdec->fifo.data_lock );
while ( DECODER_FIFO_ISEMPTY(p_vdec->fifo) )
{
pthread_cond_wait( &p_vdec->fifo.data_wait, &p_vdec->fifo.data_lock );
vlc_cond_wait( &p_vdec->fifo.data_wait, &p_vdec->fifo.data_lock );
}
p_vdec->bit_stream.p_ts = DECODER_FIFO_START( p_vdec->fifo )->p_first_ts;
p_vdec->bit_stream.i_byte = p_vdec->bit_stream.p_ts->i_payload_start;
pthread_mutex_unlock( &p_vdec->fifo.data_lock );
vlc_mutex_unlock( &p_vdec->fifo.data_lock );
#if 0
/* ?? */
......@@ -250,7 +250,7 @@ static void ErrorThread( vdec_thread_t *p_vdec )
{
/* We take the lock, because we are going to read/write the start/end
* indexes of the decoder fifo */
pthread_mutex_lock( &p_vdec->fifo.data_lock );
vlc_mutex_lock( &p_vdec->fifo.data_lock );
/* ?? trash all trashable PES packets */
while( !DECODER_FIFO_ISEMPTY(p_vdec->fifo) )
......@@ -259,7 +259,7 @@ static void ErrorThread( vdec_thread_t *p_vdec )
DECODER_FIFO_INCSTART( p_vdec->fifo );
}
pthread_mutex_unlock( &p_vdec->fifo.data_lock );
vlc_mutex_unlock( &p_vdec->fifo.data_lock );
/* Sleep a while */
msleep( VDEC_IDLE_SLEEP );
}
......
This diff is collapsed.
......@@ -11,7 +11,6 @@
* Preamble
*******************************************************************************/
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
......@@ -27,6 +26,7 @@
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "xutils.h"
#include "input.h"
......
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