apparently, -DWIN_SOUND was to workaround cygwin not defining _WIN32. But we explicitely -D_WIN32. SMH.

Also, re-order a couple #if trees so SDL takes precedence over WIN32, etc.
This commit is contained in:
Kelvin Sherlock 2019-02-20 23:47:42 -05:00
parent adeb2006f7
commit 56528ab928
3 changed files with 21 additions and 25 deletions

View File

@ -203,7 +203,6 @@ if (DRIVER MATCHES "WIN32")
target_link_libraries(GSplus comdlg32 Shlwapi IPHlpApi target_link_libraries(GSplus comdlg32 Shlwapi IPHlpApi
winmm gdi32 dsound comctl32 ws2_32 shell32 winmm gdi32 dsound comctl32 ws2_32 shell32
) )
target_compile_definitions(GSplus PRIVATE WIN_SOUND)
endif() endif()
if (DRIVER MATCHES "SDL") if (DRIVER MATCHES "SDL")

View File

@ -32,8 +32,7 @@ int g_queued_nonsamps = 0;
int g_num_osc_interrupting = 0; int g_num_osc_interrupting = 0;
int g_sound_play_depth = 0; int g_sound_play_depth = 0;
/* Workaround - gcc in cygwin wasn't defining _WIN32, substituted WIN_SOUND instead */ #if defined(HPUX) || defined(__linux__) || defined(_WIN32) || defined(MAC) || defined(HAVE_SDL)
#if defined(HPUX) || defined(__linux__) || defined(WIN_SOUND) || defined(MAC) || defined(HAVE_SDL)
int g_audio_enable = -1; int g_audio_enable = -1;
#else #else
# if defined(OSS) # if defined(OSS)
@ -243,8 +242,7 @@ void sound_init() {
void sound_init_general() { void sound_init_general() {
/* Workaround - gcc in cygwin wasn't defining _WIN32 */ #if !defined(_WIN32) && !defined(MAC) && !defined(HAVE_SDL)
#if !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(MAC) && !defined(HAVE_SDL)
int pid; int pid;
int shmid; int shmid;
int tmp; int tmp;
@ -255,8 +253,7 @@ void sound_init_general() {
int size; int size;
int ret; int ret;
/* Workaround - gcc in cygwin wasn't defining _WIN32 */ #if !defined(_WIN32) && !defined(MAC) && !defined(HAVE_SDL)
#if !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(MAC) && !defined(HAVE_SDL)
if(!g_use_shmem) { if(!g_use_shmem) {
if(g_audio_enable < 0) { if(g_audio_enable < 0) {
printf("Defaulting audio off for slow X display\n"); printf("Defaulting audio off for slow X display\n");
@ -273,8 +270,7 @@ void sound_init_general() {
} }
size = SOUND_SHM_SAMP_SIZE * SAMPLE_CHAN_SIZE; size = SOUND_SHM_SAMP_SIZE * SAMPLE_CHAN_SIZE;
/* Workaround - gcc in cygwin wasn't defining _WIN32 */ #if !defined(_WIN32) && !defined(MAC) && !defined(HAVE_SDL)
#if !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(MAC) && !defined(HAVE_SDL)
shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | 0777); shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | 0777);
if(shmid < 0) { if(shmid < 0) {
printf("sound_init: shmget ret: %d, errno: %d\n", shmid, errno); printf("sound_init: shmget ret: %d, errno: %d\n", shmid, errno);
@ -303,8 +299,8 @@ void sound_init_general() {
g_sound_shm_addr = shmaddr; g_sound_shm_addr = shmaddr;
fflush(stdout); fflush(stdout);
/* Workaround - gcc in cygwin wasn't defining _WIN32 */
#if !defined(MAC) && !defined(WIN_SOUND) && !defined(__CYGWIN__) && !defined(HAVE_SDL) #if !defined(MAC) && !defined(_WIN32) && !defined(HAVE_SDL)
/* prepare pipe so parent can signal child each other */ /* prepare pipe so parent can signal child each other */
/* pipe[0] = read side, pipe[1] = write end */ /* pipe[0] = read side, pipe[1] = write end */
ret = pipe(&g_pipe_fd[0]); ret = pipe(&g_pipe_fd[0]);
@ -356,9 +352,9 @@ void sound_init_general() {
#else #else
# if defined (HAVE_SDL) # if defined (HAVE_SDL)
sdlsnd_init(shmaddr); sdlsnd_init(shmaddr);
# elif defined (WIN_SOUND) # elif defined (_WIN32)
win32snd_init(shmaddr); win32snd_init(shmaddr);
# elif defined (MAC) && !defined(HAVE_SDL) # elif defined (MAC)
macsnd_init(shmaddr); macsnd_init(shmaddr);
# endif # endif
#endif #endif
@ -419,13 +415,14 @@ void sound_shutdown() {
// OG stop sound and free memory on sound_shutdown // OG stop sound and free memory on sound_shutdown
sound_reset(g_cur_dcycs); sound_reset(g_cur_dcycs);
#ifdef WIN_SOUND /* Workaround - gcc in cygwin wasn't defining _WIN32 */
win32snd_shutdown(); #if defined(HAVE_SDL)
#elif defined(HAVE_SDL)
if((g_audio_enable != 0)) { if((g_audio_enable != 0)) {
//sdlsnd_shutdown(); //sdlsnd_shutdown();
sound_shutdown_sdl(); sound_shutdown_sdl();
} }
#elif defined(_WIN32)
win32snd_shutdown();
#else #else
if((g_audio_enable != 0) && g_pipe_fd[1] != 0) { if((g_audio_enable != 0) && g_pipe_fd[1] != 0) {
close(g_pipe_fd[1]); close(g_pipe_fd[1]);
@ -607,11 +604,11 @@ void send_sound(int real_samps, int size) {
} }
DOC_LOG("send_sound", -1, g_last_sound_play_dsamp, DOC_LOG("send_sound", -1, g_last_sound_play_dsamp,
(real_samps << 30) + size); (real_samps << 30) + size);
// Workaround - gcc in cygwin wasn't defining _WIN32
#if defined(WIN_SOUND) || defined(MAC) && !defined(HAVE_SDL) #if defined(HAVE_SDL)
child_sound_playit(tmp);
#elif defined(HAVE_SDL)
sound_write_sdl( real_samps, size); sound_write_sdl( real_samps, size);
#elif defined(_WIN32) || defined(MAC)
child_sound_playit(tmp);
#else #else
/* Although this looks like a big/little-endian issue, since the */ /* Although this looks like a big/little-endian issue, since the */
/* child is also reading an int, it just works with no byte swap */ /* child is also reading an int, it just works with no byte swap */

View File

@ -21,7 +21,7 @@ long sound_init_device_sdl();
# include <sys/soundcard.h> # include <sys/soundcard.h>
#endif #endif
#ifndef WIN_SOUND /* Workaround - gcc in cygwin wasn't defining _WIN32 */ #ifndef _WIN32
# include <sys/socket.h> # include <sys/socket.h>
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif
@ -77,9 +77,9 @@ void reliable_buf_write(word32 *shm_addr, int pos, int size) {
#if defined(HAVE_SDL) #if defined(HAVE_SDL)
//ret = sdl_send_audio(ptr, size); //ret = sdl_send_audio(ptr, size);
#elif defined(WIN_SOUND) #elif defined(_WIN32)
ret = win32_send_audio(ptr, size); ret = win32_send_audio(ptr, size);
#elif defined(MAC) && !defined(HAVE_SDL) #elif defined(MAC)
ret = mac_send_audio(ptr, size); ret = mac_send_audio(ptr, size);
#else #else
ret = write(g_audio_socket, ptr, size); ret = write(g_audio_socket, ptr, size);
@ -129,10 +129,10 @@ void child_sound_loop(int read_fd, int write_fd, word32 *shm_addr) {
child_sound_init_linux(); child_sound_init_linux();
#elif HPUX #elif HPUX
child_sound_init_hpdev(); child_sound_init_hpdev();
#elif WIN_SOUND #elif defined(_WIN32)
child_sound_init_win32(); child_sound_init_win32();
return; return;
#elif defined(MAC) && !defined(HAVE_SDL) #elif defined(MAC)
child_sound_init_mac(); child_sound_init_mac();
return; return;
#endif #endif