[vlc-commits] access_output: allow pf_seek to be NULL, simplify

Rémi Denis-Courmont git at videolan.org
Wed Aug 2 17:19:04 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Aug  2 18:11:40 2017 +0300| [e32479cac1cee1c2acd91fb959baa77003c37343] | committer: Rémi Denis-Courmont

access_output: allow pf_seek to be NULL, simplify

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e32479cac1cee1c2acd91fb959baa77003c37343
---

 modules/access_output/dummy.c     | 13 -------------
 modules/access_output/file.c      | 12 +++---------
 modules/access_output/http.c      | 12 ------------
 modules/access_output/livehttp.c  | 12 ------------
 modules/access_output/shout.c     | 13 -------------
 modules/access_output/udp.c       | 12 ------------
 src/stream_output/stream_output.c |  2 ++
 7 files changed, 5 insertions(+), 71 deletions(-)

diff --git a/modules/access_output/dummy.c b/modules/access_output/dummy.c
index 8b2e6bc4c1..ba656e2663 100644
--- a/modules/access_output/dummy.c
+++ b/modules/access_output/dummy.c
@@ -55,7 +55,6 @@ vlc_module_end ()
  * Exported prototypes
  *****************************************************************************/
 static ssize_t Write( sout_access_out_t *, block_t * );
-static int     Seek ( sout_access_out_t *, off_t  );
 
 /*****************************************************************************
  * Open: open the file
@@ -66,7 +65,6 @@ static int Open( vlc_object_t *p_this )
 
     p_access->p_sys    = NULL;
     p_access->pf_write = Write;
-    p_access->pf_seek  = Seek;
 
     msg_Dbg( p_access, "dummy stream output access opened" );
     return VLC_SUCCESS;
@@ -101,14 +99,3 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
     (void)p_access;
     return i_write;
 }
-
-/*****************************************************************************
- * Seek: seek to a specific location in a file
- *****************************************************************************/
-static int Seek( sout_access_out_t *p_access, off_t i_pos )
-{
-    (void)p_access; (void)i_pos;
-    return 0;
-}
-
-
diff --git a/modules/access_output/file.c b/modules/access_output/file.c
index 3325672d14..fbefce0be8 100644
--- a/modules/access_output/file.c
+++ b/modules/access_output/file.c
@@ -192,12 +192,6 @@ static int Seek( sout_access_out_t *p_access, off_t i_pos )
     return lseek( (intptr_t)p_access->p_sys, i_pos, SEEK_SET );
 }
 
-static int NoSeek(sout_access_out_t *access, off_t pos)
-{
-    (void) access; (void) pos;
-    return -1;
-}
-
 static int Control( sout_access_out_t *p_access, int i_query, va_list args )
 {
     switch( i_query )
@@ -212,7 +206,7 @@ static int Control( sout_access_out_t *p_access, int i_query, va_list args )
         case ACCESS_OUT_CAN_SEEK:
         {
             bool *pb = va_arg( args, bool * );
-            *pb = p_access->pf_seek == Seek;
+            *pb = p_access->pf_seek != NULL;
             break;
         }
 
@@ -348,13 +342,13 @@ static int Open( vlc_object_t *p_this )
     else if (S_ISSOCK(st.st_mode))
     {
         p_access->pf_write = Send;
-        p_access->pf_seek = NoSeek;
+        p_access->pf_seek = NULL;
     }
 #endif
     else
     {
         p_access->pf_write = WritePipe;
-        p_access->pf_seek = NoSeek;
+        p_access->pf_seek = NULL;
     }
     p_access->pf_control = Control;
     p_access->p_sys    = (void *)(intptr_t)fd;
diff --git a/modules/access_output/http.c b/modules/access_output/http.c
index 2b5769e299..38d633a0ed 100644
--- a/modules/access_output/http.c
+++ b/modules/access_output/http.c
@@ -90,7 +90,6 @@ static const char *const ppsz_sout_options[] = {
 };
 
 static ssize_t Write( sout_access_out_t *, block_t * );
-static int Seek ( sout_access_out_t *, off_t  );
 static int Control( sout_access_out_t *, int, va_list );
 
 struct sout_access_out_sys_t
@@ -295,7 +294,6 @@ static int Open( vlc_object_t *p_this )
     p_sys->b_header_complete  = false;
 
     p_access->pf_write       = Write;
-    p_access->pf_seek        = Seek;
     p_access->pf_control     = Control;
 
     return VLC_SUCCESS;
@@ -462,13 +460,3 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
 
     return( i_err < 0 ? VLC_EGENERIC : i_len );
 }
