Commit c3348c4b authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

chromecast: delay the Demux() call until the Chromecast is ready to receive data

Otherwise we start sending data while the connection is being established and
we miss the beginning of the file.
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent f11a78db
......@@ -130,6 +130,8 @@ private:
}
}
void waitAppStarted();
int connectChromecast();
void disconnectChromecast();
......@@ -225,6 +227,8 @@ private:
static void set_length(void*, mtime_t length);
static mtime_t get_time(void*);
static double get_position(void*);
static void wait_app_started(void*);
};
#endif /* VLC_CHROMECAST_H */
......@@ -38,6 +38,8 @@ typedef struct
void (*pf_set_length)(void*, mtime_t length);
mtime_t (*pf_get_time)(void*);
double (*pf_get_position)(void*);
void (*pf_wait_app_started)(void*);
} chromecast_common;
# ifdef __cplusplus
......
......@@ -121,6 +121,7 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device
common.pf_get_position = get_position;
common.pf_get_time = get_time;
common.pf_set_length = set_length;
common.pf_wait_app_started = wait_app_started;
assert( var_Type( p_module->p_parent->p_parent, CC_SHARED_VAR_NAME) == 0 );
if (var_Create( p_module->p_parent->p_parent, CC_SHARED_VAR_NAME, VLC_VAR_ADDRESS ) == VLC_SUCCESS )
......@@ -976,6 +977,16 @@ void intf_sys_t::requestPlayerSeek()
notifySendRequest();
}
void intf_sys_t::waitAppStarted()
{
vlc_mutex_locker locker(&lock);
mutex_cleanup_push(&lock);
while ( conn_status != CHROMECAST_APP_STARTED &&
conn_status != CHROMECAST_CONNECTION_DEAD )
vlc_cond_wait(&loadCommandCond, &lock);
vlc_cleanup_pop();
}
mtime_t intf_sys_t::get_time(void *pt)
{
intf_sys_t *p_this = reinterpret_cast<intf_sys_t*>(pt);
......@@ -995,3 +1006,9 @@ void intf_sys_t::set_length(void *pt, mtime_t length)
intf_sys_t *p_this = reinterpret_cast<intf_sys_t*>(pt);
p_this->i_length = length;
}
void intf_sys_t::wait_app_started(void *pt)
{
intf_sys_t *p_this = reinterpret_cast<intf_sys_t*>(pt);
p_this->waitAppStarted();
}
......@@ -41,6 +41,7 @@ struct demux_sys_t
demux_sys_t(demux_t * const demux, chromecast_common * const renderer)
:p_demux(demux)
,p_renderer(renderer)
,demuxReady(false)
{
}
......@@ -69,12 +70,21 @@ struct demux_sys_t
int Demux()
{
if (!demuxReady)
{
msg_Dbg(p_demux, "wait to demux");
p_renderer->pf_wait_app_started( p_renderer->p_opaque );
demuxReady = true;
msg_Dbg(p_demux, "ready to demux");
}
return demux_Demux( p_demux->p_next );
}
protected:
demux_t * const p_demux;
chromecast_common * const p_renderer;
bool demuxReady;
};
static int Demux( demux_t *p_demux_filter )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment