Commit: 96dd213e7ecabeffc682aee40b4102296ab062de
Author: Jörg Müller
Date:   Mon Mar 3 23:57:59 2014 +0100
Branches: master
https://developer.blender.org/rB96dd213e7ecabeffc682aee40b4102296ab062de

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.

===================================================================

M       intern/audaspace/intern/AUD_C-API.cpp
M       intern/audaspace/intern/AUD_C-API.h
M       source/blender/blenkernel/intern/sound.c
M       source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
M       source/gameengine/Converter/KX_ConvertActuators.cpp
M       source/gameengine/GamePlayer/ghost/GPG_Application.cpp
M       source/gameengine/Ketsji/KX_KetsjiEngine.cpp
M       source/gameengine/Ketsji/KX_SoundActuator.cpp
M       source/gameengine/Ketsji/KX_SoundActuator.h

===================================================================

diff --git a/intern/audaspace/intern/AUD_C-API.cpp 
b/intern/audaspace/intern/AUD_C-API.cpp
index 78b9279..2ee141a 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 657d4e6..5e7db1d 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__
diff --git a/source/blender/blenkernel/intern/sound.c 
b/source/blender/blenkernel/intern/sound.c
index 46a5091..3accf21 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -176,6 +176,7 @@ void BKE_sound_init(struct Main *bmain)
 {
        AUD_DeviceSpecs specs;
        int device, buffersize;
+       const char* device_name;
 
        device = U.audiodevice;
        buffersize = U.mixbufsize;
@@ -186,6 +187,22 @@ void BKE_sound_init(struct Main *bmain)
        if (force_device >= 0)
                device = force_device;
 
+       switch(device)
+       {
+       case AUD_SDL_DEVICE:
+               device_name = "SDL";
+               break;
+       case AUD_OPENAL_DEVICE:
+               device_name = "OpenAL";
+               break;
+       case AUD_JACK_DEVICE:
+               device_name = "Jack";
+               break;
+       default:
+               device_name = "Null";
+               break;
+       }
+
        if (buffersize < 128)
                buffersize = AUD_DEFAULT_BUFFER_SIZE;
 
@@ -198,8 +215,8 @@ void BKE_sound_init(struct Main *bmain)
        if (specs.channels <= AUD_CHANNELS_INVALID)
                specs.channels = AUD_CHANNELS_STEREO;
 
-       if (!AUD_init(device, specs, buffersize))
-               AUD_init(AUD_NULL_DEVICE, specs, buffersize);
+       if (!AUD_init(device_name, "Blender", specs, buffersize))
+               AUD_init("Null", "Blender", specs, buffersize);
 
        BKE_sound_init_main(bmain);
 }
@@ -207,7 +224,7 @@ void BKE_sound_init(struct Main *bmain)
 void BKE_sound_init_main(struct Main *bmain)
 {
 #ifdef WITH_JACK
-       AUD_setSyncCallback(sound_sync_callback, bmain);
+       AUD_setSynchronizerCallback(sound_sync_callback, bmain);
 #else
        (void)bmain; /* unused */
 #endif
@@ -557,7 +574,7 @@ void BKE_sound_play_scene(struct Scene *scene)
        }
 
        if (scene->audio.flag & AUDIO_SYNC)
-               AUD_startPlayback();
+               AUD_playSynchronizer();
 
        AUD_unlock();
 }
@@ -568,7 +585,7 @@ void BKE_sound_stop_scene(struct Scene *scene)
                AUD_pause(scene->playback_handle);
 
                if (scene->audio.flag & AUDIO_SYNC)
-                       AUD_stopPlayback();
+                       AUD_stopSynchronizer();
        }
 }
 
@@ -607,7 +624,7 @@ void BKE_sound_seek_scene(struct Main *bmain, struct Scene 
*scene)
        if (scene->audio.flag & AUDIO_SCRUB && !animation_pl

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to