HMUSIC channel position

Started by Irrational86, 6 Aug '03 - 21:42

Irrational86

Hi, this is my code to get the MOD position 2 seconds before the end of the MOD.
var y: Int64;

y := Trunc(BASS_ChannelBytes2Seconds(ChanHandle, BASS_MusicGetLength(ChanHandle, True))) - 2;

BASS_ChannelSetPosition(ChanHandle, MAKELONG(y, $FFFF));

y := BASS_ChannelGetPosition(ChanHandle);
The value that y gets at the end is 0, why!? I dont understand, first y gets the right time in seconds, then i set it as the position, and i try to assign the new position to y and it returns 0...please help

podobo

I believe I had a similar problem before.. and the solution was to call BASS_MusicPreBuf on the channel right after setting the position.  The new position didn't seem to register until either playback or prebuffering started.


Irrational86

Thanks a lot podobo, the PreBuf function did the work...thank you...


Now this is for Ian. I set a BASS_SYNC_SLIDE and if its a stream, and i call BASS_StreamFree from inside the callback, the program crashes. If its a MOD file, the BASS_MusicFree doesnt crash, but instead it crashes on BASS_Free...Ian, why??

Ian @ un4seen

hmm... there shouldn't be any problem using BASS_StreamFree or BASS_MusicFree within a sync callback (I ran a quick test here, and it was fine). Does it crash every time, and can you provide details (eg. location, registers, callstack) of the crashes?

Irrational86

#4
Ok ummm...it only gives an Access Violation while running under the delphi IDE, if running alone it does not give any errors. Below are links to the screenshots of ASM code and addresses of error, etc...hope you can help...

1. The MessageBox saying the error
2. The code i use inside the SYNC_SLIDE callback
3. A piece of ASM code during the access violation
4. The rest of the ASM code after the violation

PS. Using the method i have commented out (the BeginThread one) it works perfectly fine...

Ian @ un4seen

Actually, thinking about it... the BASS_SLIDE_SYNC is a sort of "mixtime" sync, so it's not really 100% safe to free the channel in the callback - it'll work fine in some circumstances, but not in others.

I'll send an update to try, with a work-around specifically for slide syncs, allowing the callback to free the channel in all circumstances.

Irrational86

Yup...the update did the trick Ian, thanks a lot.. ;)