[xiph-cvs] cvs commit: vorbis-tools/ogg123 format.h ogg123.c oggvorbis_format.c

Stan Seibert volsung at xiph.org
Sat Dec 15 16:31:43 PST 2001



volsung     01/12/15 16:31:43

  Modified:    ogg123   Tag: volsung_kc_20011011 format.h ogg123.c
                        oggvorbis_format.c
  Log:
  Added seeking interface to decoders.  Now we can skip the first 'n' seconds
  of audio.  No more features before RC3.  Now we test mercilessly.

Revision  Changes    Path
No                   revision

No                   revision

1.1.2.4   +6 -1      vorbis-tools/ogg123/Attic/format.h

Index: format.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/format.h,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- format.h	2001/12/11 18:46:23	1.1.2.3
+++ format.h	2001/12/16 00:31:41	1.1.2.4
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: format.h,v 1.1.2.3 2001/12/11 18:46:23 volsung Exp $
+ last mod: $Id: format.h,v 1.1.2.4 2001/12/16 00:31:41 volsung Exp $
 
  ********************************************************************/
 
@@ -52,6 +52,10 @@
   void *private;
 } decoder_t;
 
+/* whence constants */
+#define DECODER_SEEK_START 1
+#define DECODER_SEEK_CUR   2
+
 typedef struct format_t {
   char *name;
 
@@ -61,6 +65,7 @@
                        decoder_callbacks_t *callbacks, void *callback_arg);
   int (* read) (decoder_t *decoder, void *ptr, int nbytes, int *eos, 
                 audio_format_t *audio_fmt);
+  int (* seek) (decoder_t *decoder, double offset, int whence);
   decoder_stats_t* (* statistics) (decoder_t *decoder);
   void (* cleanup) (decoder_t *decoder);
 } format_t;

1.39.2.30.2.22 +6 -1      vorbis-tools/ogg123/ogg123.c

Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.39.2.30.2.21
retrieving revision 1.39.2.30.2.22
diff -u -r1.39.2.30.2.21 -r1.39.2.30.2.22
--- ogg123.c	2001/12/14 17:54:05	1.39.2.30.2.21
+++ ogg123.c	2001/12/16 00:31:41	1.39.2.30.2.22
@@ -14,7 +14,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ogg123.c,v 1.39.2.30.2.21 2001/12/14 17:54:05 volsung Exp $
+ last mod: $Id: ogg123.c,v 1.39.2.30.2.22 2001/12/16 00:31:41 volsung Exp $
 
  ********************************************************************/
 
@@ -409,6 +409,11 @@
     buffer_thread_start (audio_buffer);
   }
 
+  /* Skip over audio */
+  if (options.seekpos > 0.0) {
+    if (!format->seek(decoder, options.seekpos, DECODER_SEEK_START))
+      status_error("Could not skip %f seconds of audio.", options.seekpos);
+  }
 
   /* Main loop:  Iterates over all of the logical bitstreams in the file */
   while (!eof && !sig_request.exit) {

1.1.2.8   +24 -1     vorbis-tools/ogg123/Attic/oggvorbis_format.c

Index: oggvorbis_format.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Attic/oggvorbis_format.c,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- oggvorbis_format.c	2001/12/14 17:54:05	1.1.2.7
+++ oggvorbis_format.c	2001/12/16 00:31:42	1.1.2.8
@@ -11,7 +11,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: oggvorbis_format.c,v 1.1.2.7 2001/12/14 17:54:05 volsung Exp $
+ last mod: $Id: oggvorbis_format.c,v 1.1.2.8 2001/12/16 00:31:42 volsung Exp $
 
  ********************************************************************/
 
@@ -194,6 +194,28 @@
 }
 
 
+int ovf_seek (decoder_t *decoder, double offset, int whence)
+{
+  ovf_private_t *priv = decoder->private;
+  int ret;
+  double cur;
+
+  if (whence == DECODER_SEEK_CUR) {
+    cur = ov_time_tell(&priv->vf);
+    if (cur >= 0.0)
+      offset += cur;
+    else
+      return 0;
+  }
+
+  ret = ov_time_seek(&priv->vf, offset);
+  if (ret == 0)
+    return 1;
+  else
+    return 0;
+}
+
+
 decoder_stats_t *ovf_statistics (decoder_t *decoder)
 {
   ovf_private_t *priv = decoder->private;
@@ -237,6 +259,7 @@
   &ovf_can_decode,
   &ovf_init,
   &ovf_read,
+  &ovf_seek,
   &ovf_statistics,
   &ovf_cleanup,
 };

--- >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