[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11673] branches/soc-2007-hcube/intern/ tinySND/sdl: API change, SND_Device inherits SND_DataConsumer.
Csaba Hruska
csaba.hruska at gmail.com
Sun Aug 19 12:27:41 CEST 2007
Revision: 11673
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11673
Author: hcube
Date: 2007-08-19 12:27:41 +0200 (Sun, 19 Aug 2007)
Log Message:
-----------
API change, SND_Device inherits SND_DataConsumer.
Modified Paths:
--------------
branches/soc-2007-hcube/intern/tinySND/sdl/SDLDevice.cpp
branches/soc-2007-hcube/intern/tinySND/sdl/SDLDevice.h
Modified: branches/soc-2007-hcube/intern/tinySND/sdl/SDLDevice.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/sdl/SDLDevice.cpp 2007-08-19 10:26:16 UTC (rev 11672)
+++ branches/soc-2007-hcube/intern/tinySND/sdl/SDLDevice.cpp 2007-08-19 10:27:41 UTC (rev 11673)
@@ -1,16 +1,25 @@
#include "SDLDevice.h"
+#include "SND_Defines.h"
#include "SND_SoundInterface.h"
#include <stdio.h>
+SDLDevice::SDLDevice()
+{
+ mInput = 0;
+ // clear callback
+ mCallback = 0;
+ mUserData1 = 0;
+ mUserData2 = 0;
+}
+
+SDLDevice::~SDLDevice()
+{
+}
+
+
bool SDLDevice::initialize()
{
- // all channel is free
- for( int i = 0 ; i < 6 ; i++ )
- {
- mSounds[ i ] = 0;
- }
-
// Initialize the SDL library
if ( SDL_Init(0) < 0 )
{
@@ -83,6 +92,17 @@
SDL_PauseAudio(1);
}
+int SDLDevice::getAudioBufferSize()
+{
+ // !!!! NOT IMPLEMENTED YET !!!!
+ return 1024;
+}
+
+void SDLDevice::setAudioBufferSize( int bufferSize )
+{
+ // !!!! NOT IMPLEMENTED YET !!!!
+}
+
void SDLDevice::fill_audio(void *udata, Uint8 *stream, int len)
{
((SDLDevice*)udata)->fill_audio_do((Sint16*)stream, len);
@@ -90,42 +110,22 @@
void SDLDevice::fill_audio_do(Sint16 *stream, int len)
{
- float *buffer[6];
int framesNum = len / mAudioSpec.channels / 2; // requested data len per channel
- int i, j;
- // currently only supports AUDIO_S16SYS
-
- // processing sound calculations, and getting the final pcm data to buffer
- for( i = 0 ; i < 6 ; i++ )
- {
- if( mSounds[i] != 0 && mSounds[i]->isDataAvailable() )
- {
- buffer[i] = mSounds[i]->getPCMDataPtr( framesNum );
- }
- else
- {
- buffer[i] = 0;
- }
- }
-
- for( i = 0 ; i < framesNum ; i++ )
- {
- // now we fill the buffer, making float -> AUDIO_S16SYS conversion
- for( j = 0 ; j < mAudioSpec.channels ; j++ )
- {
- if( buffer[j] != 0 )
- {
- stream[0] = (Sint16)(buffer[j][0]*32767.0);
- buffer[j]++;
- }
- else
- {
- stream[0] = 0;
- }
- stream++;
- }
- }
+ // call callback
+ if( mCallback != 0 )
+ {
+ (*mCallback)( framesNum, mUserData1, mUserData2 );
+ }
+
+ if( mInput )
+ {
+ mInput->fillBuffer( (char*)stream, framesNum );
+ }
+ else
+ {
+ memset( stream, (char)0, len );
+ }
}
int SDLDevice::getNumChannels(void)
@@ -133,27 +133,35 @@
return mAudioSpec.channels;
}
+void SDLDevice::setNumChannels( int channelsNum )
+{
+ // !!!! NOT IMPLEMENTED YET !!!!
+}
+
char* SDLDevice::getChannelName( int hwChannelIdx )
{
// more descriptive name will come soon. ex: left, right, center, etc
return "SDL Audio Channel";
}
-void SDLDevice::assignSoundToChannel( int hwChannelIdx, SND_SoundInterface *sound )
+float SDLDevice::getSampleRate(void)
{
- if( hwChannelIdx < 0 || hwChannelIdx >=6 )
- {
- return;
- }
- mSounds[ hwChannelIdx ] = sound;
+ return (float)mAudioSpec.freq;
}
-float SDLDevice::getSampleRate(void)
+void SDLDevice::setSampleRate( float sampleRate )
{
- return (float)mAudioSpec.freq;
+ // !!!! NOT IMPLEMENTED YET !!!!
}
-int SDLDevice::getBitRate(void)
+int SDLDevice::getSampleFormat(void)
{
- return 16;
+ // currently only supports AUDIO_S16SYS
+ return SND_FORMAT_PCM_16;
}
+
+void SDLDevice::setSampleFormat( int sampleFormat )
+{
+ // !!!! NOT IMPLEMENTED YET !!!!
+}
+
Modified: branches/soc-2007-hcube/intern/tinySND/sdl/SDLDevice.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/sdl/SDLDevice.h 2007-08-19 10:26:16 UTC (rev 11672)
+++ branches/soc-2007-hcube/intern/tinySND/sdl/SDLDevice.h 2007-08-19 10:27:41 UTC (rev 11673)
@@ -7,6 +7,9 @@
class SDLDevice: public SND_Device
{
public:
+
+ SDLDevice();
+ ~SDLDevice();
bool initialize();
bool finalize();
@@ -15,12 +18,19 @@
void enable();
void disable();
+ int getAudioBufferSize();
+ void setAudioBufferSize( int bufferSize );
+
int getNumChannels();
+ void setNumChannels( int channelsNum );
+
char* getChannelName( int hwChannelIdx );
- void assignSoundToChannel( int hwChannelIdx, SND_SoundInterface *sound );
float getSampleRate();
- int getBitRate();
+ void setSampleRate( float sampleRate );
+
+ int getSampleFormat();
+ void setSampleFormat( int sampleFormat );
private:
static void fill_audio(void *udata, Uint8 *stream, int len);
@@ -28,7 +38,6 @@
private:
SDL_AudioSpec mAudioSpec;
- SND_SoundInterface *mSounds[6];
bool mIsEnabled;
More information about the Bf-blender-cvs
mailing list