Author Topic: HMUSIC channel position  (Read 8550 times)

Irrational86

  • Posts: 960
HMUSIC channel position
« on: 6 Aug '03 - 21:42 »
Hi, this is my code to get the MOD position 2 seconds before the end of the MOD.
Code: [Select]
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
« Last Edit: 6 Aug '03 - 21:44 by XMinioNX »

podobo

  • Posts: 59
Re: HMUSIC channel position
« Reply #1 on: 6 Aug '03 - 22:24 »
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

  • Posts: 960
Re: HMUSIC channel position
« Reply #2 on: 7 Aug '03 - 02:21 »
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

  • Administrator
  • Posts: 26083
Re: HMUSIC channel position
« Reply #3 on: 7 Aug '03 - 12:52 »
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

  • Posts: 960
Re: HMUSIC channel position
« Reply #4 on: 7 Aug '03 - 22:55 »
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...
« Last Edit: 7 Aug '03 - 23:07 by XMinioNX »

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: HMUSIC channel position
« Reply #5 on: 8 Aug '03 - 16:40 »
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

  • Posts: 960
Re: HMUSIC channel position
« Reply #6 on: 8 Aug '03 - 18:29 »
Yup...the update did the trick Ian, thanks a lot.. ;)