summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins/invoker
diff options
context:
space:
mode:
Diffstat (limited to 'src/uscxml/plugins/invoker')
-rw-r--r--src/uscxml/plugins/invoker/CMakeLists.txt23
-rw-r--r--src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp54
-rw-r--r--src/uscxml/plugins/invoker/audio/OpenALInvoker.h7
-rw-r--r--src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp25
4 files changed, 72 insertions, 37 deletions
diff --git a/src/uscxml/plugins/invoker/CMakeLists.txt b/src/uscxml/plugins/invoker/CMakeLists.txt
index 5f1f6a0..def840a 100644
--- a/src/uscxml/plugins/invoker/CMakeLists.txt
+++ b/src/uscxml/plugins/invoker/CMakeLists.txt
@@ -1,4 +1,5 @@
# sample invoker - include to make sure it compiles
+set(USCXML_INVOKERS "sample ${USCXML_INVOKERS}")
file(GLOB_RECURSE SAMPLE_INVOKER
sample/*.cpp
sample/*.h
@@ -17,6 +18,7 @@ endif()
# DirMon invoker to watch for filesystem changes
+set(USCXML_INVOKERS "dirmon ${USCXML_INVOKERS}")
file(GLOB_RECURSE DIRMON_INVOKER
filesystem/dirmon/*.cpp
filesystem/dirmon/*.h
@@ -51,8 +53,9 @@ else()
endif()
-# System invoker to open a native command
+# XHTML invoker
+set(USCXML_INVOKERS "xhtml ${USCXML_INVOKERS}")
file(GLOB_RECURSE XHTML_INVOKER
xhtml/*.cpp
xhtml/*.h
@@ -130,6 +133,7 @@ endif()
# calendar invoker
if (LIBICAL_FOUND)
+ set(USCXML_INVOKERS "calendar ${USCXML_INVOKERS}")
file(GLOB_RECURSE CALENDAR_INVOKER
calendar/*.cpp
calendar/*.h
@@ -150,6 +154,7 @@ endif()
# location invoker
if (CORELOCATION_LIBRARY AND OFF)
+ set(USCXML_INVOKERS "location ${USCXML_INVOKERS}")
file(GLOB_RECURSE LOCATION_INVOKER
location/CoreLocation/*.cpp
location/CoreLocation/*.mm
@@ -171,6 +176,7 @@ endif()
# UMUNDO invoker
if (UMUNDO_FOUND)
+ set(USCXML_INVOKERS "umundo ${USCXML_INVOKERS}")
file(GLOB_RECURSE UMUNDO_INVOKER
umundo/*.cpp
umundo/*.cc
@@ -192,6 +198,7 @@ endif()
# USCXML invoker
+set(USCXML_INVOKERS "scxml ${USCXML_INVOKERS}")
file(GLOB_RECURSE USCXML_INVOKER
scxml/*.cpp
scxml/*.h)
@@ -210,6 +217,7 @@ endif()
# HTTP server invoker
+set(USCXML_INVOKERS "httpservlet ${USCXML_INVOKERS}")
file(GLOB_RECURSE HTTPSERVLET_INVOKER
http/*.cpp
http/*.h)
@@ -228,6 +236,7 @@ endif()
# Heartbeat invoker
+set(USCXML_INVOKERS "heartbeat ${USCXML_INVOKERS}")
file(GLOB_RECURSE HEARTBEAT_INVOKER
heartbeat/*.cpp
heartbeat/*.h
@@ -245,7 +254,8 @@ endif()
# OpenSceneGraph invoker
-if (OPENSCENEGRAPH_FOUND AND OPENGL_FOUND)
+if (OPENSCENEGRAPH_FOUND AND OPENGL_FOUND)
+ set(USCXML_INVOKERS "scenegraph ${USCXML_INVOKERS}")
file(GLOB OPENSCENEGRAPH_INVOKER
graphics/openscenegraph/*.cpp
graphics/openscenegraph/*.h)
@@ -264,6 +274,7 @@ if (OPENSCENEGRAPH_FOUND AND OPENGL_FOUND)
list (APPEND USCXML_FILES ${OPENSCENEGRAPH_INVOKER})
endif()
+ set(USCXML_INVOKERS "osgvonvert ${USCXML_INVOKERS}")
file(GLOB OPENSCENEGRAPH_CONVERTER_INVOKER
graphics/openscenegraph/converter/*.cpp
graphics/openscenegraph/converter/*.h)
@@ -287,7 +298,8 @@ endif()
# OpenAL modality components
if (OPENAL_FOUND AND (LIBSNDFILE_FOUND OR AUDIOTOOLBOX_FOUND))
- file(GLOB_RECURSE OPENAL_INVOKER
+ set(USCXML_INVOKERS "openal ${USCXML_INVOKERS}")
+ file(GLOB_RECURSE OPENAL_INVOKER
audio/OpenAL*.cpp
audio/OpenAL*.h)
if (LIBSNDFILE_FOUND)
@@ -321,6 +333,7 @@ endif()
# MILES modality components
if (MILES_FOUND)
+ set(USCXML_INVOKERS "miles ${USCXML_INVOKERS}")
file(GLOB_RECURSE MILES_INVOKER
miles/*.cpp
miles/*.h)
@@ -345,6 +358,7 @@ endif()
# VoiceXML modality components
if (UMUNDO_FOUND)
+ set(USCXML_INVOKERS "vxml ${USCXML_INVOKERS}")
file(GLOB_RECURSE VXML_INVOKER
vxml/*.cpp
vxml/*.h
@@ -362,4 +376,5 @@ if (UMUNDO_FOUND)
endif()
set(USCXML_INCLUDE_DIRS ${USCXML_INCLUDE_DIRS} PARENT_SCOPE)
-set(USCXML_FILES ${USCXML_FILES} PARENT_SCOPE) \ No newline at end of file
+set(USCXML_FILES ${USCXML_FILES} PARENT_SCOPE)
+set(USCXML_INVOKERS ${USCXML_INVOKERS} PARENT_SCOPE)
diff --git a/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp b/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp
index 477a788..d038573 100644
--- a/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp
+++ b/src/uscxml/plugins/invoker/audio/OpenALInvoker.cpp
@@ -29,7 +29,12 @@ OpenALInvoker::OpenALInvoker() {
_alContext = NULL;
_alDevice = NULL;
_thread = NULL;
- _listenerPos[0] = _listenerPos[1] = _listenerPos[2] = 0;
+ _listenerPos[0] = _listenerPos[1] = _listenerPos[2] = 0;
+ _listenerVel[0] = _listenerVel[1] = _listenerVel[2] = 0;
+ _maxPos[0] = _maxPos[1] = _maxPos[2] = 1;
+
+ _listenerOrient[0] = _listenerOrient[1] = _listenerOrient[3] = _listenerOrient[5] = 0;
+ _listenerOrient[2] = _listenerOrient[4] = 1.0;
}
OpenALInvoker::~OpenALInvoker() {
@@ -103,8 +108,12 @@ void OpenALInvoker::send(const SendRequest& req) {
getPosFromParams(req.params, _sources[req.sendid]->pos);
+ _sources[req.sendid]->pos[0] -= _listenerPos[0];
+ _sources[req.sendid]->pos[1] -= _listenerPos[1];
+ _sources[req.sendid]->pos[2] -= _listenerPos[2];
try {
_sources[req.sendid]->player->setPosition(_sources[req.sendid]->pos);
+
} catch (std::exception ex) {
returnErrorExecution(ex.what());
}
@@ -135,6 +144,7 @@ void OpenALInvoker::send(const SendRequest& req) {
if (boost::iequals(req.name, "move.listener")) {
getPosFromParams(req.params, _listenerPos);
+
try {
alcMakeContextCurrent(_alContext);
alListenerfv(AL_POSITION, _listenerPos);
@@ -251,6 +261,17 @@ void OpenALInvoker::invoke(const InvokeRequest& req) {
throw std::string("__FILE__ __LINE__ openal error opening device");
}
+ std::multimap<std::string, std::string>::const_iterator paramIter = req.params.begin();
+ while(paramIter != req.params.end()) {
+ if (boost::iequals(paramIter->first, "maxX"))
+ _maxPos[0] = strTo<float>(paramIter->second);
+ if (boost::iequals(paramIter->first, "maxY"))
+ _maxPos[1] = strTo<float>(paramIter->second);
+ if (boost::iequals(paramIter->first, "maxZ"))
+ _maxPos[2] = strTo<float>(paramIter->second);
+ paramIter++;
+ }
+
// create new context with device
_alContext = alcCreateContext (_alDevice, NULL);
if (_alContext == NULL) {
@@ -261,19 +282,16 @@ void OpenALInvoker::invoke(const InvokeRequest& req) {
// std::cout << boost::lexical_cast<std::string>(_alContext);
// std::cout << boost::lexical_cast<std::string>(_alDevice);
-// alcMakeContextCurrent(_alContext);
+ alcMakeContextCurrent(_alContext);
// float listener[3] = {0,0,0};
// alListenerfv(AL_POSITION, listener);
-//
-// float orientation[6] = {
-// 0.0, 0.0, -1.0, // direction
-// 0.0, 1.0, 0.0 }; //up
-// alListenerfv(AL_ORIENTATION, orientation);
-//
-// float velocity[3] = { 0.0, 0.0, 0.0}; //up
-// alListenerfv(AL_VELOCITY, velocity);
-//
-// alListenerf(AL_GAIN, 0.5);
+
+ alcMakeContextCurrent(_alContext);
+ alListenerfv(AL_POSITION, _listenerPos);
+ alListenerfv(AL_VELOCITY, _listenerVel);
+ alListenerfv(AL_ORIENTATION, _listenerOrient);
+
+ alListenerf(AL_GAIN, 0.5);
start();
}
@@ -325,18 +343,18 @@ void OpenALInvoker::getPosFromParams(const std::multimap<std::string, std::strin
float rad = posToRadian(params.find("circle")->second);
position[0] = cosf(rad);
position[2] = -1 * sinf(rad); // z axis increases to front
- position[0] *= 150;
- position[2] *= 150;
+// position[0] *= 150;
+// position[2] *= 150;
}
} catch (boost::bad_lexical_cast& e) {
LOG(ERROR) << "Cannot interpret circle as float value in params: " << e.what();
}
-// position[0] = position[0] / _maxPos[0];
-// position[1] = position[1] / _maxPos[1];
-// position[2] = position[2] / _maxPos[2];
- // std::cout << _pos[0] << ":" << _pos[1] << ":" << _pos[2] << std::endl;
+ position[0] = position[0] / _maxPos[0];
+ position[1] = position[1] / _maxPos[1];
+ position[2] = position[2] / _maxPos[2];
+// std::cout << position[0] << ":" << position[1] << ":" << position[2] << std::endl;
}
diff --git a/src/uscxml/plugins/invoker/audio/OpenALInvoker.h b/src/uscxml/plugins/invoker/audio/OpenALInvoker.h
index 2ef567b..9b71d95 100644
--- a/src/uscxml/plugins/invoker/audio/OpenALInvoker.h
+++ b/src/uscxml/plugins/invoker/audio/OpenALInvoker.h
@@ -31,7 +31,7 @@ public:
bool finished;
int read;
int written;
- float pos[3];
+ ALfloat pos[3];
URL file;
PCMConverter* transform;
};
@@ -66,7 +66,10 @@ protected:
bool _isStarted;
bool _isRunning;
- float _listenerPos[3];
+ ALfloat _listenerPos[3];
+ ALfloat _listenerVel[3];
+ ALfloat _listenerOrient[6];
+ float _maxPos[3];
static void fillBuffers(void* userdata);
void start();
diff --git a/src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp b/src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp
index a5f90b8..64fa70a 100644
--- a/src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp
+++ b/src/uscxml/plugins/invoker/audio/OpenALPlayer.cpp
@@ -83,7 +83,7 @@ OpenALPlayer::~OpenALPlayer() {
}
alDeleteBuffers(_nrBuffers, _bufferIds);
for (int i = 0; i < _nrBuffers; i++) {
- assert(!alIsBuffer(_bufferIds[i]));
+// assert(!alIsBuffer(_bufferIds[i]));
}
free(_buffers);
free(_bufferIds);
@@ -160,28 +160,27 @@ void OpenALPlayer::init() {
}
// set our position and various flags to meaningful defaults
+ alSourcei (_alId, AL_SOURCE_RELATIVE, AL_TRUE);
+ checkOpenALError(__LINE__);
alSourcei(_alId, AL_LOOPING, AL_FALSE);
checkOpenALError(__LINE__);
alSourcefv(_alId, AL_POSITION, _position);
checkOpenALError(__LINE__);
- alSourcef(_alId,AL_REFERENCE_DISTANCE, 5.0f);
- checkOpenALError(__LINE__);
-// alDistanceModel(AL_LINEAR_DISTANCE);
-// checkOpenALError(__LINE__);
-// alSourcefv(_alId, AL_VELOCITY, _velocity);
-// checkOpenALError(__LINE__);
-// alSourcefv(_alId, AL_DIRECTION, _direction);
+// alSourcef(_alId,AL_REFERENCE_DISTANCE, 5.0f);
// checkOpenALError(__LINE__);
+ alDistanceModel(AL_LINEAR_DISTANCE);
+ checkOpenALError(__LINE__);
+ alSourcefv(_alId, AL_VELOCITY, _velocity);
+ checkOpenALError(__LINE__);
+ alSourcefv(_alId, AL_DIRECTION, _direction);
+ checkOpenALError(__LINE__);
// alSourcef (_alId, AL_ROLLOFF_FACTOR, 1.0);
// checkOpenALError(__LINE__);
- alSourcef(_alId,AL_REFERENCE_DISTANCE, 5.0f);
- checkOpenALError(__LINE__);
+// alSourcef(_alId,AL_REFERENCE_DISTANCE, 5.0f);
+// checkOpenALError(__LINE__);
// float listener[] = { 0.0, 0.0, 0.0 };
// alListenerfv(AL_POSITION, listener);
// checkOpenALError(__LINE__);
-
- alSourcei (_alId, AL_SOURCE_RELATIVE, AL_TRUE);
- checkOpenALError(__LINE__);
}
/**