X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fsound%2Fsample_openal.hxx;h=706fa8d07383106ccf8bfe13667ac9d03f8180a2;hb=c188f6e3cb210327723356386d07dc1d56326ab4;hp=d2cb1824763a7a76b3769397bc80a0956c9464e0;hpb=3cd4c5566f8c418bc9bbb6026072eb0192027993;p=simgear.git diff --git a/simgear/sound/sample_openal.hxx b/simgear/sound/sample_openal.hxx index d2cb1824..706fa8d0 100644 --- a/simgear/sound/sample_openal.hxx +++ b/simgear/sound/sample_openal.hxx @@ -30,19 +30,19 @@ #ifndef _SG_SAMPLE_HXX #define _SG_SAMPLE_HXX 1 -#ifndef __cplusplus -# error This library requires C++ -#endif - #include #include -#include #include #include #include + +class SGPath; -// #include +#ifndef AL_FORMAT_MONO8 + #define AL_FORMAT_MONO8 0x1100 +#endif + /** * manages everything we need to know for an individual audio sample @@ -59,11 +59,10 @@ public: /** * Constructor - * @param path Path name to sound * @param file File name of sound Buffer data is freed by the sample group */ - SGSoundSample( const char *path, const char *file ); + SGSoundSample(const char *file, const SGPath& currentDir); /** * Constructor. @@ -82,14 +81,16 @@ public: /** * Destructor */ - ~SGSoundSample (); + virtual ~SGSoundSample (); /** - * Detect wheter this audio sample holds the information of a sound file. + * Detect whether this audio sample holds the information of a sound file. * @return Return true if this audio sample is to be constructed from a file. */ inline bool is_file() const { return _is_file; } + SGPath file_path() const; + /** * Test if this audio sample configuration has changed since the last call. * Calling this function will reset the flag so calling it a second @@ -101,7 +102,7 @@ public: } /** - * Test if static dataa of audio sample configuration has changed. + * Test if static data of audio sample configuration has changed. * Calling this function will reset the flag so calling it a second * time in a row will return false. * @return Return true is the static data has changed in the mean time. @@ -115,8 +116,8 @@ public: * at the next call op SoundGroup::update() * @param _loop Define whether this sound should be played in a loop. */ - void play( bool loop ) { - _playing = true; _loop = loop; _changed = true; + void play( bool loop = false ) { + _playing = true; _loop = loop; _changed = true; _static_changed = true; } /** @@ -128,7 +129,7 @@ public: /** * Schedule this audio sample to stop playing. */ - void stop() { + virtual void stop() { _playing = false; _changed = true; } @@ -150,6 +151,22 @@ public: */ inline bool is_playing() { return _playing; } + + /** + * Set this sample to out-of-range (or not) and + * Schedule this audio sample to stop (or start) playing. + */ + inline void set_out_of_range(bool oor = true) { + _out_of_range = oor; _playing = (!oor && _loop); _changed = true; + } + + /** + * Test if this sample to out-of-range or not. + */ + inline bool test_out_of_range() { + return _out_of_range; + } + /** * Set the data associated with this audio sample * @param data Pointer to a memory block containg this audio sample data. @@ -158,7 +175,7 @@ public: inline void set_data( const unsigned char **data ) { _data = (unsigned char*)*data; *data = NULL; } - inline void set_data( void **data ) { + inline void set_data( const void **data ) { _data = (unsigned char*)*data; *data = NULL; } @@ -179,7 +196,7 @@ public: * Set the source id of this source * @param sid OpenAL source-id */ - void set_source(unsigned int sid) { + virtual inline void set_source(unsigned int sid) { _source = sid; _valid_source = true; _changed = true; } @@ -187,24 +204,24 @@ public: * Get the OpenAL source id of this source * @return OpenAL source-id */ - inline unsigned int get_source() { return _source; } + virtual inline unsigned int get_source() { return _source; } /** * Test if the source-id of this audio sample may be passed to OpenAL. * @return true if the source-id is valid */ - inline bool is_valid_source() const { return _valid_source; } + virtual inline bool is_valid_source() const { return _valid_source; } /** * Set the source-id of this audio sample to invalid. */ - inline void no_valid_source() { _valid_source = false; } + virtual inline void no_valid_source() { _valid_source = false; } /** * Set the OpenAL buffer-id of this source * @param bid OpenAL buffer-id */ - void set_buffer(unsigned int bid) { + inline void set_buffer(unsigned int bid) { _buffer = bid; _valid_buffer = true; _changed = true; } @@ -443,6 +460,8 @@ public: */ inline std::string get_sample_name() const { return _refname; } + inline virtual bool is_queue() const { return false; } + void update_pos_and_orientation(); private: @@ -491,9 +510,10 @@ private: bool _playing; bool _changed; bool _static_changed; + bool _out_of_range; bool _is_file; - string random_string(); + std::string random_string(); };