From 54d2ed599981f71a040ec214a2fc88bb5488e73a Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Borel?= Date: Wed, 6 Mar 2002 12:26:35 +0000 Subject: [PATCH] *Fixed demux plugin selection. *Take the lock on stream in VCDInit. PLease test, as I don't have any VCD to do it. --- plugins/dvd/dvd_access.c | 4 +- plugins/dvd/dvd_demux.c | 8 +-- plugins/vcd/input_vcd.c | 120 ++------------------------------------- 3 files changed, 9 insertions(+), 123 deletions(-) diff --git a/plugins/dvd/dvd_access.c b/plugins/dvd/dvd_access.c index c48a76fb03..ff51e4b894 100644 --- a/plugins/dvd/dvd_access.c +++ b/plugins/dvd/dvd_access.c @@ -8,7 +8,7 @@ * -dvd_udf to find files ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: dvd_access.c,v 1.1 2002/03/06 01:20:56 stef Exp $ + * $Id: dvd_access.c,v 1.2 2002/03/06 12:26:35 stef Exp $ * * Author: Stéphane Borel * @@ -237,6 +237,8 @@ static int DVDOpen( struct input_thread_s *p_input ) vlc_mutex_unlock( &p_input->stream.stream_lock ); + p_input->psz_demux = "dvd"; + return 0; } diff --git a/plugins/dvd/dvd_demux.c b/plugins/dvd/dvd_demux.c index 389c54cd88..35b5962fab 100644 --- a/plugins/dvd/dvd_demux.c +++ b/plugins/dvd/dvd_demux.c @@ -1,7 +1,7 @@ /* dvd_demux.c: DVD demux functions. ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: dvd_demux.c,v 1.1 2002/03/06 01:20:56 stef Exp $ + * $Id: dvd_demux.c,v 1.2 2002/03/06 12:26:35 stef Exp $ * * Author: Stéphane Borel * @@ -88,12 +88,6 @@ void _M( demux_getfunctions)( function_list_t * p_function_list ) *****************************************************************************/ static int DVDInit( input_thread_t * p_input ) { - - if( strncmp( p_input->p_access_module->psz_name, "dvd", 3 ) ) - { - return -1; - } - vlc_mutex_lock( &p_input->stream.stream_lock ); DVDLaunchDecoders( p_input ); diff --git a/plugins/vcd/input_vcd.c b/plugins/vcd/input_vcd.c index f255389f07..cb81290620 100644 --- a/plugins/vcd/input_vcd.c +++ b/plugins/vcd/input_vcd.c @@ -133,7 +133,6 @@ static int VCDOpen( struct input_thread_s *p_input ) if( p_vcd == NULL ) { intf_ErrMsg( "vcd error: out of memory" ); - p_input->b_error = 1; return -1; } @@ -196,7 +195,6 @@ static int VCDOpen( struct input_thread_s *p_input ) if( p_vcd->i_handle == -1 ) { intf_ErrMsg( "input: vcd: Could not open %s\n", psz_source ); - p_input->b_error = 1; free (p_vcd); return -1; } @@ -208,14 +206,12 @@ static int VCDOpen( struct input_thread_s *p_input ) { intf_ErrMsg( "input: vcd: was unable to count tracks" ); free( p_vcd ); - p_input->b_error = 1; return -1; } else if( p_vcd->nb_tracks <= 1 ) { intf_ErrMsg( "input: vcd: no movie tracks found" ); free( p_vcd ); - p_input->b_error = 1; return -1; } @@ -225,7 +221,6 @@ static int VCDOpen( struct input_thread_s *p_input ) { input_BuffersEnd( p_input->p_method_data ); free( p_vcd ); - p_input->b_error = 1; return -1; } @@ -265,6 +260,8 @@ static int VCDOpen( struct input_thread_s *p_input ) vlc_mutex_unlock( &p_input->stream.stream_lock ); + p_input->psz_demux = "vcd"; + return 0; } @@ -429,8 +426,9 @@ static int VCDInit( input_thread_t * p_input ) { es_descriptor_t * p_es; + vlc_mutex_lock( &p_input->stream.stream_lock ); + /* Set program information. */ - input_AddProgram( p_input, 0, sizeof( stream_ps_data_t ) ); p_input->stream.p_selected_program = p_input->stream.pp_programs[0]; @@ -478,114 +476,6 @@ static void VCDEnd( input_thread_t * p_input ) } -/***************************************************************************** - * The following functions are extracted from mpeg_ps, they should soon - * be placed in mpeg_system.c so that plugins can use them. - *****************************************************************************/ - -/***************************************************************************** - * PSRead: reads one PS packet - *****************************************************************************/ -#define PEEK( SIZE ) \ - i_error = input_Peek( p_input, &p_peek, SIZE ); \ - if( i_error == -1 ) \ - { \ - return( -1 ); \ - } \ - else if( i_error < SIZE ) \ - { \ - /* EOF */ \ - return( 0 ); \ - } - -static __inline__ ssize_t PSRead( input_thread_t * p_input, - data_packet_t ** pp_data ) -{ - byte_t * p_peek; - size_t i_packet_size; - ssize_t i_error, i_read; - - /* Read what we believe to be a packet header. */ - PEEK( 4 ); - - if( *p_peek || *(p_peek + 1) || *(p_peek + 2) != 1 ) - { - if( *p_peek || *(p_peek + 1) || *(p_peek + 2) ) - { - /* It is common for MPEG-1 streams to pad with zeros - * (although it is forbidden by the recommendation), so - * don't bother everybody in this case. */ - intf_WarnMsg( 3, "input warning: garbage at input (0x%x%x%x%x)", - *p_peek, *(p_peek + 1), *(p_peek + 2), *(p_peek + 3) ); - } - - /* This is not the startcode of a packet. Read the stream - * until we find one. */ - while( *p_peek || *(p_peek + 1) || *(p_peek + 2) != 1 ) - { - p_input->p_current_data++; - PEEK( 4 ); - } - /* Packet found. */ - } - - /* 0x1B9 == SYSTEM_END_CODE, it is only 4 bytes long. */ - if( p_peek[3] != 0xB9 ) - { - /* The packet is at least 6 bytes long. */ - PEEK( 6 ); - - if( p_peek[3] != 0xBA ) - { - /* That's the case for all packets, except pack header. */ - i_packet_size = (p_peek[4] << 8) | p_peek[5]; - } - else - { - /* Pack header. */ - if( (p_peek[4] & 0xC0) == 0x40 ) - { - /* MPEG-2 */ - i_packet_size = 8; - } - else if( (p_peek[4] & 0xF0) == 0x20 ) - { - /* MPEG-1 */ - i_packet_size = 6; - } - else - { - intf_ErrMsg( "Unable to determine stream type" ); - return( -1 ); - } - } - } - else - { - /* System End Code */ - i_packet_size = -2; - } - - /* Fetch a packet of the appropriate size. */ - i_read = input_SplitBuffer( p_input, pp_data, i_packet_size + 6 ); - if( i_read <= 0 ) - { - return( i_read ); - } - - /* In MPEG-2 pack headers we still have to read stuffing bytes. */ - if( ((*pp_data)->p_demux_start[3] == 0xBA) && (i_packet_size == 8) ) - { - size_t i_stuffing = ((*pp_data)->p_demux_start[13] & 0x7); - /* Force refill of the input buffer - though we don't care - * about p_peek. Please note that this is unoptimized. */ - PEEK( i_stuffing ); - p_input->p_current_data += i_stuffing; - } - - return( 1 ); -} - /***************************************************************************** * PSDemux: reads and demuxes data packets ***************************************************************************** @@ -601,7 +491,7 @@ static int PSDemux( input_thread_t * p_input ) data_packet_t * p_data; ssize_t i_result; - i_result = PSRead( p_input, &p_data ); + i_result = input_ReadPS( p_input, &p_data ); if( i_result <= 0 ) { -- 2.39.2