summaryrefslogtreecommitdiff
path: root/src/lib/resampler_manager.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-06-21 21:10:10 +0200
committerCarl Hetherington <cth@carlh.net>2021-04-25 00:12:02 +0200
commitdd3862c76cc158fe7cda50cfb4ef11d07a2483e2 (patch)
treee75a99e6f821834dca2d70a82922fdef91d8c516 /src/lib/resampler_manager.h
parent151f5c81fade29e9bebea9904fd85975351b7b78 (diff)
Had a go, gave up.
Diffstat (limited to 'src/lib/resampler_manager.h')
-rw-r--r--src/lib/resampler_manager.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/lib/resampler_manager.h b/src/lib/resampler_manager.h
new file mode 100644
index 000000000..25c0a5e9e
--- /dev/null
+++ b/src/lib/resampler_manager.h
@@ -0,0 +1,54 @@
+#include "audio_content.h"
+#include "dcpomatic_time.h"
+#include <boost/noncopyable.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include <vector>
+
+
+class AudioContent;
+class AudioDecoder;
+class AudioStream;
+class Resampler;
+
+
+class ResamplerManager : public boost::noncopyable
+{
+public:
+ ResamplerManager (boost::weak_ptr<const Film> film)
+ : _film (film)
+ {}
+
+ void add (dcpomatic::DCPTime start, dcpomatic::DCPTime end, boost::shared_ptr<AudioContent> content, boost::shared_ptr<AudioDecoder> decoder);
+ boost::shared_ptr<Resampler> get (AudioDecoder* decoder, AudioStreamPtr stream, bool fast);
+
+private:
+ friend struct resampler_manager_setup_test;
+
+ class Group
+ {
+ public:
+ Group (dcpomatic::DCPTime start_, dcpomatic::DCPTime end_, boost::shared_ptr<AudioContent> content, boost::shared_ptr<AudioDecoder> decoder)
+ : start(start_)
+ , end(end_)
+ {
+ contents.push_back (content);
+ decoders.push_back (decoder);
+ resamplers.resize (content->streams().size());
+ }
+
+ dcpomatic::DCPTime start;
+ dcpomatic::DCPTime end;
+ std::vector<boost::shared_ptr<AudioContent> > contents;
+ std::vector<boost::shared_ptr<AudioDecoder> > decoders;
+ std::vector<boost::shared_ptr<Resampler> > resamplers;
+ };
+
+ bool can_share (Group const& a, Group const& b) const;
+ void coalesce ();
+ bool coalesce_pass ();
+
+ boost::weak_ptr<const Film> _film;
+ std::vector<Group> _groups;
+};
+