[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11813] branches/soc-2007-hcube: Added getCallback function.

Csaba Hruska csaba.hruska at gmail.com
Fri Aug 24 19:46:08 CEST 2007


Revision: 11813
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11813
Author:   hcube
Date:     2007-08-24 19:46:08 +0200 (Fri, 24 Aug 2007)

Log Message:
-----------
Added getCallback function. Added jack backend first version. Renamed method: getSoundByIdx to getSound. Changed DataConsumer::finalize return value to void.

Modified Paths:
--------------
    branches/soc-2007-hcube/intern/tinySND/SConscript
    branches/soc-2007-hcube/intern/tinySND/SND_DataConsumer.h
    branches/soc-2007-hcube/intern/tinySND/SND_DataMultiplexer.h
    branches/soc-2007-hcube/intern/tinySND/SND_FXMixer.h
    branches/soc-2007-hcube/intern/tinySND/SND_SoundInterface.h
    branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.cpp
    branches/soc-2007-hcube/intern/tinySND/intern/SND_DataConsumer.cpp
    branches/soc-2007-hcube/intern/tinySND/intern/SND_DataMultiplexer.cpp
    branches/soc-2007-hcube/intern/tinySND/intern/SND_FXMixer.cpp
    branches/soc-2007-hcube/intern/tinySND/intern/SND_SoundInterface.cpp
    branches/soc-2007-hcube/intern/tinySND/portaudio/portaudioDevice.cpp
    branches/soc-2007-hcube/intern/tinySND/portaudio/portaudioDevice.h
    branches/soc-2007-hcube/intern/tinySND/sdl/SDLDevice.cpp
    branches/soc-2007-hcube/intern/tinySND/sdl/SDLDevice.h
    branches/soc-2007-hcube/intern/tinySND/sndfile/sndfileWriter.cpp
    branches/soc-2007-hcube/intern/tinySND/sndfile/sndfileWriter.h
    branches/soc-2007-hcube/source/blender/src/header_seq.c
    branches/soc-2007-hcube/source/blender/src/seqaudio.c

Added Paths:
-----------
    branches/soc-2007-hcube/intern/tinySND/jack/
    branches/soc-2007-hcube/intern/tinySND/jack/jackDevice.cpp
    branches/soc-2007-hcube/intern/tinySND/jack/jackDevice.h

Modified: branches/soc-2007-hcube/intern/tinySND/SConscript
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SConscript	2007-08-24 17:34:45 UTC (rev 11812)
+++ branches/soc-2007-hcube/intern/tinySND/SConscript	2007-08-24 17:46:08 UTC (rev 11813)
@@ -2,9 +2,9 @@
 
 Import ('env')
 
-sources = env.Glob('portaudio/*.cpp') + env.Glob('sdl/*.cpp') + env.Glob('samplerate/*.cpp') + env.Glob('sndfile/*.cpp') + env.Glob('ffmpeg/*.cpp') + env.Glob('blender/*.cpp') + env.Glob('intern/*.cpp')
+sources = env.Glob('jack/*.cpp') + env.Glob('portaudio/*.cpp') + env.Glob('sdl/*.cpp') + env.Glob('samplerate/*.cpp') + env.Glob('sndfile/*.cpp') + env.Glob('ffmpeg/*.cpp') + env.Glob('blender/*.cpp') + env.Glob('intern/*.cpp')
 
-incs = '. samplerate blender sdl portaudio sndfile ffmpeg' + ' ' + env['BF_SDL_INC']
+incs = '. samplerate blender sdl jack portaudio sndfile ffmpeg' + ' ' + env['BF_SDL_INC']
 defs = ''
 #if env['WITH_BF_OPENAL']:
 #    sources += env.Glob('openal/*.cpp') + env.Glob('sdl/*.cpp')

Modified: branches/soc-2007-hcube/intern/tinySND/SND_DataConsumer.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SND_DataConsumer.h	2007-08-24 17:34:45 UTC (rev 11812)
+++ branches/soc-2007-hcube/intern/tinySND/SND_DataConsumer.h	2007-08-24 17:46:08 UTC (rev 11813)
@@ -11,26 +11,27 @@
     
 	virtual			~SND_DataConsumer() {}
     
-    virtual bool	initialize() = 0;
-    virtual bool	finalize() = 0;
-
-    virtual float	getSampleRate() = 0;
+	virtual bool	initialize() = 0;
+	virtual void	finalize() = 0;
+	
+	virtual float	getSampleRate() = 0;
 	virtual	void	setSampleRate( float sampleRate ) = 0;
 	
 	virtual int		getSampleFormat() = 0;
 	virtual	void	setSampleFormat( int sampleFormat ) = 0;
 	
-    virtual int		getNumChannels() = 0;
+	virtual int		getNumChannels() = 0;
 	virtual	void	setNumChannels( int channelsNum ) = 0;
 	
 	virtual void	consumeData( int framesNum ) = 0;
 
