From 398f4ee7634b00cd2dffd5c335c6249845951a64 Mon Sep 17 00:00:00 2001 From: groogy Date: Thu, 25 Nov 2010 11:04:17 +0000 Subject: [PATCH] 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 --- .../ruby/sfml-audio/audio/SoundRecorder.cpp | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/bindings/ruby/sfml-audio/audio/SoundRecorder.cpp b/bindings/ruby/sfml-audio/audio/SoundRecorder.cpp index a7929935e..dfde9a1d3 100644 --- a/bindings/ruby/sfml-audio/audio/SoundRecorder.cpp +++ b/bindings/ruby/sfml-audio/audio/SoundRecorder.cpp @@ -22,14 +22,14 @@ #include "SoundStream.hpp" #include "main.hpp" -#include +#include VALUE globalSoundRecorderClass; class rbSoundRecorder : public sf::SoundRecorder { public: - SoundRecorder() + rbSoundRecorder() { } @@ -44,7 +44,7 @@ public: protected: virtual bool OnStart() { - if( rb_respond_to( myOnStartID ) == 0 ) + if( rb_respond_to( mySelf, myOnStartID ) == 0 ) { return true; } @@ -63,7 +63,7 @@ protected: virtual void OnStop() { - if( rb_respond_to( myOnStopID ) != 0 ) + if( rb_respond_to( mySelf, myOnStopID ) != 0 ) { rb_funcall( mySelf, myOnStopID, 0 ); } @@ -71,20 +71,19 @@ protected: 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] ) ); + } + + if( rb_funcall( mySelf, myOnProcessSamplesID, 2, samples, INT2FIX( someCount ) ) == Qfalse ) + { + return false; } else { - if( rb_funcall( mySelf, myOnProcessSamples, 0 ) == Qfalse ) - { - return false; - } - else - { - return true; - } + return true; } } @@ -222,11 +221,14 @@ void Init_SoundRecorder( void ) rb_define_method( globalSoundRecorderClass, "getSampleRate", SoundRecorder_GetSampleRate, 0 ); // Class Aliases - rb_define_alias( globalSoundRecorderClass, "is_available", "isAvailable" ); - rb_define_alias( globalSoundRecorderClass, "available?", "isAvailable" ); + rb_define_alias( CLASS_OF( globalSoundRecorderClass ), "is_available", "isAvailable" ); + rb_define_alias( CLASS_OF( globalSoundRecorderClass ), "available?", "isAvailable" ); // Instance Aliases rb_define_alias( globalSoundRecorderClass, "get_sample_rate", "getSampleRate" ); rb_define_alias( globalSoundRecorderClass, "sampleRate", "getSampleRate" ); rb_define_alias( globalSoundRecorderClass, "sample_rate", "getSampleRate" ); + + rb_define_alias( globalSoundRecorderClass, "on_start", "on_start" ); + rb_define_alias( globalSoundRecorderClass, "on_stop", "on_stop" ); }