1
0
Fork 0

Fix Windows warning during Windows compilation

Make sure OpenAL context is setup before opening capture device
This commit is contained in:
Clément de l'Hamaide 2013-09-27 15:37:07 +02:00
parent 8d415eafa3
commit fc25f29d3c
3 changed files with 28 additions and 10 deletions

View file

@ -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 # even if we don't select the codec, speex is used for pre-processing audio
set(ENABLE_SPEXX 1) set(ENABLE_SPEXX 1)
@ -112,6 +112,18 @@ add_definitions(-DLIBIAX)
add_definitions(-DHAS_STRING_H -DHAS_STDLIB_H) add_definitions(-DHAS_STRING_H -DHAS_STDLIB_H)
add_definitions(-DCODEC_GSM) 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)
include_directories(${PROJECT_SOURCE_DIR}/utils/iaxclient/lib/libiax2/src) include_directories(${PROJECT_SOURCE_DIR}/utils/iaxclient/lib/libiax2/src)
include_directories(${PROJECT_SOURCE_DIR}/utils/iaxclient/lib/gsm/inc) include_directories(${PROJECT_SOURCE_DIR}/utils/iaxclient/lib/gsm/inc)
@ -122,3 +134,4 @@ add_library(iaxclient_lib STATIC
${SPEEX_SOURCES} ${SPEEX_SOURCES}
${LIBIAX2_SOURCES}) ${LIBIAX2_SOURCES})
# eof

View file

@ -263,14 +263,7 @@ int openal_initialize(struct iaxc_audio_driver *d, int sample_rate)
int err = alGetError(); int err = alGetError();
d->priv = priv; d->priv = priv;
// First we are looking for input device // First we are looking for output 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
priv->out_ctx = alcGetCurrentContext(); priv->out_ctx = alcGetCurrentContext();
if( priv->out_ctx == NULL ) { // FGCom standalone only 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); alcMakeContextCurrent(priv->out_ctx);
if ((err = alGetError())) return openal_error("alcMakeContextCurrent", err); 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->sample_rate = sample_rate;
priv->num_buffers = 20; priv->num_buffers = 20;
priv->input_level = 0; priv->input_level = 0;

View file

@ -923,8 +923,12 @@ void iax_set_jb_target_extra( long value )
int iax_init(int preferredportno) int iax_init(int preferredportno)
{ {
int portno = 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) if (iax_recvfrom == (iax_recvfrom_t)recvfrom)
#endif // !_MSC_VER
{ {
struct sockaddr_in sin; struct sockaddr_in sin;
socklen_t sinlen; socklen_t sinlen;