I’ve done a program in Delphi and have a problem closing and reinit FMOD. That’s the FMOD-involved events:
1) Init FMOD with global settings (OK)
2) Play songs in a “preview box” with global settings (OK)
3) Select a song from another box (OK)
4) Import cd tracks
Note that I close and reinit FMOD for every item of the list, because I may change the global audio settings.
Now the problem: when I’ve to rip a cd track I init FMOD as shown in the cddarip example, FMOD rips the track correctly, I call FSOUND_Close, reinit with global settings and… BOOM.
I tracked the code, all streams are closed correctly, DSP callback is unactive.
Tnx in advance.
- Iago asked 14 years ago
I’m mostly using fmod with my player in VB6 ide, and it works fine… just avoid simply stopping the problem crashes of course, because vb6 doesn’t know fmod.dll has to be closed. You can however break and change your program and continue without problems (as long as no restart/program stop is required), or even call the unload function in the immidiate window and then stop your program without a crash
I don’t know why the cddarip example doesn’t need to specify an MMX mixer but, that is, it works.
I found this trick after testing ALL possible combinations of mixer/output/device/buffers etc.; I also noticed that with FPU mixer and “normal” output and device (i.e. my soundcard) my procedure works (obviously ripping at 1x, while playing), even if this is an unwanted case.
Howewer, I’m happy man now 😛
Hm, my VB6 player supports runtime changing of sound device without any problems (tested with fmod 3.6x / 3.7x).
Anywhy, you should not reinit fmod in not required. Stop playback and change device if required, or set an boolean variable whether a reinit is required after current track
Eheh, I know that’s a problem related to my code and not to FMOD, that’s why I’m here!
When I use FMOD to play or mix tracks I have no crashes. Pls look at this code:
var RipStream : TFileStream;
WavRec : WAVRecord; // header from Audio Tools Library
stream_ended: Boolean = False;
byteswritten: integer = 0;
function EndCallback(Stream: PFSoundStream; Buff: Pointer; Len, Param: Integer): ByteBool; stdcall;
function DSP_RawWriteCallback(originalbuffer, newbuffer: Pointer; Len, Param: Integer): Pointer; stdcall;
If Assigned(RipStream) and not stream_ended
RipStream.Write(NewBuffer^, len shl 2);
Inc(byteswritten, len shl 2);
procedure RipTrack(Drive: string; Track: integer; FName: string);
stream, rawwrite_dsp: Pointer;
If not FSOUND_SetOutput(FSOUND_OUTPUT_NOSOUND_NONREALTIME) then Abort;
If FSOUND_Init(44100, 1000, 0) then // it might be closed before
RipStream:= TFileStream.Create(FName, fmCreate);
rawwrite_dsp:= FSOUND_DSP_Create(DSP_RawWriteCallback, FSOUND_DSP_DEFAULTPRIORITY_USER, 0);
If rawwrite_dsp = nil then Abort;
Stream:= FSOUND_Stream_Open(PChar(Drive), FSOUND_NORMAL, 0, 0);
If Stream = nil then Abort;
If not FSOUND_Stream_SetEndCallback(stream, endcallback, 0) then Abort;
If not FSOUND_Stream_SetSubStream(stream, track – 1) then Abort;
While not stream_ended
If not FSOUND_Stream_Close(stream) then Abort;
WavRec.FileSize:= sizeOf(WavRec) + byteswritten – 8;
end else Abort;
(FSOUND_Close and FSOUND_Init with global settings here)
The result is that the engine is closed, the track is ripped and saved and a crash happen with FSOUND_Close.
I’m wrong with callbacks?
Please login first to submit.