[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12554] branches/soc-2007-hcube/intern/ tinySND: fixed all optional lib handling in scons scripts.

Csaba Hruska csaba.hruska at gmail.com
Sun Nov 11 17:18:11 CET 2007


Revision: 12554
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12554
Author:   hcube
Date:     2007-11-11 17:18:11 +0100 (Sun, 11 Nov 2007)

Log Message:
-----------
fixed all optional lib handling in scons scripts. now all WITH_BF_xxx is handled properly. 

Modified Paths:
--------------
    branches/soc-2007-hcube/intern/tinySND/SConscript
    branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.cpp
    branches/soc-2007-hcube/intern/tinySND/mad/madReader.cpp

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

Modified: branches/soc-2007-hcube/intern/tinySND/SConscript
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SConscript	2007-11-11 16:13:27 UTC (rev 12553)
+++ branches/soc-2007-hcube/intern/tinySND/SConscript	2007-11-11 16:18:11 UTC (rev 12554)
@@ -9,29 +9,36 @@
 if env['WITH_BF_SDL']:
     sources += env.Glob('sdl/*.cpp')
     incs += ' sdl ' + env['BF_SDL_INC']
+    defs += ' WITH_SDL'
 
 if env['WITH_BF_PORTAUDIO']:
     sources += env.Glob('portaudio/*.cpp')
     incs += ' portaudio ' + env['BF_PORTAUDIO_INC']
+    defs += ' WITH_PORTAUDIO'
 
 if env['WITH_BF_JACK']:
     sources += env.Glob('jack/*.cpp')
     incs += ' jack ' + env['BF_JACK_INC']
+    defs += ' WITH_JACK'
 
 if env['WITH_BF_SNDFILE']:
     sources += env.Glob('sndfile/*.cpp')
     incs += ' sndfile ' + env['BF_SNDFILE_INC']
+    defs += ' WITH_SNDFILE'
 
 if env['WITH_BF_FFMPEG']:
     sources += env.Glob('ffmpeg/*.cpp')
     incs += ' ffmpeg ' + env['BF_FFMPEG_INC']
+    defs += ' WITH_FFMPEG'
 
 if env['WITH_BF_MAD']:
     sources += env.Glob('mad/*.cpp')
     incs += ' mad ' + env['BF_MAD_INC']
+    defs += ' WITH_MAD'
 
 if env['WITH_BF_VORBIS']:
     sources += env.Glob('vorbis/*.cpp')
     incs += ' vorbis ' + env['BF_VORBIS_INC']
+    defs += ' WITH_VORBIS'
 
 env.BlenderLib ('bf_soundsystem', sources, Split(incs), Split(defs), libtype=['core','player'], priority = [90,50] )

Added: branches/soc-2007-hcube/intern/tinySND/SND_NullDevice.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SND_NullDevice.h	                        (rev 0)
+++ branches/soc-2007-hcube/intern/tinySND/SND_NullDevice.h	2007-11-11 16:18:11 UTC (rev 12554)
@@ -0,0 +1,36 @@
+#ifndef __SND_NULLDEVICE_H__
+#define __SND_NULLDEVICE_H__
+
+#include "SND_Device.h"
+
+class SND_NullDevice: public SND_Device
+{
+public:
+	bool	initialize();
+	void	finalize();
+	
+	float	getSampleRate();
+	void	setSampleRate( float sampleRate );
+	
+	int		getSampleFormat();
+	void	setSampleFormat( int sampleFormat );
+	
+	int		getNumChannels();
+	void	setNumChannels( int channelsNum );
+
+	// enables/disables audio device temporarly
+    bool	isEnabled();
+    void	enable();
+    void	disable();
+
+	int		getAudioBufferSize();
+	void	setAudioBufferSize( int bufferSize );
+
+    char*	getChannelName( int hwChannelIdx );
+    
+private:
+    bool    mEnabled;
+};
+
+#endif //__SND_NULLDEVICE_H__
+

Modified: branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.cpp	2007-11-11 16:13:27 UTC (rev 12553)
+++ branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.cpp	2007-11-11 16:18:11 UTC (rev 12554)
@@ -4,6 +4,7 @@
 
 #include "SND_C-api.h"
 #include "SND_Device.h"
+#include "SND_NullDevice.h"
 #include "SND_FXSample.h"
 #include "SND_FXMixer.h"
 #include "SND_FXSRC.h"
@@ -11,14 +12,35 @@
 #include "SND_WavReader.h"
 #include "SND_AiffReader.h"
 
+#ifdef WITH_SDL
 #include "SDLDevice.h"
+#endif
+
+#ifdef WITH_PORTAUDIO
 #include "portaudioDevice.h"
+#endif
+
+#ifdef WITH_JACK
 #include "jackDevice.h"
+#endif
+
+#ifdef WITH_SNDFILE
 #include "sndfileReader.h"
 #include "sndfileWriter.h"
+#endif
+
+#ifdef WITH_FFMPEG
 #include "ffmpegReader.h"
+#endif
+
+#ifdef WITH_VORBIS
 #include "vorbisReader.h"
