diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-03-15 23:39:25 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-04-19 23:04:32 +0100 |
| commit | fe99d14e3047e9302e94db372923c92291016f1c (patch) | |
| tree | 7a826e545927e576794af532fb403506f33603a7 /src/lib | |
| parent | 81301e260bad6944a75b3d20c1be4f2ff9929db7 (diff) | |
First bits of audio support.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/butler.cc | 18 | ||||
| -rw-r--r-- | src/lib/butler.h | 11 | ||||
| -rw-r--r-- | src/lib/config.cc | 11 | ||||
| -rw-r--r-- | src/lib/config.h | 38 | ||||
| -rw-r--r-- | src/lib/wscript | 1 |
5 files changed, 75 insertions, 4 deletions
diff --git a/src/lib/butler.cc b/src/lib/butler.cc index 1dbad6152..175846d63 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -34,13 +34,16 @@ using boost::optional; /** Video readahead in frames */ #define VIDEO_READAHEAD 10 -Butler::Butler (weak_ptr<const Film> film, shared_ptr<Player> player) +Butler::Butler (weak_ptr<const Film> film, shared_ptr<Player> player, AudioMapping audio_mapping, int audio_channels) : _film (film) , _player (player) , _pending_seek_accurate (false) , _finished (false) + , _audio_mapping (audio_mapping) + , _audio_channels (audio_channels) { _player_video_connection = _player->Video.connect (bind (&Butler::video, this, _1, _2)); + _player_audio_connection = _player->Audio.connect (bind (&Butler::audio, this, _1, _2)); _player_changed_connection = _player->Changed.connect (bind (&Butler::player_changed, this)); _thread = new boost::thread (bind (&Butler::thread, this)); } @@ -135,6 +138,12 @@ Butler::video (shared_ptr<PlayerVideo> video, DCPTime time) } void +Butler::audio (shared_ptr<AudioBuffers> audio, DCPTime time) +{ + +} + +void Butler::player_changed () { optional<DCPTime> t; @@ -148,3 +157,10 @@ Butler::player_changed () seek (*t, true); } } + +void +Butler::get_audio (float* out, Frame frames) +{ + _audio.get (reinterpret_cast<float*> (out), _audio_channels, frames); + _summon.notify_all (); +} diff --git a/src/lib/butler.h b/src/lib/butler.h index e02351b0f..d6742dcfa 100644 --- a/src/lib/butler.h +++ b/src/lib/butler.h @@ -19,6 +19,8 @@ */ #include "video_ring_buffers.h" +#include "audio_ring_buffers.h" +#include "audio_mapping.h" #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> #include <boost/thread.hpp> @@ -32,15 +34,17 @@ class PlayerVideo; class Butler : public boost::noncopyable { public: - Butler (boost::weak_ptr<const Film> film, boost::shared_ptr<Player> player); + Butler (boost::weak_ptr<const Film> film, boost::shared_ptr<Player> player, AudioMapping map, int audio_channels); ~Butler (); void seek (DCPTime position, bool accurate); std::pair<boost::shared_ptr<PlayerVideo>, DCPTime> get_video (); + void get_audio (float* out, Frame frames); private: void thread (); void video (boost::shared_ptr<PlayerVideo> video, DCPTime time); + void audio (boost::shared_ptr<AudioBuffers> audio, DCPTime time); void player_changed (); boost::weak_ptr<const Film> _film; @@ -48,6 +52,7 @@ private: boost::thread* _thread; VideoRingBuffers _video; + AudioRingBuffers _audio; boost::mutex _mutex; boost::condition _summon; @@ -57,6 +62,10 @@ private: bool _finished; + AudioMapping _audio_mapping; + int _audio_channels; + boost::signals2::scoped_connection _player_video_connection; + boost::signals2::scoped_connection _player_audio_connection; boost::signals2::scoped_connection _player_changed_connection; }; diff --git a/src/lib/config.cc b/src/lib/config.cc index 79486c602..4376ff057 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -116,6 +116,7 @@ Config::set_defaults () _dcp_metadata_filename_format = dcp::NameFormat ("%t"); _dcp_asset_filename_format = dcp::NameFormat ("%t"); _jump_to_selected = true; + _sound_output = optional<string> (); _allowed_dcp_frame_rates.clear (); _allowed_dcp_frame_rates.push_back (24); @@ -308,7 +309,11 @@ try _kdm_filename_format = dcp::NameFormat (f.optional_string_child("KDMFilenameFormat").get_value_or ("KDM %f %c %s")); _dcp_metadata_filename_format = dcp::NameFormat (f.optional_string_child("DCPMetadataFilenameFormat").get_value_or ("%t")); _dcp_asset_filename_format = dcp::NameFormat (f.optional_string_child("DCPAssetFilenameFormat").get_value_or ("%t")); +<<<<<<< 8de6a5d1d054bab25ab0d86bc48442d9d6adb849 _jump_to_selected = f.optional_bool_child("JumpToSelected").get_value_or (true); +======= + _sound_output = f.optional_string_child("SoundOutput"); +>>>>>>> First bits of audio support. /* Replace any cinemas from config.xml with those from the configured file */ if (boost::filesystem::exists (_cinemas_file)) { @@ -476,7 +481,13 @@ Config::write_config () const root->add_child("KDMContainerNameFormat")->add_child_text (_kdm_container_name_format.specification ()); root->add_child("DCPMetadataFilenameFormat")->add_child_text (_dcp_metadata_filename_format.specification ()); root->add_child("DCPAssetFilenameFormat")->add_child_text (_dcp_asset_filename_format.specification ()); +<<<<<<< 8de6a5d1d054bab25ab0d86bc48442d9d6adb849 root->add_child("JumpToSelected")->add_child_text (_jump_to_selected ? "1" : "0"); +======= + if (_sound_output) { + root->add_child("SoundOutput")->add_child_text (_sound_output.get()); + } +>>>>>>> First bits of audio support. try { doc.write_to_file_formatted (path("config.xml").string ()); diff --git a/src/lib/config.h b/src/lib/config.h index ed29a8f24..abfdba3dd 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -67,6 +67,7 @@ public: USE_ANY_SERVERS, SERVERS, CINEMAS, + SOUND_OUTPUT, OTHER }; @@ -306,6 +307,10 @@ public: return _jump_to_selected; } + boost::optional<std::string> sound_output () const { + return _sound_output; + } + /** @param n New number of local encoding threads */ void set_num_local_encoding_threads (int n) { maybe_set (_num_local_encoding_threads, n); @@ -521,6 +526,21 @@ public: maybe_set (_confirm_kdm_email, s); } + void set_sound_output (std::string o) + { + maybe_set (_sound_output, o, SOUND_OUTPUT); + } + + void unset_sound_output () + { + if (!_sound_output) { + return; + } + + _sound_output = boost::none; + changed (); + } + void set_kdm_container_name_format (dcp::NameFormat n) { maybe_set (_kdm_container_name_format, n); } @@ -582,12 +602,21 @@ private: boost::filesystem::path directory_or (boost::optional<boost::filesystem::path> dir, boost::filesystem::path a) const; template <class T> - void maybe_set (T& member, T new_value) { + void maybe_set (T& member, T new_value, Property prop = OTHER) { if (member == new_value) { return; } member = new_value; - changed (); + changed (prop); + } + + template <class T> + void maybe_set (boost::optional<T>& member, T new_value, Property prop = OTHER) { + if (member && member.get() == new_value) { + return; + } + member = new_value; + changed (prop); } /** number of threads to use for J2K encoding on the local machine */ @@ -669,7 +698,12 @@ private: dcp::NameFormat _kdm_container_name_format; dcp::NameFormat _dcp_metadata_filename_format; dcp::NameFormat _dcp_asset_filename_format; +<<<<<<< 8de6a5d1d054bab25ab0d86bc48442d9d6adb849 bool _jump_to_selected; +======= + /** name of a specific sound output stream to use for preview */ + boost::optional<std::string> _sound_output; +>>>>>>> First bits of audio support. /** Singleton instance, or 0 */ static Config* _instance; diff --git a/src/lib/wscript b/src/lib/wscript index 23e846812..7b19108f5 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -34,6 +34,7 @@ sources = """ audio_merger.cc audio_point.cc audio_processor.cc + audio_ring_buffers.cc audio_stream.cc butler.cc case_insensitive_sorter.cc |
