From 6fd53f0b97b06f8bb718bef6da0d90df95f64e03 Mon Sep 17 00:00:00 2001 From: Sascha Volkenandt Date: Mon, 15 Jan 2007 19:35:06 +0000 Subject: - moved ajax script to separate file - moved call of ajax object to page element - introduced page element for replaying recordings - introduced task for replaying recordings - added replay button to recordings page --- tasks.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 11 deletions(-) (limited to 'tasks.cpp') diff --git a/tasks.cpp b/tasks.cpp index 63a3358..07275e5 100644 --- a/tasks.cpp +++ b/tasks.cpp @@ -1,33 +1,68 @@ #include +#include +#include #include "tasks.h" namespace vdrlive { TaskManager::TaskManager(): - m_switchChannel( 0 ), - m_switchResult( false ) + m_switchChannel( 0, false ), + m_replayRecording( "", false ) { } bool TaskManager::SwitchChannel( int number ) { - cMutexLock lock( this ); - m_switchChannel = number; - m_scheduleWait.Wait( *this ); - return m_switchResult; + return ScheduleCommand( m_switchChannel, number ); + //cMutexLock lock( this ); + //m_switchChannel.first = number; + //m_scheduleWait.Wait( *this ); + //return m_switchChannel.second; +} + +bool TaskManager::ReplayRecording( std::string const& fileName ) +{ + return ScheduleCommand( m_replayRecording, fileName ); + //cMutexLock lock( this ); + //m_replayFileName = fileName; + //m_scheduleWait.Wait( *this ); + //return m_replayResult; } void TaskManager::DoScheduledWork() { - if ( m_switchChannel == 0 ) + if ( m_switchChannel.first == 0 && m_replayRecording.first.empty() ) return; cMutexLock lock( this ); - if ( m_switchChannel != 0 ) { - m_switchResult = Channels.SwitchTo( m_switchChannel ); - m_switchChannel = 0; - m_scheduleWait.Broadcast(); + if ( m_switchChannel.first != 0 ) + DoSwitchChannel(); + if ( !m_replayRecording.first.empty() ) + DoReplayRecording(); + m_scheduleWait.Broadcast(); +} + +void TaskManager::DoSwitchChannel() +{ + m_switchChannel.second = Channels.SwitchTo( m_switchChannel.first ); + m_switchChannel.first = 0; +} + +void TaskManager::DoReplayRecording() +{ + bool result = false; + cThreadLock lock( &Recordings ); + + cRecording* recording = Recordings.GetByName( m_replayRecording.first.c_str() ); + if ( recording ) { + cReplayControl::SetRecording( 0, 0 ); + cControl::Shutdown(); + cReplayControl::SetRecording( recording->FileName(), recording->Title() ); + cControl::Launch( new cReplayControl ); + cControl::Attach(); + result = true; } + m_replayRecording.first.clear(); } TaskManager& LiveTaskManager() -- cgit v1.2.3