I have one problem with FreePascal 2.4.x and DirectSound - my application crash when I use two and more threads for playing OGG. But I have no problems when I compile my code by FreePascal 2.2.4 and any version of Delphi(7,2009,2010). Maybe this is a luck that I have no problems with Delphi, but maybe I do something wrong. Can you help me?
Here you can find source code and all needed dll's. Examples only for Lazarus, but you can adopt them for Delphi(there are only few lines of code in unit1.pas). Directory "source" contains "lite" version of modules from ZenGL library. "Problematic" functions - snd_PlayFile and snd_ProcFile(thread function) in zgl_sound.pas. DirectSound stuff contained in zgl_sound_dsound.pas. All other code works fine, because there are no problems with OpenAL variant.
Oh... there is one problem with ButtonClick function in unit1.pas, so here correct code for example:
Code:var t : Double; a : Integer; begin wnd_Handle := Form1.Handle; // getting handle of Window for DirectSound snd_Init(); // Sound subsystem initialization snd_PlayFile( 'music.ogg' ); // creating first thread for playing t := timer_GetTicks(); while timer_GetTicks() - t < 1000 do; // waiting one second a := snd_PlayFile( 'music.ogg' ); // creating second thread for playing while sfStream[ a ]._playing do; // waiting before second thread end playing end;