summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/content.cc17
-rw-r--r--src/lib/content.h4
-rw-r--r--src/lib/sndfile_content.cc17
3 files changed, 26 insertions, 12 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc
index 950814491..44b52a471 100644
--- a/src/lib/content.cc
+++ b/src/lib/content.cc
@@ -71,6 +71,7 @@ void
Content::as_xml (xmlpp::Node* node) const
{
boost::mutex::scoped_lock lm (_mutex);
+
node->add_child("Path")->add_child_text (_path.string());
node->add_child("Digest")->add_child_text (_digest);
node->add_child("Position")->add_child_text (lexical_cast<string> (_position));
@@ -81,14 +82,18 @@ Content::as_xml (xmlpp::Node* node) const
void
Content::examine (shared_ptr<Job>)
{
+ boost::mutex::scoped_lock lm (_mutex);
+ boost::filesystem::path p = _path;
+ lm.unlock ();
+
string d;
- if (boost::filesystem::is_regular_file (_path)) {
- d = md5_digest (_path);
+ if (boost::filesystem::is_regular_file (p)) {
+ d = md5_digest (p);
} else {
- d = md5_digest_directory (_path);
+ d = md5_digest_directory (p);
}
-
- boost::mutex::scoped_lock lm (_mutex);
+
+ lm.lock ();
_digest = d;
}
@@ -158,7 +163,7 @@ Content::technical_summary () const
Time
Content::length_after_trim () const
{
- return full_length () - _trim_start - _trim_end;
+ return full_length() - trim_start() - trim_end();
}
/** @param t A time relative to the start of this content (not the position).
diff --git a/src/lib/content.h b/src/lib/content.h
index e3f559752..3c57dddbe 100644
--- a/src/lib/content.h
+++ b/src/lib/content.h
@@ -114,6 +114,10 @@ protected:
void signal_changed (int);
boost::weak_ptr<const Film> _film;
+
+ /** _mutex which should be used to protect accesses, as examine
+ jobs can update content state in threads other than the main one.
+ */
mutable boost::mutex _mutex;
private:
diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc
index 7d09f715c..d57cf04e3 100644
--- a/src/lib/sndfile_content.cc
+++ b/src/lib/sndfile_content.cc
@@ -117,9 +117,13 @@ SndfileContent::examine (shared_ptr<Job> job)
signal_changed (AudioContentProperty::AUDIO_LENGTH);
signal_changed (AudioContentProperty::AUDIO_FRAME_RATE);
- /* XXX: do this in signal_changed...? */
- _audio_mapping = AudioMapping (_audio_channels);
- _audio_mapping.make_default ();
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ /* XXX: do this in signal_changed...? */
+ _audio_mapping = AudioMapping (_audio_channels);
+ _audio_mapping.make_default ();
+ }
+
signal_changed (AudioContentProperty::AUDIO_MAPPING);
}
@@ -129,9 +133,10 @@ SndfileContent::as_xml (xmlpp::Node* node) const
node->add_child("Type")->add_child_text ("Sndfile");
Content::as_xml (node);
AudioContent::as_xml (node);
- node->add_child("AudioChannels")->add_child_text (lexical_cast<string> (_audio_channels));
- node->add_child("AudioLength")->add_child_text (lexical_cast<string> (_audio_length));
- node->add_child("AudioFrameRate")->add_child_text (lexical_cast<string> (_audio_frame_rate));
+
+ node->add_child("AudioChannels")->add_child_text (lexical_cast<string> (audio_channels ()));
+ node->add_child("AudioLength")->add_child_text (lexical_cast<string> (audio_length ()));
+ node->add_child("AudioFrameRate")->add_child_text (lexical_cast<string> (content_audio_frame_rate ()));
_audio_mapping.as_xml (node->add_child("AudioMapping"));
}