Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. multimedia timers synchronization

multimedia timers synchronization

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
12 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anilaabc
    wrote on last edited by
    #1

    we have four threads which have to call with milliseconds interval (66.67ms,200ms,10ms,100ms these are time intervals for resuming threads) "windows timers" does not provide accuracy (perfect) by using windows timers results are not well accurate but if we use multimedia timers then there is problem of synchronization. processor does not takes windows event (mean mouse click or key pressed or repaint window etc etc these event take log time of interval to process ) we need much accuracy and fast user intraction with my application (mean click and key press etc etc) what can be solution? and how can sychronize windows events with multimedia timers??

    S 1 Reply Last reply
    0
    • A anilaabc

      we have four threads which have to call with milliseconds interval (66.67ms,200ms,10ms,100ms these are time intervals for resuming threads) "windows timers" does not provide accuracy (perfect) by using windows timers results are not well accurate but if we use multimedia timers then there is problem of synchronization. processor does not takes windows event (mean mouse click or key pressed or repaint window etc etc these event take log time of interval to process ) we need much accuracy and fast user intraction with my application (mean click and key press etc etc) what can be solution? and how can sychronize windows events with multimedia timers??

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      Are you trying to pass multimedia timer events into your window handling code or the other way round? If it's the first option and you're using timerSetEvent, you could do this:

      1. For each timer events, create a kernel event.
      2. Create the the timer event using the flag TIME_CALLBACK_EVENT_SET and pass the kernel event handle as the callback procedure.
      3. Create a thread with a function that (in a loop) does a WaitForMultipleObjects, waiting for any one of the kernel events set by the timers.
      4. When an event is detected in the thread function, POST a window message as appropriate.

      The general pattern of setting kernel events with timer events allows you to transfer the timer event into another thread. BTW - do you realise that the multimedia timer API is obsolete and could easily disappear soon? You might be better off using timer queues (see this article for a description[^]) that, as far as I can tell, have the same resolution and accuracy as multimedia timers. Also, it looks like they're better tied into the Windows synchronisation functionality.

      M 1 Reply Last reply
      0
      • S Stuart Dootson

        Are you trying to pass multimedia timer events into your window handling code or the other way round? If it's the first option and you're using timerSetEvent, you could do this:

        1. For each timer events, create a kernel event.
        2. Create the the timer event using the flag TIME_CALLBACK_EVENT_SET and pass the kernel event handle as the callback procedure.
        3. Create a thread with a function that (in a loop) does a WaitForMultipleObjects, waiting for any one of the kernel events set by the timers.
        4. When an event is detected in the thread function, POST a window message as appropriate.

        The general pattern of setting kernel events with timer events allows you to transfer the timer event into another thread. BTW - do you realise that the multimedia timer API is obsolete and could easily disappear soon? You might be better off using timer queues (see this article for a description[^]) that, as far as I can tell, have the same resolution and accuracy as multimedia timers. Also, it looks like they're better tied into the Windows synchronisation functionality.

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        Stuart Dootson wrote:

        do you realise that the multimedia timer API is obsolete and could easily disappear soon?

        Hi Stuart, Where did you hear that? Link? Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        C S 2 Replies Last reply
        0
        • M Mark Salsbery

          Stuart Dootson wrote:

          do you realise that the multimedia timer API is obsolete and could easily disappear soon?

          Hi Stuart, Where did you hear that? Link? Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          C Online
          C Online
          CPallini
          wrote on last edited by
          #4

          Mark Salsbery wrote:

          Hi Stuart, Where did you hear that?

          I told him. ;) :-D

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          M 1 Reply Last reply
          0
          • C CPallini

            Mark Salsbery wrote:

            Hi Stuart, Where did you hear that?

            I told him. ;) :-D

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            So where did YOU hear that? ;P I don't see any indication that the multimedia timer APIs are deprecated. Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            C 1 Reply Last reply
            0
            • M Mark Salsbery

              So where did YOU hear that? ;P I don't see any indication that the multimedia timer APIs are deprecated. Mark

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              C Online
              C Online
              CPallini
              wrote on last edited by
              #6

              Mark Salsbery wrote:

              So where did YOU hear that

              If I remember well, Stuart Dootson told me. :rolleyes:

              Mark Salsbery wrote:

              I don't see any indication that the multimedia timer APIs are deprecated.

              Because we should keep it secret. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              M S 2 Replies Last reply
              0
              • C CPallini

                Mark Salsbery wrote:

                So where did YOU hear that

                If I remember well, Stuart Dootson told me. :rolleyes:

                Mark Salsbery wrote:

                I don't see any indication that the multimedia timer APIs are deprecated.

                Because we should keep it secret. :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                CPallini wrote:

                Because we should keep it secret.

                ok. shhhhh :)

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                1 Reply Last reply
                0
                • M Mark Salsbery

                  Stuart Dootson wrote:

                  do you realise that the multimedia timer API is obsolete and could easily disappear soon?

                  Hi Stuart, Where did you hear that? Link? Mark

                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                  S Offline
                  S Offline
                  Stuart Dootson
                  wrote on last edited by
                  #8

                  That's what I read into this page[^]. Looking at Larry Osterman's blog post[^] again, it's just timeSetEvent and timeKillEvent.

                  M 1 Reply Last reply
                  0
                  • S Stuart Dootson

                    That's what I read into this page[^]. Looking at Larry Osterman's blog post[^] again, it's just timeSetEvent and timeKillEvent.

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    Excellent! Thank you :) Mark

                    Mark Salsbery Microsoft MVP - Visual C++ :java:

                    1 Reply Last reply
                    0
                    • C CPallini

                      Mark Salsbery wrote:

                      So where did YOU hear that

                      If I remember well, Stuart Dootson told me. :rolleyes:

                      Mark Salsbery wrote:

                      I don't see any indication that the multimedia timer APIs are deprecated.

                      Because we should keep it secret. :)

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                      [My articles]

                      S Offline
                      S Offline
                      Stuart Dootson
                      wrote on last edited by
                      #10

                      CPallini wrote:

                      Because we should keep it secret

                      But now you've let the cat out of the bag!!! The boys'll be round to sort you out ;)

                      M C 2 Replies Last reply
                      0
                      • S Stuart Dootson

                        CPallini wrote:

                        Because we should keep it secret

                        But now you've let the cat out of the bag!!! The boys'll be round to sort you out ;)

                        M Offline
                        M Offline
                        Mark Salsbery
                        wrote on last edited by
                        #11

                        It's only me....I won't tell anyone!

                        Mark Salsbery Microsoft MVP - Visual C++ :java:

                        1 Reply Last reply
                        0
                        • S Stuart Dootson

                          CPallini wrote:

                          Because we should keep it secret

                          But now you've let the cat out of the bag!!! The boys'll be round to sort you out ;)

                          C Online
                          C Online
                          CPallini
                          wrote on last edited by
                          #12

                          Wow the cat is out, hence is alive: we should tell to Mr. Schroedinger... (or is the above another secret?) :-D

                          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                          [My articles]

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups