From 506a6eb522d36d618bc4cacfae814b8222d120c2 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 1 Nov 2011 16:58:35 +0000 Subject: [PATCH] Fix delay loop condition in BPushGamesound test. It seems to work mostly fine. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43069 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../push_game_sound_test/push_game_sound_test.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/tests/kits/game/push_game_sound_test/push_game_sound_test.cpp b/src/tests/kits/game/push_game_sound_test/push_game_sound_test.cpp index f48b7044e5..3ebf3dbbbf 100644 --- a/src/tests/kits/game/push_game_sound_test/push_game_sound_test.cpp +++ b/src/tests/kits/game/push_game_sound_test/push_game_sound_test.cpp @@ -127,7 +127,7 @@ main(int argc, char *argv[]) & media_raw_audio_format::B_AUDIO_SIZE_MASK); size_t decodedSize = 0; size_t partPos = 0; - size_t pos = pushGameSound.CurrentPosition(); + size_t pos = 0; /*pushGameSound.CurrentPosition();*/ key_info keyInfo; while (true) { @@ -159,6 +159,7 @@ main(int argc, char *argv[]) printf("\rtime: %.2f", (double)mediaTrack->CurrentTime() / 1000000LL); fflush(stdout); + continue; } @@ -168,9 +169,11 @@ main(int argc, char *argv[]) if (bufferSize <= pos) pos = 0; - // playback sync - while (pushGameSound.CurrentPosition() == pos) - snooze(100); + // playback sync - wait for the buffer part we're about to fill to be + // played + while (pushGameSound.CurrentPosition() >= pos + bufferPartSize + || pushGameSound.CurrentPosition() < pos) + snooze(1000 * framesPerBufferPart / gsFormat.frame_rate); // check escape key state if (get_key_info(&keyInfo) != B_OK) {