1. anatoly techtonik
  2. audiosocket

Commits

anatoly techtonik  committed d0b0a97

100% CPU: This commit adds a counter that show how many checks for
the end of buffer playback is made every time a new block
is scheduled.

On my machine (Ubuntu+Wine) 5 blocks result in about 150000 checks
each with total ~750000 check for a 3 seconds long sample, which is
~250000 checks per second. There should be only one.

  • Participants
  • Parent commits cf5b6c9
  • Branches default

Comments (0)

Files changed (1)

File audiosocket.py

View file
         self._schedule_block(data, self.headers[i])
 
       debug("waiting for block %d" % curblock)
+
+      # waiting until buffer playback is finished by constantly polling
+      # its status eats 100% CPU time. this counts how many checks are made
+      pollsnum = 0
+
       while True:
+        pollsnum += 1
         # unpreparing the header fails until the block is played
         ret = winmm.waveOutUnprepareHeader(
                 self.hwaveout,
         if ret != MMSYSERR_NOERROR:
           sys.exit('Error: waveOutUnprepareHeader failed with code 0x%x' % ret)
         break
+      print "%s checks" % pollsnum
 
       # Switch waiting pointer to the next block
       curblock = (curblock + 1) % len(self.headers)