diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-04-26 21:35:02 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-04-26 21:35:02 +0100 |
| commit | d851e5d3fd3e5af48c7e464a305c9d0001999700 (patch) | |
| tree | b0b492079c7addf898acb4aa1b9dd72b1f1efeeb /src/lib | |
| parent | ef5bc177625b9365c42cbabf3f3e45d6689305b5 (diff) | |
Fix content length reporting; fix crash when player has audio disabled.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.cc | 8 | ||||
| -rw-r--r-- | src/lib/film.h | 4 | ||||
| -rw-r--r-- | src/lib/player.cc | 4 | ||||
| -rw-r--r-- | src/lib/playlist.cc | 12 | ||||
| -rw-r--r-- | src/lib/playlist.h | 1 |
5 files changed, 25 insertions, 4 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 361031fc8..98c6c0610 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1215,6 +1215,12 @@ Film::video_length () const return _playlist->video_length (); } +ContentVideoFrame +Film::content_length () const +{ + return _playlist->content_length (); +} + /** Unfortunately this is needed as the GUI has FFmpeg-specific controls */ shared_ptr<FFmpegContent> Film::ffmpeg () const @@ -1311,7 +1317,7 @@ Film::content_changed (boost::weak_ptr<Content> c, int p) set_dcp_frame_rate (best_dcp_frame_rate (video_frame_rate ())); } else if (p == AudioContentProperty::AUDIO_CHANNELS) { set_audio_mapping (_playlist->default_audio_mapping ()); - } + } if (ui_signaller) { ui_signaller->emit (boost::bind (boost::ref (ContentChanged), c, p)); diff --git a/src/lib/film.h b/src/lib/film.h index 071f474ac..43b5d1a17 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -113,7 +113,9 @@ public: float video_frame_rate () const; libdcp::Size video_size () const; - ContentVideoFrame video_length () const; + ContentVideoFrame video_length () const; + + ContentVideoFrame content_length () const; std::vector<FFmpegSubtitleStream> ffmpeg_subtitle_streams () const; boost::optional<FFmpegSubtitleStream> ffmpeg_subtitle_stream () const; diff --git a/src/lib/player.cc b/src/lib/player.cc index 4caddb7e6..7c75597ea 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -89,7 +89,7 @@ Player::pass () } - if (!_video && _playlist->audio_from() == Playlist::AUDIO_FFMPEG && _sequential_audio_decoder < _audio_decoders.size ()) { + if (!_video && _audio && _playlist->audio_from() == Playlist::AUDIO_FFMPEG && _sequential_audio_decoder < _audio_decoders.size ()) { /* We're not producing video, so we may need to run FFmpeg content to get the audio */ @@ -103,7 +103,7 @@ Player::pass () } - if (_playlist->audio_from() == Playlist::AUDIO_SNDFILE) { + if (_audio && _playlist->audio_from() == Playlist::AUDIO_SNDFILE) { /* We're getting audio from SndfileContent */ diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index e32788951..3c69ae15f 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -276,3 +276,15 @@ Playlist::video_digest () const return md5_digest (t.c_str(), t.length()); } + +ContentVideoFrame +Playlist::content_length () const +{ + float const vfr = video_frame_rate() > 0 ? video_frame_rate() : 24; + int const afr = audio_frame_rate() > 0 ? audio_frame_rate() : 48000; + + return max ( + video_length(), + ContentVideoFrame (audio_length() * vfr / afr) + ); +} diff --git a/src/lib/playlist.h b/src/lib/playlist.h index 9a2627b1d..85bde64ff 100644 --- a/src/lib/playlist.h +++ b/src/lib/playlist.h @@ -64,6 +64,7 @@ public: ContentVideoFrame video_length () const; AudioMapping default_audio_mapping () const; + ContentVideoFrame content_length () const; enum AudioFrom { AUDIO_FFMPEG, |
