Replace direct use of usleep()

master
Cameron Cawley 5 years ago committed by Ozkan Sezer
parent 4161197698
commit 8752414fa8
  1. 4
      Makefile.os2
  2. 4
      Makefile.w32
  3. 4
      configure.ac
  4. 7
      src/Makefile.am
  5. 2
      src/common.h
  6. 61
      src/delay.c
  7. 2
      src/main.c
  8. 3
      src/sound_coreaudio.c
  9. 2
      src/watcom/unistd.h
  10. 14
      src/watcom/usleep.c
  11. 2
      src/win32/unistd.h
  12. 48
      src/win32/usleep.c
  13. 8
      vc/xmp.vcproj

@ -32,14 +32,14 @@ CFLAGS+= -5s
AOUT=xmp.exe
COMPILE=$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES)
OBJ = commands.obj getopt_long.obj info.obj main.obj options.obj read_config.obj sound.obj sound_aiff.obj sound_file.obj sound_null.obj sound_wav.obj sound_dart.obj terminal.obj usleep.obj
OBJ = commands.obj delay.obj getopt_long.obj info.obj main.obj options.obj read_config.obj sound.obj sound_aiff.obj sound_file.obj sound_null.obj sound_wav.obj sound_dart.obj terminal.obj
all: $(AOUT)
$(AOUT): $(OBJ)
wlink N $(AOUT) SYS OS2V2 OP QUIET LIBR {$(LIBS)} F {$(OBJ)}
.c: src;src/watcom
.c: src
.c.obj:
$(COMPILE) -fo=$^@ $<

@ -32,14 +32,14 @@ CFLAGS+= -5s
AOUT=xmp.exe
COMPILE=$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES)
OBJ = commands.obj getopt_long.obj info.obj main.obj options.obj read_config.obj sound.obj sound_aiff.obj sound_file.obj sound_null.obj sound_wav.obj sound_win32.obj terminal.obj usleep.obj
OBJ = commands.obj delay.obj getopt_long.obj info.obj main.obj options.obj read_config.obj sound.obj sound_aiff.obj sound_file.obj sound_null.obj sound_wav.obj sound_win32.obj terminal.obj
all: $(AOUT)
$(AOUT): $(OBJ)
wlink N $(AOUT) SYS NT OP QUIET LIBR {$(LIBS)} F {$(OBJ)}
.c: src;src/win32
.c: src
.c.obj:
$(COMPILE) -fo=$^@ $<

@ -96,7 +96,7 @@ AC_DEFUN([AC_CHECK_DEFINED],[
AS_VAR_POPDEF([ac_var])dnl
])
AC_CHECK_HEADERS([getopt.h signal.h sys/time.h sys/audioio.h])
AC_CHECK_HEADERS([getopt.h signal.h sys/select.h sys/time.h sys/audioio.h])
case $host_os in
dnl don't check half-baked termios for amiga or dos targets.
amigaos*|aros*|morphos*|*djgpp) ;;
@ -265,6 +265,6 @@ XMP_TRY_COMPILE(whether compiler understands -Wunused-result,
int main(){}],
CFLAGS="${CFLAGS} -Wno-unused-result")
AC_CHECK_FUNCS(kill getopt_long)
AC_CHECK_FUNCS(kill getopt_long usleep select)
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT

@ -7,8 +7,8 @@ AM_CFLAGS = -Wall
bin_PROGRAMS = xmp
xmp_SOURCES = \
commands.c common.h getopt_long.h list.h getopt_long.c info.c main.c \
options.c read_config.c sound.c sound.h sound_file.c sound_null.c \
commands.c common.h delay.c getopt_long.h list.h getopt_long.c info.c \
main.c options.c read_config.c sound.c sound.h sound_file.c sound_null.c \
sound_wav.c sound_aiff.c terminal.c
xmp_LDADD = ${LIBXMP_LIBS}
xmp_LDFLAGS = ${XMP_DARWIN_LDFLAGS}
@ -96,5 +96,4 @@ pkgsysconfdir = ${sysconfdir}/${PACKAGE_NAME}
pkgsysconf_DATA = modules.conf xmp.conf
EXTRA_DIST = ${man_MANS} ${pkgsysconf_DATA} \
win32/usleep.c win32/unistd.h \
watcom/usleep.c watcom/unistd.h
win32/unistd.h watcom/unistd.h

