diff options
author | Jörg Müller <nexyon@gmail.com> | 2014-03-04 02:57:59 +0400 |
---|---|---|
committer | Jörg Müller <nexyon@gmail.com> | 2015-07-28 15:01:52 +0300 |
commit | 96dd213e7ecabeffc682aee40b4102296ab062de (patch) | |
tree | ab07e2786bcd81b137c40f8ce2084ccec62075e6 /intern/audaspace | |
parent | d3acfa1d87ccc7932b61311b7084951dcce67eba (diff) |
Audaspace: preparing to use standalone library.
- Renamed some functions.
- Using C API instead of C++ in the game engine, as the standalone is C++11.
Diffstat (limited to 'intern/audaspace')
-rw-r--r-- | intern/audaspace/intern/AUD_C-API.cpp | 74 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_C-API.h | 36 |
2 files changed, 45 insertions, 65 deletions
diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp index 78b9279a54a..2ee141a7e8f 100644 --- a/intern/audaspace/intern/AUD_C-API.cpp +++ b/intern/audaspace/intern/AUD_C-API.cpp @@ -130,7 +130,7 @@ void AUD_exitOnce() #endif } -int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize) +int AUD_init(const char* device, const char* name, AUD_DeviceSpecs specs, int buffersize) { boost::shared_ptr<AUD_IDevice> dev; @@ -138,47 +138,46 @@ int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize) AUD_exit(); } + std::string dname = device; + try { - switch(device) { - case AUD_NULL_DEVICE: + if(dname == "Null") { dev = boost::shared_ptr<AUD_IDevice>(new AUD_NULLDevice()); - break; + } #ifdef WITH_SDL - case AUD_SDL_DEVICE: - if (SDL_Init == (void *)0) { - printf("Warning: SDL libraries are not installed\n"); - // No break, fall through to default, to return false - } - else { - dev = boost::shared_ptr<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize)); - break; - } + else if(dname == "SDL") + { + dev = boost::shared_ptr<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize)); + } #endif #ifdef WITH_OPENAL - case AUD_OPENAL_DEVICE: + else if(dname == "OpenAL") + { dev = boost::shared_ptr<AUD_IDevice>(new AUD_OpenALDevice(specs, buffersize)); - break; + } #endif #ifdef WITH_JACK - case AUD_JACK_DEVICE: + else if(dname == "Jack") + { #ifdef __APPLE__ struct stat st; if (stat("/Library/Frameworks/Jackmp.framework", &st) != 0) { printf("Warning: Jack Framework not installed\n"); - // No break, fall through to default, to return false + return false; } else #endif if (!AUD_jack_supported()) { - printf("Warning: Jack client not installed\n"); - // No break, fall through to default, to return false + printf("Warning: Jack cllient not installed\n"); + return false; } else { - dev = boost::shared_ptr<AUD_IDevice>(new AUD_JackDevice("Blender", specs, buffersize)); - break; + dev = boost::shared_ptr<AUD_IDevice>(new AUD_JackDevice(name, specs, buffersize)); } + } #endif - default: + else + { return false; } @@ -266,7 +265,7 @@ PyObject *AUD_initPython() return module; } -void *AUD_getPythonFactory(AUD_Sound *sound) +void *AUD_getPythonSound(AUD_Sound *sound) { if (sound) { Factory *obj = (Factory *) Factory_empty(); @@ -279,7 +278,7 @@ void *AUD_getPythonFactory(AUD_Sound *sound) return NULL; } -AUD_Sound *AUD_getPythonSound(void *sound) +AUD_Sound *AUD_getSoundFromPython(void *sound) { Factory *factory = checkFactory((PyObject *)sound); @@ -488,6 +487,11 @@ int AUD_stop(AUD_Handle *handle) return result; } +void AUD_stopAll(void) +{ + AUD_device->stopAll(); +} + int AUD_setKeep(AUD_Handle *handle, int keep) { assert(handle); @@ -1015,7 +1019,7 @@ void AUD_setSequencerSpecs(AUD_Sound *sequencer, AUD_Specs specs) dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setSpecs(specs); } -void AUD_seekSequencer(AUD_Handle *handle, float time) +void AUD_seekSynchronizer(AUD_Handle *handle, float time) { #ifdef WITH_JACK AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get()); @@ -1030,7 +1034,7 @@ void AUD_seekSequencer(AUD_Handle *handle, float time) } } -float AUD_getSequencerPosition(AUD_Handle *handle) +float AUD_getSynchronizerPosition(AUD_Handle *handle) { #ifdef WITH_JACK AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get()); @@ -1045,7 +1049,7 @@ float AUD_getSequencerPosition(AUD_Handle *handle) } } -void AUD_startPlayback() +void AUD_playSynchronizer() { #ifdef WITH_JACK AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get()); @@ -1055,7 +1059,7 @@ void AUD_startPlayback() #endif } -void AUD_stopPlayback() +void AUD_stopSynchronizer() { #ifdef WITH_JACK AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get()); @@ -1066,7 +1070,7 @@ void AUD_stopPlayback() } #ifdef WITH_JACK -void AUD_setSyncCallback(AUD_syncFunction function, void *data) +void AUD_setSynchronizerCallback(AUD_syncFunction function, void *data) { AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get()); if (device) { @@ -1075,7 +1079,7 @@ void AUD_setSyncCallback(AUD_syncFunction function, void *data) } #endif -int AUD_doesPlayback() +int AUD_isSynchronizerPlaying() { #ifdef WITH_JACK AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get()); @@ -1283,16 +1287,6 @@ AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *sequencer, f } } -boost::shared_ptr<AUD_IDevice> AUD_getDevice() -{ - return AUD_device; -} - -AUD_I3DDevice *AUD_get3DDevice() -{ - return AUD_3ddevice; -} - int AUD_isJackSupported(void) { #ifdef WITH_JACK diff --git a/intern/audaspace/intern/AUD_C-API.h b/intern/audaspace/intern/AUD_C-API.h index 657d4e6fd02..5e7db1dbe5e 100644 --- a/intern/audaspace/intern/AUD_C-API.h +++ b/intern/audaspace/intern/AUD_C-API.h @@ -77,7 +77,7 @@ extern void AUD_exitOnce(void); * \param buffersize The buffersize for the device. * \return Whether the device has been initialized. */ -extern int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize); +extern int AUD_init(const char* device, const char* name, AUD_DeviceSpecs specs, int buffersize); /** * Unitinitializes an audio device. @@ -212,6 +212,8 @@ extern int AUD_resume(AUD_Handle *handle); */ extern int AUD_stop(AUD_Handle *handle); +extern void AUD_stopAll(void); + /** * Sets the end behaviour of a playing or paused sound. * \param handle The handle to the sound. @@ -604,24 +606,24 @@ extern void AUD_setSequencerSpecs(AUD_Sound *sequencer, AUD_Specs specs); * \param handle Playback handle. * \param time Time in seconds to seek to. */ -extern void AUD_seekSequencer(AUD_Handle *handle, float time); +extern void AUD_seekSynchronizer(AUD_Handle *handle, float time); /** * Returns the current sound scene playback time. * \param handle Playback handle. * \return The playback time in seconds. */ -extern float AUD_getSequencerPosition(AUD_Handle *handle); +extern float AUD_getSynchronizerPosition(AUD_Handle *handle); /** * Starts the playback of jack transport if possible. */ -extern void AUD_startPlayback(void); +extern void AUD_playSynchronizer(void); /** * Stops the playback of jack transport if possible. */ -extern void AUD_stopPlayback(void); +extern void AUD_stopSynchronizer(void); #ifdef WITH_JACK /** @@ -629,14 +631,14 @@ extern void AUD_stopPlayback(void); * \param function The callback function. * \param data The data parameter for the callback. */ -extern void AUD_setSyncCallback(AUD_syncFunction function, void *data); +extern void AUD_setSynchronizerCallback(AUD_syncFunction function, void *data); #endif /** * Returns whether jack transport is currently playing. * \return Whether jack transport is currently playing. */ -extern int AUD_doesPlayback(void); +extern int AUD_isSynchronizerPlaying(void); /** * Reads a sound into a buffer for drawing at a specific sampling rate. @@ -747,36 +749,20 @@ extern AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *seque * \param sound The sound factory. * \return The python factory. */ -extern void *AUD_getPythonFactory(AUD_Sound *sound); +extern void *AUD_getPythonSound(AUD_Sound *sound); /** * Retrieves the sound factory of a python factory. * \param sound The python factory. * \return The sound factory. */ -extern AUD_Sound *AUD_getPythonSound(void *sound); +extern AUD_Sound *AUD_getSoundFromPython(void *sound); #endif extern int AUD_isJackSupported(void); #ifdef __cplusplus } - -#include <boost/shared_ptr.hpp> -class AUD_IDevice; -class AUD_I3DDevice; - -/** - * Returns the current playback device. - * \return The playback device. - */ -boost::shared_ptr<AUD_IDevice> AUD_getDevice(); - -/** - * Returns the current playback 3D device. - * \return The playback 3D device. - */ -AUD_I3DDevice *AUD_get3DDevice(); #endif #endif //__AUD_C_API_H__ |