This and the previous commit somewhat improve the previously
terrible behaviour when seeking during playback, probably
introduced by the idle update stuff.
, _slider (new wxSlider (this, wxID_ANY, 0, 0, 4096))
, _viewer (viewer)
, _slider_being_moved (false)
, _slider (new wxSlider (this, wxID_ANY, 0, 0, 4096))
, _viewer (viewer)
, _slider_being_moved (false)
- , _was_running_before_slider (false)
, _outline_content (0)
, _eye (0)
, _jump_to_selected (0)
, _outline_content (0)
, _eye (0)
, _jump_to_selected (0)
if (!page && !_slider_being_moved) {
/* This is the first event of a drag; stop playback for the duration of the drag */
if (!page && !_slider_being_moved) {
/* This is the first event of a drag; stop playback for the duration of the drag */
- _was_running_before_slider = _viewer->stop ();
_slider_being_moved = true;
}
_slider_being_moved = true;
}
void
Controls::slider_released ()
{
void
Controls::slider_released ()
{
- if (_was_running_before_slider) {
- /* Restart after a drag */
- _viewer->start ();
- }
+ /* Restart after a drag */
+ _viewer->resume ();
_slider_being_moved = false;
}
_slider_being_moved = false;
}
typedef std::pair<boost::shared_ptr<dcp::CPL>, boost::filesystem::path> CPL;
bool _slider_being_moved;
typedef std::pair<boost::shared_ptr<dcp::CPL>, boost::filesystem::path> CPL;
bool _slider_being_moved;
- bool _was_running_before_slider;
wxCheckBox* _outline_content;
wxChoice* _eye;
wxCheckBox* _outline_content;
wxChoice* _eye;
, _audio_channels (0)
, _audio_block_size (1024)
, _playing (false)
, _audio_channels (0)
, _audio_block_size (1024)
, _playing (false)
, _latency_history_count (0)
, _dropped (0)
, _closed_captions_dialog (new ClosedCaptionsDialog(p, this))
, _latency_history_count (0)
, _dropped (0)
, _closed_captions_dialog (new ClosedCaptionsDialog(p, this))
void
FilmViewer::recreate_butler ()
{
void
FilmViewer::recreate_butler ()
{
- bool const was_running = stop ();
_butler.reset ();
if (!_film) {
_butler.reset ();
if (!_film) {
_closed_captions_dialog->set_film_and_butler (_film, _butler);
_closed_captions_dialog->set_film_and_butler (_film, _butler);
- if (was_running) {
- start ();
- }
- if (_playing && (time() - _player_video.second) > one_video_frame()) {
+ if (_playing && !_suspended && (time() - _player_video.second) > one_video_frame()) {
/* Too late; just drop this frame before we try to get its image (which will be the time-consuming
part if this frame is J2K).
*/
/* Too late; just drop this frame before we try to get its image (which will be the time-consuming
part if this frame is J2K).
*/
void
FilmViewer::timer ()
{
void
FilmViewer::timer ()
{
- if (!_film || !_playing) {
+ if (!_film || !_playing || _suspended) {
_player->set_video_container_size (_out_size);
}
_player->set_video_container_size (_out_size);
}
+void
+FilmViewer::suspend ()
+{
+ ++_suspended;
+ if (_audio.isStreamRunning()) {
+ _audio.abortStream();
+ }
+}
+
+void
+FilmViewer::resume ()
+{
+ --_suspended;
+ if (_playing && !_suspended) {
+ if (_audio.isStreamOpen()) {
+ _audio.setStreamTime (_video_position.seconds());
+ _audio.startStream ();
+ }
+ timer ();
+ }
+}
+
void
FilmViewer::start ()
{
void
FilmViewer::start ()
{
- bool const was_running = stop ();
_closed_captions_dialog->clear ();
_butler->seek (t, accurate);
_closed_captions_dialog->clear ();
_butler->seek (t, accurate);
request_idle_get ();
} else {
request_idle_get ();
} else {
+ /* Make sure we get a frame so that _video_position is set up before we resume */
+ while (!get(true)) {}
void start ();
bool stop ();
void start ();
bool stop ();
+ void suspend ();
+ void resume ();
bool playing () const {
return _playing;
}
bool playing () const {
return _playing;
}
int _audio_channels;
unsigned int _audio_block_size;
bool _playing;
int _audio_channels;
unsigned int _audio_block_size;
bool _playing;
boost::shared_ptr<Butler> _butler;
std::list<Frame> _latency_history;
boost::shared_ptr<Butler> _butler;
std::list<Frame> _latency_history;