Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


DirectMusic timing

This topic is 6181 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Has anyone successfully used the AdvisePeriodic() timing function originating from DirectMusic? I''m having real trouble getting the semaphore to do anything useful. Here''s the code: sound_sem = CreateSemaphore(NULL, 5, 10, NULL); if (sound_sem == NULL) fprintf(stderr, "Error creating semaphore\n"); CoInitialize(NULL); if (CoCreateInstance(CLSID_SystemClock, NULL, CLSCTX_INPROC, IID_IReferenceClock, (LPVOID*)&pRefClock) != S_OK) fprintf(stderr, "Error initialising COM\n"); if (pRefClock->AdvisePeriodic(1, 166667, sound_sem, &sound_timer) != S_OK) fprintf(stderr, "Error creating timer\n"); for (; { WaitForSingleObject(sound_sem); do_whatever(); } Unfortunately the timer appears to do nothing, at least the way this is coded. Can anyone please help? Thanks in advance! Alex.

Share this post

Link to post
Share on other sites
It seems to work OK in DirectX 8.1 I don''t know if there were problems in previous versions.

Your WaitForSingleObject call is invalid - You''re missing the 2nd parameter. I assume you are using INFINITE just to see if it returns at all.

Just to clarify the problem: If you breakpoint the WaitForSingleObject call and then single-step over it does the app just hang there?


Share this post

Link to post
Share on other sites
I incorrectly made the assumption that WaitForSingleObject() would only return _after_ the time I specified in AdvisePeriodic(). However it should check for WAIT_OBJECT_0. The code should read:

if (WaitForSingleObject(sound_sem, 0) == WAIT_OBJECT_0)
Thanks for responding though.


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!