views:

50

answers:

1

Hi all,

I load my music track using SDL_mixer function:

Mix_Music * SDLCALL Mix_LoadMUS(const char *file);

For synchronization with video I need to know current music position. How can I determine this?

A: 

SDL doesn't seem to expose an easy hook for what you want. Once you trigger Mix_PlayMusic you have a hook to be notified when the music is done playing with Mix_HookMusicFinished, but that's about it.

You could use a completely independent clock mechanism for the video, and trust that the timing is going to "just line up" (e.g. if it's a 4 minute song, it will be done playing exactly 4 minutes after you call play). But since I doubt you're developing for a Real-Time OS, the results won't be ideal.

It might be possible for you to install a hook via Mix_SetPostMix. The "effect" you'd install wouldn't actually be for modifying the audio stream, but just keeping tabs on how many samples have been played and do corrections to the video accordingly. (Just thinking out loud here.)

Hostile Fork