From: Clément de l'Hamaide Date: Fri, 27 Sep 2013 13:37:07 +0000 (+0200) Subject: Fix Windows warning during Windows compilation X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fc25f29d3c6e7f87fa0df43774fa15a969e362c7;p=flightgear.git Fix Windows warning during Windows compilation Make sure OpenAL context is setup before opening capture device --- diff --git a/utils/iaxclient/lib/CMakeLists.txt b/utils/iaxclient/lib/CMakeLists.txt index 25936f2a0..28cce58f6 100644 --- a/utils/iaxclient/lib/CMakeLists.txt +++ b/utils/iaxclient/lib/CMakeLists.txt @@ -1,4 +1,4 @@ - +# CMakeLists.txt, for utils/iaxclient/lib - 20130925 # even if we don't select the codec, speex is used for pre-processing audio set(ENABLE_SPEXX 1) @@ -112,6 +112,18 @@ add_definitions(-DLIBIAX) add_definitions(-DHAS_STRING_H -DHAS_STDLIB_H) add_definitions(-DCODEC_GSM) +if (MSVC) + # turn off various warnings + set(WFLAGS) + foreach(warning 4244 4305 4996) + set(WFLAGS "${WFLAGS} /wd${warning}") + endforeach() + add_definitions(${WFLAGS}) +endif () + +add_definitions( -DHAVE_CONFIG_H ) # to use fgfs config.h to get FG version, if needed +add_definitions( -DLIBVER="SVN 261" ) # add an iaxclient_lib version string + include_directories(${PROJECT_SOURCE_DIR}/utils/iaxclient/lib) include_directories(${PROJECT_SOURCE_DIR}/utils/iaxclient/lib/libiax2/src) include_directories(${PROJECT_SOURCE_DIR}/utils/iaxclient/lib/gsm/inc) @@ -122,3 +134,4 @@ add_library(iaxclient_lib STATIC ${SPEEX_SOURCES} ${LIBIAX2_SOURCES}) +# eof diff --git a/utils/iaxclient/lib/audio_openal.c b/utils/iaxclient/lib/audio_openal.c index 4b4b14718..1faaf1f0e 100644 --- a/utils/iaxclient/lib/audio_openal.c +++ b/utils/iaxclient/lib/audio_openal.c @@ -263,14 +263,7 @@ int openal_initialize(struct iaxc_audio_driver *d, int sample_rate) int err = alGetError(); d->priv = priv; - // First we are looking for input device - priv->in_dev = alcCaptureOpenDevice(NULL, 8000, AL_FORMAT_MONO16, 800); - if (!priv->in_dev) return openal_error("alcCaptureOpenDevice", alGetError()); - - alcCaptureStart(priv->in_dev); - if ((err = alGetError())) return openal_error("alcCaptureStart", err); - - // Then we look for output device + // First we are looking for output device priv->out_ctx = alcGetCurrentContext(); if( priv->out_ctx == NULL ) { // FGCom standalone only @@ -284,6 +277,14 @@ int openal_initialize(struct iaxc_audio_driver *d, int sample_rate) alcMakeContextCurrent(priv->out_ctx); if ((err = alGetError())) return openal_error("alcMakeContextCurrent", err); + // Then we look for input device + priv->in_dev = alcCaptureOpenDevice(NULL, 8000, AL_FORMAT_MONO16, 800); + if (!priv->in_dev) return openal_error("alcCaptureOpenDevice", alGetError()); + if ((err = alGetError())) return openal_error("alcCaptureOpenDevice1", alGetError()); + + alcCaptureStart(priv->in_dev); + if ((err = alGetError())) return openal_error("alcCaptureStart", err); + priv->sample_rate = sample_rate; priv->num_buffers = 20; priv->input_level = 0; diff --git a/utils/iaxclient/lib/libiax2/src/iax.c b/utils/iaxclient/lib/libiax2/src/iax.c index 50364cc95..5faa20581 100644 --- a/utils/iaxclient/lib/libiax2/src/iax.c +++ b/utils/iaxclient/lib/libiax2/src/iax.c @@ -923,8 +923,12 @@ void iax_set_jb_target_extra( long value ) int iax_init(int preferredportno) { int portno = preferredportno; - +#ifndef _MSC_VER // avoid compare of address of imported function + /* MSVC only - In certain circumstances the addresses placed in iax_sendto and iax_recvfrom + can be an offset to a jump table, making a compare of the current address to the address + of the actual imported function fail. */ if (iax_recvfrom == (iax_recvfrom_t)recvfrom) +#endif // !_MSC_VER { struct sockaddr_in sin; socklen_t sinlen;