Author Topic: Problem with metadata SYNCPROC  (Read 4427 times)

Jimbo

  • Posts: 10
Problem with metadata SYNCPROC
« on: 24 Jul '03 - 02:09 »
I've recently been trying out the internet file streaming feature, and have run across an intermittent bug. I'm using a simple SYNCPROC to notify me of any changes to the metadata, which works fine most of the time:

void CALLBACK metadataSyncProc(HSYNC handle, DWORD channel, DWORD data, DWORD user)
{
 char *tags=(char*)data;
 while(tags&&*tags)
 {
   // Do stuff with the Ogg comments
   tags+=strlen(tags)+1;
 }
}

My program is occasionally locking up when playing an Ogg stream, and I managed to track down the problem to the callback function. Is it always guaranteed that any series of Ogg comments will be terminated with a double null? If not, then that would explain the problem (although I don't know what the solution would be in such a case).

By the way, I'm using the Virgin Radio streams to test with:
http://www.virginradio.co.uk/thestation/listen/ogg.html

Worth a listen :)

Thanks,
Jim

Ian @ un4seen

  • Administrator
  • Posts: 23386
Re: Problem with metadata SYNCPROC
« Reply #1 on: 25 Jul '03 - 13:38 »
Quote
Is it always guaranteed that any series of Ogg comments will be terminated with a double null?

Yes, it is :)

By "locking up", do you mean your app stops responding to key presses/etc? If so, I don't think that'd be a problem in the callback, as that is executed in a BASS thread - not your app's main thread. Unless it's the "// Do stuff with the Ogg comments" bit causing trouble - what happens if you remove that?

Jimbo

  • Posts: 10
Re: Problem with metadata SYNCPROC
« Reply #2 on: 25 Jul '03 - 18:26 »
Yep, the program just stops responding, and keeps looping the last chunk of data in the buffer until I kill it.

I'm not doing too much in the callback, just searching the string data for artist/title comments, and updating the title text in my main program window at the end.

I did try the callback with the bare minimum of code as given above, and I still got the same problem. I then added some code to write to a logfile, and was able to see when the function was being called, but not exiting. It would get the artist and title tags, but the next call to strlen() would cause the program to freeze.

This only happens very occasionally, say once in every 100 function calls, and I've only ever noticed it while I was playing a game, so it only seems to happen under a heavy CPU load.

It's really got me stumped. If I had any straws to grasp, I'd grasp them ;)

Jim

Jimbo

  • Posts: 10
Re: Problem with metadata SYNCPROC
« Reply #3 on: 25 Jul '03 - 23:33 »
Well, I seem to have fixed things by using PostMessage in the callback proc, then using BASS_StreamGetTags to get the tags later:

void CALLBACK metadataSyncProc(HSYNC handle, DWORD channel, DWORD data, DWORD user)
{
CView* pMyView=(CView*)user;
pMyView->PostMessage(UPDATETAGS);
}

I'm still not sure what the problem was, but naturally enough it was nothing to do with the BASS library ;D

Thanks,
Jim

Ian @ un4seen

  • Administrator
  • Posts: 23386
Re: Problem with metadata SYNCPROC
« Reply #4 on: 26 Jul '03 - 13:32 »
Ah well, all's well that ends well :)

Btw, you could use a message sync - cut out the middle man ;D
Code: [Select]
BASS_ChannelSetSync(channel,BASS_SYNC_META|BASS_SYNC_MESSAGE,0,(SYNCPROC)UPDATETAGS,0);