diff options
-rw-r--r-- | tasks.cpp | 46 | ||||
-rw-r--r-- | tasks.h | 9 |
2 files changed, 26 insertions, 29 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; @@ -18,8 +18,7 @@ class TaskManager: public cMutex typedef std::deque< Task* > TaskQueue; public: - bool Execute( Task* task, std::string& error ); - bool Execute( Task* task ); + bool Execute( Task& task ); // may only be called from Plugin::MainThreadHook void DoScheduledTasks(); @@ -58,7 +57,7 @@ private: class SwitchChannelTask: public Task { public: - SwitchChannelTask( tChannelID channel ): m_channel( channel ) {} + explicit SwitchChannelTask( tChannelID channel ): m_channel( channel ) {} private: tChannelID m_channel; @@ -69,12 +68,12 @@ private: class ReplayRecordingTask: public Task { public: - ReplayRecordingTask( std::string const& recording ): m_recording( recording ) {} + explicit ReplayRecordingTask( std::string const& recording ): m_recording( recording ) {} private: std::string m_recording; - virtual void Action() {} + virtual void Action(); }; |