[xiph-commits] r3761 - in liboggplay/trunk: include/oggplay src/liboggplay

doublec at svn.annodex.net doublec at svn.annodex.net
Mon Nov 3 13:59:56 PST 2008


Author: doublec
Date: 2008-11-03 13:59:55 -0800 (Mon, 03 Nov 2008)
New Revision: 3761

Modified:
   liboggplay/trunk/include/oggplay/oggplay.h
   liboggplay/trunk/include/oggplay/oggplay_reader.h
   liboggplay/trunk/src/liboggplay/oggplay.c
   liboggplay/trunk/src/liboggplay/oggplay_seek.c
   liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c
Log:
Provide a way to get duration of Ogg file. Fixes #424.
Changed oggplay_get_duration to use liboggz to get the
duration if a 'duration' function is not provided by the
reader. The reader duration type was also changed from int to
ogg_int64_t.


Modified: liboggplay/trunk/include/oggplay/oggplay.h
===================================================================
--- liboggplay/trunk/include/oggplay/oggplay.h	2008-11-03 21:44:58 UTC (rev 3760)
+++ liboggplay/trunk/include/oggplay/oggplay.h	2008-11-03 21:59:55 UTC (rev 3761)
@@ -134,7 +134,7 @@
 int
 oggplay_get_available(OggPlay *player);
 
-int
+ogg_int64_t
 oggplay_get_duration(OggPlay * player);
 
 int

Modified: liboggplay/trunk/include/oggplay/oggplay_reader.h
===================================================================
--- liboggplay/trunk/include/oggplay/oggplay_reader.h	2008-11-03 21:44:58 UTC (rev 3760)
+++ liboggplay/trunk/include/oggplay/oggplay_reader.h	2008-11-03 21:59:55 UTC (rev 3761)
@@ -54,7 +54,7 @@
   int               (*available)(struct _OggPlayReader *me,
                                               ogg_int64_t current_bytes,
                                               ogg_int64_t current_time);
-  int               (*duration)(struct _OggPlayReader *me);
+  ogg_int64_t       (*duration)(struct _OggPlayReader *me);
   int               (*finished_retrieving)(struct _OggPlayReader *me);
 
   /* low-level io functions for oggz */

Modified: liboggplay/trunk/src/liboggplay/oggplay.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay.c	2008-11-03 21:44:58 UTC (rev 3760)
+++ liboggplay/trunk/src/liboggplay/oggplay.c	2008-11-03 21:59:55 UTC (rev 3761)
@@ -634,14 +634,21 @@
 
 }
 
-int
+ogg_int64_t
 oggplay_get_duration(OggPlay *me) {
 
   if (me == NULL) {
     return E_OGGPLAY_BAD_OGGPLAY;
   }
 
-  return me->reader->duration(me->reader);
+  if (me->reader->duration) 
+    return me->reader->duration(me->reader);
+  else {
+    ogg_int64_t pos = oggz_tell_units(me->oggz);
+    ogg_int64_t duration = oggz_seek_units(me->oggz, 0, SEEK_END);
+    oggz_seek_units(me->oggz, pos, SEEK_SET);
+    return duration;
+  }
 }
 
 int

Modified: liboggplay/trunk/src/liboggplay/oggplay_seek.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_seek.c	2008-11-03 21:44:58 UTC (rev 3760)
+++ liboggplay/trunk/src/liboggplay/oggplay_seek.c	2008-11-03 21:59:55 UTC (rev 3761)
@@ -55,7 +55,7 @@
     return E_OGGPLAY_CANT_SEEK;
   }
 
-  eof = me->reader->duration(me->reader);
+  eof = oggplay_get_duration(me);
   if (eof > -1 && milliseconds > eof) {
     return E_OGGPLAY_CANT_SEEK;
   }

Modified: liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c	2008-11-03 21:44:58 UTC (rev 3760)
+++ liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c	2008-11-03 21:59:55 UTC (rev 3761)
@@ -597,7 +597,7 @@
 
 }
 
-int
+ogg_int64_t
 oggplay_tcp_reader_duration(OggPlayReader * opr) {
   OggPlayTCPReader    *me = (OggPlayTCPReader *)opr;
   return me->duration;



More information about the commits mailing list