Forgot to pass the sample pointer in the OnProcessSamples function and also some aliases.

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1709 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
groogy 2010-11-25 11:04:17 +00:00
parent d22a5648d4
commit 398f4ee763

View File

@ -22,14 +22,14 @@
#include "SoundStream.hpp" #include "SoundStream.hpp"
#include "main.hpp" #include "main.hpp"
#include <SFML/Audio/SoundStream.hpp> #include <SFML/Audio/SoundRecorder.hpp>
VALUE globalSoundRecorderClass; VALUE globalSoundRecorderClass;
class rbSoundRecorder : public sf::SoundRecorder class rbSoundRecorder : public sf::SoundRecorder
{ {
public: public:
SoundRecorder() rbSoundRecorder()
{ {
} }
@ -44,7 +44,7 @@ public:
protected: protected:
virtual bool OnStart() virtual bool OnStart()
{ {
if( rb_respond_to( myOnStartID ) == 0 ) if( rb_respond_to( mySelf, myOnStartID ) == 0 )
{ {
return true; return true;
} }
@ -63,7 +63,7 @@ protected:
virtual void OnStop() virtual void OnStop()
{ {
if( rb_respond_to( myOnStopID ) != 0 ) if( rb_respond_to( mySelf, myOnStopID ) != 0 )
{ {
rb_funcall( mySelf, myOnStopID, 0 ); rb_funcall( mySelf, myOnStopID, 0 );
} }
@ -71,13 +71,13 @@ protected:
virtual bool OnProcessSamples( const sf::Int16 *someSamples, std::size_t someCount ) virtual bool OnProcessSamples( const sf::Int16 *someSamples, std::size_t someCount )
{ {
if( rb_respond_to( myOnProcessSamples ) == 0 ) VALUE samples = rb_ary_new2( someCount );
for(unsigned long index = 0; index < someCount; index++)
{ {
return true; rb_ary_store( samples, index, INT2FIX( someSamples[index] ) );
} }
else
{ if( rb_funcall( mySelf, myOnProcessSamplesID, 2, samples, INT2FIX( someCount ) ) == Qfalse )
if( rb_funcall( mySelf, myOnProcessSamples, 0 ) == Qfalse )
{ {
return false; return false;
} }
@ -86,7 +86,6 @@ protected:
return true; return true;
} }
} }
}
VALUE mySelf; VALUE mySelf;
ID myOnStartID; ID myOnStartID;
@ -222,11 +221,14 @@ void Init_SoundRecorder( void )
rb_define_method( globalSoundRecorderClass, "getSampleRate", SoundRecorder_GetSampleRate, 0 ); rb_define_method( globalSoundRecorderClass, "getSampleRate", SoundRecorder_GetSampleRate, 0 );
// Class Aliases // Class Aliases
rb_define_alias( globalSoundRecorderClass, "is_available", "isAvailable" ); rb_define_alias( CLASS_OF( globalSoundRecorderClass ), "is_available", "isAvailable" );
rb_define_alias( globalSoundRecorderClass, "available?", "isAvailable" ); rb_define_alias( CLASS_OF( globalSoundRecorderClass ), "available?", "isAvailable" );
// Instance Aliases // Instance Aliases
rb_define_alias( globalSoundRecorderClass, "get_sample_rate", "getSampleRate" ); rb_define_alias( globalSoundRecorderClass, "get_sample_rate", "getSampleRate" );
rb_define_alias( globalSoundRecorderClass, "sampleRate", "getSampleRate" ); rb_define_alias( globalSoundRecorderClass, "sampleRate", "getSampleRate" );
rb_define_alias( globalSoundRecorderClass, "sample_rate", "getSampleRate" ); rb_define_alias( globalSoundRecorderClass, "sample_rate", "getSampleRate" );
rb_define_alias( globalSoundRecorderClass, "on_start", "on_start" );
rb_define_alias( globalSoundRecorderClass, "on_stop", "on_stop" );
} }