switch from Glib::Mutex to an object monitor (using LumieraMutex)
This commit is contained in:
parent
6c3492396c
commit
48a632434a
2 changed files with 23 additions and 12 deletions
|
|
@ -36,9 +36,7 @@ PlaybackController::PlaybackController() :
|
|||
|
||||
PlaybackController::~PlaybackController()
|
||||
{
|
||||
mutex.lock();
|
||||
finish_playback_thread = true;
|
||||
mutex.unlock();
|
||||
quit_playback_thread();
|
||||
if (thread)
|
||||
thread->join();
|
||||
}
|
||||
|
|
@ -46,7 +44,7 @@ PlaybackController::~PlaybackController()
|
|||
void
|
||||
PlaybackController::play()
|
||||
{
|
||||
Glib::Mutex::Lock lock(mutex);
|
||||
Lock sync(this);
|
||||
try
|
||||
{
|
||||
playHandle = & (proc::DummyPlayer::facade().start());
|
||||
|
|
@ -65,7 +63,7 @@ PlaybackController::play()
|
|||
void
|
||||
PlaybackController::pause()
|
||||
{
|
||||
Glib::Mutex::Lock lock(mutex);
|
||||
Lock sync(this);
|
||||
playing = false;
|
||||
if (playHandle)
|
||||
playHandle->pause(true);
|
||||
|
|
@ -74,7 +72,7 @@ PlaybackController::pause()
|
|||
void
|
||||
PlaybackController::stop()
|
||||
{
|
||||
Glib::Mutex::Lock lock(mutex);
|
||||
Lock sync(this);
|
||||
playing = false;
|
||||
// TODO: stop player somehow?
|
||||
}
|
||||
|
|
@ -82,7 +80,7 @@ PlaybackController::stop()
|
|||
bool
|
||||
PlaybackController::is_playing()
|
||||
{
|
||||
Glib::Mutex::Lock lock(mutex);
|
||||
Lock sync(this);
|
||||
return playing;
|
||||
}
|
||||
|
||||
|
|
@ -94,6 +92,13 @@ PlaybackController::start_playback_thread()
|
|||
this, &PlaybackController::playback_thread), true);
|
||||
}
|
||||
|
||||
void
|
||||
PlaybackController::quit_playback_thread()
|
||||
{
|
||||
Lock sync(this);
|
||||
finish_playback_thread = true;
|
||||
}
|
||||
|
||||
void
|
||||
PlaybackController::attach_viewer(
|
||||
const sigc::slot<void, void*>& on_frame)
|
||||
|
|
@ -107,7 +112,7 @@ PlaybackController::playback_thread()
|
|||
for(;;)
|
||||
{
|
||||
{
|
||||
Glib::Mutex::Lock lock(mutex);
|
||||
Lock sync(this);
|
||||
if(finish_playback_thread)
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,16 +27,22 @@
|
|||
#define PLAYBACK_CONTROLLER_HPP
|
||||
|
||||
#include "include/dummy-player-facade.h"
|
||||
#include "lib/sync.hpp"
|
||||
|
||||
#include <sigc++/sigc++.h>
|
||||
#include <glibmm.h>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
namespace gui {
|
||||
namespace controller {
|
||||
namespace controller {
|
||||
|
||||
using lib::Sync;
|
||||
using lib::NonrecursiveLock_NoWait;
|
||||
|
||||
|
||||
class PlaybackController
|
||||
: boost::noncopyable
|
||||
: boost::noncopyable,
|
||||
public Sync<NonrecursiveLock_NoWait>
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
@ -58,6 +64,8 @@ private:
|
|||
|
||||
void start_playback_thread();
|
||||
|
||||
void quit_playback_thread();
|
||||
|
||||
void playback_thread();
|
||||
|
||||
void pull_frame();
|
||||
|
|
@ -68,8 +76,6 @@ private:
|
|||
|
||||
Glib::Thread *thread;
|
||||
|
||||
Glib::StaticMutex mutex;
|
||||
|
||||
Glib::Dispatcher dispatcher;
|
||||
|
||||
volatile bool finish_playback_thread;
|
||||
|
|
|
|||
Loading…
Reference in a new issue