[vlc-devel] ps.c and VCD's use

rocky at panix.com rocky at panix.com
Wed Jul 23 03:41:26 CEST 2003


(If you are in a hurry and just want to get to the patch, see towards
the bottom of this note.)

In trying to get Chapter/Entry selection working (alluded to in one of
my earlier postings) I've come across what looks to me like a bug in
ps.c.

Recall the problem is that I set i_tell in the VCD plugin, but
when
  p_input->stream.b_seekable = 1
there would be reads of sectors starting at that Chapter/Entry
followed by a seek to the beginning of the Title/Track. If 
  p_input->stream.b_seekable = 0
things would be okay.

By trial and error using gdb -p <process> (also alluded to in one of
my earlier postings) I was able to set a breakpoint and look at the
call stack to find where this seek to the beginning of the track
occurs.  In particular it is in Activate() of
modules/demux/mpeg/ps.c. 

At the beginning of Activate(), some tests for the beginning of an
MPEG PS stream are made. But it doesn't set the sector to 0 to
increase the likelihood that it is start of a MPEG PS. In my situation
the VCD plugin sets the starting point for desired "Entry" which does
not have to be the beginning of an MPEG PS stream. Furthermore, after
making the MPEG PS tests, Activate() tries to reset the stream
presumably to where it was before reading the beginning of the
MPEG. But this too seems faulty in that it does a seek 0 which again
may not be the right place for starting at a particular entry. In
other words, I think the seeks are backwards: a seek 0 *should* be
done before making the MPEG PS test, and a seek <saved location>
rather than universally 0 should be made afterwards. 

Perhaps this is made clear by the following suggested patch

-------------- next part --------------
--- ps.c.~1.9~	2003-07-22 20:58:14.000000000 -0400
+++ ps.c	2003-07-22 20:57:59.000000000 -0400
@@ -2,7 +2,7 @@
  * ps.c : Program Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: ps.c,v 1.1 2003/07/23 00:57:11 rocky Exp $
+ * $Id: ps.c,v 1.9 2003/03/09 23:39:05 jlj Exp $
  *
  * Authors: Christophe Massiot <massiot at via.ecp.fr>
  *
@@ -146,7 +146,10 @@
         stream_ps_data_t * p_demux_data =
              (stream_ps_data_t *)p_input->stream.pp_programs[0]->p_demux_data;
 
+	off_t i_tell = p_input->stream.p_selected_area->i_tell;
+
         /* Pre-parse the stream to gather stream_descriptor_t. */
+        p_input->pf_seek( p_input, (off_t) 0 );
         p_input->stream.pp_programs[0]->b_is_ok = 0;
         p_demux_data->i_PSM_version = EMPTY_PSM_VERSION;
 
@@ -183,7 +186,7 @@
             }
         }
         input_AccessReinit( p_input );
-        p_input->pf_seek( p_input, (off_t)0 );
+        p_input->pf_seek( p_input, i_tell );
         vlc_mutex_lock( &p_input->stream.stream_lock );
 
         if( p_demux_data->b_has_PSM )
-------------- next part --------------

Next problem. The Chapter Up/Down buttons don't have any effect.
These buttons probably need trigger a call VCDSeek somehow and I don't see
how that cause and effect is supposed to happen. Clues? 

Thanks.



More information about the vlc-devel mailing list