-
-/*****************************************************************************
- * Seek: seek to a specific location in a file
- *****************************************************************************/
-static int Seek( sout_access_out_t *p_access, off_t i_pos )
-{
-    (void)i_pos;
-    msg_Warn( p_access, "HTTP sout access cannot seek" );
-    return VLC_EGENERIC;
-}
diff --git a/modules/access_output/livehttp.c b/modules/access_output/livehttp.c
index 02ff70e5bd..235b26b819 100644
--- a/modules/access_output/livehttp.c
+++ b/modules/access_output/livehttp.c
@@ -160,7 +160,6 @@ static const char *const ppsz_sout_options[] = {
 };
 
 static ssize_t Write( sout_access_out_t *, block_t * );
-static int Seek ( sout_access_out_t *, off_t  );
 static int Control( sout_access_out_t *, int, va_list );
 
 typedef struct output_segment
@@ -303,7 +302,6 @@ static int Open( vlc_object_t *p_this )
     p_sys->psz_cursegPath = NULL;
 
     p_access->pf_write = Write;
-    p_access->pf_seek  = Seek;
     p_access->pf_control = Control;
 
     return VLC_SUCCESS;
@@ -1058,13 +1056,3 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
 
     return i_write;
 }
-
-/*****************************************************************************
- * Seek: seek to a specific location in a file
- *****************************************************************************/
-static int Seek( sout_access_out_t *p_access, off_t i_pos )
-{
-    (void) i_pos;
-    msg_Err( p_access, "livehttp sout access cannot seek" );
-    return -1;
-}
diff --git a/modules/access_output/shout.c b/modules/access_output/shout.c
index 5a844c7054..2beb131f69 100644
--- a/modules/access_output/shout.c
+++ b/modules/access_output/shout.c
@@ -150,7 +150,6 @@ static const char *const ppsz_sout_options[] = {
  * Exported prototypes
  *****************************************************************************/
 static ssize_t Write( sout_access_out_t *, block_t * );
-static int Seek ( sout_access_out_t *, off_t  );
 static int Control( sout_access_out_t *, int, va_list );
 
 struct sout_access_out_sys_t
@@ -378,7 +377,6 @@ static int Open( vlc_object_t *p_this )
     }
 
     p_access->pf_write = Write;
-    p_access->pf_seek  = Seek;
     p_access->pf_control = Control;
 
     msg_Dbg( p_access, "shout access output opened (%s@%s:%i/%s)",
@@ -482,14 +480,3 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
 
     return i_write;
 }
-
-/*****************************************************************************
- * Seek: seek to a specific location -- not supported
- *****************************************************************************/
-static int Seek( sout_access_out_t *p_access, off_t i_pos )
-{
-    VLC_UNUSED(i_pos);
-    msg_Err( p_access, "cannot seek on shout" );
-    return VLC_EGENERIC;
-}
-
diff --git a/modules/access_output/udp.c b/modules/access_output/udp.c
index 2ce33a503a..1204eab750 100644
--- a/modules/access_output/udp.c
+++ b/modules/access_output/udp.c
@@ -104,7 +104,6 @@ static const char *const ppsz_core_options[] = {
 };
 
 static ssize_t Write   ( sout_access_out_t *, block_t * );
-static int  Seek    ( sout_access_out_t *, off_t  );
 static int Control( sout_access_out_t *, int, va_list );
 
 static void* ThreadWrite( void * );
@@ -226,7 +225,6 @@ static int Open( vlc_object_t *p_this )
     }
 
     p_access->pf_write = Write;
-    p_access->pf_seek = Seek;
     p_access->pf_control = Control;
 
     return VLC_SUCCESS;
@@ -352,16 +350,6 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
 }
 
 /*****************************************************************************
- * Seek: seek to a specific location in a file
- *****************************************************************************/
-static int Seek( sout_access_out_t *p_access, off_t i_pos )
-{
-    (void) i_pos;
-    msg_Err( p_access, "UDP sout access cannot seek" );
-    return -1;
-}
-
-/*****************************************************************************
  * NewUDPPacket: allocate a new UDP packet of size p_sys->i_mtu
  *****************************************************************************/
 static block_t *NewUDPPacket( sout_access_out_t *p_access, mtime_t i_dts)
diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c
index d4492f32d9..a30e66852c 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -301,6 +301,8 @@ void sout_AccessOutDelete( sout_access_out_t *p_access )
  *****************************************************************************/
 int sout_AccessOutSeek( sout_access_out_t *p_access, off_t i_pos )
 {
+    if (p_access->pf_seek == NULL)
+        return VLC_EGENERIC;
     return p_access->pf_seek( p_access, i_pos );
 }
 



More information about the vlc-commits mailing list