[xiph-commits] r3004 - in liboggplay/trunk/src: liboggplay tools

shans at svn.annodex.net shans at svn.annodex.net
Tue Jun 19 06:43:08 PDT 2007


Author: shans
Date: 2007-06-19 06:43:08 -0700 (Tue, 19 Jun 2007)
New Revision: 3004

Modified:
   liboggplay/trunk/src/liboggplay/oggplay.c
   liboggplay/trunk/src/liboggplay/oggplay_data.c
   liboggplay/trunk/src/liboggplay/oggplay_file_reader.c
   liboggplay/trunk/src/tools/glut-player.c
Log:
Forward seeking kinda works.  I still need to flush out the buffer so 
that the change is immediate, and we still need a fix to the current
oggz seeking problem.
Backward seeking doesn't work.
There's still some printfs in the seek code but you shouldn't be using 
it, so there.



Modified: liboggplay/trunk/src/liboggplay/oggplay.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay.c	2007-06-19 12:41:29 UTC (rev 3003)
+++ liboggplay/trunk/src/liboggplay/oggplay.c	2007-06-19 13:43:08 UTC (rev 3004)
@@ -97,6 +97,8 @@
    */
   me->oggz = oggz_new(OGGZ_READ | OGGZ_AUTO);
   oggz_io_set_read(me->oggz, me->reader->io_read, me->reader);
+  oggz_io_set_seek(me->oggz, me->reader->io_seek, me->reader);
+  oggz_io_set_tell(me->oggz, me->reader->io_tell, me->reader);
   oggz_set_read_callback(me->oggz, -1, oggplay_callback_predetected, me);
   
   while (1) {

Modified: liboggplay/trunk/src/liboggplay/oggplay_data.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_data.c	2007-06-19 12:41:29 UTC (rev 3003)
+++ liboggplay/trunk/src/liboggplay/oggplay_data.c	2007-06-19 13:43:08 UTC (rev 3004)
@@ -89,7 +89,7 @@
  */
 void
 oggplay_data_add_to_list_front(OggPlayDecode *decode, OggPlayDataHeader *data) {
-  if (decode->end_of_data_list == NULL) {
+  if (decode->data_list == NULL) {
     decode->data_list = decode->end_of_data_list = data;
     data->next = NULL;
   } else {
@@ -99,6 +99,17 @@
 }
 
 void
+_print_list(char *name, OggPlayDataHeader *p) {
+    printf("%s: ", name);
+    for (; p != NULL; p = p->next) {
+      printf("%lld[%d]", p->presentation_time >> 32, p->lock);
+      if (p->next != NULL) printf("->");
+    }
+    printf("\n");
+}
+ 
+
+void
 oggplay_data_add_to_list (OggPlayDecode *decode, OggPlayDataHeader *data) {
   
   /*
@@ -107,16 +118,32 @@
    */
   
   OggPlayDataHeader *next_in_list;
-
+  
+  //_print_list("before", decode->data_list);
+  //_print_list("untimed before", decode->untimed_data_list);
+  
   if (data->presentation_time == -1) {
     data->next = decode->untimed_data_list;
     decode->untimed_data_list = data;
   } else { 
     /*
-     * process the untimestamped data into the timestamped data list
+     * process the untimestamped data into the timestamped data list.
+     *
+     * First store any old data.
      */
-    ogg_int64_t presentation_time = data->presentation_time;
-    next_in_list = data;
+    OggPlayDataHeader *temp_list          = decode->data_list;
+    OggPlayDataHeader *end_of_temp_list   = decode->end_of_data_list;
+    ogg_int64_t presentation_time         = data->presentation_time;
+    next_in_list                          = data;
+
+    /*
+     * we need to insert in reverse order, so set the data list to NULL
+     * otherwise adding to the front will be bad.
+     */
+    if (temp_list != NULL) {
+      decode->data_list = NULL;
+    }
+    
     while (decode->untimed_data_list != NULL) {
       OggPlayDataHeader *untimed = decode->untimed_data_list;
 
@@ -134,6 +161,14 @@
       }
 
     }
+
+    /* 
+     * re-prepend any old data 
+     */
+    if (temp_list != NULL) {
+      end_of_temp_list->next = decode->data_list;
+      decode->data_list = temp_list;
+    }
   
     oggplay_data_add_to_list_end(decode, data);
 
@@ -148,6 +183,9 @@
     }
       
   }
+  
+  //_print_list("after", decode->data_list);
+  //_print_list("untimed after", decode->untimed_data_list);
 
 }
 

Modified: liboggplay/trunk/src/liboggplay/oggplay_file_reader.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_file_reader.c	2007-06-19 12:41:29 UTC (rev 3003)
+++ liboggplay/trunk/src/liboggplay/oggplay_file_reader.c	2007-06-19 13:43:08 UTC (rev 3004)
@@ -77,12 +77,23 @@
   return E_OGGPLAY_OK;
 }
 
-static int
+OggPlayErrorCode
 oggplay_file_reader_seek(OggPlayReader * handle, OGGZ * oggz, 
                                                 ogg_int64_t milliseconds) {
+  ogg_int64_t new_pos;
 
-  return E_OGGPLAY_CANT_SEEK;
+  printf("old time: %lld\n", oggz_tell_units(oggz));
+  printf("old_pos: %d\n", ((OggPlayFileReader *)handle)->current_position);
+  printf("seeking to %lld\n", milliseconds);
+  new_pos = oggz_seek_units(oggz, milliseconds, SEEK_SET);
+  printf("new time: %lld\n", new_pos);
+  printf("tell sez: %lld\n", oggz_tell_units(oggz));
+  printf("new pos: %d\n", ((OggPlayFileReader *)handle)->current_position);
+  if (new_pos == -1)
+    return E_OGGPLAY_CANT_SEEK;
   
+  return E_OGGPLAY_OK;
+  
 }
 
 static size_t

Modified: liboggplay/trunk/src/tools/glut-player.c
===================================================================
--- liboggplay/trunk/src/tools/glut-player.c	2007-06-19 12:41:29 UTC (rev 3003)
+++ liboggplay/trunk/src/tools/glut-player.c	2007-06-19 13:43:08 UTC (rev 3004)
@@ -330,11 +330,11 @@
     oggplay_close(player);
     exit(0);
   } else if (k == 'l') {
-    if (oggplay_seek(player, ld_time + 1000) == E_OGGPLAY_CANT_SEEK) {
+    if (oggplay_seek(player, ld_time + 5000) == E_OGGPLAY_CANT_SEEK) {
       printf("can't seek forwards!\n");
     }
   } else if (k == 'k') {
-    if (oggplay_seek(player, ld_time - 1000) == E_OGGPLAY_CANT_SEEK) {
+    if (oggplay_seek(player, ld_time - 5000) == E_OGGPLAY_CANT_SEEK) {
       printf("cant seek backwards!\n");
     }
   }



More information about the commits mailing list