diff options
author | Sascha Volkenandt <sascha (at) akv-soft (dot) de> | 2007-01-18 17:14:25 +0000 |
---|---|---|
committer | Sascha Volkenandt <sascha (at) akv-soft (dot) de> | 2007-01-18 17:14:25 +0000 |
commit | 5c45eb690e1a54eb6d90d4cef573104f1c034415 (patch) | |
tree | 4bab86c55e1c60cfd1b1936b8c20d15a8ab41837 | |
parent | 7de66ca6d2bcfc308781eb1c8d22a76df33f34a5 (diff) | |
download | vdr-plugin-live-5c45eb690e1a54eb6d90d4cef573104f1c034415.tar.gz vdr-plugin-live-5c45eb690e1a54eb6d90d4cef573104f1c034415.tar.bz2 |
- improved error handling and task creation (on stack is possible, now)
- fully implemented PlayRecordingTask
-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(); }; |