vlc | branch: master | Hugo Beauzée-Luyssen <[email protected]> | Thu Mar 2 10:01:20 2017 +0100| [b887d8d37309434f1ad70da13ec6b1ad709cb65d] | committer: Hugo Beauzée-Luyssen
chromecast: Directly send request instead of using interruptions > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b887d8d37309434f1ad70da13ec6b1ad709cb65d --- modules/stream_out/chromecast/chromecast.h | 6 +-- modules/stream_out/chromecast/chromecast_ctrl.cpp | 46 ++++++++--------------- 2 files changed, 16 insertions(+), 36 deletions(-) diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h index d187061..d491a92 100644 --- a/modules/stream_out/chromecast/chromecast.h +++ b/modules/stream_out/chromecast/chromecast.h @@ -131,7 +131,7 @@ private: vlc_tls_creds_t *m_creds; vlc_tls_t *m_tls; unsigned m_receiver_requestId; - unsigned m_requestId; + std::atomic_uint m_requestId; std::string m_serverIp; }; @@ -158,8 +158,6 @@ private: void processMessage(const castchannel::CastMessage &msg); - void notifySendRequest(); - void setPauseState(bool paused); void setTitle( const char *psz_title ); @@ -212,8 +210,6 @@ private: ChromecastCommunication m_communication; States m_state; - std::atomic_bool m_requested_stop; - std::atomic_bool m_requested_seek; std::string m_artwork; std::string m_title; diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp index fc7f84b..6874341 100644 --- a/modules/stream_out/chromecast/chromecast_ctrl.cpp +++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp @@ -82,8 +82,6 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device , m_streaming_port(port) , m_communication( p_this, device_addr.c_str(), device_port ) , m_state( Authenticating ) - , m_requested_stop(false) - , m_requested_seek(false) , m_ctl_thread_interrupt(p_interrupt) , m_time_playback_started( VLC_TS_INVALID ) , m_ts_local_start( VLC_TS_INVALID ) @@ -543,25 +541,6 @@ bool intf_sys_t::handleMessages() bool b_timeout = false; mtime_t i_begin_time = mdate(); - if ( m_requested_stop.exchange(false) && !m_mediaSessionId.empty() ) - { - m_communication.msgPlayerStop( m_appTransportId, m_mediaSessionId ); - } - - if ( m_requested_seek.exchange(false) && !m_mediaSessionId.empty() ) - { - char current_time[32]; - m_seek_request_time = mdate() + SEEK_FORWARD_OFFSET; - if( snprintf( current_time, sizeof(current_time), "%.3f", double( m_seek_request_time ) / 1000000.0 ) >= (int)sizeof(current_time) ) - { - msg_Err( m_module, "snprintf() truncated string for mediaSessionId" ); - current_time[sizeof(current_time) - 1] = '\0'; - } - // No need to change the state to "Seeking" it was already done upon requesting - /* send a fake time to seek to, to make sure the device flushes its buffers */ - m_communication.msgPlayerSeek( m_appTransportId, m_mediaSessionId, current_time ); - } - /* Packet structure: * +------------------------------------+------------------------------+ * | Payload size (uint32_t big endian) | Payload data | @@ -577,7 +556,6 @@ bool intf_sys_t::handleMessages() &b_timeout ); if ( i_ret < 0 ) { - // If we need to process a command, let it happen at next iteration if ( errno == EINTR ) return true; // An error occured, we give up @@ -625,25 +603,31 @@ bool intf_sys_t::handleMessages() return true; } -void intf_sys_t::notifySendRequest() -{ - vlc_interrupt_raise( m_ctl_thread_interrupt ); -} - void intf_sys_t::requestPlayerStop() { - m_requested_stop = true; - notifySendRequest(); + vlc_mutex_locker locker(&m_lock); + if ( m_mediaSessionId.empty() == true ) + return; + m_communication.msgPlayerStop( m_appTransportId, m_mediaSessionId ); } void intf_sys_t::requestPlayerSeek(mtime_t pos) { vlc_mutex_locker locker(&m_lock); + if ( m_mediaSessionId.empty() == true ) + return; if ( pos != VLC_TS_INVALID ) m_ts_local_start = pos; - m_requested_seek = true; + char current_time[32]; + m_seek_request_time = mdate() + SEEK_FORWARD_OFFSET; + if( snprintf( current_time, sizeof(current_time), "%.3f", double( m_seek_request_time ) / 1000000.0 ) >= (int)sizeof(current_time) ) + { + msg_Err( m_module, "snprintf() truncated string for mediaSessionId" ); + current_time[sizeof(current_time) - 1] = '\0'; + } + /* send a fake time to seek to, to make sure the device flushes its buffers */ + m_communication.msgPlayerSeek( m_appTransportId, m_mediaSessionId, current_time ); setState( Seeking ); - notifySendRequest(); } void intf_sys_t::setPauseState(bool paused) _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
