diff options
| author | Fabien Costantini <fabien@onepost.net> | 2014-05-21 04:10:12 +0000 |
|---|---|---|
| committer | Fabien Costantini <fabien@onepost.net> | 2014-05-21 04:10:12 +0000 |
| commit | 54b0123eab05295c4f510692bef48c0ac7618607 (patch) | |
| tree | bacc68bc8db89fba29363b8e8d0e8bfc57cea4ba /test | |
| parent | 2c820fd53dad8a753721a9a4ff5d8daced7345ee (diff) | |
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
Diffstat (limited to 'test')
| -rw-r--r-- | test/sudoku.cxx | 13 |
1 files changed, 7 insertions, 6 deletions
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, |
