From 2072c668df9ad48586fd2750713da0be742dda6d Mon Sep 17 00:00:00 2001 From: Sascha Volkenandt Date: Sat, 13 Jan 2007 18:37:21 +0000 Subject: - added service to switch channels by channel-id --- tasks.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tasks.cpp (limited to 'tasks.cpp') diff --git a/tasks.cpp b/tasks.cpp new file mode 100644 index 0000000..63a3358 --- /dev/null +++ b/tasks.cpp @@ -0,0 +1,39 @@ +#include +#include "tasks.h" + +namespace vdrlive { + +TaskManager::TaskManager(): + m_switchChannel( 0 ), + m_switchResult( false ) +{ +} + +bool TaskManager::SwitchChannel( int number ) +{ + cMutexLock lock( this ); + m_switchChannel = number; + m_scheduleWait.Wait( *this ); + return m_switchResult; +} + +void TaskManager::DoScheduledWork() +{ + if ( m_switchChannel == 0 ) + return; + + cMutexLock lock( this ); + if ( m_switchChannel != 0 ) { + m_switchResult = Channels.SwitchTo( m_switchChannel ); + m_switchChannel = 0; + m_scheduleWait.Broadcast(); + } +} + +TaskManager& LiveTaskManager() +{ + static TaskManager instance; + return instance; +} + +} // namespace vdrlive -- cgit v1.2.3