bazz

vgmplay mac osx patch

Aug 27th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.77 KB | None | 0 0
  1. diff --git a/VGMPlay/ChipMapper.c b/VGMPlay/ChipMapper.c
  2. index 0c27432..a16d238 100644
  3. --- a/VGMPlay/ChipMapper.c
  4. +++ b/VGMPlay/ChipMapper.c
  5. @@ -17,11 +17,21 @@
  6.  #else
  7.  #ifndef DISABLE_HW_SUPPORT
  8.  #include <unistd.h>
  9. +#ifdef __APPLE__
  10. +#include <architecture/i386/io.h>
  11. +#else
  12.  #include <sys/io.h>
  13. +#endif /* __APPLE__ */
  14.  #endif
  15.  #include <time.h>
  16.  #endif
  17.  
  18. +#ifdef __APPLE__
  19. +#define ioperm(x,y,z) 0
  20. +#define outb(x,y) 0
  21. +#define inb(x) 0
  22. +#endif
  23. +
  24.  #include "chips/mamedef.h"
  25.  
  26.  #include "chips/ChipIncl.h"
  27. diff --git a/VGMPlay/Makefile b/VGMPlay/Makefile
  28. index 0de15b5..b3099a1 100644
  29. --- a/VGMPlay/Makefile
  30. +++ b/VGMPlay/Makefile
  31. @@ -8,11 +8,18 @@
  32.  # TODO: Make this look less horrible.
  33.  # TODO: Make it not include pt_ioctl.c when DISABLE_HW_SUPPORT is active.
  34.  
  35. +# Uncomment if you build on Mac OSX
  36. +MACOSX = 1
  37. +
  38.  # Uncomment if you build on Windows using MinGW.
  39.  #WINDOWS = 1
  40.  
  41.  # Uncomment if you want to use libao instead of OSS for sound streaming under Linux
  42.  USE_LIBAO = 1
  43. +# Mac requires libAO
  44. +ifdef MACOSX
  45. +USE_LIBAO = 1
  46. +endif
  47.  
  48.  CC = gcc
  49.  PREFIX = /usr/local
  50. @@ -43,6 +50,11 @@ LDFLAGS := -lm -lz $(LDFLAGS)
  51.  ifdef WINDOWS
  52.  # for Windows, add kernel32 and winmm (Multimedia APIs)
  53.  LDFLAGS += -lkernel32 -lwinmm
  54. +else MACOSX
  55. +CFLAGS += -I/usr/include/malloc
  56. +MAINFLAGS += -pthread -DSHARE_PREFIX=\"$(PREFIX)\"
  57. +# Mac requires libAO
  58. +LDFLAGS += -lao
  59.  else
  60.  # for Linux, add librt (clock stuff) and libpthread (threads)
  61.  LDFLAGS += -lrt -lpthread -pthread
  62. diff --git a/VGMPlay/Stream.c b/VGMPlay/Stream.c
  63. index b24cac2..2bb58ae 100644
  64. --- a/VGMPlay/Stream.c
  65. +++ b/VGMPlay/Stream.c
  66. @@ -16,6 +16,8 @@
  67.  #include <fcntl.h>
  68.  #ifdef __NetBSD__
  69.  #include <sys/audioio.h>
  70. +#elif defined(__APPLE__)
  71. +// nothing
  72.  #else
  73.  #include <linux/soundcard.h>
  74.  #endif
  75. diff --git a/VGMPlay/VGMPlay.c b/VGMPlay/VGMPlay.c
  76. index c24e8ae..93e1d95 100644
  77. --- a/VGMPlay/VGMPlay.c
  78. +++ b/VGMPlay/VGMPlay.c
  79. @@ -44,7 +44,27 @@
  80.  #else  //ifdef UNIX
  81.  #include <limits.h>        // for PATH_MAX
  82.  #include <pthread.h>   // for pthread functions
  83. +
  84. +// (suitable?) Apple substitute for clock_gettime()
  85. +#ifdef __MACH__
  86. +#include <mach/mach_time.h>
  87. +#define CLOCK_REALTIME 0
  88. +#define CLOCK_MONOTONIC 0
  89. +int clock_gettime(int clk_id, struct timespec *t){
  90. +    mach_timebase_info_data_t timebase;
  91. +    mach_timebase_info(&timebase);
  92. +    uint64_t time;
  93. +    time = mach_absolute_time();
  94. +    double nseconds = ((double)time * (double)timebase.numer)/((double)timebase.denom);
  95. +    double seconds = ((double)time * (double)timebase.numer)/((double)timebase.denom * 1e9);
  96. +    t->tv_sec = seconds;
  97. +    t->tv_nsec = nseconds;
  98. +    return 0;
  99. +}
  100. +#else
  101.  #include <time.h>      // for clock_gettime()
  102. +#endif
  103. +
  104.  #include <unistd.h>        // for usleep()
  105.  
  106.  #define MAX_PATH   PATH_MAX
Advertisement
Add Comment
Please, Sign In to add comment