[xiph-cvs] cvs commit: theora/examples splayer.c

Mauricio Piacentini mauricio at xiph.org
Mon Jul 7 08:27:56 PDT 2003



mauricio    03/07/07 11:27:55

  Modified:    examples splayer.c
  Log:
  fix to make splayer compatible with video-only theora streams, getting time information from SDL

Revision  Changes    Path
1.5       +19 -6     theora/examples/splayer.c

Index: splayer.c
===================================================================
RCS file: /usr/local/cvsroot/theora/examples/splayer.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- splayer.c	12 Jun 2003 10:39:38 -0000	1.4
+++ splayer.c	7 Jul 2003 15:27:55 -0000	1.5
@@ -507,6 +507,9 @@
 SAMPLE      *samples; /*local buffer for samples*/
 double latency_sec = 0;
 
+/*ticks information to be used if the audio stream is not present*/
+int    currentTicks = -1;
+
 /*initial state of the audio stream*/
 int isPlaying = 0;
 PaError err;
@@ -631,12 +634,22 @@
 
 
 double get_time(){
-  /*not entirely accurate with the WAVE OUT device, but good enough
-  at this stage. Needs to be reworked to account for blank audio
-  data written to the stream...*/
-  double curtime = (double) (GetAudioStreamTime( aOutStream ) / vi.rate) -  latency_sec;
-  if (curtime<0) curtime = 0;
-  return  curtime  ;
+    double curtime;
+    if (vorbis_p){
+     /*not entirely accurate with the WAVE OUT device, but good enough
+     at this stage. Needs to be reworked to account for blank audio
+     data written to the stream...*/
+      curtime = (double) (GetAudioStreamTime( aOutStream ) / vi.rate) -  latency_sec;
+      if (curtime<0) curtime = 0;
+	} else {
+        /*initialize timer variable if not set yet*/
+        if (currentTicks==-1) {
+            currentTicks = SDL_GetTicks();
+            return currentTicks;
+        }
+		curtime = (double) (SDL_GetTicks() - currentTicks)/1000.0F;
+	}
+    return  curtime  ;
 }
 
 

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list