changeset 36433:3a192d8ecc56

Revise and fix stream control for VCD. A VCD's stream->priv is a pointer of type mp_vcd_priv_t and not one of type stream_priv_s. Add a struct member 'track' to mp_vcd_priv_t to store the track information there.
author ib
date Mon, 02 Dec 2013 13:53:03 +0000
parents 9893f5323b22
children 72438f81faab
files stream/stream_vcd.c stream/vcd_read.h stream/vcd_read_darwin.h stream/vcd_read_fbsd.h stream/vcd_read_os2.h stream/vcd_read_win32.h
diffstat 6 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/stream/stream_vcd.c	Sun Dec 01 04:17:02 2013 +0000
+++ b/stream/stream_vcd.c	Mon Dec 02 13:53:03 2013 +0000
@@ -90,14 +90,13 @@
 }
 
 static int control(stream_t *stream, int cmd, void *arg) {
-  struct stream_priv_s *p = stream->priv;
+  mp_vcd_priv_t *vcd = stream->priv;
   switch(cmd) {
     case STREAM_CTRL_GET_NUM_TITLES:
     case STREAM_CTRL_GET_NUM_CHAPTERS:
     {
-      mp_vcd_priv_t *vcd = vcd_read_toc(stream->fd);
       if (!vcd)
-        break;
+        return STREAM_ERROR;
       *(unsigned int *)arg = vcd_end_track(vcd);
       return STREAM_OK;
     }
@@ -105,19 +104,18 @@
     {
       int r;
       unsigned int track = *(unsigned int *)arg + 1;
-      mp_vcd_priv_t *vcd = vcd_read_toc(stream->fd);
       if (!vcd)
-        break;
+        return STREAM_ERROR;
       r = vcd_seek_to_track(vcd, track);
       if (r >= 0) {
-        p->track = track;
+        vcd->track = track;
         return STREAM_OK;
       }
       break;
     }
     case STREAM_CTRL_GET_CURRENT_CHAPTER:
     {
-      *(unsigned int *)arg = p->track - 1;
+      *(unsigned int *)arg = vcd->track - 1;
       return STREAM_OK;
     }
   }
@@ -227,6 +225,8 @@
   }
 #endif
 
+  vcd->track = p->track;
+
   stream->fd = f;
   stream->type = STREAMTYPE_VCD;
   stream->sector_size = VCD_SECTOR_DATA;
--- a/stream/vcd_read.h	Sun Dec 01 04:17:02 2013 +0000
+++ b/stream/vcd_read.h	Mon Dec 02 13:53:03 2013 +0000
@@ -44,6 +44,7 @@
   struct cdrom_tocentry entry;
   char buf[VCD_SECTOR_SIZE];
   struct cdrom_tochdr tochdr;
+  unsigned int track;
 };
 
 static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect){
--- a/stream/vcd_read_darwin.h	Sun Dec 01 04:17:02 2013 +0000
+++ b/stream/vcd_read_darwin.h	Mon Dec 02 13:53:03 2013 +0000
@@ -55,6 +55,7 @@
 	dk_cd_read_track_info_t entry;
 	struct CDDiscInfo hdr;
 	CDMSF msf;
+	unsigned int track;
 } mp_vcd_priv_t;
 
 static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned int sect)
--- a/stream/vcd_read_fbsd.h	Sun Dec 01 04:17:02 2013 +0000
+++ b/stream/vcd_read_fbsd.h	Mon Dec 02 13:53:03 2013 +0000
@@ -67,6 +67,7 @@
   cdsector_t buf;
 #endif
   struct ioc_toc_header tochdr;
+  unsigned int track;
 } mp_vcd_priv_t;
 
 static inline void
--- a/stream/vcd_read_os2.h	Sun Dec 01 04:17:02 2013 +0000
+++ b/stream/vcd_read_os2.h	Mon Dec 02 13:53:03 2013 +0000
@@ -39,6 +39,7 @@
     int        iLastTrack;
     struct msf msfLeadOut;
     BYTE       abVCDSector[VCD_SECTOR_SIZE];
+    unsigned int track;
 } mp_vcd_priv_t;
 
 static inline void vcd_set_msf(mp_vcd_priv_t *vcd, unsigned sect)
--- a/stream/vcd_read_win32.h	Sun Dec 01 04:17:02 2013 +0000
+++ b/stream/vcd_read_win32.h	Mon Dec 02 13:53:03 2013 +0000
@@ -38,6 +38,7 @@
     CDROM_TOC toc;
     unsigned sect;
     char buf[VCD_SECTOR_SIZE];
+    unsigned int track;
 };
 
 static inline void vcd_set_msf(mp_vcd_priv_t* vcd, unsigned sect)