<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1170" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I have been tracing the channel change code to 
track down a pause during channel change, and I have got stuck.&nbsp; Can anyone 
help with some ideas on where to look please.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Basically the motivation is to see if I can't 
speedup channel change time.&nbsp; What I'm finding is that when tracing through 
tv_play.cpp in ChangeChannel the lines:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; 
activenvp-&gt;Pause(false);<BR>&nbsp;&nbsp;&nbsp; 
activerbuffer-&gt;WaitForPause();<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Are taking up to 600ms+ to complete.&nbsp; This is 
using a DVB card as the input source.&nbsp; </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>At first I thought I had it sussed with the 
following:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>--- 
NuppelVideoPlayer.cpp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 23 Nov 2003 05:44:16 
-0000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.297<BR>+++ 
NuppelVideoPlayer.cpp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 23 Nov 2003 18:42:59 
-0000<BR>@@ -1518,7 +1528,7 
@@<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
//printf("startplaying waiting for 
unpause\n");<BR>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
usleep(500);<BR>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
usleep(100);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
continue;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>However, this merely pushes the wait time into the 
ringbuffer-&gt;WaitForPause();&nbsp; So first of all, why usleep(500) anyway? 
And also, does anyone have any ideas on how to trace where this second call is 
spending all it's time?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Here's what I checked: The play loop in dvbrecorder 
appears to be very responsive, it only seems to be reading a single ts frame at 
a time.&nbsp; In the "if (paused)" section of the play loop there is no 
significant time delay pausing the recorder thread.&nbsp; Also I can't spot any 
significant delays pausing the decoder thread, it seems to be decoding a single 
frame each time round the play loop, so it should be pretty responsive?&nbsp; So 
what the heck is it doing for 600ms?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I think this would be a useful speedup if this 
pausing delay could be worked out.&nbsp; If anyone wants to time this for 
themselves try the following:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>--- tv_play.cpp 23 Nov 2003 01:15:30 
-0000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.122<BR>+++ tv_play.cpp 23 Nov 2003 
18:43:04 -0000<BR>@@ -1669,6 +1669,8 @@</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;void TV::ChangeChannel(int 
direction)<BR>&nbsp;{<BR>+&nbsp;&nbsp;&nbsp; QTime 
qtm;qtm.start();<BR>+&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Starting Channel 
Change\r\n";<BR>&nbsp;&nbsp;&nbsp;&nbsp; bool muted = false;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp; if (volumeControl 
&amp;&amp; !volumeControl-&gt;GetMute() &amp;&amp; activenvp == nvp)<BR>@@ 
-1684,20 +1686,28 @@<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; paused 
= false;<BR>&nbsp;&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>+&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Before Pause:" 
&lt;&lt; qtm.elapsed() &lt;&lt; "\r\n";<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
activenvp-&gt;Pause(false);<BR>+&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Pause Issued:" 
&lt;&lt; qtm.elapsed() &lt;&lt; "\r\n";<BR>&nbsp;&nbsp;&nbsp;&nbsp; // all we 
care about is the ringbuffer being paused, here..<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
activerbuffer-&gt;WaitForPause();<BR>+&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Paused:" 
&lt;&lt; qtm.elapsed() &lt;&lt; "\r\n";</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp; // Save the current 
channel if this is the first time<BR>&nbsp;&nbsp;&nbsp;&nbsp; if 
(channame_vector.size() == 0 &amp;&amp; activenvp == 
nvp)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
AddPreviousChannel();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp; 
activerecorder-&gt;Pause();<BR>+&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Active 
Recorder Paused:" &lt;&lt; qtm.elapsed() &lt;&lt; 
"\r\n";<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
activerbuffer-&gt;Reset();<BR>+&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Buffer 
reset:"&nbsp; &lt;&lt; qtm.elapsed() &lt;&lt; 
"\r\n";<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
activerecorder-&gt;ChangeChannel(direction);<BR>+&nbsp;&nbsp;&nbsp; cout 
&lt;&lt; "Active Recorder Channel Changed:" &lt;&lt; qtm.elapsed() &lt;&lt; 
"\r\n";</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp; 
activenvp-&gt;ResetPlaying();<BR>+&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Reset 
Playing:" &lt;&lt; qtm.elapsed() &lt;&lt; "\r\n";<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
activenvp-&gt;Unpause(false);<BR>+&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Un Paused:" 
&lt;&lt; qtm.elapsed() &lt;&lt; "\r\n";</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp; if (activenvp == 
nvp)<BR>&nbsp;&nbsp;&nbsp;&nbsp; {<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;</DIV></FONT>
<DIV><FONT face=Arial size=2>However, whilst I was fiddling it occurs to me that 
the current mpegrecorder.cpp uses this in the StartRecording loop:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret = 
read(readfd, buffer, 256000);<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Someone with a PVR card might want to try dropping 
the read size to say 64000.&nbsp; Just eyeballing the code, but this&nbsp;would 
appear to make the record loop more responsive and speedup the pausing 
code?&nbsp; I don't have one, so feedback appreciated..</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>The other thing I don't quite understand is how 
much pre-buffering is required for various input sources.&nbsp; It seems at 
least for DVB input sources that the following change works very 
well:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>--- videoout_xv.cpp&nbsp;&nbsp;&nbsp;&nbsp; 10 Nov 
2003 21:45:01 -0000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.87<BR>+++ 
videoout_xv.cpp&nbsp;&nbsp;&nbsp;&nbsp; 23 Nov 2003 18:43:04 -0000<BR>@@ -46,7 
+46,8 @@</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;const int kNumBuffers = 31;<BR>&nbsp;const 
int kNeedFreeFrames = 1;<BR>-const int kPrebufferFrames = 12;<BR>+//const int 
kPrebufferFrames = 12;<BR>+const int kPrebufferFrames = 2;<BR>&nbsp;const int 
kKeepPrebuffer = 2;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;struct XvData<BR></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>What are the issues with reducing this?&nbsp; Also, 
what is the difference between kKeppPrebuffer and kPrebufferFrames?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>In any case, with these changes, at least for the 
times when the pause runs quickly, the channel change time is pretty good 
really.&nbsp; Any chance someone could pitch in with some feedback and lets see 
if we can't tune this a little</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Ed</DIV></FONT></BODY></HTML>