+#endif
 
+#ifdef WITH_MAD
+#include "madReader.h"
+#endif
+
 #ifdef WIN32
 #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
 #endif //WIN32
@@ -95,11 +117,35 @@
 	gCallbackFunction = 0;
 	gCallbackUserData1 = 0;
 	gCallbackUserData2 = 0;
+
+	gDevice = 0;	
+
+#ifdef WITH_SDL
+    if( gDevice == 0 )
+    {
+        gDevice = new SDLDevice();
+    }
+#endif
+
+#ifdef WITH_PORTAUDIO
+    if( gDevice == 0 )
+    {
+        gDevice = new portaudioDevice();
+    }
+#endif
+
+#ifdef WITH_JACK
+    if( gDevice == 0 )
+    {
+        gDevice = new jackDevice();
+    }
+#endif
+
+    if( gDevice == 0 )
+    {
+        gDevice = new SND_NullDevice();
+    }
 	
-    gDevice = new SDLDevice();
-//    gDevice = new portaudioDevice();
-//    gDevice = new jackDevice();
-
     gDevice->initialize();
     
 	gDataMultiplexer = new SND_DataMultiplexer();
@@ -317,7 +363,7 @@
 	float sampleRate = gDevice->getSampleRate();
 	std::vector<SND_Sound*>::const_iterator i;
 	for( i = gSounds.begin() ; i != gSounds.end() ; ++i )
-	{
+    {
 		SND_Sound *sound = (*i);
 		for( std::vector<SND_FXSRC*>::iterator j = sound->mSRCs.begin() ; j != sound->mSRCs.end() ; ++j )
 		{
@@ -357,6 +403,7 @@
 		// try Aiff
 		dataReader = new SND_AiffReader( filename );
 	}
+#ifdef WITH_VORBIS
 	if( !dataReader->isFormatSupported() )
 	{
 		delete dataReader;
@@ -364,13 +411,26 @@
 		// try vorbis
 		dataReader = new vorbisReader( filename );
 	}
+#endif
+#ifdef WITH_MAD
 	if( !dataReader->isFormatSupported() )
 	{
 		delete dataReader;
 
+		// try vorbis
+		dataReader = new madReader( filename );
+	}
+#endif
+#ifdef WITH_FFMPEG
+	if( !dataReader->isFormatSupported() )
+	{
+		delete dataReader;
+
 		// try ffmpeg
 		dataReader = new ffmpegReader( filename );
 	}
+#endif
+#ifdef WITH_SNDFILE
 	if( !dataReader->isFormatSupported() )
 	{
 		delete dataReader;
@@ -378,6 +438,7 @@
 		// try sndfile
 		dataReader = new sndfileReader( filename );
 	}
+#endif
 	
 	// no lib can open this file
 	if( !dataReader->isFormatSupported() )

Added: branches/soc-2007-hcube/intern/tinySND/intern/SND_NullDevice.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/intern/SND_NullDevice.cpp	                        (rev 0)
+++ branches/soc-2007-hcube/intern/tinySND/intern/SND_NullDevice.cpp	2007-11-11 16:18:11 UTC (rev 12554)
@@ -0,0 +1,67 @@
+#include "SND_NullDevice.h"
+
+bool SND_NullDevice::initialize()
+{
+    return true;
+}
+
+void SND_NullDevice::finalize()
+{
+}
+
+float SND_NullDevice::getSampleRate()
+{
+    return 44100.0;
+}
+
+void SND_NullDevice::setSampleRate( float sampleRate )
+{
+}
+
+int SND_NullDevice::getSampleFormat()
+{
+    return SND_FORMAT_FLOAT;
+}
+
+void SND_NullDevice::setSampleFormat( int sampleFormat )
+{
+}
+
+int SND_NullDevice::getNumChannels()
+{
+    return 2;
+}
+
+void SND_NullDevice::setNumChannels( int channelsNum )
+{
+}
+
+bool SND_NullDevice::isEnabled()
+{
+    return mEnabled;
+}
+
+void SND_NullDevice::enable()
+{
+    mEnabled = true;
+}
+
+void SND_NullDevice::disable()
+{
+    mEnabled = false;
+}
+
+int SND_NullDevice::getAudioBufferSize()
+{
+    return 1;
+}
+
+void SND_NullDevice::setAudioBufferSize( int bufferSize )
+{
+}
+
+char* SND_NullDevice::getChannelName( int hwChannelIdx )
+{
+    return "null channel";
+}
+    

Modified: branches/soc-2007-hcube/intern/tinySND/mad/madReader.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/mad/madReader.cpp	2007-11-11 16:13:27 UTC (rev 12553)
+++ branches/soc-2007-hcube/intern/tinySND/mad/madReader.cpp	2007-11-11 16:18:11 UTC (rev 12554)
@@ -4,6 +4,9 @@
 
 madReader::madReader( char *filename )
 {
+    mIsFormatSupported = false;
+    return;
+    
 	mFile = fopen( filename, "rb" );
 
 	if( mFile == 0 )





More information about the Bf-blender-cvs mailing list