summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-04-26 21:35:02 +0100
committerCarl Hetherington <cth@carlh.net>2013-04-26 21:35:02 +0100
commitd851e5d3fd3e5af48c7e464a305c9d0001999700 (patch)
treeb0b492079c7addf898acb4aa1b9dd72b1f1efeeb /src
parentef5bc177625b9365c42cbabf3f3e45d6689305b5 (diff)
Fix content length reporting; fix crash when player has audio disabled.
Diffstat (limited to 'src')
-rw-r--r--src/lib/film.cc8
-rw-r--r--src/lib/film.h4
-rw-r--r--src/lib/player.cc4
-rw-r--r--src/lib/playlist.cc12
-rw-r--r--src/lib/playlist.h1
-rw-r--r--src/wx/film_editor.cc25
6 files changed, 39 insertions, 15 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,
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc
index f9ca8609b..f909a8e2e 100644
--- a/src/wx/film_editor.cc
+++ b/src/wx/film_editor.cc
@@ -60,6 +60,7 @@ using std::fixed;
using std::setprecision;
using std::list;
using std::vector;
+using std::max;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
@@ -742,7 +743,7 @@ FilmEditor::film_content_changed (weak_ptr<Content> content, int property)
} else if (property == FFmpegContentProperty::AUDIO_STREAMS) {
setup_streams ();
setup_show_audio_sensitivity ();
- } else if (property == VideoContentProperty::VIDEO_LENGTH) {
+ } else if (property == VideoContentProperty::VIDEO_LENGTH || property == AudioContentProperty::AUDIO_LENGTH) {
setup_length ();
boost::shared_ptr<Content> c = content.lock ();
if (c && c == selected_content()) {
@@ -786,17 +787,19 @@ void
FilmEditor::setup_length ()
{
stringstream s;
- if (_film->video_frame_rate() > 0 && _film->video_length()) {
- s << _film->video_length() << " "
- << wx_to_std (_("frames")) << "; " << seconds_to_hms (_film->video_length() / _film->video_frame_rate());
- } else if (_film->video_length()) {
- s << _film->video_length() << " "
- << wx_to_std (_("frames"));
- }
+ ContentVideoFrame const frames = _film->content_length ();
+
+ if (frames && _film->video_frame_rate()) {
+ s << frames << " " << wx_to_std (_("frames")) << "; " << seconds_to_hms (frames / _film->video_frame_rate());
+ } else if (frames) {
+ s << frames << " " << wx_to_std (_("frames"));
+ }
+
_length->SetLabel (std_to_wx (s.str ()));
- if (_film->video_length()) {
- _trim_start->SetRange (0, _film->video_length());
- _trim_end->SetRange (0, _film->video_length());
+
+ if (frames) {
+ _trim_start->SetRange (0, frames);
+ _trim_end->SetRange (0, frames);
}
}