[vlc-devel] [PATCH 1/2] stream: add stream_DemuxAlive

Francois Cartegnie fcvlcdev at free.fr
Sat Dec 27 17:26:47 CET 2014


We had no way to know if the demux failed at some point or
has reached EOF.
---
 include/vlc_stream.h     |  2 ++
 src/input/stream_demux.c | 11 +++++++++++
 src/libvlccore.sym       |  1 +
 3 files changed, 14 insertions(+)

diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index 37e6b2d..bfef94e 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -194,6 +194,8 @@ VLC_API void stream_DemuxSend( stream_t *s, block_t *p_block );
  */
 VLC_API int stream_DemuxControlVa( stream_t *s, int, va_list );
 
+VLC_API bool stream_DemuxAlive( stream_t *s );
+
 static inline int stream_DemuxControl( stream_t *s, int query, ... )
 {
     va_list ap;
diff --git a/src/input/stream_demux.c b/src/input/stream_demux.c
index 9bf3343..7302220 100644
--- a/src/input/stream_demux.c
+++ b/src/input/stream_demux.c
@@ -154,6 +154,11 @@ int stream_DemuxControlVa( stream_t *s, int query, va_list args )
     return VLC_SUCCESS;
 }
 
+bool stream_DemuxAlive( stream_t *s )
+{
+    return atomic_load( &s->p_sys->active );
+}
+
 static void DStreamDelete( stream_t *s )
 {
     stream_sys_t *p_sys = s->p_sys;
@@ -331,7 +336,10 @@ static void* DStreamThread( void *obj )
     p_demux = demux_New( s, s->p_input, "", p_sys->psz_name, "", s, p_sys->out,
                          false );
     if( p_demux == NULL )
+    {
+        atomic_store( &p_sys->active, false );
         return NULL;
+    }
 
     /* stream_Demux cannot apply DVB filters.
      * Get all programs and let the E/S output sort them out. */
@@ -364,7 +372,10 @@ static void* DStreamThread( void *obj )
         }
 
         if( demux_Demux( p_demux ) <= 0 )
+        {
+            atomic_store( &p_sys->active, false );
             break;
+        }
     }
 
     /* Explicit kludge: the stream is destroyed by the owner of the
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 7f06ed6..a7fbdae 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -393,6 +393,7 @@ stream_Block
 stream_BlockRemaining
 stream_Control
 stream_Delete
+stream_DemuxAlive
 stream_DemuxNew
 stream_DemuxSend
 stream_DemuxControlVa
-- 
2.1.0




More information about the vlc-devel mailing list