diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-08-09 15:05:52 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-08-09 15:05:52 (GMT) |
commit | 6dce9df7f483f3229bb2f34f0386ce37a1551e07 (patch) | |
tree | 1d3acaec4612d74ee3234c808df7ae5fa3b4ef9f /src/uscxml/plugins/invoker/audio/OpenALInvoker.h | |
parent | 01f8198f8b548e3f28cad1a441ceb8af6ea850a4 (diff) | |
download | uscxml-6dce9df7f483f3229bb2f34f0386ce37a1551e07.zip uscxml-6dce9df7f483f3229bb2f34f0386ce37a1551e07.tar.gz uscxml-6dce9df7f483f3229bb2f34f0386ce37a1551e07.tar.bz2 |
Extended Java bindings and OpenAL invoker
Diffstat (limited to 'src/uscxml/plugins/invoker/audio/OpenALInvoker.h')
-rw-r--r-- | src/uscxml/plugins/invoker/audio/OpenALInvoker.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/uscxml/plugins/invoker/audio/OpenALInvoker.h b/src/uscxml/plugins/invoker/audio/OpenALInvoker.h new file mode 100644 index 0000000..c0ed842 --- /dev/null +++ b/src/uscxml/plugins/invoker/audio/OpenALInvoker.h @@ -0,0 +1,88 @@ +#ifndef OPENALINVOKER_H_W09J90F0 +#define OPENALINVOKER_H_W09J90F0 + +#include "uscxml/config.h" +#include <uscxml/Interpreter.h> +#include "OpenALPlayer.h" + +#include "PCMConverter.h" +#ifdef LIBSNDFILE_FOUND +# include "LibSoundFile.h" +#else +# ifdef AUDIOTOOLBOX_FOUND +# include "AudioToolbox.h" +# endif +#endif + +#ifdef BUILD_AS_PLUGINS +#include "uscxml/plugins/Plugins.h" +#endif + +namespace uscxml { + +class OpenALSource { +public: + OpenALSource(); + ~OpenALSource(); + + OpenALPlayer* player; + char buffer[ALPLAY_AUDIO_BUFFER_SIZE]; + bool loop; + bool finished; + int read; + int written; + float pos[3]; + URL file; + PCMConverter* transform; +}; + +class OpenALInvoker : public InvokerImpl { +public: + OpenALInvoker(); + virtual ~OpenALInvoker(); + virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter); + + virtual std::set<std::string> getNames() { + std::set<std::string> names; + names.insert("openal"); + names.insert("spatial-audio"); + names.insert("http://uscxml.tk.informatik.tu-darmstadt.de/#openal"); + return names; + } + + virtual Data getDataModelVariables(); + virtual void send(const SendRequest& req); + virtual void cancel(const std::string sendId); + virtual void invoke(const InvokeRequest& req); + +protected: + std::map<std::string, OpenALSource*> _sources; + ALCcontext* _alContext; + ALCdevice* _alDevice; + + tthread::recursive_mutex _mutex; + tthread::thread* _thread; + tthread::condition_variable _sourcesAvailable; + + bool _isStarted; + bool _isRunning; + + static void fillBuffers(void* userdata); + void start(); + + void notifyOfEnd(OpenALSource*); + void notifyOfLoop(OpenALSource*); + + float posToRadian(const std::string& pos); + void getPosFromParams(const std::multimap<std::string, std::string>& params, float* position); + +}; + +#ifdef BUILD_AS_PLUGINS +PLUMA_INHERIT_PROVIDER(OpenALInvoker, InvokerImpl); +#endif + +} + + +#endif /* end of include guard: OPENALINVOKER_H_W09J90F0 */ |