X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fsndfile_content.cc;h=beee7cd9d0aa33c37dfa31d789b4ef076d3eacfa;hb=09a9ac376db005a40a351736bcff4077f098825d;hp=539b0dfb586a4926c47e4e1f3e6678966e254ad9;hpb=9525e7726e4d488f193957d4fcf1cc1725581ae8;p=dcpomatic.git diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc index 539b0dfb5..beee7cd9d 100644 --- a/src/lib/sndfile_content.cc +++ b/src/lib/sndfile_content.cc @@ -31,9 +31,9 @@ using std::cout; using boost::shared_ptr; using boost::lexical_cast; -SndfileContent::SndfileContent (boost::filesystem::path f) - : Content (f) - , AudioContent (f) +SndfileContent::SndfileContent (shared_ptr f, boost::filesystem::path p) + : Content (f, p) + , AudioContent (f, p) , _audio_channels (0) , _audio_length (0) , _audio_frame_rate (0) @@ -41,13 +41,14 @@ SndfileContent::SndfileContent (boost::filesystem::path f) } -SndfileContent::SndfileContent (shared_ptr node) - : Content (node) - , AudioContent (node) +SndfileContent::SndfileContent (shared_ptr f, shared_ptr node) + : Content (f, node) + , AudioContent (f, node) { _audio_channels = node->number_child ("AudioChannels"); - _audio_length = node->number_child ("AudioLength"); + _audio_length = node->number_child ("AudioLength"); _audio_frame_rate = node->number_child ("AudioFrameRate"); + _audio_mapping = AudioMapping (node->node_child ("AudioMapping")); } string @@ -68,7 +69,7 @@ SndfileContent::information () const s << String::compose ( _("%1 channels, %2kHz, %3 samples"), audio_channels(), - audio_frame_rate() / 1000.0, + content_audio_frame_rate() / 1000.0, audio_length() ); @@ -91,10 +92,13 @@ SndfileContent::clone () const } void -SndfileContent::examine (shared_ptr film, shared_ptr job, bool quick) +SndfileContent::examine (shared_ptr job) { job->set_progress_unknown (); - Content::examine (film, job, quick); + Content::examine (job); + + shared_ptr film = _film.lock (); + assert (film); SndfileDecoder dec (film, shared_from_this()); @@ -108,6 +112,10 @@ SndfileContent::examine (shared_ptr film, shared_ptr job, bool quick) signal_changed (AudioContentProperty::AUDIO_CHANNELS); signal_changed (AudioContentProperty::AUDIO_LENGTH); signal_changed (AudioContentProperty::AUDIO_FRAME_RATE); + + /* XXX: do this in signal_changed...? */ + _audio_mapping = AudioMapping (_audio_channels); + signal_changed (AudioContentProperty::AUDIO_MAPPING); } void @@ -115,8 +123,38 @@ 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 (_audio_channels)); node->add_child("AudioLength")->add_child_text (lexical_cast (_audio_length)); node->add_child("AudioFrameRate")->add_child_text (lexical_cast (_audio_frame_rate)); + _audio_mapping.as_xml (node->add_child("AudioMapping")); } +Time +SndfileContent::length () const +{ + shared_ptr film = _film.lock (); + assert (film); + + return film->audio_frames_to_time (audio_length ()); +} + +int +SndfileContent::output_audio_frame_rate () const +{ + shared_ptr film = _film.lock (); + assert (film); + + return film->dcp_audio_frame_rate (); +} + +void +SndfileContent::set_audio_mapping (AudioMapping m) +{ + { + boost::mutex::scoped_lock lm (_mutex); + _audio_mapping = m; + } + + signal_changed (AudioContentProperty::AUDIO_MAPPING); +}