Fix the most obvious lockups ... but the design still doesn't feel right for me!
This commit is contained in:
parent
58512e8a34
commit
e524e8c528
3 changed files with 36 additions and 26 deletions
|
|
@ -43,25 +43,29 @@ PlaybackController::~PlaybackController()
|
|||
void
|
||||
PlaybackController::play()
|
||||
{
|
||||
Lock sync(this);
|
||||
try
|
||||
if (playing && thread && playHandle)
|
||||
{
|
||||
if (playing && thread && playHandle) playHandle->pause(false);
|
||||
else
|
||||
{
|
||||
playHandle = & (proc::DummyPlayer::facade().start());
|
||||
if (thread)
|
||||
end_playback_thread();
|
||||
start_playback_thread();
|
||||
playing = true;
|
||||
}
|
||||
}
|
||||
catch (lumiera::error::State& err)
|
||||
{
|
||||
WARN (operate, "failed to start playback: %s" ,err.what());
|
||||
lumiera_error();
|
||||
playing = false;
|
||||
playHandle->pause(false);
|
||||
return;
|
||||
}
|
||||
if (thread)
|
||||
end_playback_thread();
|
||||
|
||||
{
|
||||
Lock sync(this);
|
||||
try
|
||||
{
|
||||
playHandle = & (proc::DummyPlayer::facade().start());
|
||||
start_playback_thread();
|
||||
playing = true;
|
||||
}
|
||||
catch (lumiera::error::State& err)
|
||||
{
|
||||
WARN (operate, "failed to start playback: %s" ,err.what());
|
||||
lumiera_error();
|
||||
playing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -76,11 +80,13 @@ PlaybackController::pause()
|
|||
void
|
||||
PlaybackController::stop()
|
||||
{
|
||||
Lock sync(this);
|
||||
playing = false;
|
||||
{
|
||||
Lock sync(this);
|
||||
playing = false;
|
||||
playHandle = 0;
|
||||
// TODO: stop player somehow?
|
||||
}
|
||||
end_playback_thread();
|
||||
playHandle = 0;
|
||||
// TODO: stop player somehow?
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -102,11 +108,15 @@ PlaybackController::start_playback_thread()
|
|||
void
|
||||
PlaybackController::end_playback_thread()
|
||||
{
|
||||
Lock sync(this);
|
||||
finish_playback_thread = true;
|
||||
{
|
||||
Lock sync(this);
|
||||
finish_playback_thread = true;
|
||||
playing = false;
|
||||
}
|
||||
if (thread)
|
||||
thread->join();
|
||||
thread = 0;
|
||||
finish_playback_thread = false;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ namespace gui {
|
|||
namespace controller {
|
||||
|
||||
using lib::Sync;
|
||||
using lib::NonrecursiveLock_NoWait;
|
||||
using lib::RecursiveLock_NoWait;
|
||||
|
||||
|
||||
class PlaybackController
|
||||
: boost::noncopyable,
|
||||
public Sync<NonrecursiveLock_NoWait>
|
||||
public Sync<RecursiveLock_NoWait>
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ namespace proc {
|
|||
ProcessImpl::setRate (uint fps)
|
||||
{
|
||||
// REQUIRE (fps==0 || fps_==0 ); //////////////TODO: reactivate this check when we have really independent processes which can be stopped!
|
||||
REQUIRE (fps==0 || !play_ );
|
||||
// REQUIRE (fps==0 || !play_ ); //////////////TODO: reactivate this check when we have really independent processes which can be stopped!
|
||||
|
||||
fps_ = fps;
|
||||
play_ = (fps != 0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue