Hello everybody,
I've searched the forum with the word
BASS_ChannelSetSync but found nothing related to my problem, so I ask here :
Programming with FreePascal/Lazarus (more or less = Delphi), I'm trying to detect when the currently playing song stops at the end of file (= end of data ?).
Starting with the snippet found here,
http://www.un4seen.com/forum/?topic=17382.msg121948#msg121948, I've played with
procedure EndSyncProc(handle: HSYNC; channel, data: DWORD; user: Pointer); {$IFDEF MSWINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
begin
// do something at the end here
ShowMessage('Here');
end;
procedure TMainForm.Button1Click(Sender: TObject);
begin // http://www.un4seen.com/forum/?topic=17382.msg121948#msg121948
//str:= BASS_StreamCreateFile(False, pchar('/ian_garbarek-2sec.wav'), 0, 0, BASS_STREAM_AUTOFREE);
str:= BASS_StreamCreateFile(False, pchar('/ian_garbarek-2sec.wav'), 0, 0, 0);
BASS_ChannelSetSync(str, BASS_SYNC_END, 0, @EndSyncProc, nil);
BASS_ChannelPlay(str, false);
end;
but I've never seen the MessageBox "Here", cos' the prog crashes with
"Le projet project1 a levé une exception de class "External: SIGSEGV".
à l'adresse B793FF45"
when reaching the end of file.
Tried with other songs = same problem, tried the song with 3 different players found in my machine = no problem.
At the time of crash, assembly Window poping up says :
...
B793FEE3 e938e2ffff jmp 0xb793e120
B793FEE8 8d832c79feff lea -0x186d4(%ebx),%eax
B793FEEE 89442408 mov %eax,0x8(%esp)
B793FEF2 8d83787ffeff lea -0x18088(%ebx),%eax
B793FEF8 89442404 mov %eax,0x4(%esp)
B793FEFC 8d836b55fcff lea -0x3aa95(%ebx),%eax
B793FF02 890424 mov %eax,(%esp)
B793FF05 e8e690faff call 0xb78e8ff0
B793FF0A 8b5c2410 mov 0x10(%esp),%ebx
B793FF0E 8b742414 mov 0x14(%esp),%esi
B793FF12 8b7c2418 mov 0x18(%esp),%edi
B793FF16 83c41c add $0x1c,%esp
B793FF19 c3 ret
B793FF1A 8db600000000 lea 0x0(%esi),%esi
B793FF20 56 push %esi
B793FF21 53 push %ebx
B793FF22 83ec74 sub $0x74,%esp
B793FF25 8b8c2480000000 mov 0x80(%esp),%ecx
B793FF2C e8aaa5faff call 0xb78ea4db
B793FF31 81c3b7300400 add $0x430b7,%ebx
B793FF37 8bb42484000000 mov 0x84(%esp),%esi
B793FF3E 8b942488000000 mov 0x88(%esp),%edx
B793FF45 f6415030 testb $0x30,0x50(%ecx) <<< crash here
B793FF49 750b jne 0xb793ff56
B793FF4B 0fb64148 movzbl 0x48(%ecx),%eax
B793FF4F 83e0fb and $0xfffffffb,%eax
B793FF52 3c02 cmp $0x2,%al
B793FF54 750a jne 0xb793ff60
B793FF56 83c474 add $0x74,%esp
B793FF59 5b pop %ebx
B793FF5A 5e pop %esi
B793FF5B c3 ret
...
HTH but, sorry, I don't speak assembly's language...
Same behaviour with
BASS_ChannelSetSync(str, BASS_SYNC_END, 0, @EndSyncProc, Self);
or
BASS_ChannelSetSync(str, BASS_SYNC_END, 0, @EndSyncProc, pointer(0));
I test on an old machine with Linux Debian 7 32 bits, an old Lazarus 1.4.0 and BASS 2.4.15.1, and I have the same problem with a brand new machine running Linux Debian 10.6 64 bits, a last Lazarus 2.0.12 and BASS 2.4.16.7.
And there is no problem if I comment out that line.
Help welcome, have a nice day.
--
jp