2009-06-21 05:24:30 +02:00
|
|
|
#ifndef CAUDIOMANAGER_H_INCLUDED
|
|
|
|
#define CAUDIOMANAGER_H_INCLUDED
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include "cAudio.h"
|
|
|
|
#include "../include/IAudioDecoderFactory.h"
|
|
|
|
#include "cListener.h"
|
|
|
|
#include "../include/IAudioManager.h"
|
2009-08-29 13:24:31 +02:00
|
|
|
#include "../Headers/cMutex.h"
|
2009-11-20 04:39:56 +01:00
|
|
|
|
|
|
|
#include <AL/al.h>
|
|
|
|
#include <AL/alc.h>
|
2009-06-21 05:24:30 +02:00
|
|
|
|
|
|
|
namespace cAudio
|
|
|
|
{
|
|
|
|
class IAudio;
|
|
|
|
|
|
|
|
class cAudioManager : public IAudioManager
|
|
|
|
{
|
2009-08-26 01:56:35 +02:00
|
|
|
public:
|
2009-11-20 04:39:56 +01:00
|
|
|
cAudioManager() { }
|
|
|
|
virtual ~cAudioManager() { }
|
2009-09-12 07:59:28 +02:00
|
|
|
|
2009-08-08 07:51:32 +02:00
|
|
|
//!Inits the audio manager calling the alut/etc start ups
|
2009-11-20 04:39:56 +01:00
|
|
|
virtual bool initialize(const char* deviceName = 0x0, int outputFrequency = -1, int eaxEffectSlots = 4);
|
2009-08-26 01:56:35 +02:00
|
|
|
//!Shuts everything down
|
|
|
|
virtual void shutDown();
|
2009-11-20 04:39:56 +01:00
|
|
|
|
|
|
|
//! Returns the name of an available playback device.
|
|
|
|
/** \param index: Specify which name to retrieve ( Range: 0 to getAvailableDeviceCount()-1 ) */
|
|
|
|
virtual const char* getAvailableDeviceName(unsigned int index);
|
|
|
|
//! Returns the number of playback devices available for use.
|
|
|
|
virtual unsigned int getAvailableDeviceCount();
|
|
|
|
//! Returns the name of the default system playback device.
|
|
|
|
virtual const char* getDefaultDeviceName();
|
|
|
|
|
2009-08-08 07:51:32 +02:00
|
|
|
//!Creates the cAudio object
|
2009-08-26 01:56:35 +02:00
|
|
|
virtual IAudio* createFromFile(const std::string& identifier,const std::string& file,bool stream = false);
|
2009-08-08 07:51:32 +02:00
|
|
|
//!Loads ogg from memory or virtual file system
|
2009-08-11 19:57:20 +02:00
|
|
|
virtual IAudio* createFromMemory(const std::string& identifier, const char* data, size_t length, std::string ext);
|
2009-08-26 01:56:35 +02:00
|
|
|
//!Loads raw audio from memory.
|
2009-08-11 19:57:20 +02:00
|
|
|
virtual IAudio* createFromRaw(const std::string& identifier,const char* data, size_t length, unsigned int frequency, AudioFormats format);
|
2009-08-26 01:56:35 +02:00
|
|
|
|
|
|
|
//!Register Audio Codec
|
2009-08-11 19:57:20 +02:00
|
|
|
virtual bool registerAudioDecoder(IAudioDecoderFactory* factory, std::string extension);
|
|
|
|
//!Unregister Audio Codec (allows you to prevent an file type from being playable with new sound sources)
|
|
|
|
//!Note that all current sound sources will still continue to use any currently allocated decoders.
|
2009-11-20 04:39:56 +01:00
|
|
|
//!Will NOT delete any user added factory instance, you must do that yourself
|
2009-08-11 19:57:20 +02:00
|
|
|
virtual void unRegisterAudioDecoder(std::string extension);
|
|
|
|
//!Returns whether an audio decoder is currently registered for this file type
|
|
|
|
virtual bool isAudioDecoderRegistered(std::string extension);
|
|
|
|
//!Returns a registered audio decoder factory
|
|
|
|
virtual IAudioDecoderFactory* getAudioDecoderFactory(std::string extension);
|
|
|
|
|
2009-08-26 01:56:35 +02:00
|
|
|
//!Updates the cAudio playback
|
2009-08-11 19:57:20 +02:00
|
|
|
virtual void update();
|
2009-08-26 01:56:35 +02:00
|
|
|
//!Gets you the cAudio object you want
|
2009-08-11 19:57:20 +02:00
|
|
|
virtual IAudio *getSound(std::string identifier);
|
2009-08-26 01:56:35 +02:00
|
|
|
//!Releases "ALL" cAudio objects
|
2009-08-11 19:57:20 +02:00
|
|
|
virtual void release();
|
2009-06-21 05:24:30 +02:00
|
|
|
|
2009-11-20 04:39:56 +01:00
|
|
|
//! Grabs a list of available devices, as well as the default system one
|
|
|
|
void getAvailableDevices();
|
2009-06-21 05:24:30 +02:00
|
|
|
|
2009-11-20 04:39:56 +01:00
|
|
|
virtual IListener* getListener() { return &initlistener; }
|
2009-08-29 13:24:31 +02:00
|
|
|
|
2009-08-26 01:56:35 +02:00
|
|
|
private:
|
2009-08-29 13:24:31 +02:00
|
|
|
//Mutex for thread syncronization
|
|
|
|
cAudioMutex Mutex;
|
2009-11-20 04:39:56 +01:00
|
|
|
|
|
|
|
//Make a Openal context pointer
|
|
|
|
ALCcontext *Context;
|
|
|
|
//Make a openal device pointer
|
|
|
|
ALCdevice *Device;
|
|
|
|
|
2009-08-08 07:51:32 +02:00
|
|
|
//!The map that holds the cAudio objects
|
2009-08-26 01:56:35 +02:00
|
|
|
std::map<std::string, IAudio*> audiomap;
|
2009-08-08 07:51:32 +02:00
|
|
|
//!Decoder map that holds all decoders by file extension
|
|
|
|
std::map<std::string, IAudioDecoderFactory*> decodermap;
|
2009-08-26 01:56:35 +02:00
|
|
|
//!The listener object
|
2009-08-08 07:51:32 +02:00
|
|
|
cListener initlistener;
|
2009-11-20 04:39:56 +01:00
|
|
|
//! Check for OpenAL errors
|
|
|
|
void checkError();
|
|
|
|
|
|
|
|
std::vector<std::string> AvailableDevices;
|
|
|
|
std::string DefaultDevice;
|
2009-06-21 05:24:30 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //! CAUDIOMANAGER_H_INCLUDED
|