Skip to content
Snippets Groups Projects
Commit 1d974c2b authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Resolve more MSVC warnings.

parent b7d8315a
No related branches found
No related tags found
No related merge requests found
Pipeline #5745 canceled
...@@ -59,6 +59,8 @@ ...@@ -59,6 +59,8 @@
* 4244 appears to be for implicit conversions * 4244 appears to be for implicit conversions
* warning C4244: '=': conversion from 'uint64_t' to 'int', possible loss of data * warning C4244: '=': conversion from 'uint64_t' to 'int', possible loss of data
* 4267 is the same thing, but from size_t. * 4267 is the same thing, but from size_t.
* 4018 warns when comparing signed and unsigned if the signed is implicitly
* converted to unsigned (so more sane than -Wsign-compare)
*/ */
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable : 4244 4267 4018) #pragma warning(disable : 4244 4267 4018)
......
...@@ -64,6 +64,8 @@ DLLEXPORT dll_handle xp_dlopen(const char **names, int mode, int major) ...@@ -64,6 +64,8 @@ DLLEXPORT dll_handle xp_dlopen(const char **names, int mode, int major)
char fname[MAX_PATH+1]; char fname[MAX_PATH+1];
dll_handle ret=NULL; dll_handle ret=NULL;
(void)mode; // Not used on Win32.
(void)major; // Not used on Win32.
for(; *names && (*names)[0]; names++) { for(; *names && (*names)[0]; names++) {
sprintf(fname, "%s.dll", *names); sprintf(fname, "%s.dll", *names);
if((ret=LoadLibrary(fname))!=NULL) if((ret=LoadLibrary(fname))!=NULL)
......
...@@ -83,6 +83,10 @@ static size_t sample_size; ...@@ -83,6 +83,10 @@ static size_t sample_size;
#endif #endif
#ifdef _MSC_VER
#pragma warning(disable : 4244 4267 4018)
#endif
static bool sound_device_open_failed=false; static bool sound_device_open_failed=false;
#ifdef USE_ALSA_SOUND #ifdef USE_ALSA_SOUND
static bool alsa_device_open_failed=false; static bool alsa_device_open_failed=false;
...@@ -215,7 +219,7 @@ struct alsa_api_struct *alsa_api=NULL; ...@@ -215,7 +219,7 @@ struct alsa_api_struct *alsa_api=NULL;
#ifdef XPDEV_THREAD_SAFE #ifdef XPDEV_THREAD_SAFE
static void init_sample(void); static void init_sample(void);
static bool xp_play_sample_locked(const unsigned char *sample, size_t size, bool background); static bool xp_play_sample_locked(unsigned char *sample, size_t size, bool background);
#endif #endif
/********************************************************************************/ /********************************************************************************/
...@@ -239,10 +243,6 @@ void xptone_makewave(double freq, unsigned char *wave, int samples, enum WAVE_SH ...@@ -239,10 +243,6 @@ void xptone_makewave(double freq, unsigned char *wave, int samples, enum WAVE_SH
inc=8.0*atan(1.0); inc=8.0*atan(1.0);
inc *= ((double)freq / (double)S_RATE); inc *= ((double)freq / (double)S_RATE);
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4244)
#endif
for(i=0;i<samples;i++) { for(i=0;i<samples;i++) {
pos=(inc*(double)i); pos=(inc*(double)i);
pos -= (int)(pos/WAVE_TPI)*WAVE_TPI; pos -= (int)(pos/WAVE_TPI)*WAVE_TPI;
...@@ -276,9 +276,6 @@ void xptone_makewave(double freq, unsigned char *wave, int samples, enum WAVE_SH ...@@ -276,9 +276,6 @@ void xptone_makewave(double freq, unsigned char *wave, int samples, enum WAVE_SH
break; break;
} }
} }
#ifdef _MSC_VER
#pragma warning(pop)
#endif
/* Now we have a "perfect" wave... /* Now we have a "perfect" wave...
* we must clean it up now to avoid click/pop * we must clean it up now to avoid click/pop
...@@ -997,6 +994,7 @@ void xp_play_sample_thread(void *data) ...@@ -997,6 +994,7 @@ void xp_play_sample_thread(void *data)
size_t this_sample_size; size_t this_sample_size;
int freed; int freed;
(void)data; // Unused
SetThreadName("Sample Play"); SetThreadName("Sample Play");
sample_thread_running=true; sample_thread_running=true;
sem_post(&sample_complete_sem); sem_post(&sample_complete_sem);
...@@ -1082,7 +1080,7 @@ init_sample(void) ...@@ -1082,7 +1080,7 @@ init_sample(void)
sem_init(&sample_complete_sem, 0, 0); sem_init(&sample_complete_sem, 0, 0);
} }
static bool xp_play_sample_locked(const unsigned char *sample, size_t size, bool background) static bool xp_play_sample_locked(unsigned char *sample, size_t size, bool background)
{ {
if(!sample_thread_running) { if(!sample_thread_running) {
_beginthread(xp_play_sample_thread, 0,NULL); _beginthread(xp_play_sample_thread, 0,NULL);
...@@ -1114,7 +1112,7 @@ static bool xp_play_sample_locked(const unsigned char *sample, size_t size, bool ...@@ -1114,7 +1112,7 @@ static bool xp_play_sample_locked(const unsigned char *sample, size_t size, bool
* This MUST not return false after sample goes into the sample buffer in the background. * This MUST not return false after sample goes into the sample buffer in the background.
* If it does, the caller won't be able to free() it. * If it does, the caller won't be able to free() it.
*/ */
bool xp_play_sample(const unsigned char *sample, size_t size, bool background) bool xp_play_sample(unsigned char *sample, size_t size, bool background)
{ {
bool ret; bool ret;
pthread_once(&sample_initialized_pto, init_sample); pthread_once(&sample_initialized_pto, init_sample);
...@@ -1125,11 +1123,12 @@ bool xp_play_sample(const unsigned char *sample, size_t size, bool background) ...@@ -1125,11 +1123,12 @@ bool xp_play_sample(const unsigned char *sample, size_t size, bool background)
return(ret); return(ret);
} }
#else #else
bool xp_play_sample(const unsigned char *sample, size_t sample_size, bool background) bool xp_play_sample(unsigned char *sample, size_t sample_size, bool background)
{ {
bool must_close=false; bool must_close=false;
bool ret; bool ret;
(void)background; // Never used when single-threaded
if(handle_type==SOUND_DEVICE_CLOSED) { if(handle_type==SOUND_DEVICE_CLOSED) {
must_close=true; must_close=true;
if(!xptone_open()) if(!xptone_open())
...@@ -1160,15 +1159,8 @@ bool xptone(double freq, DWORD duration, enum WAVE_SHAPE shape) ...@@ -1160,15 +1159,8 @@ bool xptone(double freq, DWORD duration, enum WAVE_SHAPE shape)
freq=17; freq=17;
samples=S_RATE*duration/1000; samples=S_RATE*duration/1000;
if(freq) { if(freq) {
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4244)
#endif
if(samples<=S_RATE/freq*2) if(samples<=S_RATE/freq*2)
samples=S_RATE/freq*2; samples=S_RATE/freq*2;
#ifdef _MSC_VER
#pragma warning(pop)
#endif
} }
if(freq==0 || samples > S_RATE/freq*2) { if(freq==0 || samples > S_RATE/freq*2) {
int sample_len; int sample_len;
......
...@@ -38,7 +38,7 @@ DLLEXPORT void xptone_makewave(double freq, unsigned char *wave, int samples, en ...@@ -38,7 +38,7 @@ DLLEXPORT void xptone_makewave(double freq, unsigned char *wave, int samples, en
DLLEXPORT bool xptone_open(void); DLLEXPORT bool xptone_open(void);
DLLEXPORT bool xptone_close(void); DLLEXPORT bool xptone_close(void);
DLLEXPORT void xpbeep(double freq, DWORD duration); DLLEXPORT void xpbeep(double freq, DWORD duration);
DLLEXPORT bool xp_play_sample(const unsigned char *sample, size_t sample_size, bool background); DLLEXPORT bool xp_play_sample(unsigned char *sample, size_t sample_size, bool background);
DLLEXPORT void xptone_complete(void); DLLEXPORT void xptone_complete(void);
DLLEXPORT bool xptone(double freq, DWORD duration, enum WAVE_SHAPE); DLLEXPORT bool xptone(double freq, DWORD duration, enum WAVE_SHAPE);
#ifdef __unix__ #ifdef __unix__
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment