Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. void BenchmarkCallback(void* userdata, Uint8* stream, int len)
  2. {
  3.     SDL_AudioSpec* spec = (SDL_AudioSpec*) userdata;
  4.     uint32_t SamplesWritten = len / (spec->size / spec->samples);
  5.     memset(stream, 0x10, len);
  6.     if (SecondDone)
  7.         ; /* Don't update anything anymore! */
  8.     else if (AlmostDone) {
  9.         if (--AlmostDone == 0) {
  10.             clock_gettime(CLOCK_MONOTONIC, &EndTime);
  11.             SecondDone = true;
  12.         }
  13.     } else if (SamplesWritten >= SamplesRemaining) {
  14.         SamplesRemaining = 0;
  15.         /* We are almost done, but we must wait for SDL to request 2 more
  16.          * buffers via this callback, because only then will we know that
  17.          * everything has actually played. */
  18.         AlmostDone = 2;
  19.     } else {
  20.         SamplesRemaining -= SamplesWritten;
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement