[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22518] branches/blender2.5/blender: Added jack audio support, building with cmake only currently, feel free to add scons and maybe cmake.
Joerg Mueller
nexyon at gmail.com
Sun Aug 16 16:53:11 CEST 2009
Revision: 22518
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22518
Author: nexyon
Date: 2009-08-16 16:53:11 +0200 (Sun, 16 Aug 2009)
Log Message:
-----------
Added jack audio support, building with cmake only currently, feel free to add scons and maybe cmake.
Modified Paths:
--------------
branches/blender2.5/blender/CMake/macros.cmake
branches/blender2.5/blender/CMakeLists.txt
branches/blender2.5/blender/intern/audaspace/CMakeLists.txt
branches/blender2.5/blender/intern/audaspace/SDL/AUD_SDLDevice.cpp
branches/blender2.5/blender/intern/audaspace/SDL/AUD_SDLDevice.h
branches/blender2.5/blender/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
branches/blender2.5/blender/intern/audaspace/intern/AUD_C-API.cpp
branches/blender2.5/blender/intern/audaspace/intern/AUD_C-API.h
branches/blender2.5/blender/intern/audaspace/intern/AUD_Space.h
branches/blender2.5/blender/source/blender/makesrna/intern/rna_userdef.c
Added Paths:
-----------
branches/blender2.5/blender/intern/audaspace/jack/
branches/blender2.5/blender/intern/audaspace/jack/AUD_JackDevice.cpp
branches/blender2.5/blender/intern/audaspace/jack/AUD_JackDevice.h
Modified: branches/blender2.5/blender/CMake/macros.cmake
===================================================================
--- branches/blender2.5/blender/CMake/macros.cmake 2009-08-16 14:52:05 UTC (rev 22517)
+++ branches/blender2.5/blender/CMake/macros.cmake 2009-08-16 14:53:11 UTC (rev 22518)
@@ -54,6 +54,9 @@
IF(WITH_OPENAL)
LINK_DIRECTORIES(${OPENAL_LIBPATH})
ENDIF(WITH_OPENAL)
+ IF(WITH_JACK)
+ LINK_DIRECTORIES(${JACK_LIBPATH})
+ ENDIF(WITH_JACK)
IF(WITH_FFTW3)
LINK_DIRECTORIES(${FFTW3_LIBPATH})
ENDIF(WITH_FFTW3)
@@ -108,6 +111,9 @@
IF(WITH_OPENAL)
TARGET_LINK_LIBRARIES(${target} ${OPENAL_LIBRARY})
ENDIF(WITH_OPENAL)
+ IF(WITH_JACK)
+ TARGET_LINK_LIBRARIES(${target} ${JACK_LIB})
+ ENDIF(WITH_JACK)
IF(WITH_SDL)
TARGET_LINK_LIBRARIES(${target} ${SDL_LIBRARY})
ENDIF(WITH_SDL)
Modified: branches/blender2.5/blender/CMakeLists.txt
===================================================================
--- branches/blender2.5/blender/CMakeLists.txt 2009-08-16 14:52:05 UTC (rev 22517)
+++ branches/blender2.5/blender/CMakeLists.txt 2009-08-16 14:53:11 UTC (rev 22518)
@@ -69,6 +69,7 @@
OPTION(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" OFF)
OPTION(WITH_WEBPLUGIN "Enable Web Plugin (Unix only)" OFF)
OPTION(WITH_FFTW3 "Enable FFTW3 support" OFF)
+OPTION(WITH_JACK "Enable Jack Support (http://www.jackaudio.org)" OFF)
OPTION(WITH_INSTALL "Install accompanying scripts and language files needed to run blender" ON)
IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
@@ -100,6 +101,13 @@
ENDIF(OPENAL_FOUND)
ENDIF(WITH_OPENAL)
+ IF(WITH_JACK)
+ SET(JACK /usr)
+ SET(JACK_INC ${JACK}/include/jack)
+ SET(JACK_LIB jack)
+ SET(JACK_LIBPATH ${JACK}/lib)
+ ENDIF(WITH_JACK)
+
FIND_LIBRARY(INTL_LIBRARY
NAMES intl
PATHS
@@ -230,6 +238,13 @@
SET(OPENAL_LIBPATH ${OPENAL}/lib)
ENDIF(CMAKE_CL_64)
+ IF(WITH_JACK)
+ SET(JACK ${LIBDIR}/jack)
+ SET(JACK_INC ${JACK}/include/jack)
+ SET(JACK_LIB jack)
+ SET(JACK_LIBPATH ${JACK}/lib)
+ ENDIF(WITH_JACK)
+
IF(CMAKE_CL_64)
SET(PNG_LIBRARIES libpng)
ELSE(CMAKE_CL_64)
@@ -363,6 +378,12 @@
ENDIF(OPENAL_FOUND)
ENDIF(WITH_OPENAL)
+ IF(WITH_JACK)
+ SET(JACK /usr)
+ SET(JACK_INC ${JACK}/include/jack)
+ SET(JACK_LIB jack)
+ SET(JACK_LIBPATH ${JACK}/lib)
+ ENDIF(WITH_JACK)
SET(PYTHON_VERSION 3.1)
Modified: branches/blender2.5/blender/intern/audaspace/CMakeLists.txt
===================================================================
--- branches/blender2.5/blender/intern/audaspace/CMakeLists.txt 2009-08-16 14:52:05 UTC (rev 22517)
+++ branches/blender2.5/blender/intern/audaspace/CMakeLists.txt 2009-08-16 14:53:11 UTC (rev 22518)
@@ -47,6 +47,12 @@
ENDIF(FRAMEWORK)
ENDIF(WITH_OPENAL)
-SET(SRC ${SRC} ${FFMPEGSRC} ${SDLSRC} ${OPENALSRC})
+IF(WITH_JACK)
+ SET(INC ${INC} jack ${JACK_INC})
+ FILE(GLOB JACKSRC jack/*.cpp)
+ ADD_DEFINITIONS(-DWITH_JACK)
+ENDIF(WITH_JACK)
+SET(SRC ${SRC} ${FFMPEGSRC} ${SDLSRC} ${OPENALSRC} ${JACKSRC})
+
BLENDERLIB(bf_audaspace "${SRC}" "${INC}")
Modified: branches/blender2.5/blender/intern/audaspace/SDL/AUD_SDLDevice.cpp
===================================================================
--- branches/blender2.5/blender/intern/audaspace/SDL/AUD_SDLDevice.cpp 2009-08-16 14:52:05 UTC (rev 22517)
+++ branches/blender2.5/blender/intern/audaspace/SDL/AUD_SDLDevice.cpp 2009-08-16 14:53:11 UTC (rev 22518)
@@ -27,13 +27,11 @@
#include "AUD_SDLDevice.h"
#include "AUD_IReader.h"
-#include <SDL.h>
-
-// this is the callback function for SDL, it only calls the class
-void mixAudio(void *data, Uint8* buffer, int length)
+void AUD_SDLDevice::SDL_mix(void *data, Uint8* buffer, int length)
{
AUD_SDLDevice* device = (AUD_SDLDevice*)data;
- device->SDLmix((sample_t *)buffer, length);
+
+ device->mix((sample_t*)buffer, length/AUD_SAMPLE_SIZE(device->m_specs));
}
AUD_SDLDevice::AUD_SDLDevice(AUD_Specs specs, int buffersize)
@@ -56,7 +54,7 @@
format.format = AUDIO_S16SYS;
format.channels = m_specs.channels;
format.samples = buffersize;
- format.callback = &mixAudio;
+ format.callback = AUD_SDLDevice::SDL_mix;
format.userdata = this;
if(SDL_OpenAudio(&format, &obtained) != 0)
@@ -86,11 +84,6 @@
destroy();
}
-void AUD_SDLDevice::SDLmix(sample_t* buffer, int length)
-{
- mix(buffer, length/AUD_SAMPLE_SIZE(m_specs));
-}
-
void AUD_SDLDevice::playing(bool playing)
{
SDL_PauseAudio(playing ? 0 : 1);
Modified: branches/blender2.5/blender/intern/audaspace/SDL/AUD_SDLDevice.h
===================================================================
--- branches/blender2.5/blender/intern/audaspace/SDL/AUD_SDLDevice.h 2009-08-16 14:52:05 UTC (rev 22517)
+++ branches/blender2.5/blender/intern/audaspace/SDL/AUD_SDLDevice.h 2009-08-16 14:53:11 UTC (rev 22518)
@@ -28,11 +28,22 @@
#include "AUD_SoftwareDevice.h"
+#include <SDL.h>
+
/**
* This device plays back through SDL, the simple direct media layer.
*/
class AUD_SDLDevice : public AUD_SoftwareDevice
{
+private:
+ /**
+ * Mixes the next bytes into the buffer.
+ * \param data The SDL device.
+ * \param buffer The target buffer.
+ * \param length The length in bytes to be filled.
+ */
+ static void SDL_mix(void *data, Uint8* buffer, int length);
+
protected:
virtual void playing(bool playing);
@@ -50,14 +61,6 @@
* Closes the SDL audio device.
*/
virtual ~AUD_SDLDevice();
-
- /**
- * Mixes the next bytes into the buffer.
- * \param buffer The target buffer.
- * \param length The length in bytes to be filled.
- * \warning This function shall not be called from outside!
- */
- void SDLmix(sample_t* buffer, int length);
};
#endif //AUD_SDLDEVICE
Modified: branches/blender2.5/blender/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
===================================================================
--- branches/blender2.5/blender/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp 2009-08-16 14:52:05 UTC (rev 22517)
+++ branches/blender2.5/blender/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp 2009-08-16 14:53:11 UTC (rev 22518)
@@ -34,7 +34,7 @@
#include <libavformat/avformat.h>
}
-// This function transforms a FFMPEG SampleFormat to or own sample format
+// This function transforms a FFMPEG SampleFormat to our own sample format
static inline AUD_SampleFormat FFMPEG_TO_AUD(SampleFormat fmt)
{
switch(fmt)
Modified: branches/blender2.5/blender/intern/audaspace/intern/AUD_C-API.cpp
===================================================================
--- branches/blender2.5/blender/intern/audaspace/intern/AUD_C-API.cpp 2009-08-16 14:52:05 UTC (rev 22517)
+++ branches/blender2.5/blender/intern/audaspace/intern/AUD_C-API.cpp 2009-08-16 14:53:11 UTC (rev 22518)
@@ -23,10 +23,6 @@
* ***** END LGPL LICENSE BLOCK *****
*/
-/*#define WITH_SDL
-#define WITH_FFMPEG
-#define WITH_OPENAL*/
-
#include "AUD_NULLDevice.h"
#include "AUD_I3DDevice.h"
#include "AUD_StreamBufferFactory.h"
@@ -47,6 +43,10 @@
#include "AUD_OpenALDevice.h"
#endif
+#ifdef WITH_JACK
+#include "AUD_JackDevice.h"
+#endif
+
#ifdef WITH_FFMPEG
#include "AUD_FFMPEGFactory.h"
extern "C" {
@@ -98,6 +98,11 @@
dev = new AUD_OpenALDevice(specs, buffersize);
break;
#endif
+#ifdef WITH_JACK
+ case AUD_JACK_DEVICE:
+ dev = new AUD_JackDevice(specs);
+ break;
+#endif
default:
return false;
}
@@ -126,6 +131,9 @@
#ifdef WITH_OPENAL
AUD_available_devices[i++] = AUD_OPENAL_DEVICE;
#endif
+#ifdef WITH_JACK
+ AUD_available_devices[i++] = AUD_JACK_DEVICE;
+#endif
AUD_available_devices[i++] = AUD_NULL_DEVICE;
return AUD_available_devices;
}
Modified: branches/blender2.5/blender/intern/audaspace/intern/AUD_C-API.h
===================================================================
--- branches/blender2.5/blender/intern/audaspace/intern/AUD_C-API.h 2009-08-16 14:52:05 UTC (rev 22517)
+++ branches/blender2.5/blender/intern/audaspace/intern/AUD_C-API.h 2009-08-16 14:53:11 UTC (rev 22518)
@@ -36,7 +36,8 @@
{
AUD_NULL_DEVICE = 0,
AUD_SDL_DEVICE,
- AUD_OPENAL_DEVICE
+ AUD_OPENAL_DEVICE,
+ AUD_JACK_DEVICE
} AUD_DeviceType;
typedef struct
Modified: branches/blender2.5/blender/intern/audaspace/intern/AUD_Space.h
===================================================================
--- branches/blender2.5/blender/intern/audaspace/intern/AUD_Space.h 2009-08-16 14:52:05 UTC (rev 22517)
+++ branches/blender2.5/blender/intern/audaspace/intern/AUD_Space.h 2009-08-16 14:53:11 UTC (rev 22518)
@@ -180,7 +180,8 @@
AUD_ERROR_FILE,
AUD_ERROR_FFMPEG,
AUD_ERROR_SDL,
- AUD_ERROR_OPENAL
+ AUD_ERROR_OPENAL,
+ AUD_ERROR_JACK
} AUD_Error;
/// Message codes.
Added: branches/blender2.5/blender/intern/audaspace/jack/AUD_JackDevice.cpp
===================================================================
--- branches/blender2.5/blender/intern/audaspace/jack/AUD_JackDevice.cpp (rev 0)
+++ branches/blender2.5/blender/intern/audaspace/jack/AUD_JackDevice.cpp 2009-08-16 14:53:11 UTC (rev 22518)
@@ -0,0 +1,149 @@
+/*
+ * $Id: AUD_SDLDevice.cpp 22328 2009-08-09 23:23:19Z gsrb3d $
+ *
+ * ***** BEGIN LGPL LICENSE BLOCK *****
+ *
+ * Copyright 2009 Jörg Hermann Müller
+ *
+ * This file is part of AudaSpace.
+ *
+ * AudaSpace is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * AudaSpace is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * ***** END LGPL LICENSE BLOCK *****
+ */
+
+#include "AUD_FloatMixer.h"
+#include "AUD_JackDevice.h"
+#include "AUD_IReader.h"
+#include "AUD_Buffer.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+// AUD_XXX this is not realtime suitable!
+int AUD_JackDevice::jack_mix(jack_nframes_t length, void *data)
+{
+ AUD_JackDevice* device = (AUD_JackDevice*)data;
+ int samplesize = AUD_SAMPLE_SIZE(device->m_specs);
+ if(device->m_buffer->getSize() < samplesize * length)
+ device->m_buffer->resize(samplesize * length);
+ device->mix(device->m_buffer->getBuffer(), length);
+
+ float* in = (float*) device->m_buffer->getBuffer();
+ float* out;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list