[MPlayer-cvslog] r21674 - trunk/stream/stream_file.c

nicodvb subversion at mplayerhq.hu
Mon Dec 18 21:55:13 CET 2006


Author: nicodvb
Date: Mon Dec 18 21:55:12 2006
New Revision: 21674

Modified:
   trunk/stream/stream_file.c

Log:
implemented STREAM_CTRL_GET_SIZE

Modified: trunk/stream/stream_file.c
==============================================================================
--- trunk/stream/stream_file.c	(original)
+++ trunk/stream/stream_file.c	Mon Dec 18 21:55:12 2006
@@ -68,6 +68,22 @@
   return 1;
 }
 
+static int control(stream_t *s, int cmd, void *arg) {
+  switch(cmd) {
+    case STREAM_CTRL_GET_SIZE: {
+      off_t size;
+
+      size = lseek(s->fd, 0, SEEK_END);
+      lseek(s->fd, s->pos, SEEK_SET);
+      if(size != (off_t)-1) {
+        *((off_t*)arg) = size;
+        return 1;
+      }
+    }
+  }
+  return STREAM_UNSUPORTED;
+}
+
 static int open_f(stream_t *stream,int mode, void* opts, int* file_format) {
   int f;
   mode_t m = 0;
@@ -148,6 +164,7 @@
   stream->fd = f;
   stream->fill_buffer = fill_buffer;
   stream->write_buffer = write_buffer;
+  stream->control = control;
 
   m_struct_free(&stream_opts,opts);
   return STREAM_OK;



More information about the MPlayer-cvslog mailing list