diff options
author | Chris Robinson <[email protected]> | 2015-12-04 19:09:48 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2015-12-04 19:09:48 -0800 |
commit | 482372577e6eaa9f4b857dc3a335e67efd1ee367 (patch) | |
tree | 0c025eae5873f32d1dcf641a675c3d95a4eb1dd3 | |
parent | 4e6acfa0d549281efcbe8293d95b76a37deb370d (diff) |
Avoid using usleep in the examples
We already have an al_nssleep wrapper in the common lib we can use.
-rw-r--r-- | CMakeLists.txt | 15 | ||||
-rw-r--r-- | examples/alhrtf.c | 2 | ||||
-rw-r--r-- | examples/allatency.c | 2 | ||||
-rw-r--r-- | examples/alloopback.c | 2 | ||||
-rw-r--r-- | examples/alreverb.c | 2 | ||||
-rw-r--r-- | examples/alstream.c | 2 | ||||
-rw-r--r-- | examples/altonegen.c | 2 | ||||
-rw-r--r-- | examples/common/alhelpers.h | 10 |
8 files changed, 18 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f3651dcc..126364d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1230,27 +1230,32 @@ IF(ALSOFT_EXAMPLES) ${SDL_SOUND_INCLUDE_DIR}) ADD_EXECUTABLE(alstream examples/alstream.c) - TARGET_LINK_LIBRARIES(alstream ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ${LIBNAME}) + TARGET_LINK_LIBRARIES(alstream ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} + common ${LIBNAME}) SET_PROPERTY(TARGET alstream APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}) ADD_EXECUTABLE(alreverb examples/alreverb.c) - TARGET_LINK_LIBRARIES(alreverb ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ${LIBNAME}) + TARGET_LINK_LIBRARIES(alreverb ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} + common ${LIBNAME}) SET_PROPERTY(TARGET alreverb APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}) ADD_EXECUTABLE(allatency examples/allatency.c) - TARGET_LINK_LIBRARIES(allatency ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ${LIBNAME}) + TARGET_LINK_LIBRARIES(allatency ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} + common ${LIBNAME}) SET_PROPERTY(TARGET allatency APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}) ADD_EXECUTABLE(alloopback examples/alloopback.c) - TARGET_LINK_LIBRARIES(alloopback ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ${LIBNAME}) + TARGET_LINK_LIBRARIES(alloopback ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} + common ${LIBNAME}) SET_PROPERTY(TARGET alloopback APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}) ADD_EXECUTABLE(alhrtf examples/alhrtf.c) - TARGET_LINK_LIBRARIES(alhrtf ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ${LIBNAME}) + TARGET_LINK_LIBRARIES(alhrtf ex-common ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} + common ${LIBNAME}) SET_PROPERTY(TARGET alhrtf APPEND PROPERTY INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}) diff --git a/examples/alhrtf.c b/examples/alhrtf.c index 6dac5308..b18a5115 100644 --- a/examples/alhrtf.c +++ b/examples/alhrtf.c @@ -227,7 +227,7 @@ int main(int argc, char **argv) angle = 0.0; alSourcePlay(source); do { - Sleep(10); + al_nssleep(10000000); /* Rotate the source around the listener by about 1/4 cycle per second. * Only affects mono sounds. diff --git a/examples/allatency.c b/examples/allatency.c index deb13d3b..afef43ca 100644 --- a/examples/allatency.c +++ b/examples/allatency.c @@ -182,7 +182,7 @@ int main(int argc, char **argv) /* Play the sound until it finishes. */ alSourcePlay(source); do { - Sleep(10); + al_nssleep(10000000); alGetSourcei(source, AL_SOURCE_STATE, &state); /* Get the source offset and latency. AL_SEC_OFFSET_LATENCY_SOFT will diff --git a/examples/alloopback.c b/examples/alloopback.c index 04c92818..c5dee36d 100644 --- a/examples/alloopback.c +++ b/examples/alloopback.c @@ -216,7 +216,7 @@ int main(int argc, char *argv[]) /* Play the sound until it finishes. */ alSourcePlay(source); do { - Sleep(10); + al_nssleep(10000000); alGetSourcei(source, AL_SOURCE_STATE, &state); } while(alGetError() == AL_NO_ERROR && state == AL_PLAYING); diff --git a/examples/alreverb.c b/examples/alreverb.c index 420b1c55..7d2bb343 100644 --- a/examples/alreverb.c +++ b/examples/alreverb.c @@ -311,7 +311,7 @@ int main(int argc, char **argv) /* Play the sound until it finishes. */ alSourcePlay(source); do { - Sleep(10); + al_nssleep(10000000); alGetSourcei(source, AL_SOURCE_STATE, &state); } while(alGetError() == AL_NO_ERROR && state == AL_PLAYING); diff --git a/examples/alstream.c b/examples/alstream.c index 2972d375..63478d6a 100644 --- a/examples/alstream.c +++ b/examples/alstream.c @@ -318,7 +318,7 @@ int main(int argc, char **argv) } while(UpdatePlayer(player)) - Sleep(10); + al_nssleep(10000000); /* All done with this file. Close it and go to the next */ ClosePlayerFile(player); diff --git a/examples/altonegen.c b/examples/altonegen.c index 65980529..74a04ee2 100644 --- a/examples/altonegen.c +++ b/examples/altonegen.c @@ -246,7 +246,7 @@ int main(int argc, char *argv[]) alSourcePlay(source); do { ALint pos; - Sleep(10); + al_nssleep(10000000); alGetSourcei(source, AL_SAMPLE_OFFSET, &pos); alGetSourcei(source, AL_SOURCE_STATE, &state); if(pos < last_pos && state == AL_PLAYING) diff --git a/examples/common/alhelpers.h b/examples/common/alhelpers.h index 62ed5be2..1b4d2fbf 100644 --- a/examples/common/alhelpers.h +++ b/examples/common/alhelpers.h @@ -1,18 +1,12 @@ #ifndef ALHELPERS_H #define ALHELPERS_H -#ifndef _WIN32 -#include <unistd.h> -#define Sleep(x) usleep((x)*1000) -#else -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#endif - #include "AL/alc.h" #include "AL/al.h" #include "AL/alext.h" +#include "threads.h" + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ |