summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-06-02 21:14:24 +0100
committerCarl Hetherington <cth@carlh.net>2016-06-02 21:14:24 +0100
commitca436a8e96e02f982790d4168ac3dfe1d589451c (patch)
tree6f3ee681e03c2633b48fedb3e11b5ce2fadbaa06 /src/lib
parent6f68971e81a9b16973b3784f2f3f93f42ceb2af1 (diff)
Fix crash when loading old state files.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/audio_content.cc13
-rw-r--r--src/lib/audio_content.h2
-rw-r--r--src/lib/dcp_content.cc2
-rw-r--r--src/lib/ffmpeg_content.cc2
-rw-r--r--src/lib/film.cc5
-rw-r--r--src/lib/subtitle_content.cc11
6 files changed, 30 insertions, 5 deletions
diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc
index 2b402991c..7a4ca63a9 100644
--- a/src/lib/audio_content.cc
+++ b/src/lib/audio_content.cc
@@ -58,8 +58,19 @@ AudioContent::AudioContent (Content* parent)
}
shared_ptr<AudioContent>
-AudioContent::from_xml (Content* parent, cxml::ConstNodePtr node)
+AudioContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version)
{
+ if (version < 34) {
+ /* With old metadata FFmpeg content has the audio-related tags even with no
+ audio streams, so check for that.
+ */
+ if (node->string_child("Type") == "FFmpeg" && node->node_children("AudioStream").empty()) {
+ return shared_ptr<AudioContent> ();
+ }
+
+ /* Otherwise we can drop through to the newer logic */
+ }
+
if (!node->optional_number_child<double> ("AudioGain")) {
return shared_ptr<AudioContent> ();
}
diff --git a/src/lib/audio_content.h b/src/lib/audio_content.h
index da00bfeb1..92491bf89 100644
--- a/src/lib/audio_content.h
+++ b/src/lib/audio_content.h
@@ -82,7 +82,7 @@ public:
void add_properties (std::list<UserProperty> &) const;
- static boost::shared_ptr<AudioContent> from_xml (Content* parent, cxml::ConstNodePtr);
+ static boost::shared_ptr<AudioContent> from_xml (Content* parent, cxml::ConstNodePtr, int version);
private:
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index d23b4e351..b46b3dab7 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -75,7 +75,7 @@ DCPContent::DCPContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, in
: Content (film, node)
{
video = VideoContent::from_xml (this, node, version);
- audio = AudioContent::from_xml (this, node);
+ audio = AudioContent::from_xml (this, node, version);
subtitle = SubtitleContent::from_xml (this, node, version);
audio->set_stream (
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc
index 0f66180d0..b2b67e565 100644
--- a/src/lib/ffmpeg_content.cc
+++ b/src/lib/ffmpeg_content.cc
@@ -73,7 +73,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, cxml::ConstNodePtr no
: Content (film, node)
{
video = VideoContent::from_xml (this, node, version);
- audio = AudioContent::from_xml (this, node);
+ audio = AudioContent::from_xml (this, node, version);
subtitle = SubtitleContent::from_xml (this, node, version);
list<cxml::NodePtr> c = node->node_children ("SubtitleStream");
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 6b3625d9e..c8dfdfe63 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -108,8 +108,11 @@ using boost::is_any_of;
*
* 32 -> 33
* Changed <Period> to <Subtitle> in FFmpegSubtitleStream
+ * 33 -> 34
+ * Content only contains audio/subtitle-related tags if those things
+ * are present.
*/
-int const Film::current_state_version = 33;
+int const Film::current_state_version = 34;
/** Construct a Film object in a given directory.
*
diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc
index a45b0a24f..5b3b453b6 100644
--- a/src/lib/subtitle_content.cc
+++ b/src/lib/subtitle_content.cc
@@ -69,6 +69,17 @@ SubtitleContent::SubtitleContent (Content* parent)
shared_ptr<SubtitleContent>
SubtitleContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version)
{
+ if (version < 34) {
+ /* With old metadata FFmpeg content has the subtitle-related tags even with no
+ subtitle streams, so check for that.
+ */
+ if (node->string_child("Type") == "FFmpeg" && node->node_children("SubtitleStream").empty()) {
+ return shared_ptr<SubtitleContent> ();
+ }
+
+ /* Otherwise we can drop through to the newer logic */
+ }
+
if (!node->optional_number_child<double>("SubtitleXOffset") && !node->optional_number_child<double>("SubtitleOffset")) {
return shared_ptr<SubtitleContent> ();
}