[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11739] branches/soc-2007-hcube: Added API to access mixbuffer, can be used for ffmpeg audio saving.

Csaba Hruska csaba.hruska at gmail.com
Mon Aug 20 14:16:11 CEST 2007


Revision: 11739
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11739
Author:   hcube
Date:     2007-08-20 14:16:11 +0200 (Mon, 20 Aug 2007)

Log Message:
-----------
Added API to access mixbuffer, can be used for ffmpeg audio saving.

Modified Paths:
--------------
    branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.cpp
    branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.h
    branches/soc-2007-hcube/source/blender/include/BAU_soundsystem.h
    branches/soc-2007-hcube/source/blender/src/soundsystem.c

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-20 11:24:05 UTC (rev 11738)
+++ branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.cpp	2007-08-20 12:16:11 UTC (rev 11739)
@@ -46,7 +46,8 @@
 enum PlayTarget
 {
 	AUDIODEVICE_TARGET		= 0,
-	AUDIOFILE_TARGET		= 1
+	AUDIOFILE_TARGET		= 1,
+	AUDIOBUFFER_TARGET		= 2
 };
 
 static PlayTarget				gPlayTarget			= AUDIODEVICE_TARGET;
@@ -143,12 +144,20 @@
 	{
 		return (int)gDevice->getSampleRate();
 	}
-	else
+
+	if(	gPlayTarget == AUDIOFILE_TARGET )
 	{
 	    assert( gFileWriter != 0 );
 		return (int)gFileWriter->getSampleRate();
 	}
 	
+	if(	gPlayTarget == AUDIOBUFFER_TARGET )
+	{
+	    assert( gFileWriter != 0 );
+		// !!!! UNIMPLEMENTED YET !!!!
+		return 0;
+	}
+	
 	return 0;
 }
 
@@ -245,7 +254,26 @@
 	gPlayTarget = AUDIODEVICE_TARGET;
 }
 
+// mixbuffer handling
+int SND_MixBufferOpen( int sampleRate )
+{
+	// !!!! UNIMPLEMENTED YET !!!!
+	gDevice->disable();
+	gPlayTarget = AUDIOBUFFER_TARGET;
+	return true;
+}
+void SND_MixBufferFill( void *buffer, int framesNum )
+{
+	// !!!! UNIMPLEMENTED YET !!!!
+}
 
+void SND_MixBufferClose(void)
+{
+	// !!!! UNIMPLEMENTED YET !!!!
+	gDevice->enable();
+	gPlayTarget = AUDIODEVICE_TARGET;
+}
+
 // sound handling
 
  // hides various DataProvider backends

Modified: branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.h	2007-08-20 11:24:05 UTC (rev 11738)
+++ branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.h	2007-08-20 12:16:11 UTC (rev 11739)
@@ -40,6 +40,11 @@
 extern void		SND_FileWriteFrames( int framesNum );
 extern void		SND_FileClose(void);
 
+// mixbuffer handling
+extern int		SND_MixBufferOpen( int sampleRate );
+extern void		SND_MixBufferFill( void *buffer, int framesNum );
+extern void		SND_MixBufferClose(void);
+
 // sound handling
 extern SND_SoundIHandle	SND_SoundNew( char *filename ); // hides various DataProvider backends
 extern void		SND_SoundDelete( SND_SoundIHandle soundHandle );

Modified: branches/soc-2007-hcube/source/blender/include/BAU_soundsystem.h
===================================================================
--- branches/soc-2007-hcube/source/blender/include/BAU_soundsystem.h	2007-08-20 11:24:05 UTC (rev 11738)
+++ branches/soc-2007-hcube/source/blender/include/BAU_soundsystem.h	2007-08-20 12:16:11 UTC (rev 11739)
@@ -17,12 +17,18 @@
 int     audio_file_openforwrite(char *name, int sampleRate);
 void    audio_file_writeframes(int framesNum);
 void    audio_file_close(void);
+
+// mixbuffer functions, allows to reach mixed and multiplexed sound data.
+// now it supports signed 16 bit pcm data and 2 channel
+int     audio_mixbuffer_open(int sampleRate);
+void    audio_mixbuffer_fill(void *buffer, int framesNum);
+void    audio_mixbuffer_close(void);
 	
 // bSample functions
 struct bSample* audio_sample_new(char *name);
 struct bSample* audio_sample_find(char *name);
-int             audio_sample_load(struct bSample* sample);
-void            audio_sample_unload(struct bSample* sample);
+int             audio_sample_load(struct bSample *sample);
+void            audio_sample_unload(struct bSample *sample);
 
 // pcm data parameters:  4KHz and 8 bit, it is just visual purpuses
 char*           audio_sample_getvisualpcmdata(struct bSample *sample, int channelIdx);
@@ -30,8 +36,8 @@
 // bSound functions
 // hint: a bSound->sample cant be NULL, always have to be a valid pointer
 struct bSound*  audio_sound_new(char *name);
-void            audio_sound_delete(struct bSound* sound);
-struct bSound*  audio_sound_clone(struct bSound* originalsound);
+void            audio_sound_delete(struct bSound *sound);
+struct bSound*  audio_sound_clone(struct bSound *originalsound);
 struct bSound*  audio_sound_findbyid(char *id_name);
 
 int             audio_sound_isplaying(struct bSound *sound);

Modified: branches/soc-2007-hcube/source/blender/src/soundsystem.c
===================================================================
--- branches/soc-2007-hcube/source/blender/src/soundsystem.c	2007-08-20 11:24:05 UTC (rev 11738)
+++ branches/soc-2007-hcube/source/blender/src/soundsystem.c	2007-08-20 12:16:11 UTC (rev 11739)
@@ -120,6 +120,21 @@
 	SND_FileClose();
 }
 
+int audio_mixbuffer_open(int sampleRate)
+{
+	return SND_MixBufferOpen( sampleRate );
+}
+
+void audio_mixbuffer_fill(void *buffer, int framesNum)
+{
+	SND_MixBufferFill( buffer, framesNum );
+}
+
+void audio_mixbuffer_close(void)
+{
+	SND_MixBufferClose();
+}
+
 struct bSample*	audio_sample_new( char *name )
 {
 	bSample *sample = NULL;





More information about the Bf-blender-cvs mailing list