+/**
+ * set the orientation of the listener (in opengl coordinates)
+ *
+ * Description: ORIENTATION is a pair of 3-tuples representing the
+ * 'at' direction vector and 'up' direction of the Object in
+ * Cartesian space. AL expects two vectors that are orthogonal to
+ * each other. These vectors are not expected to be normalized. If
+ * one or more vectors have zero length, implementation behavior
+ * is undefined. If the two vectors are linearly dependent,
+ * behavior is undefined.
+ */
+void SGSoundMgr::set_orientation( SGQuatd ori )
+{
+ _orientation = ori;
+
+ SGVec3d sgv_up = ori.rotate(SGVec3d::e2());
+ SGVec3d sgv_at = ori.rotate(SGVec3d::e3());
+ _at_up_vec[0] = sgv_at[0];
+ _at_up_vec[1] = sgv_at[1];
+ _at_up_vec[2] = sgv_at[2];
+ _at_up_vec[3] = sgv_up[0];
+ _at_up_vec[4] = sgv_up[1];
+ _at_up_vec[5] = sgv_up[2];
+ _changed = true;
+}
+
+// Get an unused source id
+//
+// The Sound Manager should keep track of the sources in use, the distance
+// of these sources to the listener and the volume (also based on audio cone
+// and hence orientation) of the sources.
+//
+// The Sound Manager is (and should be) the only one knowing about source
+// management. Sources further away should be suspendped to free resources for
+// newly added sounds close by.
+unsigned int SGSoundMgr::request_source()
+{
+ unsigned int source = NO_SOURCE;
+
+ if (_free_sources.size() > 0) {
+ source = _free_sources.back();
+ _free_sources.pop_back();
+ _sources_in_use.push_back(source);