[vlc-commits] [Git][videolan/vlc][master] 2 commits: chromecast: Avoid closing receiver after playback handoff
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Wed Jun 3 15:44:22 UTC 2026
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
c949c06f by Dave Nicolson at 2026-06-03T17:10:18+02:00
chromecast: Avoid closing receiver after playback handoff
- - - - -
52a3e65d by Dave Nicolson at 2026-06-03T17:10:18+02:00
chromecast: Use constexpr for handoff timeout
- - - - -
3 changed files:
- modules/stream_out/chromecast/cast.cpp
- modules/stream_out/chromecast/chromecast.h
- modules/stream_out/chromecast/chromecast_ctrl.cpp
Changes:
=====================================
modules/stream_out/chromecast/cast.cpp
=====================================
@@ -53,6 +53,8 @@
namespace {
+static constexpr vlc_tick_t CHROMECAST_HANDOFF_ATTACH_TIMEOUT = VLC_TICK_FROM_SEC(5);
+
struct sout_access_out_sys_t
{
sout_access_out_sys_t(httpd_host_t *httpd_host, intf_sys_t * const intf);
@@ -63,6 +65,7 @@ struct sout_access_out_sys_t
void prepare(sout_stream_t *p_stream, const std::string &mime);
int url_cb(httpd_client_t *cl, httpd_message_t *answer, const httpd_message_t *query);
void fifo_put_back(block_t *);
+ bool waitForClient(vlc_tick_t timeout, bool drained = false);
ssize_t write(sout_access_out_t *p_access, block_t *p_block);
void close();
@@ -562,6 +565,23 @@ int sout_access_out_sys_t::url_cb(httpd_client_t *cl, httpd_message_t *answer,
return VLC_SUCCESS;
}
+bool sout_access_out_sys_t::waitForClient(vlc_tick_t timeout, bool drained)
+{
+ const vlc_tick_t deadline = vlc_tick_now() + timeout;
+ while (vlc_tick_now() < deadline)
+ {
+ vlc_fifo_Lock(m_fifo);
+ const bool has_client = m_client != NULL && (!drained || vlc_fifo_GetBytes(m_fifo) == 0);
+ vlc_fifo_Unlock(m_fifo);
+
+ if (has_client)
+ return true;
+
+ vlc_tick_sleep(VLC_TICK_FROM_MS(100));
+ }
+ return false;
+}
+
ssize_t sout_access_out_sys_t::write(sout_access_out_t *p_access, block_t *p_block)
{
size_t i_len = p_block->i_buffer;
@@ -733,6 +753,11 @@ static void DelInternal(sout_stream_t *p_stream, void *_id, bool reset_config)
if ( p_sys->out_streams.empty() )
{
+ if (p_sys->access_out_live.waitForClient(CHROMECAST_HANDOFF_ATTACH_TIMEOUT))
+ {
+ p_sys->access_out_live.waitForClient(CHROMECAST_HANDOFF_ATTACH_TIMEOUT, true);
+ p_sys->p_intf->preservePlaybackOnTeardown();
+ }
p_sys->stopSoutChain(p_stream);
p_sys->p_intf->requestPlayerStop();
p_sys->access_out_live.clear();
=====================================
modules/stream_out/chromecast/chromecast.h
=====================================
@@ -193,6 +193,7 @@ struct intf_sys_t
int httpd_file_fill( uint8_t *psz_request, uint8_t **pp_data, size_t *pi_data );
void interrupt_wake_up();
+ void preservePlaybackOnTeardown();
private:
void reinit();
bool handleMessages();
=====================================
modules/stream_out/chromecast/chromecast_ctrl.cpp
=====================================
@@ -251,6 +251,12 @@ intf_sys_t::~intf_sys_t()
free( m_art_url );
}
+void intf_sys_t::preservePlaybackOnTeardown()
+{
+ vlc::threads::mutex_locker locker( m_lock );
+ m_state = TakenOver;
+}
+
void intf_sys_t::reinit()
{
assert( m_state == Dead );
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d08ea6b6203010f5af53adce84cb0b4e8c8f20bb...52a3e65d1a3c99e83b75e185eeb015de57c7ee3e
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d08ea6b6203010f5af53adce84cb0b4e8c8f20bb...52a3e65d1a3c99e83b75e185eeb015de57c7ee3e
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list