diff options
author | Sakari Bergen <sakari.bergen@beatwaves.net> | 2010-03-15 19:11:48 +0000 |
---|---|---|
committer | Sakari Bergen <sakari.bergen@beatwaves.net> | 2010-03-15 19:11:48 +0000 |
commit | 830911f6f9451d83a58043b3f9084d3caa164b7b (patch) | |
tree | f4ca4e3d86b51d66e7cecfb6b370cc4eb553e2d7 /libs/audiographer/audiographer/utils | |
parent | 44f4b84551d36ef4103d09452768f5ba53e0002c (diff) |
Fix export, which has been broken since the boost::signals2 changes. Also update Audiographer, bacause of its incomplete sndfile handling. Audiographer is equal to revision 74
git-svn-id: svn://localhost/ardour2/branches/3.0@6760 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/audiographer/audiographer/utils')
-rw-r--r-- | libs/audiographer/audiographer/utils/identity_vertex.h | 22 | ||||
-rw-r--r-- | libs/audiographer/audiographer/utils/listed_source.h | 51 |
2 files changed, 73 insertions, 0 deletions
diff --git a/libs/audiographer/audiographer/utils/identity_vertex.h b/libs/audiographer/audiographer/utils/identity_vertex.h new file mode 100644 index 0000000000..147939a7c5 --- /dev/null +++ b/libs/audiographer/audiographer/utils/identity_vertex.h @@ -0,0 +1,22 @@ +#ifndef AUDIOGRAPHER_IDENTITY_VERTEX_H +#define AUDIOGRAPHER_IDENTITY_VERTEX_H + +#include "audiographer/utils/listed_source.h" +#include "audiographer/sink.h" + +namespace AudioGrapher +{ + +/// Outputs its input directly to a number of Sinks +template<typename T = DefaultSampleType> +class IdentityVertex : public ListedSource<T>, Sink<T> +{ + public: + void process (ProcessContext<T> const & c) { ListedSource<T>::output(c); } + void process (ProcessContext<T> & c) { ListedSource<T>::output(c); } +}; + + +} // namespace + +#endif // AUDIOGRAPHER_IDENTITY_VERTEX_H diff --git a/libs/audiographer/audiographer/utils/listed_source.h b/libs/audiographer/audiographer/utils/listed_source.h new file mode 100644 index 0000000000..b030281207 --- /dev/null +++ b/libs/audiographer/audiographer/utils/listed_source.h @@ -0,0 +1,51 @@ +#ifndef AUDIOGRAPHER_LISTED_SOURCE_H +#define AUDIOGRAPHER_LISTED_SOURCE_H + +#include "audiographer/types.h" +#include "audiographer/source.h" + +#include <list> + +namespace AudioGrapher +{ + +/// An generic \a Source that uses a \a std::list for managing outputs +template<typename T = DefaultSampleType> +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 + |