26 May '13 - 05:40 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: SYNCPROC callback never materialises  (Read 976 times)
sam7
Posts: 36


« on: 19 Sep '09 - 20:10 »
Reply with quoteQuote

Hi all,

I have a music player with a Seek slider. It uses a SYNCPROC (BASS_SYNC_END) callback when the song ends naturally and in that callback delegate the player is stopped and the Seek slider is reset etc.

This works fine 99% of the time, but every now and then the SyncEnd callback is never given, i.e. Sub SyncEndCallback (see code below) is never called, making the player appear to "hang", and the next playlist song never starts.

It is not a problem with any specific song file (MP3) because if you play that same file 10 times after that, it ends correctly. It appears to happen randomly.

I use a BassMix mixer stream for final output.

Does anybody have any ideas or advice perhaps, or maybe see an error in my code below?

Thanks a lot

'-module level
Public gMixer As Integer '-global BassMix MIXER channel

'-form level
Private strm As Integer
Private SyncEnd As SYNCPROC

'''
'-init strm and plug into mixer (gMixer has already been started)
strm = Bass.BASS_StreamCreateFile(CurrentSongPath, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT)
strm = BassFx.BASS_FX_TempoCreate(strm, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_FX_FREESOURCE)
BassMix.BASS_Mixer_StreamAddChannel(gMixer, strm, BASSFlag.BASS_STREAM_AUTOFREE Or BASSFlag.BASS_MIXER_FILTER)

'-set up synchronizer callback
SyncEnd = New SYNCPROC(AddressOf SyncEndCallback)
BassMix.BASS_Mixer_ChannelSetSync(strm, BASSSync.BASS_SYNC_END Or BASSSync.BASS_SYNC_ONETIME, 0, SyncEnd, IntPtr.Zero)

...
Private Sub SyncEndCallback(ByVal handle As Integer, ByVal channel As Integer, ByVal data As Integer, ByVal user As IntPtr)
  Player_Stop() '-stop player and reset slider etc
End Sub '-SyncEndCallback

Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #1 on: 21 Sep '09 - 14:34 »
Reply with quoteQuote

Are you certain that the SYNCPROC isn't getting called? From what you say (eg. "hang"), it sounds like it may be getting stuck inside the SYNCPROC, eg. a dead-lock scenario. To confirm whether that's the case, you could add some logging in the "SyncEndCallback" function, eg. log the entry before the "Player_Stop" call and log the exit afterwards.

Btw, what does the "Player_Stop" function look like? Please also confirm what you mean by "hang", eg. does the GUI become unresponsive?
Logged
sam7
Posts: 36


« Reply #2 on: 23 Sep '09 - 21:03 »
Reply with quoteQuote

Hi Ian,

To debug the problem, I changed the prog so the songs all start normally, one after the other, in the same Player (no fade out/in between 2 players). Then I let it play all of last night with short 1-minute songs, and in about 500 songs the problem never once occurred.

Point is, the fact that Sub SyncEndCallback is sometimes not reached when I use both Players must be a problem with my program, and NOT because BASS does not send the SyncEnd call.

My mistake. My apologies  Embarrassed

Thx a lot.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines