projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move _state_timer into VideoView.
[dcpomatic.git]
/
src
/
wx
/
film_viewer.cc
diff --git
a/src/wx/film_viewer.cc
b/src/wx/film_viewer.cc
index 178311ac9bb0f78859c71e9569c2e524831a5eb5..c323c8281e7043ef7082c3346baf79ab97951508 100644
(file)
--- a/
src/wx/film_viewer.cc
+++ b/
src/wx/film_viewer.cc
@@
-86,7
+86,6
@@
FilmViewer::FilmViewer (wxWindow* p)
, _playing (false)
, _suspended (0)
, _latency_history_count (0)
, _playing (false)
, _suspended (0)
, _latency_history_count (0)
- , _dropped (0)
, _closed_captions_dialog (new ClosedCaptionsDialog(p, this))
, _outline_content (false)
, _eyes (EYES_LEFT)
, _closed_captions_dialog (new ClosedCaptionsDialog(p, this))
, _outline_content (false)
, _eyes (EYES_LEFT)
@@
-94,7
+93,6
@@
FilmViewer::FilmViewer (wxWindow* p)
#ifdef DCPOMATIC_VARIANT_SWAROOP
, _background_image (false)
#endif
#ifdef DCPOMATIC_VARIANT_SWAROOP
, _background_image (false)
#endif
- , _state_timer ("viewer")
, _gets (0)
, _idle_get (false)
{
, _gets (0)
, _idle_get (false)
{
@@
-122,7
+120,7
@@
FilmViewer::~FilmViewer ()
/** Ask for ::get() to be called next time we are idle */
void
/** Ask for ::get() to be called next time we are idle */
void
-FilmViewer::request_idle_
get
()
+FilmViewer::request_idle_
display_next_frame
()
{
if (_idle_get) {
return;
{
if (_idle_get) {
return;
@@
-140,7
+138,7
@@
FilmViewer::idle_handler ()
return;
}
return;
}
- if (_video_view->
get
(true)) {
+ if (_video_view->
display_next_frame
(true)) {
_idle_get = false;
} else {
/* get() could not complete quickly so we'll try again later */
_idle_get = false;
} else {
/* get() could not complete quickly so we'll try again later */
@@
-156,11
+154,8
@@
FilmViewer::set_film (shared_ptr<Film> film)
}
_film = film;
}
_film = film;
- _video_position = DCPTime ();
- _player_video.first.reset ();
- _player_video.second = DCPTime ();
- _video_view->
set_image (shared_ptr<Image>()
);
+ _video_view->
clear (
);
_closed_captions_dialog->clear ();
if (!_film) {
_closed_captions_dialog->clear ();
if (!_film) {
@@
-186,6
+181,7
@@
FilmViewer::set_film (shared_ptr<Film> film)
_player->set_play_referenced ();
_film->Change.connect (boost::bind (&FilmViewer::film_change, this, _1, _2));
_player->set_play_referenced ();
_film->Change.connect (boost::bind (&FilmViewer::film_change, this, _1, _2));
+ _film->LengthChange.connect (boost::bind(&FilmViewer::film_length_change, this));
_player->Change.connect (boost::bind (&FilmViewer::player_change, this, _1, _2, _3));
/* Keep about 1 second's worth of history samples */
_player->Change.connect (boost::bind (&FilmViewer::player_change, this, _1, _2, _3));
/* Keep about 1 second's worth of history samples */
@@
-231,9
+227,7
@@
FilmViewer::recreate_butler ()
void
FilmViewer::refresh_view ()
{
void
FilmViewer::refresh_view ()
{
- _state_timer.set ("update-view");
_video_view->update ();
_video_view->update ();
- _state_timer.unset ();
}
void
}
void
@@
-257,7
+251,6
@@
FilmViewer::video_view_sized ()
if (!quick_refresh()) {
slow_refresh ();
}
if (!quick_refresh()) {
slow_refresh ();
}
- PositionChanged ();
}
void
}
void
@@
-304,10
+297,10
@@
FilmViewer::resume ()
--_suspended;
if (_playing && !_suspended) {
if (_audio.isStreamOpen()) {
--_suspended;
if (_playing && !_suspended) {
if (_audio.isStreamOpen()) {
- _audio.setStreamTime (_video_
position
.seconds());
+ _audio.setStreamTime (_video_
view->position()
.seconds());
_audio.startStream ();
}
_audio.startStream ();
}
-
timer
();
+
_video_view->start
();
}
}
}
}
@@
-325,12
+318,11
@@
FilmViewer::start ()
}
if (_audio.isStreamOpen()) {
}
if (_audio.isStreamOpen()) {
- _audio.setStreamTime (_video_
position
.seconds());
+ _audio.setStreamTime (_video_
view->position()
.seconds());
_audio.startStream ();
}
_playing = true;
_audio.startStream ();
}
_playing = true;
- _dropped = 0;
_video_view->start ();
Started (position());
}
_video_view->start ();
Started (position());
}
@@
-348,6
+340,7
@@
FilmViewer::stop ()
}
_playing = false;
}
_playing = false;
+ _video_view->stop ();
Stopped (position());
return true;
}
Stopped (position());
return true;
}
@@
-381,22
+374,33
@@
FilmViewer::player_change (ChangeType type, int property, bool frequent)
if (!refreshed) {
slow_refresh ();
}
if (!refreshed) {
slow_refresh ();
}
- PositionChanged ();
}
void
FilmViewer::film_change (ChangeType type, Film::Property p)
{
}
void
FilmViewer::film_change (ChangeType type, Film::Property p)
{
- if (type == CHANGE_TYPE_DONE && p == Film::AUDIO_CHANNELS) {
+ if (type != CHANGE_TYPE_DONE) {
+ return;
+ }
+
+ if (p == Film::AUDIO_CHANNELS) {
recreate_butler ();
recreate_butler ();
+ } else if (p == Film::VIDEO_FRAME_RATE) {
+ _video_view->set_video_frame_rate (_film->video_frame_rate());
}
}
}
}
+void
+FilmViewer::film_length_change ()
+{
+ _video_view->set_length (_film->length());
+}
+
/** Re-get the current frame slowly by seeking */
void
FilmViewer::slow_refresh ()
{
/** Re-get the current frame slowly by seeking */
void
FilmViewer::slow_refresh ()
{
- seek (_video_
position
, true);
+ seek (_video_
view->position()
, true);
}
/** Try to re-get the current frame quickly by resetting the metadata
}
/** Try to re-get the current frame quickly by resetting the metadata
@@
-406,11
+410,11
@@
FilmViewer::slow_refresh ()
bool
FilmViewer::quick_refresh ()
{
bool
FilmViewer::quick_refresh ()
{
- if (!_player_video.first) {
+ if (!_
video_view->_
player_video.first) {
return false;
}
return false;
}
- if (!_player_video.first->reset_metadata (_film, _player->video_container_size(), _film->frame_size())) {
+ if (!_
video_view->_
player_video.first->reset_metadata (_film, _player->video_container_size(), _film->frame_size())) {
return false;
}
return false;
}
@@
-461,10
+465,9
@@
FilmViewer::seek (DCPTime t, bool accurate)
_butler->seek (t, accurate);
if (!_playing) {
_butler->seek (t, accurate);
if (!_playing) {
- request_idle_
get
();
+ request_idle_
display_next_frame
();
} else {
} else {
- /* Make sure we get a frame so that _video_position is set up before we resume */
- while (!get(true)) {}
+ while (!_video_view->display_next_frame(false)) {}
}
resume ();
}
resume ();
@@
-542,18
+545,24
@@
FilmViewer::uncorrected_time () const
return DCPTime::from_seconds (const_cast<RtAudio*>(&_audio)->getStreamTime());
}
return DCPTime::from_seconds (const_cast<RtAudio*>(&_audio)->getStreamTime());
}
- return _video_
position
;
+ return _video_
view->position()
;
}
}
-DCPTime
-FilmViewer::time () const
+optional<DCPTime>
+FilmViewer::
audio_
time () const
{
{
- if (_audio.isStreamRunning ()) {
- return DCPTime::from_seconds (const_cast<RtAudio*>(&_audio)->getStreamTime ()) -
- DCPTime::from_frames (average_latency(), _film->audio_frame_rate());
+ if (!_audio.isStreamRunning()) {
+ return optional<DCPTime>();
}
}
- return _video_position;
+ return DCPTime::from_seconds (const_cast<RtAudio*>(&_audio)->getStreamTime ()) -
+ DCPTime::from_frames (average_latency(), _film->audio_frame_rate());
+}
+
+DCPTime
+FilmViewer::time () const
+{
+ return audio_time().get_value_or(_video_view->position());
}
int
}
int
@@
-626,7
+635,7
@@
FilmViewer::show_closed_captions ()
void
FilmViewer::seek_by (DCPTime by, bool accurate)
{
void
FilmViewer::seek_by (DCPTime by, bool accurate)
{
- seek (_video_
position
+ by, accurate);
+ seek (_video_
view->position()
+ by, accurate);
}
void
}
void
@@
-634,3
+643,17
@@
FilmViewer::set_pad_black (bool p)
{
_pad_black = p;
}
{
_pad_black = p;
}
+
+/* May be called from a non-UI thread */
+void
+FilmViewer::emit_finished ()
+{
+ emit (boost::bind(boost::ref(Finished)));
+}
+
+int
+FilmViewer::dropped () const
+{
+ return _video_view->dropped ();
+}
+