Commit 881e1eca authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

chromecast: Fix playback position when starting during playback

parent 37e5556b
......@@ -173,6 +173,8 @@ private:
mtime_t getPlaybackTimestamp() const;
double getPlaybackPosition() const;
void setInitialTime( mtime_t time );
// Sets the current state and signal the associated wait cond.
// This must be called with the lock held
void setState( States state );
......@@ -190,6 +192,7 @@ private:
static void set_length(void*, mtime_t length);
static mtime_t get_time(void*);
static double get_position(void*);
static void set_initial_time( void*, mtime_t time );
static void wait_app_started(void*);
......
......@@ -40,6 +40,7 @@ typedef struct
void (*pf_set_length)(void*, mtime_t length);
mtime_t (*pf_get_time)(void*);
double (*pf_get_position)(void*);
void (*pf_set_initial_time)( void*, mtime_t time );
void (*pf_wait_app_started)(void*);
......
......@@ -95,6 +95,7 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device
m_common.pf_get_position = get_position;
m_common.pf_get_time = get_time;
m_common.pf_set_length = set_length;
m_common.pf_set_initial_time = set_initial_time;
m_common.pf_wait_app_started = wait_app_started;
m_common.pf_request_seek = request_seek;
m_common.pf_wait_seek_done = wait_seek_done;
......@@ -164,7 +165,6 @@ void intf_sys_t::setHasInput( const std::string mime_type )
// We should now be in the ready state, and therefor have a valid transportId
assert( m_state == Ready && m_appTransportId.empty() == false );
// we cannot start a new load when the last one is still processing
m_ts_local_start = VLC_TS_0;
m_communication.msgPlayerLoad( m_appTransportId, m_streaming_port, m_title, m_artwork, mime_type );
setState( Loading );
}
......@@ -730,6 +730,12 @@ double intf_sys_t::getPlaybackPosition() const
return 0.0;
}
void intf_sys_t::setInitialTime(mtime_t time)
{
if( time )
m_ts_local_start = time;
}
void intf_sys_t::setState( States state )
{
if ( m_state != state )
......@@ -756,6 +762,13 @@ double intf_sys_t::get_position(void *pt)
return p_this->getPlaybackPosition();
}
void intf_sys_t::set_initial_time(void *pt, mtime_t time )
{
intf_sys_t *p_this = static_cast<intf_sys_t*>(pt);
vlc_mutex_locker locker( &p_this->m_lock );
return p_this->setInitialTime( time );
}
void intf_sys_t::set_length(void *pt, mtime_t length)
{
intf_sys_t *p_this = static_cast<intf_sys_t*>(pt);
......
......@@ -45,6 +45,7 @@ struct demux_sys_t
,demuxReady(false)
,m_seektime( VLC_TS_INVALID )
,m_enabled( true )
,m_startTime( VLC_TS_INVALID )
{
vlc_meta_t *p_meta = vlc_meta_New();
if( likely(p_meta != NULL) )
......@@ -134,6 +135,13 @@ struct demux_sys_t
demuxReady = true;
msg_Dbg(p_demux, "ready to demux");
}
if( m_startTime == VLC_TS_INVALID )
{
if( demux_Control( p_demux->p_next, DEMUX_GET_TIME,
&m_startTime ) == VLC_SUCCESS )
p_renderer->pf_set_initial_time( p_renderer->p_opaque,
m_startTime );
}
/* hold the data while seeking */
/* wait until the device is buffering for data after the seek command */
......@@ -250,6 +258,7 @@ struct demux_sys_t
case DEMUX_FILTER_DISABLE:
m_enabled = false;
p_renderer = NULL;
m_startTime = VLC_TS_INVALID;
return VLC_SUCCESS;
}
......@@ -265,6 +274,7 @@ protected:
/* seek time kept while waiting for the chromecast to "seek" */
mtime_t m_seektime;
bool m_enabled;
mtime_t m_startTime;
};
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