-    int				getBitRate();
+	int				getBitRate();
 	
     // only same sample rate is acceptable that device has
-    void			setInput( SND_DataMultiplexer *input );
+	void			setInput( SND_DataMultiplexer *input );
 
 	// calling callback before producing pcm data to the device
+	void			getCallback( SND_CallbackFunction **callback, void **userData1, void **userData2 );
 	void			setCallback( SND_CallbackFunction *callback );
 
 	void			setUserData( void *userData1, void *userData2 );

Modified: branches/soc-2007-hcube/intern/tinySND/SND_DataMultiplexer.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SND_DataMultiplexer.h	2007-08-24 17:34:45 UTC (rev 11812)
+++ branches/soc-2007-hcube/intern/tinySND/SND_DataMultiplexer.h	2007-08-24 17:46:08 UTC (rev 11813)
@@ -15,6 +15,7 @@
 			~SND_DataMultiplexer();
     
     void	assignSoundToChannel( SND_SoundInterface *sound, int channelIdx );
+	SND_SoundInterface *getChannel( int channelIdx );
 
     int		getNumChannels();
     void	setNumChannels( int channelsNum );
@@ -26,8 +27,9 @@
 	void	fillBuffer( void *buffer, int framesNum );
 
 	// calling callback before filling the buffer
-	void			setCallback( SND_CallbackFunction *callback );
-	void			setUserData( void *userData1, void *userData2 );
+	void	getCallback( SND_CallbackFunction **callback, void **userData1, void **userData2 );
+	void	setCallback( SND_CallbackFunction *callback );
+	void	setUserData( void *userData1, void *userData2 );
     
 protected:
 	std::vector<SND_SoundInterface*>	mSounds;

Modified: branches/soc-2007-hcube/intern/tinySND/SND_FXMixer.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SND_FXMixer.h	2007-08-24 17:34:45 UTC (rev 11812)
+++ branches/soc-2007-hcube/intern/tinySND/SND_FXMixer.h	2007-08-24 17:46:08 UTC (rev 11813)
@@ -14,7 +14,7 @@
     void	addSound(SND_SoundInterface* sound);
     void	removeSound(SND_SoundInterface* sound);
 
-	SND_SoundInterface* getSoundByIdx( int idx );
+	SND_SoundInterface* getSound( int idx );
     int		getNumSounds();
 
     void	setGain( float gain );

Modified: branches/soc-2007-hcube/intern/tinySND/SND_SoundInterface.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SND_SoundInterface.h	2007-08-24 17:34:45 UTC (rev 11812)
+++ branches/soc-2007-hcube/intern/tinySND/SND_SoundInterface.h	2007-08-24 17:46:08 UTC (rev 11813)
@@ -18,6 +18,7 @@
 	
 	//todo: finish this feature, required for actuating sound ipos
 	// callback is called before real work/mixing is done in getPCMDataPtr
+	void			getCallback( SND_CallbackFunction **callback, void **userData1, void **userData2 );
 	void			setCallback( SND_CallbackFunction *callback );
 
 	void			setUserData( void *userData1, void *userData2 );

Modified: branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.cpp	2007-08-24 17:34:45 UTC (rev 11812)
+++ branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.cpp	2007-08-24 17:46:08 UTC (rev 11813)
@@ -13,6 +13,7 @@
 
 #include "SDLDevice.h"
 #include "portaudioDevice.h"
+#include "jackDevice.h"
 #include "sndfileReader.h"
 #include "sndfileWriter.h"
 #include "ffmpegReader.h"
@@ -60,7 +61,6 @@
 
 static SND_DataMultiplexer		*gCommonDataMultiplexer	= 0;
 
-
 static SND_CallbackFunction		*gCallbackFunction	= 0;
 static void						*gCallbackUserData1	= 0;
 static void						*gCallbackUserData2	= 0;
@@ -85,14 +85,20 @@
 {
     assert( gDevice == 0 );
 
+	extern void do_init_ffmpeg();
+
+//	do_init_ffmpeg();
+
 	gFileWriter = 0;
 	gPlayTarget = AUDIODEVICE_TARGET;
 	gCallbackFunction = 0;
 	gCallbackUserData1 = 0;
 	gCallbackUserData2 = 0;
 	
-    gDevice = new SDLDevice();
+//    gDevice = new SDLDevice();
 //    gDevice = new portaudioDevice();
+    gDevice = new jackDevice();
+
     gDevice->initialize();
     
 	gDataMultiplexer = new SND_DataMultiplexer();

Modified: branches/soc-2007-hcube/intern/tinySND/intern/SND_DataConsumer.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/intern/SND_DataConsumer.cpp	2007-08-24 17:34:45 UTC (rev 11812)
+++ branches/soc-2007-hcube/intern/tinySND/intern/SND_DataConsumer.cpp	2007-08-24 17:46:08 UTC (rev 11813)
@@ -37,6 +37,13 @@
 	mInput = input;
 }
 
