2009-01-17 17:12:11 +01:00
/*
2015-01-07 00:53:03 +01:00
PlaybackController - playback controller object
2010-12-17 23:28:49 +01:00
2009-01-17 17:12:11 +01:00
Copyright ( C ) Lumiera . org
2008 , Joel Holdsworth < joel @ airwebreathe . org . uk >
2010-12-17 23:28:49 +01:00
2009-01-17 17:12:11 +01:00
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License as
2010-12-17 23:28:49 +01:00
published by the Free Software Foundation ; either version 2 of
the License , or ( at your option ) any later version .
2009-01-17 17:12:11 +01:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2010-12-17 23:28:49 +01:00
2009-01-17 17:12:11 +01:00
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
2010-12-17 23:28:49 +01:00
2009-01-17 17:12:11 +01:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-02 05:25:49 +01:00
2016-11-03 18:22:31 +01:00
/** @file playback-controller.cpp
2016-11-06 14:19:14 +01:00
* * Implementation parts of PlaybackController .
* * @ warning this is preliminary code and will be reworked , once
* * we ' re able to connect to actual playback processes
* * performed by the render engine .
2016-11-03 18:20:10 +01:00
*/
2015-01-06 14:37:26 +01:00
# include "gui/ctrl/playback-controller.hpp"
2009-02-02 05:25:49 +01:00
# include "gui/display-service.hpp"
2009-01-23 04:15:58 +01:00
# include "lib/error.hpp"
2014-08-17 07:02:48 +02:00
# include "include/logging.h"
2009-02-02 05:25:49 +01:00
2009-01-17 17:12:11 +01:00
namespace gui {
2017-01-27 23:56:52 +01:00
namespace ctrl {
namespace error = lumiera : : error ;
2015-01-07 00:53:03 +01:00
PlaybackController : : PlaybackController ( )
2015-05-29 04:44:58 +02:00
: playing_ ( false )
2015-01-07 00:53:03 +01:00
, viewerHandle_ ( 0 )
2017-01-27 23:56:52 +01:00
{
instance = this ; ////////////////////////////////////////////////////////TICKET #1067 shitty workaround to allow disentangling of top-level
}
PlaybackController : : ~ PlaybackController ( )
{
instance = nullptr ; ////////////////////////////////////////////////////////TICKET #1067 shitty workaround to allow disentangling of top-level
}
2015-01-07 00:53:03 +01:00
2017-01-27 23:56:52 +01:00
PlaybackController * PlaybackController : : instance ; ////////////////////////////////////////////////////////TICKET #1067 shitty workaround to allow disentangling of top-level
PlaybackController &
PlaybackController : : get ( ) ////////////////////////////////////////////////////////TICKET #1067 shitty workaround to allow disentangling of top-level
{
if ( not instance )
throw error : : Logic ( " GTK UI is not in running state "
2018-04-02 01:48:51 +02:00
, error : : LERR_ ( LIFECYCLE ) ) ;
2017-01-27 23:56:52 +01:00
return * instance ;
}
2015-01-07 00:53:03 +01:00
void
PlaybackController : : play ( )
{
2015-05-29 04:44:58 +02:00
if ( playHandle_ )
2009-01-24 21:33:41 +01:00
{
2015-05-29 04:44:58 +02:00
playHandle_ . play ( true ) ;
playing_ = true ;
2009-01-24 21:33:41 +01:00
}
2015-01-07 00:53:03 +01:00
else if ( viewerHandle_ )
try
{
2015-05-29 04:44:58 +02:00
playHandle_ = lumiera : : DummyPlayer : : facade ( ) . start ( viewerHandle_ ) ;
playing_ = true ;
2015-01-07 00:53:03 +01:00
}
catch ( lumiera : : error : : State & err )
{
WARN ( gui , " failed to start playback: %s " , err . what ( ) ) ;
lumiera_error ( ) ;
2015-05-29 04:44:58 +02:00
playing_ = false ;
2015-01-07 00:53:03 +01:00
}
}
void
PlaybackController : : pause ( )
{
2015-05-29 04:44:58 +02:00
if ( playHandle_ )
playHandle_ . play ( false ) ;
playing_ = false ;
2015-01-07 00:53:03 +01:00
}
void
PlaybackController : : stop ( )
{
2015-05-29 04:44:58 +02:00
playHandle_ . close ( ) ;
playing_ = false ;
2015-01-07 00:53:03 +01:00
}
bool
PlaybackController : : is_playing ( )
{
2015-05-29 04:44:58 +02:00
return playing_ ;
2015-01-07 00:53:03 +01:00
}
void
2015-05-29 04:44:58 +02:00
PlaybackController : : useDisplay ( LumieraDisplaySlot display )
2015-01-07 00:53:03 +01:00
{
viewerHandle_ = display ;
}
} } // namespace gui::ctrl
2009-01-17 17:12:11 +01:00