diff options
author | Sakari Bergen <sakari.bergen@beatwaves.net> | 2009-12-27 14:46:23 +0000 |
---|---|---|
committer | Sakari Bergen <sakari.bergen@beatwaves.net> | 2009-12-27 14:46:23 +0000 |
commit | dde0848a984e06cbc1d4117d9cffa75c191f3b39 (patch) | |
tree | 11f3a5fe94ac792e753297e16e4e80dd7e296aea /libs/audiographer/audiographer/listed_source.h | |
parent | 35c72a53b4c6bbc61b4b86db9de629e18362b48d (diff) |
Re-integrate export-optimization branch.
Export now happens directly to file (unless normalizing is required), and can be easily optimized even further.
The Session process connection is still broken during export (as it was before this commit also).
git-svn-id: svn://localhost/ardour2/branches/3.0@6401 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/audiographer/audiographer/listed_source.h')
-rw-r--r-- | libs/audiographer/audiographer/listed_source.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libs/audiographer/audiographer/listed_source.h b/libs/audiographer/audiographer/listed_source.h new file mode 100644 index 0000000000..bc8f144d84 --- /dev/null +++ b/libs/audiographer/audiographer/listed_source.h @@ -0,0 +1,50 @@ +#ifndef AUDIOGRAPHER_LISTED_SOURCE_H +#define AUDIOGRAPHER_LISTED_SOURCE_H + +#include "types.h" +#include "source.h" + +#include <list> + +namespace AudioGrapher +{ + +template<typename T> +class ListedSource : public Source<T> +{ + public: + void add_output (typename Source<T>::SinkPtr output) { outputs.push_back(output); } + void clear_outputs () { outputs.clear(); } + void remove_output (typename Source<T>::SinkPtr output) { outputs.remove(output); } + + protected: + + typedef std::list<typename Source<T>::SinkPtr> SinkList; + + /// Helper for derived classes + void output (ProcessContext<T> const & c) + { + for (typename SinkList::iterator i = outputs.begin(); i != outputs.end(); ++i) { + (*i)->process (c); + } + } + + void output (ProcessContext<T> & c) + { + if (output_size_is_one()) { + // only one output, so we can keep this non-const + outputs.front()->process (c); + } else { + output (const_cast<ProcessContext<T> const &> (c)); + } + } + + inline bool output_size_is_one () { return (!outputs.empty() && ++outputs.begin() == outputs.end()); } + + SinkList outputs; +}; + +} // namespace + +#endif //AUDIOGRAPHER_LISTED_SOURCE_H + |