@ -77,6 +77,8 @@ extern struct player_mode pmode[];
int report(char *, ...);
void delay_ms(int msec);
/* option */
void get_options(int, char **, struct options *);
int read_config(struct options *);

@ -0,0 +1,61 @@
/* Extended Module Player
* Copyright (C) 1996-2016 Claudio Matsuoka and Hipolito Carraro Jr
*
* This file is part of the Extended Module Player and is distributed
* under the terms of the GNU General Public License. See the COPYING
* file for more information.
*/
#if defined(_WIN32)
#include <windows.h>
void delay_ms(int msec) {
Sleep(msec);
}
#elif defined(__OS2__)
#define INCL_DOSPROCESS
#include <os2.h>
void delay_ms(int msec) {
DosSleep(msec);
}
#elif defined(_DOS)
#include <dos.h>
void delay_ms(int msec) {
delay(msec); /* doesn't seem to use int 15h. */
}
#elif defined(HAVE_USLEEP)
#include <unistd.h>
void delay_ms(int msec) {
usleep(msec * 1000);
}
#elif defined(HAVE_SELECT)
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#else
# include <sys/time.h>
# include <sys/types.h>
# include <unistd.h>
#endif
#include <stddef.h>
void delay_ms(int msec) {
struct timeval tv;
long usec;
usec = msec * 1000;
tv.tv_sec = usec / 1000000;
tv.tv_usec = usec % 1000000;
select(0, NULL, NULL, NULL, &tv);
}
#else
#error Missing implementation of delay_ms()
#endif

@ -158,7 +158,7 @@ static void check_pause(xmp_context xc, struct control *ctl,
info_frame(mi, fi, ctl, 1);
}
while (ctl->pause) {
usleep(100000);
delay_ms(100);
read_command(xc, mi, ctl);
if (ctl->display) {
if (verbose) {

@ -10,7 +10,6 @@
#include <AudioUnit/AudioUnit.h>
#include <AudioToolbox/AudioToolbox.h>
#include <CoreServices/CoreServices.h>
#include <unistd.h>
#include "sound.h"
static AudioUnit au;
@ -230,7 +229,7 @@ static void play(void *b, int i)
/* block until we have enough free space in the buffer */
while (buf_free() < i)
usleep(100000);
delay_ms(100);
while (i) {
if ((j = write_buffer(b, i)) > 0) {

@ -3,6 +3,4 @@
#include <io.h> /* do not want Watcom unistd.h */
void usleep (unsigned long usec);
#endif

@ -1,14 +0,0 @@
#ifdef __OS2__
#define INCL_DOSPROCESS
#include <os2.h>
void usleep (unsigned long usec) {
DosSleep (usec / 1000);
}
#endif
#ifdef _DOS
#include <dos.h>
void usleep (unsigned long usec) {
delay (usec / 1000); /* doesn't seem to use int 15h. */
}
#endif

@ -3,6 +3,4 @@
#include <io.h>
void usleep(long usec);
#endif

@ -1,48 +0,0 @@
#ifndef HAVE_USLEEP
#ifdef HAVE_SELECT
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#else
# include <sys/time.h>
# include <sys/types.h>
# include <unistd.h>
#endif
void usleep(long usec)
{
struct timeval tv;
tv.tv_sec = usec / 1000000;
tv.tv_usec = usec % 1000000;
select(0, NULL, NULL, NULL, &tv);
}
#elif defined(_WIN32)
/* usleep implementation from FreeSCI */
#include <windows.h>
void usleep (long usec)
{
LARGE_INTEGER lFrequency;
LARGE_INTEGER lEndTime;
LARGE_INTEGER lCurTime;
QueryPerformanceFrequency (&lFrequency);
if (lFrequency.QuadPart) {
QueryPerformanceCounter (&lEndTime);
lEndTime.QuadPart += (LONGLONG) usec *
lFrequency.QuadPart / 1000000;
do {
QueryPerformanceCounter (&lCurTime);
Sleep(0);
} while (lCurTime.QuadPart < lEndTime.QuadPart);
}
}
#endif
#endif /* !HAVE_USLEEP */

@ -115,6 +115,10 @@
RelativePath="..\src\commands.c"
>
</File>
<File
RelativePath="..\src\delay.c"
>
</File>
<File
RelativePath="..\src\getopt_long.c"
>
@ -159,10 +163,6 @@
RelativePath="..\src\terminal.c"
>
</File>
<File
RelativePath="..\src\win32\usleep.c"
>
</File>
</Filter>
</Files>
<Globals>

Loading…
Cancel
Save