diff options
Diffstat (limited to 'tasks.cpp')
-rw-r--r-- | tasks.cpp | 46 |
1 files changed, 22 insertions, 24 deletions
@@ -3,6 +3,7 @@ #include <vdr/menu.h> #include <vdr/recording.h> #include "exception.h" +#include "recordings.h" #include "tasks.h" #include "tools.h" @@ -15,33 +16,41 @@ void SwitchChannelTask::Action() ReadLock lock( Channels ); cChannel* channel = Channels.GetByChannelID( m_channel ); if ( channel == 0 ) { - SetError( tr("Couldn't find channel or no channels available. Maybe you mistyped your request?") ); + SetError( tr("Couldn't find channel or no channels available.") ); return; } if ( !Channels.SwitchTo( channel->Number() ) ) - SetError( tr("Couldn't switch channels") ); + SetError( tr("Couldn't switch to channel.") ); +} + +void ReplayRecordingTask::Action() +{ + RecordingsManagerPtr recordings = LiveRecordingsManager(); + cRecording const* recording = recordings->GetByMd5Hash( m_recording ); + if ( recording == 0 ) { + SetError( tr("Couldn't find recording or no recordings available.") ); + return; + } + + cReplayControl::SetRecording( 0, 0 ); + cControl::Shutdown(); + cReplayControl::SetRecording( recording->FileName(), recording->Title() ); + cControl::Launch( new cReplayControl ); + cControl::Attach(); } TaskManager::TaskManager() { } -bool TaskManager::Execute( Task* task, string& error ) +bool TaskManager::Execute( Task& task ) { - auto_ptr< Task > reaper( task ); cMutexLock lock( this ); - m_taskQueue.push_back( task ); + m_taskQueue.push_back( &task ); m_scheduleWait.Wait( *this ); - error = task->Error(); - return task->Result(); -} - -bool TaskManager::Execute( Task* task ) -{ - string dummyError; - return Execute( task, dummyError ); + return task.Result(); } void TaskManager::DoScheduledTasks() @@ -58,17 +67,6 @@ void TaskManager::DoScheduledTasks() m_scheduleWait.Broadcast(); } -/* -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; -} -*/ - TaskManager& LiveTaskManager() { static TaskManager instance; |