]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/sample_openal.hxx
pass the float pointer to the isNaN function instead of the SGVec3 type
[simgear.git] / simgear / sound / sample_openal.hxx
index f673f3048b3c07f93e867663fb013095d04aaae1..0d924246eabe723e5fcc796d3b1541e355749863 100644 (file)
@@ -69,12 +69,14 @@ public:
      * Constructor.
      * @param data Pointer to a memory buffer containing this audio sample data
        The application may free the data by calling free_data(), otherwise it
-       will be resident untill the class is destroyed.
+       will be resident untill the class is destroyed. This pointer will be
+       set to NULL after calling this function.
      * @param len Byte length of array
      * @param freq Frequency of the provided data (bytes per second)
      * @param format OpenAL format id of the data
      */
-    SGSoundSample( unsigned char *data, int len, int freq,
+    SGSoundSample( void** data, int len, int freq, int format=AL_FORMAT_MONO8 );
+    SGSoundSample( const unsigned char** data, int len, int freq,
                    int format = AL_FORMAT_MONO8 );
 
     /**
@@ -121,7 +123,7 @@ public:
      * Check if this audio sample is set to be continuous looping.
      * @return Return true if this audio sample is set to looping.
      */
-    inline bool get_looping() { return _loop; }
+    inline bool is_looping() { return _loop; }
 
     /**
      * Schedule this audio sample to stop playing.
@@ -149,10 +151,16 @@ public:
     inline bool is_playing() { return _playing; }
 
     /**
-     * sSt the data associated with this audio sample
+     * Set the data associated with this audio sample
      * @param data Pointer to a memory block containg this audio sample data.
+       This pointer will be set to NULL after calling this function.
      */
-    inline void set_data( unsigned char* data ) { _data = data; }
+    inline void set_data( const unsigned char **data ) {
+        _data = (unsigned char*)*data; *data = NULL;
+    }
+    inline void set_data( void **data ) {
+        _data = (unsigned char*)*data; *data = NULL;
+    }
 
     /**
      * Return the data associated with this audio sample.
@@ -164,7 +172,7 @@ public:
      * Free the data associated with this audio sample
      */
     void free_data() {
-        if (_data != NULL) { delete _data; _data = NULL; }
+        if ( _data ) free( _data ); _data = NULL;
     }
 
     /**
@@ -295,33 +303,41 @@ public:
      * This is in the same coordinate system as OpenGL; y=up, z=back, x=right.
      * @param pos Relative position of this sound
      */
-    void set_relative_position( const SGVec3f& pos );
+    inline void set_relative_position( const SGVec3f& pos ) {
+        _relative_pos = toVec3d(pos); _changed = true;
+    }
 
     /**
      * Set the base position of this sound in Geodetic coordinates.
      * @param pos Geodetic position
      */
-    void set_position( const SGGeod& pos );
+    inline void set_position( const SGGeod& pos ) {
+        _base_pos = pos; _changed = true;
+    }
 
     /**
      * Get the absolute position of this sound.
      * This is in the same coordinate system as OpenGL; y=up, z=back, x=right.
      * @return Absolute position
      */
-    float *get_position() const { return toVec3f(_absolute_pos).data(); }
+    SGVec3d& get_position() { return _absolute_pos; }
 
     /**
      * Set the orientation of this sound.
      * @param ori Quaternation containing the orientation information
      */
-    void set_orientation( const SGQuatd& ori );
+    inline void set_orientation( const SGQuatd& ori ) {
+        _orientation = ori; _changed = true;
+    }
 
     /**
      * Set direction of this sound relative to the orientation.
      * This is in the same coordinate system as OpenGL; y=up, z=back, x=right
      * @param dir Sound emission direction
      */
-    void set_direction( const SGVec3d& dir );
+    inline void set_direction( const SGVec3f& dir ) {
+        _direction = dir; _changed = true;
+    }
 
     /**
      * Define the audio cone parameters for directional audio.
@@ -342,7 +358,8 @@ public:
      * This is in the same coordinate system as OpenGL; y=up, z=back, x=right
      * @return Orientaton vector
      */
-    float *get_orientation() { return _orivec.data(); }
+    SGVec3f& get_orientation() { return _orivec; }
+    SGVec3f& get_direction() { return _direction; }
 
     /**
      * Get the inner angle of the audio cone.
@@ -367,7 +384,7 @@ public:
      * This is in the same coordinate system as OpenGL; y=up, z=back, x=right
      * @param Velocity vector
      */
-    inline void set_velocity( const SGVec3d& vel ) {
+    inline void set_velocity( const SGVec3f& vel ) {
         _velocity = vel; _changed = true;
     }
 
@@ -376,7 +393,7 @@ public:
      * This is in the same coordinate system as OpenGL; y=up, z=back, x=right
      * @return Velocity vector
      */
-    float *get_velocity() { return toVec3f(_velocity).data(); }
+    SGVec3f& get_velocity() { return _velocity; }
 
 
     /**
@@ -418,13 +435,15 @@ public:
      */
     inline std::string get_sample_name() const { return _refname; }
 
+    void update_absolute_position();
+
 private:
 
     // Position of the source sound.
     SGVec3d _absolute_pos;      // absolute position
     SGVec3d _relative_pos;      // position relative to the base position
-    SGVec3d _direction;         // orientation offset
-    SGVec3d _velocity;          // Velocity of the source sound.
+    SGVec3f _direction;         // orientation offset
+    SGVec3f _velocity;          // Velocity of the source sound.
 
     // The position and orientation of this sound
     SGQuatd _orientation;       // base orientation
@@ -432,7 +451,7 @@ private:
     SGGeod _base_pos;          // base position
 
     std::string _refname;      // name or file path
-    unsigned char *_data;
+    unsigned char_data;
 
     // configuration values
     int _format;
@@ -464,7 +483,7 @@ private:
     bool _static_changed;
     bool _is_file;
 
-    void update_absolute_position();
+    string random_string();
 };