* When you disable ogg now vorbis/ogg projects are excluded also the Ogg source files are excluded
This commit is contained in:
parent
e637c2eba2
commit
c0d73de948
|
@ -0,0 +1,111 @@
|
|||
mark_as_advanced( CAUDIO_BUILD_EAX_PLUGIN
|
||||
CAUDIO_BUILD_MP3DECODER_PLUGIN
|
||||
CAUDIO_ENABLE_OGG
|
||||
CAUDIO_ENABLE_WAV
|
||||
CAUDIO_ENABLE_DEFAULT_FILESYSTEM
|
||||
CAUDIO_ENABLE_DEFAULT_FILE_LOGGER
|
||||
CAUDIO_ENABLE_DEFAULT_CONSOLE_LOGGER
|
||||
CAUDIO_ENABLE_THREAD_SAFETY
|
||||
CAUDIO_ENABLE_STD_MEMORY_ALLOCATOR
|
||||
CAUDIO_ENABLE_REROUTE_STL_ALLOCATIONS
|
||||
CAUDIO_ENABLE_MEMORYTRACKER
|
||||
CAUDIO_ENABLE_MEMORY_LOG_ALL_ALLOCATIONS
|
||||
CAUDIO_ENABLE_MEMORY_STATISTICS )
|
||||
|
||||
set(CAUDIO_SET_STATIC 0)
|
||||
set(CAUDIO_SET_ENABLE_EFX 0)
|
||||
set(CAUDIO_SET_ENABLE_OGG 1)
|
||||
set(CAUDIO_SET_ENABLE_WAV 1)
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_FILESYSTEM 1)
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_FILE_LOGGER 1)
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_CONSOLE_LOGGER 1)
|
||||
set(CAUDIO_SET_ENABLE_THREAD_SAFETY 1)
|
||||
set(CAUDIO_SET_ENABLE_STD_MEMORY_ALLOCATOR 1)
|
||||
set(CAUDIO_SET_ENABLE_REROUTE_STL_ALLOCATIONS 1)
|
||||
set(CAUDIO_SET_ENABLE_MEMORYTRACKER 0)
|
||||
set(CAUDIO_SET_ENABLE_MEMORY_LOG_ALL_ALLOCATIONS 0)
|
||||
set(CAUDIO_SET_ENABLE_MEMORY_STATISTICS 0)
|
||||
|
||||
if(CAUDIO_STATIC)
|
||||
set(CAUDIO_SET_STATIC 1)
|
||||
else()
|
||||
set(CAUDIO_SET_STATIC 0)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_BUILD_EAX_PLUGIN)
|
||||
set(CAUDIO_SET_ENABLE_EFX 1)
|
||||
else()
|
||||
set(CAUDIO_SET_ENABLE_EFX 0)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_OGG)
|
||||
set(CAUDIO_SET_ENABLE_OGG 1)
|
||||
else()
|
||||
set(CAUDIO_SET_ENABLE_OGG 0)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_WAV)
|
||||
set(CAUDIO_SET_ENABLE_WAV 1)
|
||||
else()
|
||||
set(CAUDIO_SET_ENABLE_WAV 0)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_DEFAULT_FILESYSTEM)
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_FILESYSTEM 1)
|
||||
else()
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_FILESYSTEM 0)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_DEFAULT_FILE_LOGGER)
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_FILE_LOGGER 1)
|
||||
else()
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_FILE_LOGGER 0)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_DEFAULT_CONSOLE_LOGGER)
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_CONSOLE_LOGGER 1)
|
||||
else()
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_CONSOLE_LOGGER 0)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_THREAD_SAFETY)
|
||||
set(CAUDIO_SET_ENABLE_THREAD_SAFETY 1)
|
||||
else()
|
||||
set(CAUDIO_SET_ENABLE_THREAD_SAFETY 0)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_STD_MEMORY_ALLOCATOR)
|
||||
set(CAUDIO_SET_ENABLE_STD_MEMORY_ALLOCATOR 1)
|
||||
else()
|
||||
set(CAUDIO_SET_ENABLE_STD_MEMORY_ALLOCATOR 0)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_REROUTE_STL_ALLOCATIONS)
|
||||
set(CAUDIO_SET_ENABLE_REROUTE_STL_ALLOCATIONS 1)
|
||||
else()
|
||||
set(CAUDIO_SET_ENABLE_REROUTE_STL_ALLOCATIONS 0)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_MEMORYTRACKER)
|
||||
set(CAUDIO_SET_ENABLE_MEMORYTRACKER 1)
|
||||
else()
|
||||
set(CAUDIO_SET_ENABLE_MEMORYTRACKER 0)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_MEMORY_LOG_ALL_ALLOCATIONS)
|
||||
set(CAUDIO_SET_ENABLE_MEMORY_LOG_ALL_ALLOCATIONS 1)
|
||||
else()
|
||||
set(CAUDIO_SET_ENABLE_MEMORY_LOG_ALL_ALLOCATIONS 0)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_MEMORY_STATISTICS)
|
||||
set(CAUDIO_SET_ENABLE_MEMORY_STATISTICS 1)
|
||||
else()
|
||||
set(CAUDIO_SET_ENABLE_MEMORY_STATISTICS 0)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_STATIC)
|
||||
set(CAUDIO_LIB_TYPE STATIC)
|
||||
else()
|
||||
set(CAUDIO_LIB_TYPE SHARED)
|
||||
endif()
|
|
@ -69,90 +69,7 @@ if(APPLE)
|
|||
option(CAUDIO_IOS_BUILD "Build for ios" FALSE)
|
||||
endif()
|
||||
|
||||
mark_as_advanced( CAUDIO_BUILD_EAX_PLUGIN
|
||||
CAUDIO_BUILD_MP3DECODER_PLUGIN
|
||||
CAUDIO_ENABLE_OGG
|
||||
CAUDIO_ENABLE_WAV
|
||||
CAUDIO_ENABLE_DEFAULT_FILESYSTEM
|
||||
CAUDIO_ENABLE_DEFAULT_FILE_LOGGER
|
||||
CAUDIO_ENABLE_DEFAULT_CONSOLE_LOGGER
|
||||
CAUDIO_ENABLE_THREAD_SAFETY
|
||||
CAUDIO_ENABLE_STD_MEMORY_ALLOCATOR
|
||||
CAUDIO_ENABLE_REROUTE_STL_ALLOCATIONS
|
||||
CAUDIO_ENABLE_MEMORYTRACKER
|
||||
CAUDIO_ENABLE_MEMORY_LOG_ALL_ALLOCATIONS
|
||||
CAUDIO_ENABLE_MEMORY_STATISTICS )
|
||||
|
||||
set(CAUDIO_SET_STATIC 0)
|
||||
set(CAUDIO_SET_ENABLE_EFX 0)
|
||||
set(CAUDIO_SET_ENABLE_OGG 1)
|
||||
set(CAUDIO_SET_ENABLE_WAV 1)
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_FILESYSTEM 1)
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_FILE_LOGGER 1)
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_CONSOLE_LOGGER 1)
|
||||
set(CAUDIO_SET_ENABLE_THREAD_SAFETY 1)
|
||||
set(CAUDIO_SET_ENABLE_STD_MEMORY_ALLOCATOR 1)
|
||||
set(CAUDIO_SET_ENABLE_REROUTE_STL_ALLOCATIONS 1)
|
||||
set(CAUDIO_SET_ENABLE_MEMORYTRACKER 0)
|
||||
set(CAUDIO_SET_ENABLE_MEMORY_LOG_ALL_ALLOCATIONS 0)
|
||||
set(CAUDIO_SET_ENABLE_MEMORY_STATISTICS 0)
|
||||
|
||||
if(CAUDIO_STATIC)
|
||||
set(CAUDIO_SET_STATIC 1)
|
||||
endif()
|
||||
if(CAUDIO_BUILD_EAX_PLUGIN)
|
||||
set(CAUDIO_SET_ENABLE_EFX 1)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_OGG)
|
||||
set(CAUDIO_SET_ENABLE_OGG 1)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_WAV)
|
||||
set(CAUDIO_SET_ENABLE_WAV 1)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_DEFAULT_FILESYSTEM)
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_FILESYSTEM 1)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_DEFAULT_FILE_LOGGER)
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_FILE_LOGGER 1)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_DEFAULT_CONSOLE_LOGGER)
|
||||
set(CAUDIO_SET_ENABLE_DEFAULT_CONSOLE_LOGGER 1)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_THREAD_SAFETY)
|
||||
set(CAUDIO_SET_ENABLE_THREAD_SAFETY 1)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_STD_MEMORY_ALLOCATOR)
|
||||
set(CAUDIO_SET_ENABLE_STD_MEMORY_ALLOCATOR 1)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_REROUTE_STL_ALLOCATIONS)
|
||||
set(CAUDIO_SET_ENABLE_REROUTE_STL_ALLOCATIONS 1)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_MEMORYTRACKER)
|
||||
set(CAUDIO_SET_ENABLE_MEMORYTRACKER 1)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_MEMORY_LOG_ALL_ALLOCATIONS)
|
||||
set(CAUDIO_SET_ENABLE_MEMORY_LOG_ALL_ALLOCATIONS 1)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_ENABLE_MEMORY_STATISTICS)
|
||||
set(CAUDIO_SET_ENABLE_MEMORY_STATISTICS 1)
|
||||
endif()
|
||||
|
||||
if(CAUDIO_STATIC)
|
||||
set(CAUDIO_LIB_TYPE STATIC)
|
||||
else()
|
||||
set(CAUDIO_LIB_TYPE SHARED)
|
||||
endif()
|
||||
include(ConfigureBuild)
|
||||
|
||||
if (CAUDIO_IOS_BUILD)
|
||||
# Set build variables
|
||||
|
@ -183,8 +100,10 @@ endif()
|
|||
include(Dependencies)
|
||||
include(InstallDependencies)
|
||||
|
||||
add_subdirectory(DependenciesSource/libogg-1.2.2)
|
||||
add_subdirectory(DependenciesSource/libvorbis-1.3.2)
|
||||
if(CAUDIO_ENABLE_OGG)
|
||||
add_subdirectory(DependenciesSource/libogg-1.2.2)
|
||||
add_subdirectory(DependenciesSource/libvorbis-1.3.2)
|
||||
endif()
|
||||
|
||||
add_subdirectory(cAudio)
|
||||
|
||||
|
|
|
@ -11,12 +11,17 @@ install(FILES ${CMAKE_BINARY_DIR}/include/cAudioBuildSettings.h DESTINATION incl
|
|||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(CAUDIO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include PARENT_SCOPE)
|
||||
|
||||
include_directories (include ${CMAKE_BINARY_DIR}/include ${OPENAL_INCLUDE_DIRS} ${OGG_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR})
|
||||
include(cAudio_src_files.cmake)
|
||||
|
||||
include(cAudio_src_files.cmake)
|
||||
add_library(cAudio ${CAUDIO_LIB_TYPE} ${file_root})
|
||||
target_link_libraries(cAudio Vorbis Ogg ${OPENAL_LIBRARIES})
|
||||
add_dependencies(cAudio Vorbis Ogg)
|
||||
|
||||
if(CAUDIO_ENABLE_OGG)
|
||||
include_directories (include ${CMAKE_BINARY_DIR}/include ${OPENAL_INCLUDE_DIRS} ${OGG_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR})
|
||||
target_link_libraries(cAudio Vorbis Ogg ${OPENAL_LIBRARIES})
|
||||
add_dependencies(cAudio Vorbis Ogg)
|
||||
else()
|
||||
include_directories (include ${CMAKE_BINARY_DIR}/include ${OPENAL_INCLUDE_DIRS})
|
||||
target_link_libraries(cAudio ${OPENAL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if (APPLE AND CAUDIO_IOS_BUILD)
|
||||
set_target_properties(cAudio PROPERTIES XCODE_ATTRIBUTE_GCC_THUMB_SUPPORT "NO")
|
||||
|
|
|
@ -16,8 +16,6 @@ set (file_root_header_files
|
|||
Headers/cMemorySource.h
|
||||
Headers/cMemoryTracker.h
|
||||
Headers/cMutex.h
|
||||
Headers/cOggAudioDecoderFactory.h
|
||||
Headers/cOggDecoder.h
|
||||
Headers/cPluginManager.h
|
||||
Headers/cRawAudioDecoderFactory.h
|
||||
Headers/cRawDecoder.h
|
||||
|
@ -79,8 +77,6 @@ set (file_root_source_files
|
|||
src/cMemorySource.cpp
|
||||
src/cMemoryTracker.cpp
|
||||
src/cMutex.cpp
|
||||
src/cOggAudioDecoderFactory.cpp
|
||||
src/cOggDecoder.cpp
|
||||
src/cPluginManager.cpp
|
||||
src/cRawDecoder.cpp
|
||||
src/cStandardMemoryProvider.cpp
|
||||
|
@ -90,6 +86,20 @@ set (file_root_source_files
|
|||
src/cAudio.cpp
|
||||
)
|
||||
|
||||
if(CAUDIO_ENABLE_OGG)
|
||||
set (file_root_header_files
|
||||
${file_root_header_files}
|
||||
Headers/cOggAudioDecoderFactory.h
|
||||
Headers/cOggDecoder.h
|
||||
)
|
||||
|
||||
set (file_root_source_files
|
||||
${file_root_source_files}
|
||||
src/cOggAudioDecoderFactory.cpp
|
||||
src/cOggDecoder.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
source_group("Header Files" FILES ${file_root_header_files})
|
||||
source_group("Include" FILES ${file_root_include})
|
||||
source_group("Util" FILES ${file_root_util})
|
||||
|
|
|
@ -5,11 +5,22 @@
|
|||
#include "../Include/cAudio.h"
|
||||
#include "../Headers/cAudioManager.h"
|
||||
#include "../Headers/cAudioCapture.h"
|
||||
#include "../Headers/cOggAudioDecoderFactory.h"
|
||||
#include "../Headers/cWavAudioDecoderFactory.h"
|
||||
#include "../Headers/cRawAudioDecoderFactory.h"
|
||||
|
||||
#if CAUDIO_COMPILE_WITH_OGG_DECODER == 1
|
||||
#include "../Headers/cOggAudioDecoderFactory.h"
|
||||
#endif
|
||||
|
||||
#if CAUDIO_COMPILE_WITH_WAV_DECODER == 1
|
||||
#include "../Headers/cWavAudioDecoderFactory.h"
|
||||
#endif
|
||||
|
||||
#include "../Headers/cRawAudioDecoderFactory.h"
|
||||
|
||||
#if CAUDIO_COMPILE_WITH_FILE_SOURCE == 1
|
||||
#include "../Headers/cFileSourceFactory.h"
|
||||
#include "../Headers/cFileSource.h"
|
||||
#endif
|
||||
|
||||
#include "../Headers/cPluginManager.h"
|
||||
#include "../Headers/cLogger.h"
|
||||
#include "../Headers/cConsoleLogReceiver.h"
|
||||
|
@ -22,141 +33,141 @@ namespace cAudio
|
|||
// Audio manager section
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
#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;
|
||||
#if CAUDIO_COMPILE_WITH_OGG_DECODER == 1
|
||||
static cOggAudioDecoderFactory OggDecoderFactory;
|
||||
#endif
|
||||
#if CAUDIO_COMPILE_WITH_WAV_DECODER == 1
|
||||
static cWavAudioDecoderFactory WavDecoderFactory;
|
||||
#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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Audio capture section
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Logger section
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
static cLogger Logger;
|
||||
static bool FirstTimeLogInit(false);
|
||||
|
||||
#if CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER == 1
|
||||
static cConsoleLogReceiver ConsoleLog;
|
||||
#endif
|
||||
|
||||
#if CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER == 1
|
||||
static cFileLogReceiver FileLog;
|
||||
static cLogger Logger;
|
||||
static bool FirstTimeLogInit(false);
|
||||
|
||||
#if CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER == 1
|
||||
static cConsoleLogReceiver ConsoleLog;
|
||||
#endif
|
||||
|
||||
CAUDIO_API ILogger* getLogger()
|
||||
{
|
||||
if(!FirstTimeLogInit)
|
||||
{
|
||||
FirstTimeLogInit = true;
|
||||
#if CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER == 1
|
||||
Logger.registerLogReceiver(&ConsoleLog, "Console");
|
||||
#endif
|
||||
#if CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER == 1
|
||||
Logger.registerLogReceiver(&FileLog,"File");
|
||||
#endif
|
||||
}
|
||||
return &Logger;
|
||||
#if CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER == 1
|
||||
static cFileLogReceiver FileLog;
|
||||
#endif
|
||||
|
||||
CAUDIO_API ILogger* getLogger()
|
||||
{
|
||||
if(!FirstTimeLogInit)
|
||||
{
|
||||
FirstTimeLogInit = true;
|
||||
#if CAUDIO_COMPILE_WITH_CONSOLE_LOG_RECEIVER == 1
|
||||
Logger.registerLogReceiver(&ConsoleLog, "Console");
|
||||
#endif
|
||||
#if CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER == 1
|
||||
Logger.registerLogReceiver(&FileLog,"File");
|
||||
#endif
|
||||
}
|
||||
return &Logger;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,182 +1,180 @@
|
|||
// 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 "../Headers/cOggDecoder.h"
|
||||
|
||||
#if CAUDIO_COMPILE_WITH_OGG_DECODER == 1
|
||||
|
||||
namespace cAudio
|
||||
{
|
||||
//! Read Vorbis Data
|
||||
size_t VorbisRead(void *ptr, size_t byteSize,size_t sizeToRead, void *datasource)
|
||||
{
|
||||
IDataSource* Stream = (IDataSource*)datasource;
|
||||
return Stream->read(ptr,byteSize*sizeToRead);
|
||||
}
|
||||
|
||||
//! Seek Vorbis Data
|
||||
int VorbisSeek(void *datasource,ogg_int64_t offset,int whence)
|
||||
{
|
||||
IDataSource* Stream = (IDataSource*)datasource;
|
||||
switch (whence)
|
||||
{
|
||||
case SEEK_SET:
|
||||
Stream->seek(offset, false);
|
||||
break;
|
||||
|
||||
case SEEK_CUR:
|
||||
Stream->seek(offset, true);
|
||||
break;
|
||||
|
||||
case SEEK_END:
|
||||
Stream->seek(Stream->getSize()-offset, false);
|
||||
break;
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! Returns the vorbis data that was stored.
|
||||
long VorbisTell(void *datasource)
|
||||
{
|
||||
return ((IDataSource*)datasource)->getCurrentPos();
|
||||
}
|
||||
|
||||
int VorbisCloseFunc(void *datasource)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
cOggDecoder::cOggDecoder(IDataSource* stream) : IAudioDecoder(stream)
|
||||
{
|
||||
vorbisCallbacks.read_func = VorbisRead;
|
||||
vorbisCallbacks.close_func = VorbisCloseFunc;
|
||||
vorbisCallbacks.seek_func = VorbisSeek;
|
||||
vorbisCallbacks.tell_func = VorbisTell;
|
||||
Valid = (ov_open_callbacks(Stream,&oggStream,NULL,0,vorbisCallbacks) == 0);
|
||||
|
||||
if(Valid)
|
||||
{
|
||||
vorbisInfo = ov_info(&oggStream, -1);
|
||||
vorbisComment = ov_comment(&oggStream,-1);
|
||||
}
|
||||
}
|
||||
|
||||
cOggDecoder::~cOggDecoder()
|
||||
{
|
||||
ov_clear(&oggStream);
|
||||
}
|
||||
|
||||
AudioFormats cOggDecoder::getFormat()
|
||||
{
|
||||
if(Valid)
|
||||
{
|
||||
if(vorbisInfo->channels == 1)
|
||||
{
|
||||
return EAF_16BIT_MONO;
|
||||
}
|
||||
else
|
||||
{
|
||||
return EAF_16BIT_STEREO;
|
||||
}
|
||||
}
|
||||
return EAF_8BIT_MONO;
|
||||
}
|
||||
|
||||
int cOggDecoder::getFrequency()
|
||||
{
|
||||
if(Valid)
|
||||
{
|
||||
return vorbisInfo->rate;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool cOggDecoder::isSeekingSupported()
|
||||
{
|
||||
if(Valid)
|
||||
{
|
||||
return (ov_seekable(&oggStream)!=0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cOggDecoder::isValid()
|
||||
{
|
||||
return Valid;
|
||||
}
|
||||
|
||||
int cOggDecoder::readAudioData(void* output, int amount)
|
||||
{
|
||||
if(Valid)
|
||||
{
|
||||
int temp = 0;
|
||||
int result = ov_read(&oggStream,(char*)output,amount,0,2,1,&temp);
|
||||
//return (result < 0) ? 0 : result;
|
||||
return result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool cOggDecoder::setPosition(int position, bool relative)
|
||||
{
|
||||
if(Valid)
|
||||
{
|
||||
if(ov_seekable(&oggStream))
|
||||
{
|
||||
return (ov_raw_seek(&oggStream,position)==0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cOggDecoder::seek(float seconds, bool relative)
|
||||
{
|
||||
if(Valid)
|
||||
{
|
||||
if(ov_seekable(&oggStream))
|
||||
{
|
||||
if(relative)
|
||||
{
|
||||
float curtime = ov_time_tell(&oggStream);
|
||||
return (ov_time_seek(&oggStream,curtime+seconds)==0);
|
||||
}
|
||||
else
|
||||
return (ov_time_seek(&oggStream,seconds)==0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
float cOggDecoder::getTotalTime()
|
||||
{
|
||||
return ov_time_total(&oggStream, -1);
|
||||
}
|
||||
|
||||
int cOggDecoder::getTotalSize()
|
||||
{
|
||||
return ov_pcm_total(&oggStream, -1) * vorbisInfo->channels;
|
||||
}
|
||||
|
||||
int cOggDecoder::getCompressedSize()
|
||||
{
|
||||
return ov_raw_total(&oggStream, -1);
|
||||
}
|
||||
|
||||
float cOggDecoder::getCurrentTime()
|
||||
{
|
||||
return ov_time_tell(&oggStream);
|
||||
}
|
||||
|
||||
int cOggDecoder::getCurrentPosition()
|
||||
{
|
||||
return ov_pcm_tell(&oggStream) * vorbisInfo->channels;
|
||||
}
|
||||
|
||||
int cOggDecoder::getCurrentCompressedPosition()
|
||||
{
|
||||
return ov_raw_tell(&oggStream);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
// For conditions of distribution and use, see copyright notice in cAudio.h
|
||||
|
||||
#include "../Headers/cOggDecoder.h"
|
||||
|
||||
#if CAUDIO_COMPILE_WITH_OGG_DECODER == 1
|
||||
|
||||
namespace cAudio
|
||||
{
|
||||
//! Read Vorbis Data
|
||||
size_t VorbisRead(void *ptr, size_t byteSize,size_t sizeToRead, void *datasource)
|
||||
{
|
||||
IDataSource* Stream = (IDataSource*)datasource;
|
||||
return Stream->read(ptr,byteSize*sizeToRead);
|
||||
}
|
||||
|
||||
//! Seek Vorbis Data
|
||||
int VorbisSeek(void *datasource,ogg_int64_t offset,int whence)
|
||||
{
|
||||
IDataSource* Stream = (IDataSource*)datasource;
|
||||
switch (whence)
|
||||
{
|
||||
case SEEK_SET:
|
||||
Stream->seek(offset, false);
|
||||
break;
|
||||
|
||||
case SEEK_CUR:
|
||||
Stream->seek(offset, true);
|
||||
break;
|
||||
|
||||
case SEEK_END:
|
||||
Stream->seek(Stream->getSize()-offset, false);
|
||||
break;
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! Returns the vorbis data that was stored.
|
||||
long VorbisTell(void *datasource)
|
||||
{
|
||||
return ((IDataSource*)datasource)->getCurrentPos();
|
||||
}
|
||||
|
||||
int VorbisCloseFunc(void *datasource)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
cOggDecoder::cOggDecoder(IDataSource* stream) : IAudioDecoder(stream)
|
||||
{
|
||||
vorbisCallbacks.read_func = VorbisRead;
|
||||
vorbisCallbacks.close_func = VorbisCloseFunc;
|
||||
vorbisCallbacks.seek_func = VorbisSeek;
|
||||
vorbisCallbacks.tell_func = VorbisTell;
|
||||
Valid = (ov_open_callbacks(Stream,&oggStream,NULL,0,vorbisCallbacks) == 0);
|
||||
|
||||
if(Valid)
|
||||
{
|
||||
vorbisInfo = ov_info(&oggStream, -1);
|
||||
vorbisComment = ov_comment(&oggStream,-1);
|
||||
}
|
||||
}
|
||||
|
||||
cOggDecoder::~cOggDecoder()
|
||||
{
|
||||
ov_clear(&oggStream);
|
||||
}
|
||||
|
||||
AudioFormats cOggDecoder::getFormat()
|
||||
{
|
||||
if(Valid)
|
||||
{
|
||||
if(vorbisInfo->channels == 1)
|
||||
{
|
||||
return EAF_16BIT_MONO;
|
||||
}
|
||||
else
|
||||
{
|
||||
return EAF_16BIT_STEREO;
|
||||
}
|
||||
}
|
||||
return EAF_8BIT_MONO;
|
||||
}
|
||||
|
||||
int cOggDecoder::getFrequency()
|
||||
{
|
||||
if(Valid)
|
||||
{
|
||||
return vorbisInfo->rate;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool cOggDecoder::isSeekingSupported()
|
||||
{
|
||||
if(Valid)
|
||||
{
|
||||
return (ov_seekable(&oggStream)!=0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cOggDecoder::isValid()
|
||||
{
|
||||
return Valid;
|
||||
}
|
||||
|
||||
int cOggDecoder::readAudioData(void* output, int amount)
|
||||
{
|
||||
if(Valid)
|
||||
{
|
||||
int temp = 0;
|
||||
return ov_read(&oggStream,(char*)output,amount,0,2,1,&temp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool cOggDecoder::setPosition(int position, bool relative)
|
||||
{
|
||||
if(Valid)
|
||||
{
|
||||
if(ov_seekable(&oggStream))
|
||||
{
|
||||
return (ov_raw_seek(&oggStream,position)==0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cOggDecoder::seek(float seconds, bool relative)
|
||||
{
|
||||
if(Valid)
|
||||
{
|
||||
if(ov_seekable(&oggStream))
|
||||
{
|
||||
if(relative)
|
||||
{
|
||||
float curtime = ov_time_tell(&oggStream);
|
||||
return (ov_time_seek(&oggStream,curtime+seconds)==0);
|
||||
}
|
||||
else
|
||||
return (ov_time_seek(&oggStream,seconds)==0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
float cOggDecoder::getTotalTime()
|
||||
{
|
||||
return ov_time_total(&oggStream, -1);
|
||||
}
|
||||
|
||||
int cOggDecoder::getTotalSize()
|
||||
{
|
||||
return ov_pcm_total(&oggStream, -1) * vorbisInfo->channels;
|
||||
}
|
||||
|
||||
int cOggDecoder::getCompressedSize()
|
||||
{
|
||||
return ov_raw_total(&oggStream, -1);
|
||||
}
|
||||
|
||||
float cOggDecoder::getCurrentTime()
|
||||
{
|
||||
return ov_time_tell(&oggStream);
|
||||
}
|
||||
|
||||
int cOggDecoder::getCurrentPosition()
|
||||
{
|
||||
return ov_pcm_tell(&oggStream) * vorbisInfo->channels;
|
||||
}
|
||||
|
||||
int cOggDecoder::getCurrentCompressedPosition()
|
||||
{
|
||||
return ov_raw_tell(&oggStream);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue