[vlc-commits] chromecast: use a pointer for m_communication
vlc/vlc-3.0 | branch: master | Thomas Guillem| Wed Mar 28 18:46:18 2018 +0200| [93ddf7868ad9663068cb38ed14a5248017deb020] | committer: Thomas Guillem chromecast: use a pointer for m_communication In order to delete/create during the life time of intf_sys_t. (cherry picked from commit a74e7ff8a1d43078a51472c110810cadc8ab1bed) Signed-off-by: Thomas Guillem > http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=93ddf7868ad9663068cb38ed14a5248017deb020 --- modules/stream_out/chromecast/chromecast.h| 2 +- modules/stream_out/chromecast/chromecast_ctrl.cpp | 45 --- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h index 417ad5b09f..5e93c70e18 100644 --- a/modules/stream_out/chromecast/chromecast.h +++ b/modules/stream_out/chromecast/chromecast.h @@ -255,7 +255,7 @@ private: on_paused_changed_itf m_on_paused_changed; void *m_on_paused_changed_data; -ChromecastCommunication m_communication; +ChromecastCommunication *m_communication; std::queue m_msgQueue; States m_state; bool m_retry_on_fail; diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp index 598cdf6392..0703c841e5 100644 --- a/modules/stream_out/chromecast/chromecast_ctrl.cpp +++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp @@ -97,7 +97,6 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device , m_on_input_event_data( NULL ) , m_on_paused_changed( NULL ) , m_on_paused_changed_data( NULL ) - , m_communication( p_this, device_addr.c_str(), device_port ) , m_state( Authenticating ) , m_retry_on_fail( false ) , m_played_once( false ) @@ -117,6 +116,8 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device , m_pause_delay( VLC_TS_INVALID ) , m_pingRetriesLeft( PING_WAIT_RETRIES ) { +m_communication = new ChromecastCommunication( p_this, device_addr.c_str(), device_port ); + m_ctl_thread_interrupt = vlc_interrupt_create(); if( unlikely(m_ctl_thread_interrupt == NULL) ) throw std::runtime_error( "error creating interrupt context" ); @@ -126,7 +127,7 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device vlc_cond_init( _pace_cond ); std::stringstream ss; -ss << "http://; << m_communication.getServerIp() << ":" << port; +ss << "http://; << m_communication->getServerIp() << ":" << port; m_art_http_ip = ss.str(); m_common.p_opaque = this; @@ -168,12 +169,12 @@ intf_sys_t::~intf_sys_t() case Stopping: case Stopped: // Generate the close messages. -m_communication.msgReceiverClose( m_appTransportId ); +m_communication->msgReceiverClose( m_appTransportId ); /* fallthrough */ case Connecting: case Connected: case Launching: -m_communication.msgReceiverClose(DEFAULT_CHOMECAST_RECEIVER); +m_communication->msgReceiverClose(DEFAULT_CHOMECAST_RECEIVER); /* fallthrough */ default: break; @@ -186,6 +187,8 @@ intf_sys_t::~intf_sys_t() vlc_interrupt_destroy( m_ctl_thread_interrupt ); +delete m_communication; + if (m_meta != NULL) vlc_meta_Delete(m_meta); @@ -316,7 +319,7 @@ void intf_sys_t::tryLoad() msg_Dbg( m_module, "Starting the media receiver application" ); // Don't use setState as we don't want to signal the condition in this case. m_state = Launching; -m_communication.msgReceiverLaunchApp(); +m_communication->msgReceiverLaunchApp(); } return; } @@ -328,7 +331,7 @@ void intf_sys_t::tryLoad() // Reset the mediaSessionID to allow the new session to become the current one. // we cannot start a new load when the last one is still processing m_last_request_id = -m_communication.msgPlayerLoad( m_appTransportId, m_streaming_port, +m_communication->msgPlayerLoad( m_appTransportId, m_streaming_port, m_mime, m_meta ); if( m_last_request_id != ChromecastCommunication::kInvalidId ) m_state = Loading; @@ -549,7 +552,7 @@ void intf_sys_t::mainLoop() vlc_interrupt_set( m_ctl_thread_interrupt ); // State was already initialized as Authenticating -m_communication.msgAuth(); +m_communication->msgAuth(); while ( !vlc_killed() ) { @@ -594,8 +597,8 @@ void intf_sys_t::processAuthMessage( const castchannel::CastMessage& msg ) { vlc_mutex_locker locker(_lock); setState( Connecting ); -m_communication.msgConnect(DEFAULT_CHOMECAST_RECEIVER); -m_communication.msgReceiverGetStatus(); +m_communication->msgConnect(DEFAULT_CHOMECAST_RECEIVER); +
[vlc-commits] chromecast: use a pointer for m_communication
vlc | branch: master | Thomas Guillem| Wed Mar 28 18:46:18 2018 +0200| [a74e7ff8a1d43078a51472c110810cadc8ab1bed] | committer: Thomas Guillem chromecast: use a pointer for m_communication In order to delete/create during the life time of intf_sys_t. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a74e7ff8a1d43078a51472c110810cadc8ab1bed --- modules/stream_out/chromecast/chromecast.h| 2 +- modules/stream_out/chromecast/chromecast_ctrl.cpp | 45 --- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h index 417ad5b09f..5e93c70e18 100644 --- a/modules/stream_out/chromecast/chromecast.h +++ b/modules/stream_out/chromecast/chromecast.h @@ -255,7 +255,7 @@ private: on_paused_changed_itf m_on_paused_changed; void *m_on_paused_changed_data; -ChromecastCommunication m_communication; +ChromecastCommunication *m_communication; std::queue m_msgQueue; States m_state; bool m_retry_on_fail; diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp index 598cdf6392..0703c841e5 100644 --- a/modules/stream_out/chromecast/chromecast_ctrl.cpp +++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp @@ -97,7 +97,6 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device , m_on_input_event_data( NULL ) , m_on_paused_changed( NULL ) , m_on_paused_changed_data( NULL ) - , m_communication( p_this, device_addr.c_str(), device_port ) , m_state( Authenticating ) , m_retry_on_fail( false ) , m_played_once( false ) @@ -117,6 +116,8 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device , m_pause_delay( VLC_TS_INVALID ) , m_pingRetriesLeft( PING_WAIT_RETRIES ) { +m_communication = new ChromecastCommunication( p_this, device_addr.c_str(), device_port ); + m_ctl_thread_interrupt = vlc_interrupt_create(); if( unlikely(m_ctl_thread_interrupt == NULL) ) throw std::runtime_error( "error creating interrupt context" ); @@ -126,7 +127,7 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device vlc_cond_init( _pace_cond ); std::stringstream ss; -ss << "http://; << m_communication.getServerIp() << ":" << port; +ss << "http://; << m_communication->getServerIp() << ":" << port; m_art_http_ip = ss.str(); m_common.p_opaque = this; @@ -168,12 +169,12 @@ intf_sys_t::~intf_sys_t() case Stopping: case Stopped: // Generate the close messages. -m_communication.msgReceiverClose( m_appTransportId ); +m_communication->msgReceiverClose( m_appTransportId ); /* fallthrough */ case Connecting: case Connected: case Launching: -m_communication.msgReceiverClose(DEFAULT_CHOMECAST_RECEIVER); +m_communication->msgReceiverClose(DEFAULT_CHOMECAST_RECEIVER); /* fallthrough */ default: break; @@ -186,6 +187,8 @@ intf_sys_t::~intf_sys_t() vlc_interrupt_destroy( m_ctl_thread_interrupt ); +delete m_communication; + if (m_meta != NULL) vlc_meta_Delete(m_meta); @@ -316,7 +319,7 @@ void intf_sys_t::tryLoad() msg_Dbg( m_module, "Starting the media receiver application" ); // Don't use setState as we don't want to signal the condition in this case. m_state = Launching; -m_communication.msgReceiverLaunchApp(); +m_communication->msgReceiverLaunchApp(); } return; } @@ -328,7 +331,7 @@ void intf_sys_t::tryLoad() // Reset the mediaSessionID to allow the new session to become the current one. // we cannot start a new load when the last one is still processing m_last_request_id = -m_communication.msgPlayerLoad( m_appTransportId, m_streaming_port, +m_communication->msgPlayerLoad( m_appTransportId, m_streaming_port, m_mime, m_meta ); if( m_last_request_id != ChromecastCommunication::kInvalidId ) m_state = Loading; @@ -549,7 +552,7 @@ void intf_sys_t::mainLoop() vlc_interrupt_set( m_ctl_thread_interrupt ); // State was already initialized as Authenticating -m_communication.msgAuth(); +m_communication->msgAuth(); while ( !vlc_killed() ) { @@ -594,8 +597,8 @@ void intf_sys_t::processAuthMessage( const castchannel::CastMessage& msg ) { vlc_mutex_locker locker(_lock); setState( Connecting ); -m_communication.msgConnect(DEFAULT_CHOMECAST_RECEIVER); -m_communication.msgReceiverGetStatus(); +m_communication->msgConnect(DEFAULT_CHOMECAST_RECEIVER); +m_communication->msgReceiverGetStatus(); } } @@ -607,7 +610,7 @@ void intf_sys_t::processHeartBeatMessage( const castchannel::CastMessage&