+void SND_DataConsumer::getCallback( SND_CallbackFunction **callback, void **userData1, void **userData2 )
+{
+	(*callback) = mCallback;
+	(*userData1) = mUserData1;
+	(*userData2) = mUserData2;
+}
+
 void SND_DataConsumer::setCallback( SND_CallbackFunction *callback )
 {
 	mCallback = callback;

Modified: branches/soc-2007-hcube/intern/tinySND/intern/SND_DataMultiplexer.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/intern/SND_DataMultiplexer.cpp	2007-08-24 17:34:45 UTC (rev 11812)
+++ branches/soc-2007-hcube/intern/tinySND/intern/SND_DataMultiplexer.cpp	2007-08-24 17:46:08 UTC (rev 11813)
@@ -10,6 +10,7 @@
 	
 	mSounds.clear();
 	mSoundBuffers.clear();
+
 	mSampleFormat = SND_FORMAT_PCM_16;
 }
 
@@ -17,9 +18,18 @@
 {
 }
 
+SND_SoundInterface *SND_DataMultiplexer::getChannel( int channelIdx )
+{
+	assert( mSounds.size() > 0 );
+	assert( channelIdx >= 0 || channelIdx < (int)mSounds.size() );
+	
+	return mSounds[ channelIdx ];
+}
+
 void SND_DataMultiplexer::assignSoundToChannel( SND_SoundInterface *sound, int channelIdx )
 {
 	assert( sound != 0 );
+	assert( mSounds.size() > 0 );
 	assert( channelIdx >= 0 || channelIdx < (int)mSounds.size() );
 
 	mSounds[ channelIdx ] = sound;
@@ -233,6 +243,13 @@
 	}
 }
 
+void SND_DataMultiplexer::getCallback( SND_CallbackFunction **callback, void **userData1, void **userData2 )
+{
+	(*callback) = mCallback;
+	(*userData1) = mUserData1;
+	(*userData2) = mUserData2;
+}
+
 void SND_DataMultiplexer::setCallback( SND_CallbackFunction *callback )
 {
 	mCallback = callback;

Modified: branches/soc-2007-hcube/intern/tinySND/intern/SND_FXMixer.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/intern/SND_FXMixer.cpp	2007-08-24 17:34:45 UTC (rev 11812)
+++ branches/soc-2007-hcube/intern/tinySND/intern/SND_FXMixer.cpp	2007-08-24 17:46:08 UTC (rev 11813)
@@ -64,7 +64,7 @@
 	}
 }
 
-SND_SoundInterface* SND_FXMixer::getSoundByIdx( int idx )
+SND_SoundInterface* SND_FXMixer::getSound( int idx )
 {
 	assert( 0 < idx );
 	assert( idx < (int)mSounds.size() );

Modified: branches/soc-2007-hcube/intern/tinySND/intern/SND_SoundInterface.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/intern/SND_SoundInterface.cpp	2007-08-24 17:34:45 UTC (rev 11812)
+++ branches/soc-2007-hcube/intern/tinySND/intern/SND_SoundInterface.cpp	2007-08-24 17:46:08 UTC (rev 11813)
@@ -1,6 +1,13 @@
 #include <assert.h>
 #include "SND_SoundInterface.h"
 
+void SND_SoundInterface::getCallback( SND_CallbackFunction **callback, void **userData1, void **userData2 )
+{
+	(*callback) = mCallback;
+	(*userData1) = mUserData1;
+	(*userData2) = mUserData2;
+}
+
 void SND_SoundInterface::setCallback( SND_CallbackFunction *callback )
 {
 	mCallback = callback;

Added: branches/soc-2007-hcube/intern/tinySND/jack/jackDevice.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/jack/jackDevice.cpp	                        (rev 0)
+++ branches/soc-2007-hcube/intern/tinySND/jack/jackDevice.cpp	2007-08-24 17:46:08 UTC (rev 11813)
@@ -0,0 +1,295 @@
+#include <assert.h>
+#include "jackDevice.h"
+#include "SND_Defines.h"
+#include "SND_SoundInterface.h"
+
+jackDevice::jackDevice()
+{
+	mInput = 0;
+	// clear callback
+	mCallback = 0;
+	mUserData1 = 0;
+	mUserData2 = 0;
+}
+
+jackDevice::~jackDevice()
+{
+}
+
+
+bool jackDevice::initialize()
+{
+	const char *client_name = "tinySND jack backend";
+	const char *server_name = NULL;
+	jack_options_t options = JackNullOption;
+	jack_status_t status;
+
+	/* open a client connection to the JACK server */
+	mClient = jack_client_open( client_name, options, &status, server_name );
+
+	if( mClient == NULL )
+	{
+		fprintf( stderr, "jack_client_open() failed, status = 0x%2.0x\n", status );
+		if( status & JackServerFailed )
+		{

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list