vlc | branch: master | Steve Lhomme <[email protected]> | Thu Jun 23 18:29:42 2016 +0200| [b58dbf8c90734f90640c7c71dde6649c77bb6904] | committer: Jean-Baptiste Kempf
chromecast: demux: rely on DEMUX_SET_PAUSE_STATE to tell the device to pause/play Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b58dbf8c90734f90640c7c71dde6649c77bb6904 --- modules/stream_out/chromecast/chromecast.h | 5 +-- modules/stream_out/chromecast/chromecast_common.h | 2 +- modules/stream_out/chromecast/chromecast_ctrl.cpp | 43 +++++++++----------- modules/stream_out/chromecast/chromecast_demux.cpp | 43 ++++++++------------ 4 files changed, 38 insertions(+), 55 deletions(-) diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h index c99d527..0b46a93 100644 --- a/modules/stream_out/chromecast/chromecast.h +++ b/modules/stream_out/chromecast/chromecast.h @@ -159,7 +159,7 @@ private: std::atomic_bool requested_stop; std::atomic_bool requested_seek; - void setInputState(input_state_e state); + void setPauseState(bool paused); void setTitle( const char *psz_title ) { @@ -201,7 +201,6 @@ private: unsigned i_requestId; bool has_input; - input_state_e input_state; std::string GetMedia(); std::string artwork; @@ -266,7 +265,7 @@ private: static void request_seek(void*, mtime_t pos); static void wait_seek_done(void*); - static void set_input_state(void*, input_state_e state); + static void set_pause_state(void*, bool paused); static void set_title(void*, const char *psz_title); static void set_artwork(void*, const char *psz_artwork); diff --git a/modules/stream_out/chromecast/chromecast_common.h b/modules/stream_out/chromecast/chromecast_common.h index 1a4338e..c126f45 100644 --- a/modules/stream_out/chromecast/chromecast_common.h +++ b/modules/stream_out/chromecast/chromecast_common.h @@ -46,7 +46,7 @@ typedef struct void (*pf_request_seek)(void*, mtime_t pos); void (*pf_wait_seek_done)(void*); - void (*pf_set_input_state)(void*, input_state_e state); + void (*pf_set_pause_state)(void*, bool paused); void (*pf_set_title)(void*, const char *psz_title); void (*pf_set_artwork)(void*, const char *psz_artwork); diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp index e0286b9..35d02b4 100644 --- a/modules/stream_out/chromecast/chromecast_ctrl.cpp +++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp @@ -109,7 +109,6 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device , i_receiver_requestId(0) , i_requestId(0) , has_input(false) - , input_state( INIT_S ) , p_ctl_thread_interrupt(p_interrupt) , m_time_playback_started( VLC_TS_INVALID ) , i_ts_local_start( VLC_TS_INVALID ) @@ -128,7 +127,7 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device common.pf_wait_app_started = wait_app_started; common.pf_request_seek = request_seek; common.pf_wait_seek_done = wait_seek_done; - common.pf_set_input_state = set_input_state; + common.pf_set_pause_state = set_pause_state; common.pf_set_artwork = set_artwork; common.pf_set_title = set_title; @@ -1059,28 +1058,24 @@ void intf_sys_t::requestPlayerSeek(mtime_t pos) notifySendRequest(); } -void intf_sys_t::setInputState(input_state_e state) +void intf_sys_t::setPauseState(bool paused) { - input_state = state; - msg_Dbg( p_module, "new %d state for %s", state, title.c_str() ); - switch( input_state ) + msg_Dbg( p_module, "%s state for %s", paused ? "paused" : "playing", title.c_str() ); + if ( !paused ) { - case PLAYING_S: - if ( !mediaSessionId.empty() && receiverState != RECEIVER_IDLE ) - { - msgPlayerPlay(); - setPlayerStatus(CMD_PLAYBACK_SENT); - } - break; - case PAUSE_S: - if ( !mediaSessionId.empty() && receiverState != RECEIVER_IDLE ) - { - msgPlayerPause(); - setPlayerStatus(CMD_PLAYBACK_SENT); - } - break; - default: - break; + if ( !mediaSessionId.empty() && receiverState != RECEIVER_IDLE ) + { + msgPlayerPlay(); + setPlayerStatus(CMD_PLAYBACK_SENT); + } + } + else + { + if ( !mediaSessionId.empty() && receiverState != RECEIVER_IDLE ) + { + msgPlayerPause(); + setPlayerStatus(CMD_PLAYBACK_SENT); + } } } @@ -1154,10 +1149,10 @@ void intf_sys_t::wait_seek_done(void *pt) p_this->waitSeekDone(); } -void intf_sys_t::set_input_state(void *pt, input_state_e state) +void intf_sys_t::set_pause_state(void *pt, bool paused) { intf_sys_t *p_this = reinterpret_cast<intf_sys_t*>(pt); - p_this->setInputState( state ); + p_this->setPauseState( paused ); } void intf_sys_t::set_title(void *pt, const char *psz_title) diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp index 82cd8f6..fdbc247 100644 --- a/modules/stream_out/chromecast/chromecast_demux.cpp +++ b/modules/stream_out/chromecast/chromecast_demux.cpp @@ -60,23 +60,19 @@ struct demux_sys_t } vlc_meta_Delete(p_meta); } - p_renderer->pf_set_input_state( p_renderer->p_opaque, - (input_state_e) var_GetInteger( p_input, "state" ) ); - var_AddCallback( p_input, "intf-event", InputEvent, this ); } ~demux_sys_t() { - demux_t *p_last_demux = p_demux->p_next; - while (p_last_demux->p_next) - p_last_demux = p_last_demux->p_next; - input_thread_t *p_input = p_last_demux->p_input; - var_DelCallback( p_input, "intf-event", InputEvent, this ); - p_renderer->pf_set_title( p_renderer->p_opaque, NULL ); p_renderer->pf_set_artwork( p_renderer->p_opaque, NULL ); } + void setPauseState(bool paused) + { + p_renderer->pf_set_pause_state( p_renderer->p_opaque, paused ); + } + /** * @brief getPlaybackTime * @return the current playback time on the device or VLC_TS_INVALID if unknown @@ -150,9 +146,6 @@ protected: bool canSeek; /* seek time kept while waiting for the chromecast to "seek" */ mtime_t m_seektime; - - static int InputEvent( vlc_object_t *p_this, char const *psz_var, - vlc_value_t oldval, vlc_value_t val, void * ); }; static int Demux( demux_t *p_demux_filter ) @@ -245,24 +238,20 @@ static int Control( demux_t *p_demux_filter, int i_query, va_list args) } break; } - } - - return demux_vaControl( p_demux_filter->p_next, i_query, args ); -} + case DEMUX_SET_PAUSE_STATE: + { + va_list ap; -int demux_sys_t::InputEvent( vlc_object_t *p_this, char const *psz_var, - vlc_value_t oldval, vlc_value_t val, void *p_data ) -{ - VLC_UNUSED(psz_var); - VLC_UNUSED(oldval); - input_thread_t *p_input = reinterpret_cast<input_thread_t*>( p_this ); - demux_sys_t *p_sys = reinterpret_cast<demux_sys_t*>( p_data ); + va_copy( ap, args ); + int paused = va_arg( ap, int ); + va_end( ap ); - if( val.i_int == INPUT_EVENT_STATE ) - p_sys->p_renderer->pf_set_input_state( p_sys->p_renderer->p_opaque, - (input_state_e) var_GetInteger( p_input, "state" ) ); + p_sys->setPauseState( paused != 0 ); + break; + } + } - return VLC_SUCCESS; + return demux_vaControl( p_demux_filter->p_next, i_query, args ); } int Open(vlc_object_t *p_this) _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
