[vlc-devel] [PATCH 2/5] chromecast: pause the input using the new INPUT_UPDATE_STATE flag

Thomas Guillem thomas at gllm.fr
Thu Jul 19 15:50:17 CEST 2018


And remove the last input_thread_t variable hack.
---
 .../chromecast/chromecast_demux.cpp           | 25 ++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp
index 915298c6e1..d9f608d9b4 100644
--- a/modules/stream_out/chromecast/chromecast_demux.cpp
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -35,6 +35,7 @@
 #include "chromecast_common.h"
 
 #include <assert.h>
+#include <atomic>
 #include <new>
 
 static void on_paused_changed_cb(void *data, bool paused);
@@ -54,6 +55,7 @@ struct demux_cc
     void init()
     {
         resetDemuxEof();
+        std::atomic_store(&m_updates, 0U);
 
         vlc_meta_t *p_meta = vlc_meta_New();
         if( likely(p_meta != NULL) )
@@ -165,6 +167,11 @@ struct demux_cc
         m_last_pos = m_start_pos;
     }
 
+    void addUpdates(unsigned flags)
+    {
+        std::atomic_fetch_or(&m_updates, flags);
+    }
+
     ~demux_cc()
     {
         if( p_renderer )
@@ -434,6 +441,18 @@ struct demux_cc
             p_renderer = NULL;
 
             return VLC_SUCCESS;
+
+        case DEMUX_TEST_AND_CLEAR_FLAGS:
+        {
+            unsigned *restrict flags = va_arg(args, unsigned *);
+            if (*flags & INPUT_UPDATE_STATE)
+            {
+                *flags &= std::atomic_fetch_and(&m_updates, ~*flags);
+                return VLC_SUCCESS;
+            }
+            else
+                return demux_Control( p_demux_filter->p_next, i_query, flags );
+        }
         }
 
         return demux_vaControl( p_demux_filter->p_next, i_query, args );
@@ -452,15 +471,15 @@ protected:
     vlc_tick_t    m_last_time;
     vlc_tick_t    m_pause_date;
     vlc_tick_t    m_pause_delay;
+    std::atomic_uint m_updates;
 };
 
 static void on_paused_changed_cb( void *data, bool paused )
 {
     demux_t *p_demux = reinterpret_cast<demux_t*>(data);
+    demux_cc *p_sys = reinterpret_cast<demux_cc*>(p_demux->p_sys);
 
-    input_thread_t *p_input = p_demux->p_next->p_input;
-    if( p_input )
-        var_SetInteger( p_input, "state", paused ? PAUSE_S : PLAYING_S );
+    p_sys->addUpdates( paused ? INPUT_UPDATE_PAUSE : INPUT_UPDATE_PLAY );
 }
 
 static int Demux( demux_t *p_demux_filter )
-- 
2.18.0



More information about the vlc-devel mailing list