* Move static helper functions into cAudio header (this increase maintainability)
This commit is contained in:
parent
3e062d42ca
commit
f6dc2e6a5e
|
@ -87,6 +87,7 @@ set (file_root_source_files
|
|||
src/cThread.cpp
|
||||
src/cWavAudioDecoderFactory.cpp
|
||||
src/cWavDecoder.cpp
|
||||
src/cAudio.cpp
|
||||
)
|
||||
|
||||
source_group("Header Files" FILES ${file_root_header_files})
|
||||
|
|
|
@ -112,21 +112,6 @@ namespace cAudio
|
|||
/** \param handler: Pointer to an event handler to remove. */
|
||||
virtual void unRegisterEventHandler(ICaptureEventHandler* handler) = 0;
|
||||
//!Removes all event handlers attached to this manager.
|
||||
virtual void unRegisterAllEventHandlers() = 0;
|
||||
|
||||
virtual void unRegisterAllEventHandlers() = 0;
|
||||
};
|
||||
|
||||
//! Creates an interface to an Audio Capture Object.
|
||||
/** Note: This is the only way to get access to the audio capture capabilities of cAudio.
|
||||
You must delete this interface using destroyAudioCapture() once you are done with it.
|
||||
\param initializeDefault: Whether to return an object initialized with the default settings. If set to false, you must make a call to initialize before audio can be captured.
|
||||
\return A pointer to the created object, NULL if the object could not be allocated.
|
||||
*/
|
||||
CAUDIO_API IAudioCapture* createAudioCapture(bool initializeDefault = true);
|
||||
|
||||
//! Destroys an interface to a previously created Audio Capture Object and frees the memory allocated for it.
|
||||
/**
|
||||
\param capture: The object to destroy
|
||||
*/
|
||||
CAUDIO_API void destroyAudioCapture(IAudioCapture* capture);
|
||||
};
|
|
@ -183,18 +183,4 @@ namespace cAudio
|
|||
protected:
|
||||
private:
|
||||
};
|
||||
|
||||
//! Creates an interface to an Audio Manager.
|
||||
/** Note: This is the only way to get access to the audio playback capabilities of cAudio.
|
||||
You must delete this interface using destroyAudioManager() once you are done with it.
|
||||
\param initializeDefault: Whether to return an object initialized with the default settings. If set to false, you must make a call to initialize before you can create audio sources.
|
||||
\return A pointer to the created object, NULL if the object could not be allocated.
|
||||
*/
|
||||
CAUDIO_API IAudioManager* createAudioManager(bool initializeDefault = true);
|
||||
|
||||
//! Destroys an interface to a previously created Audio Manager and frees the memory allocated for it.
|
||||
/**
|
||||
\param capture: The object to destroy.
|
||||
*/
|
||||
CAUDIO_API void destroyAudioManager(IAudioManager* manager);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include "IPluginManager.h"
|
||||
#include "IRefCounted.h"
|
||||
|
||||
/*! \mainpage cAudio 2.1.0 API documentation
|
||||
/*! \mainpage cAudio 2.2.0 API documentation
|
||||
*
|
||||
* <img src="../cAudioLogo.jpg"></img>
|
||||
*
|
||||
|
@ -104,4 +104,33 @@
|
|||
|
||||
//! Main namespace for the entire cAudio library
|
||||
namespace cAudio {
|
||||
|
||||
//! Creates an interface to an Audio Manager.
|
||||
/** Note: This is the only way to get access to the audio playback capabilities of cAudio.
|
||||
You must delete this interface using destroyAudioManager() once you are done with it.
|
||||
\param initializeDefault: Whether to return an object initialized with the default settings. If set to false, you must make a call to initialize before you can create audio sources.
|
||||
\return A pointer to the created object, NULL if the object could not be allocated.
|
||||
*/
|
||||
CAUDIO_API IAudioManager* createAudioManager(bool initializeDefault = true);
|
||||
|
||||
//! Destroys an interface to a previously created Audio Manager and frees the memory allocated for it.
|
||||
/**
|
||||
\param capture: The object to destroy.
|
||||
*/
|
||||
CAUDIO_API void destroyAudioManager(IAudioManager* manager);
|
||||
|
||||
|
||||
//! Creates an interface to an Audio Capture Object.
|
||||
/** Note: This is the only way to get access to the audio capture capabilities of cAudio.
|
||||
You must delete this interface using destroyAudioCapture() once you are done with it.
|
||||
\param initializeDefault: Whether to return an object initialized with the default settings. If set to false, you must make a call to initialize before audio can be captured.
|
||||
\return A pointer to the created object, NULL if the object could not be allocated.
|
||||
*/
|
||||
CAUDIO_API IAudioCapture* createAudioCapture(bool initializeDefault = true);
|
||||
|
||||
//! Destroys an interface to a previously created Audio Capture Object and frees the memory allocated for it.
|
||||
/**
|
||||
\param capture: The object to destroy
|
||||
*/
|
||||
CAUDIO_API void destroyAudioCapture(IAudioCapture* capture);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
// Copyright (c) 2008-2011 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones, Murat (wolfmanfx) Sari
|
||||
// This file is part of the "cAudio Engine"
|
||||
// For conditions of distribution and use, see copyright notice in cAudio.h
|
||||
|
||||
#include "../Include/cAudio.h"
|
||||
#include "../Headers/cAudioManager.h"
|
||||
#include "../Headers/cAudioCapture.h"
|
||||
#include "../Headers/cOggAudioDecoderFactory.h"
|
||||
#include "../Headers/cWavAudioDecoderFactory.h"
|
||||
#include "../Headers/cRawAudioDecoderFactory.h"
|
||||
#include "../Headers/cFileSourceFactory.h"
|
||||
#include "../Headers/cFileSource.h"
|
||||
#include "../Headers/cPluginManager.h"
|
||||
|
||||
namespace cAudio
|
||||
{
|
||||
#if CAUDIO_COMPILE_WITH_OGG_DECODER == 1
|
||||
static cOggAudioDecoderFactory OggDecoderFactory;
|
||||
#endif
|
||||
#if CAUDIO_COMPILE_WITH_WAV_DECODER == 1
|
||||
static cWavAudioDecoderFactory WavDecoderFactory;
|
||||
#endif
|
||||
|
||||
static cRawAudioDecoderFactory RawDecoderFactory;
|
||||
|
||||
#if CAUDIO_COMPILE_WITH_FILE_SOURCE == 1
|
||||
static cFileSourceFactory FileSourceFactory;
|
||||
#endif
|
||||
|
||||
CAUDIO_API IAudioManager* createAudioManager(bool initializeDefault)
|
||||
{
|
||||
cAudioManager* manager = CAUDIO_NEW cAudioManager;
|
||||
if(manager)
|
||||
{
|
||||
if(initializeDefault)
|
||||
manager->initialize();
|
||||
|
||||
manager->getAvailableDevices();
|
||||
|
||||
#if CAUDIO_COMPILE_WITH_OGG_DECODER == 1
|
||||
manager->registerAudioDecoder(&OggDecoderFactory, "ogg");
|
||||
#endif
|
||||
#if CAUDIO_COMPILE_WITH_WAV_DECODER == 1
|
||||
manager->registerAudioDecoder(&WavDecoderFactory, "wav");
|
||||
#endif
|
||||
|
||||
manager->registerAudioDecoder(&RawDecoderFactory, "raw");
|
||||
|
||||
#if CAUDIO_COMPILE_WITH_FILE_SOURCE == 1
|
||||
manager->registerDataSource(&FileSourceFactory, "FileSystem", 0);
|
||||
#endif
|
||||
|
||||
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
cAudioVector<IAudioPlugin*>::Type plugins = cPluginManager::Instance()->getPluginList();
|
||||
for(unsigned int i = 0; i < plugins.size(); ++i)
|
||||
{
|
||||
plugins[i]->onCreateAudioManager(manager);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
|
||||
CAUDIO_API void destroyAudioManager(IAudioManager* manager)
|
||||
{
|
||||
if(manager)
|
||||
{
|
||||
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
cAudioVector<IAudioPlugin*>::Type plugins = cPluginManager::Instance()->getPluginList();
|
||||
for(unsigned int i = 0; i < plugins.size(); ++i)
|
||||
{
|
||||
plugins[i]->onDestroyAudioManager(manager);
|
||||
}
|
||||
#endif
|
||||
|
||||
manager->unRegisterAllAudioDecoders();
|
||||
manager->unRegisterAllDataSources();
|
||||
manager->unRegisterAllEventHandlers();
|
||||
manager->shutDown();
|
||||
|
||||
CAUDIO_DELETE manager;
|
||||
manager = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
CAUDIO_API IAudioCapture* createAudioCapture(bool initializeDefault)
|
||||
{
|
||||
cAudioCapture* capture = CAUDIO_NEW cAudioCapture;
|
||||
if(capture)
|
||||
{
|
||||
if(initializeDefault)
|
||||
capture->initialize();
|
||||
|
||||
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
cAudioVector<IAudioPlugin*>::Type plugins = cPluginManager::Instance()->getPluginList();
|
||||
for(unsigned int i = 0; i < plugins.size(); ++i)
|
||||
{
|
||||
plugins[i]->onCreateAudioCapture(capture);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return capture;
|
||||
}
|
||||
|
||||
CAUDIO_API void destroyAudioCapture(IAudioCapture* capture)
|
||||
{
|
||||
if(capture)
|
||||
{
|
||||
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
cAudioVector<IAudioPlugin*>::Type plugins = cPluginManager::Instance()->getPluginList();
|
||||
for(unsigned int i = 0; i < plugins.size(); ++i)
|
||||
{
|
||||
plugins[i]->onDestoryAudioCapture(capture);
|
||||
}
|
||||
#endif
|
||||
CAUDIO_DELETE capture;
|
||||
capture = NULL;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -336,41 +336,6 @@ namespace cAudio
|
|||
};
|
||||
}
|
||||
|
||||
CAUDIO_API IAudioCapture* createAudioCapture(bool initializeDefault)
|
||||
{
|
||||
cAudioCapture* capture = CAUDIO_NEW cAudioCapture;
|
||||
if(capture)
|
||||
{
|
||||
if(initializeDefault)
|
||||
capture->initialize();
|
||||
|
||||
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
cAudioVector<IAudioPlugin*>::Type plugins = cPluginManager::Instance()->getPluginList();
|
||||
for(unsigned int i = 0; i < plugins.size(); ++i)
|
||||
{
|
||||
plugins[i]->onCreateAudioCapture(capture);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return capture;
|
||||
}
|
||||
|
||||
CAUDIO_API void destroyAudioCapture(IAudioCapture* capture)
|
||||
{
|
||||
if(capture)
|
||||
{
|
||||
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
cAudioVector<IAudioPlugin*>::Type plugins = cPluginManager::Instance()->getPluginList();
|
||||
for(unsigned int i = 0; i < plugins.size(); ++i)
|
||||
{
|
||||
plugins[i]->onDestoryAudioCapture(capture);
|
||||
}
|
||||
#endif
|
||||
CAUDIO_DELETE capture;
|
||||
capture = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void cAudioCapture::registerEventHandler(ICaptureEventHandler* handler)
|
||||
{
|
||||
if(handler)
|
||||
|
|
|
@ -3,20 +3,16 @@
|
|||
// For conditions of distribution and use, see copyright notice in cAudio.h
|
||||
|
||||
#include "../Headers/cAudioManager.h"
|
||||
#include "../Headers/cFileSource.h"
|
||||
#include "../Headers/cMemorySource.h"
|
||||
#include "../Headers/cUtils.h"
|
||||
#include "../Headers/cOggAudioDecoderFactory.h"
|
||||
#include "../Headers/cWavAudioDecoderFactory.h"
|
||||
#include "../Headers/cRawAudioDecoderFactory.h"
|
||||
#include "../Headers/cThread.h"
|
||||
|
||||
#include "../include/cAudioPlatform.h"
|
||||
#include "../include/cAudioSleep.h"
|
||||
#include "../Headers/cUtils.h"
|
||||
#include "../Headers/cThread.h"
|
||||
#include "../Headers/cLogger.h"
|
||||
#include "../Headers/cPluginManager.h"
|
||||
#include "../include/cAudioPlatform.h"
|
||||
#include "../Headers/cFileSourceFactory.h"
|
||||
#include "../Headers/cThread.h"
|
||||
|
||||
#include "../Headers/cMemorySource.h"
|
||||
#include "../Headers/cRawAudioDecoderFactory.h"
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -36,19 +32,6 @@
|
|||
|
||||
namespace cAudio
|
||||
{
|
||||
#if CAUDIO_COMPILE_WITH_OGG_DECODER == 1
|
||||
static cOggAudioDecoderFactory OggDecoderFactory;
|
||||
#endif
|
||||
#if CAUDIO_COMPILE_WITH_WAV_DECODER == 1
|
||||
static cWavAudioDecoderFactory WavDecoderFactory;
|
||||
#endif
|
||||
|
||||
static cRawAudioDecoderFactory RawDecoderFactory;
|
||||
|
||||
#if CAUDIO_COMPILE_WITH_FILE_SOURCE == 1
|
||||
static cFileSourceFactory FileSourceFactory;
|
||||
#endif
|
||||
|
||||
cAudioManager::~cAudioManager()
|
||||
{
|
||||
if (AudioThread)
|
||||
|
@ -722,60 +705,4 @@ namespace cAudio
|
|||
update();
|
||||
cAudioSleep(1);
|
||||
}
|
||||
|
||||
CAUDIO_API IAudioManager* createAudioManager(bool initializeDefault)
|
||||
{
|
||||
cAudioManager* manager = CAUDIO_NEW cAudioManager;
|
||||
if(manager)
|
||||
{
|
||||
if(initializeDefault)
|
||||
manager->initialize();
|
||||
|
||||
manager->getAvailableDevices();
|
||||
|
||||
#if CAUDIO_COMPILE_WITH_OGG_DECODER == 1
|
||||
manager->registerAudioDecoder(&OggDecoderFactory, "ogg");
|
||||
#endif
|
||||
#if CAUDIO_COMPILE_WITH_WAV_DECODER == 1
|
||||
manager->registerAudioDecoder(&WavDecoderFactory, "wav");
|
||||
#endif
|
||||
|
||||
manager->registerAudioDecoder(&RawDecoderFactory, "raw");
|
||||
|
||||
#if CAUDIO_COMPILE_WITH_FILE_SOURCE == 1
|
||||
manager->registerDataSource(&FileSourceFactory, "FileSystem", 0);
|
||||
#endif
|
||||
|
||||
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
cAudioVector<IAudioPlugin*>::Type plugins = cPluginManager::Instance()->getPluginList();
|
||||
for(unsigned int i = 0; i < plugins.size(); ++i)
|
||||
{
|
||||
plugins[i]->onCreateAudioManager(manager);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
|
||||
CAUDIO_API void destroyAudioManager(IAudioManager* manager)
|
||||
{
|
||||
if(manager)
|
||||
{
|
||||
#ifdef CAUDIO_COMPILE_WITH_PLUGIN_SUPPORT
|
||||
cAudioVector<IAudioPlugin*>::Type plugins = cPluginManager::Instance()->getPluginList();
|
||||
for(unsigned int i = 0; i < plugins.size(); ++i)
|
||||
{
|
||||
plugins[i]->onDestroyAudioManager(manager);
|
||||
}
|
||||
#endif
|
||||
|
||||
manager->unRegisterAllAudioDecoders();
|
||||
manager->unRegisterAllDataSources();
|
||||
manager->unRegisterAllEventHandlers();
|
||||
manager->shutDown();
|
||||
|
||||
CAUDIO_DELETE manager;
|
||||
manager = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue