From 54b0123eab05295c4f510692bef48c0ac7618607 Mon Sep 17 00:00:00 2001 From: Fabien Costantini Date: Wed, 21 May 2014 04:10:12 +0000 Subject: Added a new portable sleep API(ABI compatible). Now features a flexible multi-usage sleep() api accepting decimals, msleep() for millisecs only, usleep() for microsecs. Updated Makefiles, cmakefiles, vs2008, vs2010 with the new Fl_sleep add-on. Documented new API. still needs to be added in Xcode. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10150 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- test/sudoku.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'test/sudoku.cxx') diff --git a/test/sudoku.cxx b/test/sudoku.cxx index 27677b3e9..6eadbcb6a 100644 --- a/test/sudoku.cxx +++ b/test/sudoku.cxx @@ -418,18 +418,19 @@ SudokuSound::audio_cb(AudioDeviceID device, } #endif // __APPLE__ +#define NOTE_DURATION_MS 50 // Play a note for 250ms... void SudokuSound::play(char note) { Fl::check(); - + #ifdef __APPLE__ // Point to the next note... data = sample_data[note - 'A']; remaining = sample_size * 2; // Wait for the sound to complete... - usleep(50000); + Fl::msleep(NOTE_DURATION_MS); #elif defined(WIN32) if (sample_size) { @@ -437,8 +438,8 @@ void SudokuSound::play(char note) { waveOutWrite(device, header_ptr, sizeof(WAVEHDR)); - Sleep(50); - } else Beep(frequencies[note - 'A'], 50); + Fl::msleep(NOTE_DURATION_MS); + } else Beep(frequencies[note - 'A'], NOTE_DURATION_MS); #else # ifdef HAVE_ALSA_ASOUNDLIB_H @@ -448,7 +449,7 @@ void SudokuSound::play(char note) { snd_pcm_prepare(handle); snd_pcm_writei(handle, sample_data[note - 'A'], sample_size); } - usleep(50000); + Fl::msleep(NOTE_DURATION_MS); return; } # endif // HAVE_ALSA_ASOUNDLIB_H @@ -463,7 +464,7 @@ void SudokuSound::play(char note) { // Sound a tone for the given note... control.bell_percent = 100; control.bell_pitch = frequencies[note - 'A']; - control.bell_duration = 50; + control.bell_duration = NOTE_DURATION_MS; XChangeKeyboardControl(fl_display, KBBellPercent | KBBellPitch | KBBellDuration, -- cgit v1.2.3