diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-21 23:37:09 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-21 23:37:09 +0100 |
| commit | 4910d44f346cd9dfa239b5bfaca6cbda84be1e08 (patch) | |
| tree | 4d442884139fcf94ff658deaaba7307ad0e5b26e /src/lib | |
| parent | 2c50abc3535313ca2bc951cd8731fbd758055443 (diff) | |
Move audio bits into AudioContent.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/audio_content.cc | 36 | ||||
| -rw-r--r-- | src/lib/audio_content.h | 21 | ||||
| -rw-r--r-- | src/lib/film.cc | 28 | ||||
| -rw-r--r-- | src/lib/film.h | 18 | ||||
| -rw-r--r-- | src/lib/transcode_job.cc | 1 |
5 files changed, 57 insertions, 47 deletions
diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index e38d9d265..fc95acd7f 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -22,14 +22,20 @@ #include <libcxml/cxml.h> #include "audio_content.h" +using std::string; using boost::shared_ptr; +using boost::lexical_cast; int const AudioContentProperty::AUDIO_CHANNELS = 200; int const AudioContentProperty::AUDIO_LENGTH = 201; int const AudioContentProperty::AUDIO_FRAME_RATE = 202; +int const AudioContentProperty::AUDIO_GAIN = 203; +int const AudioContentProperty::AUDIO_DELAY = 204; AudioContent::AudioContent (boost::filesystem::path f) : Content (f) + , _audio_gain (0) + , _audio_delay (0) { } @@ -37,10 +43,14 @@ AudioContent::AudioContent (boost::filesystem::path f) AudioContent::AudioContent (shared_ptr<const cxml::Node> node) : Content (node) { + _audio_gain = node->number_child<float> ("AudioGain"); + _audio_delay = node->number_child<int> ("AudioDelay"); } AudioContent::AudioContent (AudioContent const & o) : Content (o) + , _audio_gain (o._audio_gain) + , _audio_delay (o._audio_delay) { } @@ -48,5 +58,31 @@ AudioContent::AudioContent (AudioContent const & o) void AudioContent::as_xml (xmlpp::Node* node) const { + boost::mutex::scoped_lock lm (_mutex); + node->add_child("AudioGain")->add_child_text (lexical_cast<string> (_audio_gain)); + node->add_child("AudioDelay")->add_child_text (lexical_cast<string> (_audio_delay)); +} + + +void +AudioContent::set_audio_gain (float g) +{ + { + boost::mutex::scoped_lock lm (_mutex); + _audio_gain = g; + } + signal_changed (AudioContentProperty::AUDIO_GAIN); } + +void +AudioContent::set_audio_delay (int d) +{ + { + boost::mutex::scoped_lock lm (_mutex); + _audio_delay = d; + } + + signal_changed (AudioContentProperty::AUDIO_DELAY); +} + diff --git a/src/lib/audio_content.h b/src/lib/audio_content.h index 51f05efb0..30524b4f4 100644 --- a/src/lib/audio_content.h +++ b/src/lib/audio_content.h @@ -35,6 +35,8 @@ public: static int const AUDIO_CHANNELS; static int const AUDIO_LENGTH; static int const AUDIO_FRAME_RATE; + static int const AUDIO_GAIN; + static int const AUDIO_DELAY; }; class AudioContent : public virtual Content @@ -51,6 +53,25 @@ public: virtual int content_audio_frame_rate () const = 0; virtual int output_audio_frame_rate (boost::shared_ptr<const Film>) const = 0; virtual AudioMapping audio_mapping () const = 0; + + void set_audio_gain (float); + void set_audio_delay (int); + + float audio_gain () const { + boost::mutex::scoped_lock lm (_mutex); + return _audio_gain; + } + + int audio_delay () const { + boost::mutex::scoped_lock lm (_mutex); + return _audio_delay; + } + +private: + /** Gain to apply to audio in dB */ + float _audio_gain; + /** Delay to apply to audio (positive moves audio later) in milliseconds */ + int _audio_delay; }; #endif diff --git a/src/lib/film.cc b/src/lib/film.cc index f05362d56..b561c2d15 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -98,8 +98,6 @@ Film::Film (string d, bool must_exist) , _container (Config::instance()->default_container ()) , _scaler (Scaler::from_id ("bicubic")) , _ab (false) - , _audio_gain (0) - , _audio_delay (0) , _with_subtitles (false) , _subtitle_offset (0) , _subtitle_scale (1) @@ -164,8 +162,6 @@ Film::Film (Film const & o) , _filters (o._filters) , _scaler (o._scaler) , _ab (o._ab) - , _audio_gain (o._audio_gain) - , _audio_delay (o._audio_delay) , _with_subtitles (o._with_subtitles) , _subtitle_offset (o._subtitle_offset) , _subtitle_scale (o._subtitle_scale) @@ -418,8 +414,6 @@ Film::write_metadata () const root->add_child("Scaler")->add_child_text (_scaler->id ()); root->add_child("AB")->add_child_text (_ab ? "1" : "0"); - root->add_child("AudioGain")->add_child_text (boost::lexical_cast<string> (_audio_gain)); - root->add_child("AudioDelay")->add_child_text (boost::lexical_cast<string> (_audio_delay)); root->add_child("WithSubtitles")->add_child_text (_with_subtitles ? "1" : "0"); root->add_child("SubtitleOffset")->add_child_text (boost::lexical_cast<string> (_subtitle_offset)); root->add_child("SubtitleScale")->add_child_text (boost::lexical_cast<string> (_subtitle_scale)); @@ -474,8 +468,6 @@ Film::read_metadata () _scaler = Scaler::from_id (f.string_child ("Scaler")); _ab = f.bool_child ("AB"); - _audio_gain = f.number_child<float> ("AudioGain"); - _audio_delay = f.number_child<int> ("AudioDelay"); _with_subtitles = f.bool_child ("WithSubtitles"); _subtitle_offset = f.number_child<float> ("SubtitleOffset"); _subtitle_scale = f.number_child<float> ("SubtitleScale"); @@ -685,26 +677,6 @@ Film::set_ab (bool a) } void -Film::set_audio_gain (float g) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _audio_gain = g; - } - signal_changed (AUDIO_GAIN); -} - -void -Film::set_audio_delay (int d) -{ - { - boost::mutex::scoped_lock lm (_state_mutex); - _audio_delay = d; - } - signal_changed (AUDIO_DELAY); -} - -void Film::set_with_subtitles (bool w) { { diff --git a/src/lib/film.h b/src/lib/film.h index 9b01dc604..71a3b1c34 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -134,8 +134,6 @@ public: FILTERS, SCALER, AB, - AUDIO_GAIN, - AUDIO_DELAY, WITH_SUBTITLES, SUBTITLE_OFFSET, SUBTITLE_SCALE, @@ -188,16 +186,6 @@ public: return _ab; } - float audio_gain () const { - boost::mutex::scoped_lock lm (_state_mutex); - return _audio_gain; - } - - int audio_delay () const { - boost::mutex::scoped_lock lm (_state_mutex); - return _audio_delay; - } - bool with_subtitles () const { boost::mutex::scoped_lock lm (_state_mutex); return _with_subtitles; @@ -246,8 +234,6 @@ public: void set_filters (std::vector<Filter const *>); void set_scaler (Scaler const *); void set_ab (bool); - void set_audio_gain (float); - void set_audio_delay (int); void set_with_subtitles (bool); void set_subtitle_offset (int); void set_subtitle_scale (float); @@ -308,10 +294,6 @@ private: has the specified filters and post-processing. */ bool _ab; - /** Gain to apply to audio in dB */ - float _audio_gain; - /** Delay to apply to audio (positive moves audio later) in milliseconds */ - int _audio_delay; /** True if subtitles should be shown for this film */ bool _with_subtitles; /** y offset for placing subtitles, in source pixels; +ve is further down diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index a0a9454b7..f9a305367 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -58,7 +58,6 @@ TranscodeJob::run () try { _film->log()->log (N_("Transcode job starting")); - _film->log()->log (String::compose (N_("Audio delay is %1ms"), _film->audio_delay())); _transcoder.reset (new Transcoder (_film, shared_from_this ())); _transcoder->go (); |
