diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-05-26 20:04:33 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-05-26 20:04:33 +0200 |
| commit | 8987f133295e352c44e05ef338eacc801c61a629 (patch) | |
| tree | 6325c00b2c1097bb483568ddad8b545e0e40f717 /src/lib | |
| parent | b6fb82e5df5551497b823f20a75c7ff94ffd1b3e (diff) | |
Fix race between the Butler thread starting and audio (perhaps) being disabled.
This could cause Butler::audio to be called with _audio_channels = 0
and _disable_audio = false, causing an exception in AudioBuffers when
remap() tried to make an AudioBuffers object with a channel count of 0.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/butler.cc | 13 | ||||
| -rw-r--r-- | src/lib/butler.h | 11 | ||||
| -rw-r--r-- | src/lib/ffmpeg_encoder.cc | 11 |
3 files changed, 21 insertions, 14 deletions
diff --git a/src/lib/butler.cc b/src/lib/butler.cc index 27b39ba4f..ce35b1f39 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -69,7 +69,8 @@ Butler::Butler ( VideoRange video_range, Image::Alignment alignment, bool fast, - bool prepare_only_proxy + bool prepare_only_proxy, + Audio audio ) : _film (film) , _player (player) @@ -81,7 +82,7 @@ Butler::Butler ( , _stop_thread (false) , _audio_mapping (audio_mapping) , _audio_channels (audio_channels) - , _disable_audio (false) + , _disable_audio (audio == Audio::DISABLED) , _pixel_format (pixel_format) , _video_range (video_range) , _alignment (alignment) @@ -394,14 +395,6 @@ Butler::get_audio (Behaviour behaviour, float* out, Frame frames) } -void -Butler::disable_audio () -{ - boost::mutex::scoped_lock lm (_mutex); - _disable_audio = true; -} - - pair<size_t, string> Butler::memory_used () const { diff --git a/src/lib/butler.h b/src/lib/butler.h index c7e71658d..79701d370 100644 --- a/src/lib/butler.h +++ b/src/lib/butler.h @@ -38,6 +38,12 @@ class PlayerVideo; class Butler : public ExceptionStore { public: + enum class Audio + { + ENABLED, + DISABLED + }; + Butler ( std::weak_ptr<const Film> film, std::shared_ptr<Player> player, @@ -47,7 +53,8 @@ public: VideoRange video_range, Image::Alignment alignment, bool fast, - bool prepare_only_proxy + bool prepare_only_proxy, + Audio audio ); ~Butler (); @@ -81,8 +88,6 @@ public: boost::optional<dcpomatic::DCPTime> get_audio (Behaviour behaviour, float* out, Frame frames); boost::optional<TextRingBuffers::Data> get_closed_caption (); - void disable_audio (); - std::pair<size_t, std::string> memory_used () const; private: diff --git a/src/lib/ffmpeg_encoder.cc b/src/lib/ffmpeg_encoder.cc index d4f0b4b47..bcf2b82de 100644 --- a/src/lib/ffmpeg_encoder.cc +++ b/src/lib/ffmpeg_encoder.cc @@ -108,7 +108,16 @@ FFmpegEncoder::FFmpegEncoder ( } _butler = std::make_shared<Butler>( - _film, _player, map, _output_audio_channels, bind(&PlayerVideo::force, FFmpegFileEncoder::pixel_format(format)), VideoRange::VIDEO, Image::Alignment::PADDED, false, false + _film, + _player, + map, + _output_audio_channels, + bind(&PlayerVideo::force, FFmpegFileEncoder::pixel_format(format)), + VideoRange::VIDEO, + Image::Alignment::PADDED, + false, + false, + Butler::Audio::ENABLED ); } |
