コード例 #1
0
ファイル: openal.c プロジェクト: teistiz/yquake2
/*
 * Initializes the OpenAL backend
 */
qboolean
AL_Init(void)
{
	int i;

	if (!QAL_Init())
	{
		Com_Printf("ERROR: OpenAL failed to initialize.\n");
		return false;
	}

	s_openal_maxgain = Cvar_Get("s_openal_maxgain", "1.0", CVAR_ARCHIVE);

	/* check for linear distance extension */
	if (!qalIsExtensionPresent("AL_EXT_LINEAR_DISTANCE"))
	{
		Com_Printf("ERROR: Required AL_EXT_LINEAR_DISTANCE extension is missing.\n");
		QAL_Shutdown();
		return false;
	}

	/* generate source names */
	qalGetError();
	qalGenSources(1, &streamSource);

	if (qalGetError() != AL_NO_ERROR)
	{
		Com_Printf("ERROR: Couldn't get a single Source.\n");
		QAL_Shutdown();
		return false;
	}
	else
	{
		/* -1 because we already got one channel for streaming */
		for (i = 0; i < MAX_CHANNELS - 1; i++)
		{
			qalGenSources(1, &s_srcnums[i]);

			if (qalGetError() != AL_NO_ERROR)
			{
				break;
			}
		}

		if (i < MIN_CHANNELS - 1)
		{
			Com_Printf("ERROR: Required at least %d sources, but got %d.\n",
					MIN_CHANNELS, i + 1);
			QAL_Shutdown();
			return false;
		}
	}

	s_numchannels = i;
	AL_InitStreamSource();
	AL_InitUnderwaterFilter();

	Com_Printf("Number of OpenAL sources: %d\n\n", s_numchannels);
	return true;
}
コード例 #2
0
ファイル: fixed.c プロジェクト: m4son/q2pro
qboolean QAL_Init(void)
{
    al_device = Cvar_Get("al_device", "", 0);

    device = alcOpenDevice(al_device->string[0] ? al_device->string : NULL);
    if (!device) {
        Com_SetLastError(va("alcOpenDevice(%s) failed", al_device->string));
        goto fail;
    }

    context = alcCreateContext(device, NULL);
    if (!context) {
        Com_SetLastError("alcCreateContext failed");
        goto fail;
    }

    if (!alcMakeContextCurrent(context)) {
        Com_SetLastError("alcMakeContextCurrent failed");
        goto fail;
    }

    al_device->flags |= CVAR_SOUND;

    return qtrue;

fail:
    QAL_Shutdown();
    return qfalse;
}
コード例 #3
0
/*
=================
S_AL_Shutdown
=================
*/
static
void S_AL_Shutdown( void )
{
	// Shut down everything
	int i;
	for (i = 0; i < MAX_RAW_STREAMS; i++)
		S_AL_StreamDie(i);
	S_AL_StopBackgroundTrack( );
	S_AL_SrcShutdown( );
	S_AL_BufferShutdown( );

	qalcDestroyContext(alContext);
	qalcCloseDevice(alDevice);

#ifdef USE_VOIP
	if (alCaptureDevice != NULL) {
		qalcCaptureStop(alCaptureDevice);
		qalcCaptureCloseDevice(alCaptureDevice);
		alCaptureDevice = NULL;
		Com_Printf( "OpenAL capture device closed.\n" );
	}
#endif

	for (i = 0; i < MAX_RAW_STREAMS; i++) {
		streamSourceHandles[i] = -1;
		streamPlaying[i] = qfalse;
		streamSources[i] = 0;
	}

	QAL_Shutdown();
}
コード例 #4
0
ファイル: al_linux.c プロジェクト: turol/webquake2
/*
 =================
 AL_Shutdown
 =================
*/
void AL_Shutdown (void){

	Com_Printf("Shutting down OpenAL subsystem\n", LOG_CLIENT);

	if (alState.hALC)
	{
		Com_Printf("...alcMakeContextCurrent( NULL ): ", LOG_CLIENT);
		if (!alcMakeContextCurrent(NULL))
			Com_Printf("failed\n", LOG_CLIENT);
		else
			Com_Printf("succeeded\n", LOG_CLIENT);

		Com_Printf("...destroying AL context\n", LOG_CLIENT);
		alcDestroyContext(alState.hALC);

		alState.hALC = NULL;
	}

	if (alState.hDevice)
	{
		Com_Printf("...closing device\n", LOG_CLIENT);
		alcCloseDevice(alState.hDevice);

		alState.hDevice = NULL;
	}

	QAL_Shutdown();

	memset(&alConfig, 0, sizeof(alConfig_t));
	memset(&alState, 0, sizeof(alState_t));
}
コード例 #5
0
ファイル: snd_al.c プロジェクト: Bad-ptr/q2pro
void AL_Shutdown( void ) {
    Com_Printf( "Shutting down OpenAL.\n" );

    if( s_numchannels ) {
        // delete source names
        qalDeleteSources( s_numchannels, s_srcnums );
        memset( s_srcnums, 0, sizeof( s_srcnums ) );
        s_numchannels = 0;
    }

    QAL_Shutdown();
}
コード例 #6
0
/*
=================
S_AL_Shutdown
=================
*/
static
void S_AL_Shutdown( void )
{
	// Shut down everything
	S_AL_StreamDie( );
	S_AL_StopBackgroundTrack( );
	S_AL_SrcShutdown( );
	S_AL_BufferShutdown( );

	qalcDestroyContext(alContext);
	qalcCloseDevice(alDevice);

	QAL_Shutdown();
}
コード例 #7
0
ファイル: snd_al.c プロジェクト: Nekrofage/Quake2RPi
void AL_Shutdown( void ) {
	Com_Printf( "Shutting down OpenAL.\n" );

	S_AL_StreamDie();

	qalDeleteSources(1, &streamSource);
	qalDeleteFilters(1, &underwaterFilter);

	if( s_numchannels ) {
		// delete source names
		qalDeleteSources( s_numchannels, s_srcnums );
		memset( s_srcnums, 0, sizeof( s_srcnums ) );
		s_numchannels = 0;
	}
	QAL_Shutdown();
}
コード例 #8
0
ファイル: qal.c プロジェクト: jayschwa/q2pro
qboolean QAL_Init(void)
{
    al_driver = Cvar_Get("al_driver", LIBAL, 0);
    al_device = Cvar_Get("al_device", "", 0);

    // don't allow absolute or relative paths
    FS_SanitizeFilenameVariable(al_driver);

    Sys_LoadLibrary(al_driver->string, NULL, &handle);
    if (!handle) {
        return qfalse;
    }

#define QAL(type, func)  q##func = Sys_GetProcAddress(handle, #func)
    QALC_IMP
    QAL_IMP
#undef QAL

    device = qalcOpenDevice(al_device->string[0] ? al_device->string : NULL);
    if (!device) {
        Com_SetLastError(va("alcOpenDevice(%s) failed", al_device->string));
        goto fail;
    }

    context = qalcCreateContext(device, NULL);
    if (!context) {
        Com_SetLastError("alcCreateContext failed");
        goto fail;
    }

    if (!qalcMakeContextCurrent(context)) {
        Com_SetLastError("alcMakeContextCurrent failed");
        goto fail;
    }

    al_driver->flags |= CVAR_SOUND;
    al_device->flags |= CVAR_SOUND;

    return qtrue;

fail:
    QAL_Shutdown();
    return qfalse;
}
コード例 #9
0
ファイル: qal_api.c プロジェクト: Bad-ptr/q2pro
qboolean QAL_Init( void ) {
    al_driver = Cvar_Get( "al_driver", DEFAULT_OPENAL_DRIVER, CVAR_SOUND );
    al_device = Cvar_Get( "al_device", "", CVAR_SOUND );

    Sys_LoadLibrary( al_driver->string, NULL, &handle );
    if( !handle ) {
        return qfalse;
    }

#define QAL(type,func)  q##func = Sys_GetProcAddress( handle, #func );
QALC_IMP
QAL_IMP
#undef QAL

    Com_DPrintf( "...opening OpenAL device: " );
    device = qalcOpenDevice( al_device->string[0] ? al_device->string : NULL );
    if( !device ) {
        goto fail;
    }
    Com_DPrintf( "ok\n" );

    Com_DPrintf( "...creating OpenAL context: " );
    context = qalcCreateContext( device, NULL );
    if( !context ) {
        goto fail;
    }
    Com_DPrintf( "ok\n" );

    Com_DPrintf( "...making context current: " );
    if( !qalcMakeContextCurrent( context ) ) {
        goto fail;
    }
    Com_DPrintf( "ok\n" );

    al_driver->flags |= CVAR_SOUND;
    al_device->flags |= CVAR_SOUND;

    return qtrue;

fail:
    Com_DPrintf( "failed\n" );
    QAL_Shutdown();
    return qfalse;
}
コード例 #10
0
ファイル: openal.c プロジェクト: axltxl/hecatomb
 /*
  * Shuts the OpenAL backend down
  */
 void
 AL_Shutdown ( void )
 {
   Com_Printf ( "Shutting down OpenAL.\n" );
   AL_StreamDie();
   qalDeleteSources ( 1, &streamSource );
 #if !defined (HT_OS_OSX)
   qalDeleteFilters ( 1, &underwaterFilter );
 #endif

   if ( s_numchannels ) {
     /* delete source names */
     qalDeleteSources ( s_numchannels, s_srcnums );
     memset ( s_srcnums, 0, sizeof ( s_srcnums ) );
     s_numchannels = 0;
   }

   QAL_Shutdown();
 }
コード例 #11
0
ファイル: snd_main.c プロジェクト: MGXRace/racesow
/*
* SF_Shutdown
*/
void SF_Shutdown( bool verbose )
{
	if( !soundpool ) {
		return;
	}
	
	SF_StopAllSounds( true, true );

	// wake up the mixer
	SF_Activate( true );

	// wait for the queue to be processed
	S_FinishSoundCmdPipe( s_cmdPipe );

	S_ShutdownBuffers();

	// shutdown backend
	S_IssueShutdownCmd( s_cmdPipe, verbose );

	// wait for the queue to be processed
	S_FinishSoundCmdPipe( s_cmdPipe );

	// wait for the backend thread to die
	trap_Thread_Join( s_backThread );
	s_backThread = NULL;

	S_DestroySoundCmdPipe( &s_cmdPipe );

#ifdef ENABLE_PLAY
	trap_Cmd_RemoveCommand( "play" );
#endif
	trap_Cmd_RemoveCommand( "music" );
	trap_Cmd_RemoveCommand( "stopmusic" );
	trap_Cmd_RemoveCommand( "prevmusic" );
	trap_Cmd_RemoveCommand( "nextmusic" );
	trap_Cmd_RemoveCommand( "pausemusic" );
	trap_Cmd_RemoveCommand( "soundlist" );
	trap_Cmd_RemoveCommand( "s_devices" );

	QAL_Shutdown();

	S_MemFreePool( &soundpool );
}
コード例 #12
0
ファイル: al.c プロジェクト: jayschwa/q2pro
qboolean AL_Init(void)
{
    int i;

    Com_DPrintf("Initializing OpenAL\n");

    if (!QAL_Init()) {
        goto fail0;
    }

    // check for linear distance extension
    if (!qalIsExtensionPresent("AL_EXT_LINEAR_DISTANCE")) {
        Com_SetLastError("AL_EXT_LINEAR_DISTANCE extension is missing");
        goto fail1;
    }

    // generate source names
    qalGetError();
    for (i = 0; i < MAX_CHANNELS; i++) {
        qalGenSources(1, &s_srcnums[i]);
        if (qalGetError() != AL_NO_ERROR) {
            break;
        }
    }

    Com_DPrintf("Got %d AL sources\n", i);

    if (i < MIN_CHANNELS) {
        Com_SetLastError("Insufficient number of AL sources");
        goto fail1;
    }

    s_numchannels = i;

    Com_Printf("OpenAL initialized.\n");
    return qtrue;

fail1:
    QAL_Shutdown();
fail0:
    Com_EPrintf("Failed to initialize OpenAL: %s\n", Com_GetLastError());
    return qfalse;
}
コード例 #13
0
ファイル: al_linux.c プロジェクト: turol/webquake2
/*
 =================
 AL_StartOpenAL
 =================
*/
static qboolean AL_StartOpenAL ()
{
	// Initialize our QAL dynamic bindings
	if (!QAL_Init())
		return false;

	// Get device list
	if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT"))
		alConfig.deviceList = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
	else
		alConfig.deviceList = "DirectSound3D\0DirectSound\0MMSYSTEM\0\0";

	// Initialize the device, context, etc...
	if (AL_InitDriver())
		return true;

	// Shutdown QAL
	QAL_Shutdown();

	return false;
}
コード例 #14
0
ファイル: snd_main.c プロジェクト: Kaperstone/warsow
/*
* S_Shutdown
*/
void S_Shutdown( qboolean verbose )
{
	S_StopStream();
	S_StopBackgroundTrack();

#ifdef ENABLE_PLAY
	trap_Cmd_RemoveCommand( "play" );
#endif
	trap_Cmd_RemoveCommand( "music" );
	trap_Cmd_RemoveCommand( "stopmusic" );
	trap_Cmd_RemoveCommand( "prevmusic" );
	trap_Cmd_RemoveCommand( "nextmusic" );
	trap_Cmd_RemoveCommand( "pausemusic" );
	trap_Cmd_RemoveCommand( "soundlist" );
	trap_Cmd_RemoveCommand( "s_devices" );

	S_ShutdownSources();
	S_ShutdownBuffers();
	S_ShutdownDecoders( verbose );

	if( alContext )
	{
		if( !snd_shutdown_bug )
			qalcMakeContextCurrent( NULL );

		qalcDestroyContext( alContext );
		alContext = NULL;
	}

	if( alDevice )
	{
		qalcCloseDevice( alDevice );
		alDevice = NULL;
	}

	QAL_Shutdown();

	S_MemFreePool( &soundpool );
}
コード例 #15
0
ファイル: snd_al.c プロジェクト: Bad-ptr/q2pro
qboolean AL_Init( void ) {
    int i;

    if( !QAL_Init() ) {
        Com_EPrintf( "OpenAL failed to initialize.\n" );
        return qfalse;
    }

    // check for linear distance extension
    if( !qalIsExtensionPresent( "AL_EXT_LINEAR_DISTANCE" ) ) {
        Com_EPrintf( "Required AL_EXT_LINEAR_DISTANCE extension is missing.\n" );
        goto fail;
    }

    // generate source names
    qalGetError();
    for( i = 0; i < MAX_CHANNELS; i++ ) {
        qalGenSources( 1, &s_srcnums[i] );
        if( qalGetError() != AL_NO_ERROR ) {
            break;
        }
    }

    if( i < MIN_CHANNELS ) {
        Com_EPrintf( "Required at least %d sources, but got %d.\n", MIN_CHANNELS, i );
        goto fail;
    }

    s_numchannels = i;

    Com_Printf( "OpenAL initialized.\n" );
    return qtrue;

fail:
    QAL_Shutdown();
    return qfalse;
}
コード例 #16
0
ファイル: snd_al_main.c プロジェクト: SHOVELL/Unvanquished
void SndAl_Shutdown( void )
{
	// Remove commands
	si.Cmd_RemoveCommand( "music" );
	si.Cmd_RemoveCommand( "play" );

	// Shut down everything
	al_stream_die();
	SndAl_StopBackgroundTrack();
	al_src_shutdown();
	al_buf_shutdown();

	if ( !snd_shutdown_bug )
	{
		qalcMakeContextCurrent( NULL );
	}

	qalcDestroyContext( alContext );
	qalcCloseDevice( alDevice );

#ifdef USE_VOIP

	if ( alCaptureDevice != NULL )
	{
		qalcCaptureStop( alCaptureDevice );
		qalcCaptureCloseDevice( alCaptureDevice );
		alCaptureDevice = NULL;
		si.Printf( PRINT_ALL, "OpenAL capture device closed.\n" );
	}

#endif

#ifdef USE_OPENAL_DLOPEN
	QAL_Shutdown();
#endif
}
コード例 #17
0
ファイル: snd_al_main.c プロジェクト: SHOVELL/Unvanquished
qboolean SndAl_Init( void )
{
	const char *device = NULL;
	// Original console variables
	s_volume = si.Cvar_Get( "s_volume", "0.8", CVAR_ARCHIVE );
	s_musicVolume = si.Cvar_Get( "s_musicvolume", "0.25", CVAR_ARCHIVE );
	s_doppler = si.Cvar_Get( "s_doppler", "1", CVAR_ARCHIVE );

	// New console variables
	s_precache = si.Cvar_Get( "al_precache", "1", CVAR_ARCHIVE );
	s_gain = si.Cvar_Get( "al_gain", "0.4", CVAR_ARCHIVE );
	s_sources = si.Cvar_Get( "al_sources", "64", CVAR_ARCHIVE );
	s_dopplerFactor = si.Cvar_Get( "al_dopplerfactor", "1.0", CVAR_ARCHIVE );
	s_dopplerSpeed = si.Cvar_Get( "al_dopplerspeed", "2200", CVAR_ARCHIVE );
	s_minDistance = si.Cvar_Get( "al_mindistance", "80", CVAR_ARCHIVE );
	s_rolloff = si.Cvar_Get( "al_rolloff", "0.25", CVAR_ARCHIVE );
	s_alDevice = si.Cvar_Get( "al_device", "", CVAR_ARCHIVE | CVAR_LATCH );
#ifdef USE_OPENAL_DLOPEN
	s_alDriver = si.Cvar_Get( "al_driver", ALDRIVER_DEFAULT, CVAR_ARCHIVE );
#endif // USE_OPENAL_DLOPEN

#ifdef USE_OPENAL_DLOPEN

	// Load QAL
	if ( !QAL_Init( s_alDriver->string ) )
	{
		si.Printf( PRINT_ALL, "not initializing.\n" );
		return qfalse;
	}

#endif // USE_OPENAL_DLOPEN
	// Open default device
	device = s_alDevice->string;

	if ( device && !*device )
	{
		device = NULL;
	}

	if ( qalcIsExtensionPresent( NULL, "ALC_ENUMERATION_EXT" ) )
	{
		char       devicenames[ 1024 ] = "";
		const char *devicelist;
#ifdef _WIN32
		const char *defaultdevice;
#endif
		int        curlen;

		// get all available devices + the default device name.
		devicelist = qalcGetString( NULL, ALC_DEVICE_SPECIFIER );
#ifdef _WIN32
		defaultdevice = qalcGetString( NULL, ALC_DEFAULT_DEVICE_SPECIFIER );

		// check whether the default device is generic hardware. If it is, change to
		// Generic Software as that one works more reliably with various sound systems.
		// If it's not, use OpenAL's default selection as we don't want to ignore
		// native hardware acceleration.
		if ( !device && !strcmp( defaultdevice, "Generic Hardware" ) )
		{
			device = "Generic Software";
		}

#endif

		// dump a list of available devices to a cvar for the user to see.
#ifndef MACOS_X

		while ( ( curlen = strlen( devicelist ) ) )
		{
			strcat( devicenames, devicelist );
			strcat( devicenames, "\n" );

			devicelist += curlen + 1;
		}

#endif
		s_alAvailableDevices = si.Cvar_Get( "al_AvailableDevices", devicenames, CVAR_ROM | CVAR_NORESTART );
	}

	alDevice = qalcOpenDevice( device );

	if ( !alDevice && device )
	{
		si.Printf( PRINT_ALL,  "Failed to open OpenAL device '%s', trying default.\n", device );
		alDevice = qalcOpenDevice( NULL );
	}

	if ( !alDevice )
	{
#ifdef USE_OPENAL_DLOPEN
		QAL_Shutdown();
#endif
		si.Printf( PRINT_ALL,  "Failed to open OpenAL device.\n" );
		return qfalse;
	}

	// Create OpenAL context
	alContext = qalcCreateContext( alDevice, NULL );

	if ( !alContext )
	{
#ifdef USE_OPENAL_DLOPEN
		QAL_Shutdown();
#endif
		qalcCloseDevice( alDevice );
		si.Printf( PRINT_ALL, "Failed to create context\n" );
		return qfalse;
	}

	qalcMakeContextCurrent( alContext );
	qalcProcessContext( alContext );

	// Print OpenAL information
	si.Printf( PRINT_ALL, "OpenAL initialised\n" );
	si.Printf( PRINT_ALL, "  Vendor:     %s\n", qalGetString( AL_VENDOR ) );
	si.Printf( PRINT_ALL, "  Version:    %s\n", qalGetString( AL_VERSION ) );
	si.Printf( PRINT_ALL, "  Renderer:   %s\n", qalGetString( AL_RENDERER ) );
	si.Printf( PRINT_ALL, "  AL Extensions: %s\n", qalGetString( AL_EXTENSIONS ) );
	si.Printf( PRINT_ALL,  "  ALC Extensions: %s\n", qalcGetString( alDevice, ALC_EXTENSIONS ) );

	if ( qalcIsExtensionPresent( NULL, "ALC_ENUMERATION_EXT" ) )
	{
		si.Printf( PRINT_ALL, "  Device:     %s\n", qalcGetString( alDevice, ALC_DEVICE_SPECIFIER ) );
		si.Printf( PRINT_ALL, "Available Devices:\n%s", s_alAvailableDevices->string );
	}

	// Check for Linux shutdown race condition
	if ( !strcmp( qalGetString( AL_VENDOR ), "J. Valenzuela" ) )
	{
		snd_shutdown_bug = qtrue;
	}

	// Initialize sources, buffers, music
	al_buf_init();
	al_src_init();

	// Set up OpenAL parameters (doppler, etc)
	qalDistanceModel( AL_INVERSE_DISTANCE_CLAMPED );
	qalDopplerFactor( s_dopplerFactor->value );
	qalDopplerVelocity( s_dopplerSpeed->value );;

	// Add commands
	si.Cmd_AddCommand( "play", S_Play_f );
	si.Cmd_AddCommand( "music", S_Music_f );
#ifdef USE_VOIP
	SndAl_InitCapture( qtrue );
#endif

	// Init successful
	si.Printf( PRINT_ALL, "initialization successful\n" );
	return qtrue;
}
コード例 #18
0
ファイル: qal.c プロジェクト: Samurai336/yquake2
/*
 * Loads the OpenAL shared lib, creates
 * a context and device handle.
 */
qboolean
QAL_Init()
{
	/* DEFAULT_OPENAL_DRIVER is defined at compile time via the compiler */
	al_driver = Cvar_Get("al_driver", DEFAULT_OPENAL_DRIVER, CVAR_ARCHIVE);
	al_device = Cvar_Get("al_device", "", CVAR_ARCHIVE);

	Com_Printf("LoadLibrary(%s)\n", al_driver->string);

	/* Load the library */
	Sys_LoadLibrary(al_driver->string, NULL, &handle);

	if (!handle)
	{
		Com_Printf("Loading %s failed! Disabling OpenAL.\n", al_driver->string);
		return false;
	}

	/* Connect function pointers to management functions */
	qalcCreateContext = Sys_GetProcAddress(handle, "alcCreateContext");
	qalcMakeContextCurrent = Sys_GetProcAddress(handle, "alcMakeContextCurrent");
	qalcProcessContext = Sys_GetProcAddress(handle, "alcProcessContext");
	qalcSuspendContext = Sys_GetProcAddress(handle, "alcSuspendContext");
	qalcDestroyContext = Sys_GetProcAddress(handle, "alcDestroyContext");
	qalcGetCurrentContext = Sys_GetProcAddress(handle, "alcGetCurrentContext");
	qalcGetContextsDevice = Sys_GetProcAddress(handle, "alcGetContextsDevice");
	qalcOpenDevice = Sys_GetProcAddress(handle, "alcOpenDevice");
	qalcCloseDevice = Sys_GetProcAddress(handle, "alcCloseDevice");
	qalcGetError = Sys_GetProcAddress(handle, "alcGetError");
	qalcIsExtensionPresent = Sys_GetProcAddress(handle, "alcIsExtensionPresent");
	qalcGetProcAddress = Sys_GetProcAddress(handle, "alcGetProcAddress");
	qalcGetEnumValue = Sys_GetProcAddress(handle, "alcGetEnumValue");
	qalcGetString = Sys_GetProcAddress(handle, "alcGetString");
	qalcGetIntegerv = Sys_GetProcAddress(handle, "alcGetIntegerv");
	qalcCaptureOpenDevice = Sys_GetProcAddress(handle, "alcCaptureOpenDevice");
	qalcCaptureCloseDevice = Sys_GetProcAddress(handle, "alcCaptureCloseDevice");
	qalcCaptureStart = Sys_GetProcAddress(handle, "alcCaptureStart");
	qalcCaptureStop = Sys_GetProcAddress(handle, "alcCaptureStop");
	qalcCaptureSamples = Sys_GetProcAddress(handle, "alcCaptureSamples");

	/* Connect function pointers to
	   to OpenAL API functions */
	qalEnable = Sys_GetProcAddress(handle, "alEnable");
	qalDisable = Sys_GetProcAddress(handle, "alDisable");
	qalIsEnabled = Sys_GetProcAddress(handle, "alIsEnabled");
	qalGetString = Sys_GetProcAddress(handle, "alGetString");
	qalGetBooleanv = Sys_GetProcAddress(handle, "alGetBooleanv");
	qalGetIntegerv = Sys_GetProcAddress(handle, "alGetIntegerv");
	qalGetFloatv = Sys_GetProcAddress(handle, "alGetFloatv");
	qalGetDoublev = Sys_GetProcAddress(handle, "alGetDoublev");
	qalGetBoolean = Sys_GetProcAddress(handle, "alGetBoolean");
	qalGetInteger = Sys_GetProcAddress(handle, "alGetInteger");
	qalGetFloat = Sys_GetProcAddress(handle, "alGetFloat");
	qalGetDouble = Sys_GetProcAddress(handle, "alGetDouble");
	qalGetError = Sys_GetProcAddress(handle, "alGetError");
	qalIsExtensionPresent = Sys_GetProcAddress(handle, "alIsExtensionPresent");
	qalGetProcAddress = Sys_GetProcAddress(handle, "alGetProcAddress");
	qalGetEnumValue = Sys_GetProcAddress(handle, "alGetEnumValue");
	qalListenerf = Sys_GetProcAddress(handle, "alListenerf");
	qalListener3f = Sys_GetProcAddress(handle, "alListener3f");
	qalListenerfv = Sys_GetProcAddress(handle, "alListenerfv");
	qalListeneri = Sys_GetProcAddress(handle, "alListeneri");
	qalListener3i = Sys_GetProcAddress(handle, "alListener3i");
	qalListeneriv = Sys_GetProcAddress(handle, "alListeneriv");
	qalGetListenerf = Sys_GetProcAddress(handle, "alGetListenerf");
	qalGetListener3f = Sys_GetProcAddress(handle, "alGetListener3f");
	qalGetListenerfv = Sys_GetProcAddress(handle, "alGetListenerfv");
	qalGetListeneri = Sys_GetProcAddress(handle, "alGetListeneri");
	qalGetListener3i = Sys_GetProcAddress(handle, "alGetListener3i");
	qalGetListeneriv = Sys_GetProcAddress(handle, "alGetListeneriv");
	qalGenSources = Sys_GetProcAddress(handle, "alGenSources");
	qalDeleteSources = Sys_GetProcAddress(handle, "alDeleteSources");
	qalIsSource = Sys_GetProcAddress(handle, "alIsSource");
	qalSourcef = Sys_GetProcAddress(handle, "alSourcef");
	qalSource3f = Sys_GetProcAddress(handle, "alSource3f");
	qalSourcefv = Sys_GetProcAddress(handle, "alSourcefv");
	qalSourcei = Sys_GetProcAddress(handle, "alSourcei");
	qalSource3i = Sys_GetProcAddress(handle, "alSource3i");
	qalSourceiv = Sys_GetProcAddress(handle, "alSourceiv");
	qalGetSourcef = Sys_GetProcAddress(handle, "alGetSourcef");
	qalGetSource3f = Sys_GetProcAddress(handle, "alGetSource3f");
	qalGetSourcefv = Sys_GetProcAddress(handle, "alGetSourcefv");
	qalGetSourcei = Sys_GetProcAddress(handle, "alGetSourcei");
	qalGetSource3i = Sys_GetProcAddress(handle, "alGetSource3i");
	qalGetSourceiv = Sys_GetProcAddress(handle, "alGetSourceiv");
	qalSourcePlayv = Sys_GetProcAddress(handle, "alSourcePlayv");
	qalSourceStopv = Sys_GetProcAddress(handle, "alSourceStopv");
	qalSourceRewindv = Sys_GetProcAddress(handle, "alSourceRewindv");
	qalSourcePausev = Sys_GetProcAddress(handle, "alSourcePausev");
	qalSourcePlay = Sys_GetProcAddress(handle, "alSourcePlay");
	qalSourceStop = Sys_GetProcAddress(handle, "alSourceStop");
	qalSourceRewind = Sys_GetProcAddress(handle, "alSourceRewind");
	qalSourcePause = Sys_GetProcAddress(handle, "alSourcePause");
	qalSourceQueueBuffers = Sys_GetProcAddress(handle, "alSourceQueueBuffers");
	qalSourceUnqueueBuffers = Sys_GetProcAddress(handle, "alSourceUnqueueBuffers");
	qalGenBuffers = Sys_GetProcAddress(handle, "alGenBuffers");
	qalDeleteBuffers = Sys_GetProcAddress(handle, "alDeleteBuffers");
	qalIsBuffer = Sys_GetProcAddress(handle, "alIsBuffer");
	qalBufferData = Sys_GetProcAddress(handle, "alBufferData");
	qalBufferf = Sys_GetProcAddress(handle, "alBufferf");
	qalBuffer3f = Sys_GetProcAddress(handle, "alBuffer3f");
	qalBufferfv = Sys_GetProcAddress(handle, "alBufferfv");
	qalBufferi = Sys_GetProcAddress(handle, "alBufferi");
	qalBuffer3i = Sys_GetProcAddress(handle, "alBuffer3i");
	qalBufferiv = Sys_GetProcAddress(handle, "alBufferiv");
	qalGetBufferf = Sys_GetProcAddress(handle, "alGetBufferf");
	qalGetBuffer3f = Sys_GetProcAddress(handle, "alGetBuffer3f");
	qalGetBufferfv = Sys_GetProcAddress(handle, "alGetBufferfv");
	qalGetBufferi = Sys_GetProcAddress(handle, "alGetBufferi");
	qalGetBuffer3i = Sys_GetProcAddress(handle, "alGetBuffer3i");
	qalGetBufferiv = Sys_GetProcAddress(handle, "alGetBufferiv");
	qalDopplerFactor = Sys_GetProcAddress(handle, "alDopplerFactor");
	qalDopplerVelocity = Sys_GetProcAddress(handle, "alDopplerVelocity");
	qalSpeedOfSound = Sys_GetProcAddress(handle, "alSpeedOfSound");
	qalDistanceModel = Sys_GetProcAddress(handle, "alDistanceModel");
#if !defined (__APPLE__)	
	qalGenFilters = Sys_GetProcAddress(handle, "alGenFilters");
	qalFilteri = Sys_GetProcAddress(handle, "alFilteri");
	qalFilterf = Sys_GetProcAddress(handle, "alFilterf");
	qalDeleteFilters = Sys_GetProcAddress(handle, "alDeleteFilters");
#endif

	/* Open the OpenAL device */
    Com_Printf("...opening OpenAL device:");

	device = qalcOpenDevice(al_device->string[0] ? al_device->string : NULL);

	if(!device)
	{
		Com_DPrintf("failed\n");
		QAL_Shutdown();
		return false;
	}

	Com_Printf("ok\n");

	/* Create the OpenAL context */
	Com_Printf("...creating OpenAL context: ");

	context = qalcCreateContext(device, NULL);

	if(!context)
	{
		Com_DPrintf("failed\n");
		QAL_Shutdown();
		return false;
	}

	Com_Printf("ok\n");

	/* Set the created context as current context */
	Com_Printf("...making context current: ");

	if (!qalcMakeContextCurrent(context))
	{
		Com_DPrintf("failed\n");
		QAL_Shutdown();
		return false;
	}

	Com_Printf("ok\n");

	/* Print OpenAL informations */
	Com_Printf("\n");
	QAL_SoundInfo();
	Com_Printf("\n");

    return true;
}
コード例 #19
0
/*
=================
S_AL_Init
=================
*/
qboolean S_AL_Init( soundInterface_t *si )
{
#if USE_OPENAL

	qboolean enumsupport, founddev = qfalse;

	if( !si ) {
		return qfalse;
	}

	// New console variables
	s_alPrecache = Cvar_Get( "s_alPrecache", "1", CVAR_ARCHIVE );
	s_alGain = Cvar_Get( "s_alGain", "0.4", CVAR_ARCHIVE );
	s_alSources = Cvar_Get( "s_alSources", "96", CVAR_ARCHIVE );
	s_alDopplerFactor = Cvar_Get( "s_alDopplerFactor", "1.0", CVAR_ARCHIVE );
	s_alDopplerSpeed = Cvar_Get( "s_alDopplerSpeed", "2200", CVAR_ARCHIVE );
	s_alMinDistance = Cvar_Get( "s_alMinDistance", "120", CVAR_CHEAT );
	s_alMaxDistance = Cvar_Get("s_alMaxDistance", "1024", CVAR_CHEAT);
	s_alRolloff = Cvar_Get( "s_alRolloff", "2", CVAR_CHEAT);
	s_alGraceDistance = Cvar_Get("s_alGraceDistance", "512", CVAR_CHEAT);

	s_alDriver = Cvar_Get( "s_alDriver", ALDRIVER_DEFAULT, CVAR_ARCHIVE );

	// Load QAL
	if( !QAL_Init( s_alDriver->string ) )
	{
		Com_Printf( "Failed to load library: \"%s\".\n", s_alDriver->string );
		return qfalse;
	}

	// Device enumeration support (extension is implemented reasonably only on Windows right now).
	if((enumsupport = qalcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")))
	{
		char devicenames[1024] = "";
		const char *devicelist;
		const char *defaultdevice;
		int curlen;
		
		// get all available devices + the default device name.
		devicelist = qalcGetString(NULL, ALC_DEVICE_SPECIFIER);
		defaultdevice = qalcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);

#ifdef _WIN32
		// check whether the default device is generic hardware. If it is, change to
		// Generic Software as that one works more reliably with various sound systems.
		// If it's not, use OpenAL's default selection as we don't want to ignore
		// native hardware acceleration.
		if(!strcmp(defaultdevice, "Generic Hardware"))
			s_alDevice = Cvar_Get("s_alDevice", ALDEVICE_DEFAULT, CVAR_ARCHIVE | CVAR_LATCH);
		else
#endif
			s_alDevice = Cvar_Get("s_alDevice", defaultdevice, CVAR_ARCHIVE | CVAR_LATCH);

		// dump a list of available devices to a cvar for the user to see.
		while((curlen = strlen(devicelist)))
		{
			Q_strcat(devicenames, sizeof(devicenames), devicelist);
			Q_strcat(devicenames, sizeof(devicenames), "\n");

			// check whether the device we want to load is available at all.
			if(!strcmp(s_alDevice->string, devicelist))
				founddev = qtrue;

			devicelist += curlen + 1;
		}

		s_alAvailableDevices = Cvar_Get("s_alAvailableDevices", devicenames, CVAR_ROM | CVAR_NORESTART);
		
		if(!founddev)
		{
			Cvar_ForceReset("s_alDevice");
			founddev = 1;
		}
	}

	if(founddev)
		alDevice = qalcOpenDevice(s_alDevice->string);
	else
		alDevice = qalcOpenDevice(NULL);

	if( !alDevice )
	{
		QAL_Shutdown( );
		Com_Printf( "Failed to open OpenAL device.\n" );
		return qfalse;
	}

	if(enumsupport)
		Cvar_Set("s_alDevice", qalcGetString(alDevice, ALC_DEVICE_SPECIFIER));

	// Create OpenAL context
	alContext = qalcCreateContext( alDevice, NULL );
	if( !alContext )
	{
		QAL_Shutdown( );
		qalcCloseDevice( alDevice );
		Com_Printf( "Failed to create OpenAL context.\n" );
		return qfalse;
	}
	qalcMakeContextCurrent( alContext );

	// Initialize sources, buffers, music
	S_AL_BufferInit( );
	S_AL_SrcInit( );

	// Set up OpenAL parameters (doppler, etc)
	qalDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
	qalDopplerFactor( s_alDopplerFactor->value );
	qalDopplerVelocity( s_alDopplerSpeed->value );

	si->Shutdown = S_AL_Shutdown;
	si->StartSound = S_AL_StartSound;
	si->StartLocalSound = S_AL_StartLocalSound;
	si->StartBackgroundTrack = S_AL_StartBackgroundTrack;
	si->StopBackgroundTrack = S_AL_StopBackgroundTrack;
	si->RawSamples = S_AL_RawSamples;
	si->StopAllSounds = S_AL_StopAllSounds;
	si->ClearLoopingSounds = S_AL_ClearLoopingSounds;
	si->AddLoopingSound = S_AL_AddLoopingSound;
	si->AddRealLoopingSound = S_AL_AddRealLoopingSound;
	si->StopLoopingSound = S_AL_StopLoopingSound;
	si->Respatialize = S_AL_Respatialize;
	si->UpdateEntityPosition = S_AL_UpdateEntityPosition;
	si->Update = S_AL_Update;
	si->DisableSounds = S_AL_DisableSounds;
	si->BeginRegistration = S_AL_BeginRegistration;
	si->RegisterSound = S_AL_RegisterSound;
	si->ClearSoundBuffer = S_AL_ClearSoundBuffer;
	si->SoundInfo = S_AL_SoundInfo;
	si->SoundList = S_AL_SoundList;

	return qtrue;
#else
	return qfalse;
#endif
}
コード例 #20
0
ファイル: snd_qal.c プロジェクト: raynorpat/cake
qboolean QAL_Init (void)
{
#ifdef _WIN32
	char *libraries[] = { "soft_oal.dll", "openal32.dll", 0 };
#elif defined(__APPLE__)
	char *libraries[] = { "libopenal.dylib", "OpenAL-Soft.framework/OpenAL-Soft", "/System/Library/Frameworks/OpenAL.framework/OpenAL", 0 };
#else
	char *libraries[] = { "libopenal.so", "libopenal.so.0", "libopenal.so.1", 0 };
#endif
	char name[256];

	// init cvars
	al_device = Cvar_Get ("al_device", "", CVAR_ARCHIVE);
	al_driver = Cvar_Get ("al_driver", "", CVAR_ARCHIVE);

	// prevent the user from screwing themselves by setting an invalid library
	strncpy(name, al_driver->string, sizeof(name));
	Com_DPrintf("LoadLibrary (%s)\n", name);
	Sys_LoadLibrary(name, NULL, &handle);
	for (int i = 0; !handle && libraries[i] != NULL; i++)
	{
		Com_DPrintf("LoadLibrary (%s)\n", libraries[i]);
		Sys_LoadLibrary(libraries[i], NULL, &handle);
		if (handle)
		{
			// hey we got one!
			Cvar_Set("al_driver", libraries[i]);
		}
	}

	if (!handle)
	{
		Com_Printf(S_COLOR_RED "Loading %s failed! Disabling OpenAL.\n", al_driver->string);
		return false;
	}

#define QAL(type,func)  q##func = Sys_GetProcAddress (handle, #func);
QALC_IMP
QAL_IMP
#undef QAL

	// open the OpenAL device
	Com_DPrintf("...opening OpenAL device: ");

	// get list of OpenAL devices
	{
		char* devices = (char*)qalcGetString(NULL, ALC_DEVICE_SPECIFIER);
		while (!device && devices && *devices != 0)
		{
			Com_DPrintf(S_COLOR_GREEN "...found OpenAL device: %s\n",devices);
			devices += strlen(devices) + 1; // on to the next device
		}
	}

	// try and open what the user has set as the device
	{
		const char *dev = al_device->string[0] ? al_device->string : qalcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
		Com_DPrintf("...attempting to open OpenAL device '%s': ", dev);
		device = qalcOpenDevice(dev);
	}

	// ugh, no device still, so open the default
	if (!device)
	{
		Com_DPrintf(S_COLOR_RED "failed!\n...attempting to open default OpenAL device: ");
		device = qalcOpenDevice(qalcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER));
	}

    if (!device)
        goto fail;
    Com_DPrintf (S_COLOR_GREEN "ok\n");

	// create OpenAL context
    Com_DPrintf ("...creating OpenAL context: ");
    context = qalcCreateContext (device, NULL);
    if (!context)
        goto fail;
    Com_DPrintf (S_COLOR_GREEN "ok\n");

	// make OpenAL context current
    Com_DPrintf ("...making context current: ");
    if (!qalcMakeContextCurrent(context))
        goto fail;
    Com_DPrintf (S_COLOR_GREEN "ok\n");

	// enumerate available HRTFs, and reset the device using one
	if (qalcIsExtensionPresent(device, "ALC_SOFT_HRTF"))
	{
		ALCint num_hrtf;

		qalcGetIntegerv(device, ALC_NUM_HRTF_SPECIFIERS_SOFT, 1, &num_hrtf);
		if (!num_hrtf)
		{
			Com_DPrintf(S_COLOR_RED "...no HRTFs found\n");
		}
		else
		{
			const char *hrtfname = "hrtf\\default-44100"; // default 44hz HRTF
			ALCint attr[5];
			ALCint index = -1;
			ALCint i;
			Com_DPrintf("...available HRTFs:\n");
			for (i = 0; i < num_hrtf; i++)
			{
				const ALCchar *name = qalcGetStringiSOFT(device, ALC_HRTF_SPECIFIER_SOFT, i);
				Com_DPrintf("    %d: %s\n", i, name);

				// Check if this is the HRTF the user requested
				if (hrtfname && strcmp(name, hrtfname) == 0)
					index = i;
			}
			i = 0;
			attr[i++] = ALC_HRTF_SOFT;
			attr[i++] = ALC_TRUE;
			if (index == -1)
			{
				if (hrtfname)
					Com_DPrintf(S_COLOR_RED "HRTF \"%s\" not found\n", hrtfname);
				Com_DPrintf(S_COLOR_GREEN "Using default HRTF...\n");
			}
			else
			{
				Com_DPrintf(S_COLOR_GREEN "Selecting HRTF %d...\n", index);
				attr[i++] = ALC_HRTF_ID_SOFT;
				attr[i++] = index;
			}
			attr[i] = 0;
			if (!qalcResetDeviceSOFT(device, attr))
				goto fail;
		}
	}

    return true;

fail:
    Com_DPrintf (S_COLOR_RED "failed\n");
    QAL_Shutdown ();
    return false;
}
コード例 #21
0
ファイル: qal.c プロジェクト: Clever-Boy/qfusion
/*
* QAL_Init
*/
bool QAL_Init( const char *libname, bool verbose )
{
	if( OpenALLib )
		return true;

	if( verbose )
		Com_Printf( "Loading OpenAL library: %s\n", libname );

	if( ( OpenALLib = OBJLOAD( libname ) ) == 0 )
	{
#ifdef _WIN32
		return false;
#else
		char fn[2048];

		if( getcwd( fn, sizeof( fn ) ) == NULL )
			return false;

		Q_strncatz( fn, "/", sizeof( fn ) );
		Q_strncatz( fn, libname, sizeof( fn ) );

		if( ( OpenALLib = OBJLOAD( fn ) ) == 0 )
			return false;
#endif
	}

	alinit_fail = false;

	qalEnable = GPA( "alEnable" );
	qalDisable = GPA( "alDisable" );
	qalIsEnabled = GPA( "alIsEnabled" );
	qalGetString = GPA( "alGetString" );
	qalGetBooleanv = GPA( "alGetBooleanv" );
	qalGetIntegerv = GPA( "alGetIntegerv" );
	qalGetFloatv = GPA( "alGetFloatv" );
	qalGetDoublev = GPA( "alGetDoublev" );
	qalGetBoolean = GPA( "alGetBoolean" );
	qalGetInteger = GPA( "alGetInteger" );
	qalGetFloat = GPA( "alGetFloat" );
	qalGetDouble = GPA( "alGetDouble" );
	qalGetError = GPA( "alGetError" );
	qalIsExtensionPresent = GPA( "alIsExtensionPresent" );
	qalGetProcAddress = GPA( "alGetProcAddress" );
	qalGetEnumValue = GPA( "alGetEnumValue" );
	qalListenerf = GPA( "alListenerf" );
	qalListener3f = GPA( "alListener3f" );
	qalListenerfv = GPA( "alListenerfv" );
	qalListeneri = GPA( "alListeneri" );
	qalGetListenerf = GPA( "alGetListenerf" );
	qalGetListener3f = GPA( "alGetListener3f" );
	qalGetListenerfv = GPA( "alGetListenerfv" );
	qalGetListeneri = GPA( "alGetListeneri" );
	qalGenSources = GPA( "alGenSources" );
	qalDeleteSources = GPA( "alDeleteSources" );
	qalIsSource = GPA( "alIsSource" );
	qalSourcef = GPA( "alSourcef" );
	qalSource3f = GPA( "alSource3f" );
	qalSourcefv = GPA( "alSourcefv" );
	qalSourcei = GPA( "alSourcei" );
	qalGetSourcef = GPA( "alGetSourcef" );
	qalGetSource3f = GPA( "alGetSource3f" );
	qalGetSourcefv = GPA( "alGetSourcefv" );
	qalGetSourcei = GPA( "alGetSourcei" );
	qalSourcePlayv = GPA( "alSourcePlayv" );
	qalSourceStopv = GPA( "alSourceStopv" );
	qalSourceRewindv = GPA( "alSourceRewindv" );
	qalSourcePausev = GPA( "alSourcePausev" );
	qalSourcePlay = GPA( "alSourcePlay" );
	qalSourceStop = GPA( "alSourceStop" );
	qalSourceRewind = GPA( "alSourceRewind" );
	qalSourcePause = GPA( "alSourcePause" );
	qalSourceQueueBuffers = GPA( "alSourceQueueBuffers" );
	qalSourceUnqueueBuffers = GPA( "alSourceUnqueueBuffers" );
	qalGenBuffers = GPA( "alGenBuffers" );
	qalDeleteBuffers = GPA( "alDeleteBuffers" );
	qalIsBuffer = GPA( "alIsBuffer" );
	qalBufferData = GPA( "alBufferData" );
	qalGetBufferf = GPA( "alGetBufferf" );
	qalGetBufferi = GPA( "alGetBufferi" );
	qalDopplerFactor = GPA( "alDopplerFactor" );
	qalDopplerVelocity = GPA( "alDopplerVelocity" );
	qalSpeedOfSound = GPA( "alSpeedOfSound" );
	qalDistanceModel = GPA( "alDistanceModel" );

	qalcCreateContext = GPA( "alcCreateContext" );
	qalcMakeContextCurrent = GPA( "alcMakeContextCurrent" );
	qalcProcessContext = GPA( "alcProcessContext" );
	qalcSuspendContext = GPA( "alcSuspendContext" );
	qalcDestroyContext = GPA( "alcDestroyContext" );
	qalcGetCurrentContext = GPA( "alcGetCurrentContext" );
	qalcGetContextsDevice = GPA( "alcGetContextsDevice" );
	qalcOpenDevice = GPA( "alcOpenDevice" );
	qalcCloseDevice = GPA( "alcCloseDevice" );
	qalcGetError = GPA( "alcGetError" );
	qalcIsExtensionPresent = GPA( "alcIsExtensionPresent" );
	qalcGetProcAddress = GPA( "alcGetProcAddress" );
	qalcGetEnumValue = GPA( "alcGetEnumValue" );
	qalcGetString = GPA( "alcGetString" );
	qalcGetIntegerv = GPA( "alcGetIntegerv" );

	if( alinit_fail )
	{
		QAL_Shutdown();
		Com_Printf( " Error: One or more symbols not found.\n" );
		return false;
	}

	return true;
}
コード例 #22
0
ファイル: qal.c プロジェクト: DanielGibson/yquake2
/*
 * Loads the OpenAL shared lib, creates
 * a context and device handle.
 */
qboolean
QAL_Init()
{
	al_device = Cvar_Get("al_device", "", CVAR_ARCHIVE);

#ifdef DLOPEN_OPENAL
	/* DEFAULT_OPENAL_DRIVER is defined at compile time via the compiler */
	al_driver = Cvar_Get("al_driver", DEFAULT_OPENAL_DRIVER, CVAR_ARCHIVE);

	Com_Printf("LoadLibrary(%s)\n", al_driver->string);

	/* Load the library */
	Sys_LoadLibrary(al_driver->string, NULL, &handle);

	if (!handle)
	{
		Com_Printf("Loading %s failed! Disabling OpenAL.\n", al_driver->string);
		return false;
	}
#	define ALSYMBOL(handle, sym) Sys_GetProcAddress(handle, #sym)
#else
	handle = NULL;
#	define ALSYMBOL(handle, sym) sym
#endif

	/* Connect function pointers to management functions */
	qalcCreateContext = ALSYMBOL(handle, alcCreateContext);
	qalcMakeContextCurrent = ALSYMBOL(handle, alcMakeContextCurrent);
	qalcProcessContext = ALSYMBOL(handle, alcProcessContext);
	qalcSuspendContext = ALSYMBOL(handle, alcSuspendContext);
	qalcDestroyContext = ALSYMBOL(handle, alcDestroyContext);
	qalcGetCurrentContext = ALSYMBOL(handle, alcGetCurrentContext);
	qalcGetContextsDevice = ALSYMBOL(handle, alcGetContextsDevice);
	qalcOpenDevice = ALSYMBOL(handle, alcOpenDevice);
	qalcCloseDevice = ALSYMBOL(handle, alcCloseDevice);
	qalcGetError = ALSYMBOL(handle, alcGetError);
	qalcIsExtensionPresent = ALSYMBOL(handle, alcIsExtensionPresent);
	qalcGetProcAddress = ALSYMBOL(handle, alcGetProcAddress);
	qalcGetEnumValue = ALSYMBOL(handle, alcGetEnumValue);
	qalcGetString = ALSYMBOL(handle, alcGetString);
	qalcGetIntegerv = ALSYMBOL(handle, alcGetIntegerv);
	qalcCaptureOpenDevice = ALSYMBOL(handle, alcCaptureOpenDevice);
	qalcCaptureCloseDevice = ALSYMBOL(handle, alcCaptureCloseDevice);
	qalcCaptureStart = ALSYMBOL(handle, alcCaptureStart);
	qalcCaptureStop = ALSYMBOL(handle, alcCaptureStop);
	qalcCaptureSamples = ALSYMBOL(handle, alcCaptureSamples);

	/* Connect function pointers to
	   to OpenAL API functions */
	qalEnable = ALSYMBOL(handle, alEnable);
	qalDisable = ALSYMBOL(handle, alDisable);
	qalIsEnabled = ALSYMBOL(handle, alIsEnabled);
	qalGetString = ALSYMBOL(handle, alGetString);
	qalGetBooleanv = ALSYMBOL(handle, alGetBooleanv);
	qalGetIntegerv = ALSYMBOL(handle, alGetIntegerv);
	qalGetFloatv = ALSYMBOL(handle, alGetFloatv);
	qalGetDoublev = ALSYMBOL(handle, alGetDoublev);
	qalGetBoolean = ALSYMBOL(handle, alGetBoolean);
	qalGetInteger = ALSYMBOL(handle, alGetInteger);
	qalGetFloat = ALSYMBOL(handle, alGetFloat);
	qalGetDouble = ALSYMBOL(handle, alGetDouble);
	qalGetError = ALSYMBOL(handle, alGetError);
	qalIsExtensionPresent = ALSYMBOL(handle, alIsExtensionPresent);
	qalGetProcAddress = ALSYMBOL(handle, alGetProcAddress);
	qalGetEnumValue = ALSYMBOL(handle, alGetEnumValue);
	qalListenerf = ALSYMBOL(handle, alListenerf);
	qalListener3f = ALSYMBOL(handle, alListener3f);
	qalListenerfv = ALSYMBOL(handle, alListenerfv);
	qalListeneri = ALSYMBOL(handle, alListeneri);
	qalListener3i = ALSYMBOL(handle, alListener3i);
	qalListeneriv = ALSYMBOL(handle, alListeneriv);
	qalGetListenerf = ALSYMBOL(handle, alGetListenerf);
	qalGetListener3f = ALSYMBOL(handle, alGetListener3f);
	qalGetListenerfv = ALSYMBOL(handle, alGetListenerfv);
	qalGetListeneri = ALSYMBOL(handle, alGetListeneri);
	qalGetListener3i = ALSYMBOL(handle, alGetListener3i);
	qalGetListeneriv = ALSYMBOL(handle, alGetListeneriv);
	qalGenSources = ALSYMBOL(handle, alGenSources);
	qalDeleteSources = ALSYMBOL(handle, alDeleteSources);
	qalIsSource = ALSYMBOL(handle, alIsSource);
	qalSourcef = ALSYMBOL(handle, alSourcef);
	qalSource3f = ALSYMBOL(handle, alSource3f);
	qalSourcefv = ALSYMBOL(handle, alSourcefv);
	qalSourcei = ALSYMBOL(handle, alSourcei);
	qalSource3i = ALSYMBOL(handle, alSource3i);
	qalSourceiv = ALSYMBOL(handle, alSourceiv);
	qalGetSourcef = ALSYMBOL(handle, alGetSourcef);
	qalGetSource3f = ALSYMBOL(handle, alGetSource3f);
	qalGetSourcefv = ALSYMBOL(handle, alGetSourcefv);
	qalGetSourcei = ALSYMBOL(handle, alGetSourcei);
	qalGetSource3i = ALSYMBOL(handle, alGetSource3i);
	qalGetSourceiv = ALSYMBOL(handle, alGetSourceiv);
	qalSourcePlayv = ALSYMBOL(handle, alSourcePlayv);
	qalSourceStopv = ALSYMBOL(handle, alSourceStopv);
	qalSourceRewindv = ALSYMBOL(handle, alSourceRewindv);
	qalSourcePausev = ALSYMBOL(handle, alSourcePausev);
	qalSourcePlay = ALSYMBOL(handle, alSourcePlay);
	qalSourceStop = ALSYMBOL(handle, alSourceStop);
	qalSourceRewind = ALSYMBOL(handle, alSourceRewind);
	qalSourcePause = ALSYMBOL(handle, alSourcePause);
	qalSourceQueueBuffers = ALSYMBOL(handle, alSourceQueueBuffers);
	qalSourceUnqueueBuffers = ALSYMBOL(handle, alSourceUnqueueBuffers);
	qalGenBuffers = ALSYMBOL(handle, alGenBuffers);
	qalDeleteBuffers = ALSYMBOL(handle, alDeleteBuffers);
	qalIsBuffer = ALSYMBOL(handle, alIsBuffer);
	qalBufferData = ALSYMBOL(handle, alBufferData);
	qalBufferf = ALSYMBOL(handle, alBufferf);
	qalBuffer3f = ALSYMBOL(handle, alBuffer3f);
	qalBufferfv = ALSYMBOL(handle, alBufferfv);
	qalBufferi = ALSYMBOL(handle, alBufferi);
	qalBuffer3i = ALSYMBOL(handle, alBuffer3i);
	qalBufferiv = ALSYMBOL(handle, alBufferiv);
	qalGetBufferf = ALSYMBOL(handle, alGetBufferf);
	qalGetBuffer3f = ALSYMBOL(handle, alGetBuffer3f);
	qalGetBufferfv = ALSYMBOL(handle, alGetBufferfv);
	qalGetBufferi = ALSYMBOL(handle, alGetBufferi);
	qalGetBuffer3i = ALSYMBOL(handle, alGetBuffer3i);
	qalGetBufferiv = ALSYMBOL(handle, alGetBufferiv);
	qalDopplerFactor = ALSYMBOL(handle, alDopplerFactor);
	qalDopplerVelocity = ALSYMBOL(handle, alDopplerVelocity);
	qalSpeedOfSound = ALSYMBOL(handle, alSpeedOfSound);
	qalDistanceModel = ALSYMBOL(handle, alDistanceModel);

	/* Open the OpenAL device */
    Com_Printf("...opening OpenAL device:");

	device = qalcOpenDevice(al_device->string[0] ? al_device->string : NULL);

	if(!device)
	{
		Com_DPrintf("failed\n");
		QAL_Shutdown();
		return false;
	}

	Com_Printf("ok\n");

	/* Create the OpenAL context */
	Com_Printf("...creating OpenAL context: ");

	context = qalcCreateContext(device, NULL);

	if(!context)
	{
		Com_DPrintf("failed\n");
		QAL_Shutdown();
		return false;
	}

	Com_Printf("ok\n");

	/* Set the created context as current context */
	Com_Printf("...making context current: ");

	if (!qalcMakeContextCurrent(context))
	{
		Com_DPrintf("failed\n");
		QAL_Shutdown();
		return false;
	}

    if (qalcIsExtensionPresent(device, "ALC_EXT_EFX") != AL_FALSE) {
        qalGenFilters = qalGetProcAddress("alGenFilters");
        qalFilteri = qalGetProcAddress("alFilteri");
        qalFilterf = qalGetProcAddress("alFilterf");
        qalDeleteFilters = qalGetProcAddress("alDeleteFilters");
    } else {
        qalGenFilters = NULL;
        qalFilteri = NULL;
        qalFilterf = NULL;
        qalDeleteFilters = NULL;
    }

	Com_Printf("ok\n");

	/* Print OpenAL informations */
	Com_Printf("\n");
	QAL_SoundInfo();
	Com_Printf("\n");

    return true;
}
コード例 #23
0
ファイル: qal.c プロジェクト: ioid3-games/ioid3-rtcw
/*
=======================================================================================================================================
QAL_Init
=======================================================================================================================================
*/
qboolean QAL_Init(const char *libname) {

	if (OpenALLib) {
		return qtrue;
	}

	if (!(OpenALLib = Sys_LoadDll(libname, qtrue)))
		return qfalse;

	alinit_fail = qfalse;

	qalEnable = GPA("alEnable");
	qalDisable = GPA("alDisable");
	qalIsEnabled = GPA("alIsEnabled");
	qalGetString = GPA("alGetString");
	qalGetBooleanv = GPA("alGetBooleanv");
	qalGetIntegerv = GPA("alGetIntegerv");
	qalGetFloatv = GPA("alGetFloatv");
	qalGetDoublev = GPA("alGetDoublev");
	qalGetBoolean = GPA("alGetBoolean");
	qalGetInteger = GPA("alGetInteger");
	qalGetFloat = GPA("alGetFloat");
	qalGetDouble = GPA("alGetDouble");
	qalGetError = GPA("alGetError");
	qalIsExtensionPresent = GPA("alIsExtensionPresent");
	qalGetProcAddress = GPA("alGetProcAddress");
	qalGetEnumValue = GPA("alGetEnumValue");
	qalListenerf = GPA("alListenerf");
	qalListener3f = GPA("alListener3f");
	qalListenerfv = GPA("alListenerfv");
	qalListeneri = GPA("alListeneri");
	qalGetListenerf = GPA("alGetListenerf");
	qalGetListener3f = GPA("alGetListener3f");
	qalGetListenerfv = GPA("alGetListenerfv");
	qalGetListeneri = GPA("alGetListeneri");
	qalGenSources = GPA("alGenSources");
	qalDeleteSources = GPA("alDeleteSources");
	qalIsSource = GPA("alIsSource");
	qalSourcef = GPA("alSourcef");
	qalSource3f = GPA("alSource3f");
	qalSourcefv = GPA("alSourcefv");
	qalSourcei = GPA("alSourcei");
	qalGetSourcef = GPA("alGetSourcef");
	qalGetSource3f = GPA("alGetSource3f");
	qalGetSourcefv = GPA("alGetSourcefv");
	qalGetSourcei = GPA("alGetSourcei");
	qalSourcePlayv = GPA("alSourcePlayv");
	qalSourceStopv = GPA("alSourceStopv");
	qalSourceRewindv = GPA("alSourceRewindv");
	qalSourcePausev = GPA("alSourcePausev");
	qalSourcePlay = GPA("alSourcePlay");
	qalSourceStop = GPA("alSourceStop");
	qalSourceRewind = GPA("alSourceRewind");
	qalSourcePause = GPA("alSourcePause");
	qalSourceQueueBuffers = GPA("alSourceQueueBuffers");
	qalSourceUnqueueBuffers = GPA("alSourceUnqueueBuffers");
	qalGenBuffers = GPA("alGenBuffers");
	qalDeleteBuffers = GPA("alDeleteBuffers");
	qalIsBuffer = GPA("alIsBuffer");
	qalBufferData = GPA("alBufferData");
	qalGetBufferf = GPA("alGetBufferf");
	qalGetBufferi = GPA("alGetBufferi");
	qalDopplerFactor = GPA("alDopplerFactor");
	qalSpeedOfSound = GPA("alSpeedOfSound");
	qalDistanceModel = GPA("alDistanceModel");

	qalcCreateContext = GPA("alcCreateContext");
	qalcMakeContextCurrent = GPA("alcMakeContextCurrent");
	qalcProcessContext = GPA("alcProcessContext");
	qalcSuspendContext = GPA("alcSuspendContext");
	qalcDestroyContext = GPA("alcDestroyContext");
	qalcGetCurrentContext = GPA("alcGetCurrentContext");
	qalcGetContextsDevice = GPA("alcGetContextsDevice");
	qalcOpenDevice = GPA("alcOpenDevice");
	qalcCloseDevice = GPA("alcCloseDevice");
	qalcGetError = GPA("alcGetError");
	qalcIsExtensionPresent = GPA("alcIsExtensionPresent");
	qalcGetProcAddress = GPA("alcGetProcAddress");
	qalcGetEnumValue = GPA("alcGetEnumValue");
	qalcGetString = GPA("alcGetString");
	qalcGetIntegerv = GPA("alcGetIntegerv");
	qalcCaptureOpenDevice = GPA("alcCaptureOpenDevice");
	qalcCaptureCloseDevice = GPA("alcCaptureCloseDevice");
	qalcCaptureStart = GPA("alcCaptureStart");
	qalcCaptureStop = GPA("alcCaptureStop");
	qalcCaptureSamples = GPA("alcCaptureSamples");

	if (alinit_fail) {
		QAL_Shutdown();
		Com_Printf(" One or more symbols not found\n");
		return qfalse;
	}

	return qtrue;
}
コード例 #24
0
/*
=================
QAL_Init
=================
*/
qboolean QAL_Init(const char *libname)
{
	if(OpenALLib)
		return qtrue;

	Com_Printf( "Loading \"%s\"...\n", libname);
	if( (OpenALLib = Sys_LoadLibrary(libname)) == 0 )
	{
#ifdef _WIN32
		return qfalse;
#else
		char fn[1024];
		Q_strncpyz( fn, Sys_Cwd( ), sizeof( fn ) );
		strncat(fn, "/", sizeof(fn) - strlen(fn) - 1);
		strncat(fn, libname, sizeof(fn) - strlen(fn) - 1);

		if( (OpenALLib = Sys_LoadLibrary(fn)) == 0 )
		{
			return qfalse;
		}
#endif
	}

	alinit_fail = qfalse;

	qalEnable = GPA("alEnable");
	qalDisable = GPA("alDisable");
	qalIsEnabled = GPA("alIsEnabled");
	qalGetString = GPA("alGetString");
	qalGetBooleanv = GPA("alGetBooleanv");
	qalGetIntegerv = GPA("alGetIntegerv");
	qalGetFloatv = GPA("alGetFloatv");
	qalGetDoublev = GPA("alGetDoublev");
	qalGetBoolean = GPA("alGetBoolean");
	qalGetInteger = GPA("alGetInteger");
	qalGetFloat = GPA("alGetFloat");
	qalGetDouble = GPA("alGetDouble");
	qalGetError = GPA("alGetError");
	qalIsExtensionPresent = GPA("alIsExtensionPresent");
	qalGetProcAddress = GPA("alGetProcAddress");
	qalGetEnumValue = GPA("alGetEnumValue");
	qalListenerf = GPA("alListenerf");
	qalListener3f = GPA("alListener3f");
	qalListenerfv = GPA("alListenerfv");
	qalListeneri = GPA("alListeneri");
	qalGetListenerf = GPA("alGetListenerf");
	qalGetListener3f = GPA("alGetListener3f");
	qalGetListenerfv = GPA("alGetListenerfv");
	qalGetListeneri = GPA("alGetListeneri");
	qalGenSources = GPA("alGenSources");
	qalDeleteSources = GPA("alDeleteSources");
	qalIsSource = GPA("alIsSource");
	qalSourcef = GPA("alSourcef");
	qalSource3f = GPA("alSource3f");
	qalSourcefv = GPA("alSourcefv");
	qalSourcei = GPA("alSourcei");
	qalGetSourcef = GPA("alGetSourcef");
	qalGetSource3f = GPA("alGetSource3f");
	qalGetSourcefv = GPA("alGetSourcefv");
	qalGetSourcei = GPA("alGetSourcei");
	qalSourcePlayv = GPA("alSourcePlayv");
	qalSourceStopv = GPA("alSourceStopv");
	qalSourceRewindv = GPA("alSourceRewindv");
	qalSourcePausev = GPA("alSourcePausev");
	qalSourcePlay = GPA("alSourcePlay");
	qalSourceStop = GPA("alSourceStop");
	qalSourceRewind = GPA("alSourceRewind");
	qalSourcePause = GPA("alSourcePause");
	qalSourceQueueBuffers = GPA("alSourceQueueBuffers");
	qalSourceUnqueueBuffers = GPA("alSourceUnqueueBuffers");
	qalGenBuffers = GPA("alGenBuffers");
	qalDeleteBuffers = GPA("alDeleteBuffers");
	qalIsBuffer = GPA("alIsBuffer");
	qalBufferData = GPA("alBufferData");
	qalGetBufferf = GPA("alGetBufferf");
	qalGetBufferi = GPA("alGetBufferi");
	qalDopplerFactor = GPA("alDopplerFactor");
	qalDopplerVelocity = GPA("alDopplerVelocity");
	qalDistanceModel = GPA("alDistanceModel");

	qalcCreateContext = GPA("alcCreateContext");
	qalcMakeContextCurrent = GPA("alcMakeContextCurrent");
	qalcProcessContext = GPA("alcProcessContext");
	qalcSuspendContext = GPA("alcSuspendContext");
	qalcDestroyContext = GPA("alcDestroyContext");
	qalcGetCurrentContext = GPA("alcGetCurrentContext");
	qalcGetContextsDevice = GPA("alcGetContextsDevice");
	qalcOpenDevice = GPA("alcOpenDevice");
	qalcCloseDevice = GPA("alcCloseDevice");
	qalcGetError = GPA("alcGetError");
	qalcIsExtensionPresent = GPA("alcIsExtensionPresent");
	qalcGetProcAddress = GPA("alcGetProcAddress");
	qalcGetEnumValue = GPA("alcGetEnumValue");
	qalcGetString = GPA("alcGetString");
	qalcGetIntegerv = GPA("alcGetIntegerv");
	qalcCaptureOpenDevice = GPA("alcCaptureOpenDevice");
	qalcCaptureCloseDevice = GPA("alcCaptureCloseDevice");
	qalcCaptureStart = GPA("alcCaptureStart");
	qalcCaptureStop = GPA("alcCaptureStop");
	qalcCaptureSamples = GPA("alcCaptureSamples");

	if(alinit_fail)
	{
		QAL_Shutdown();
		Com_Printf( " One or more symbols not found\n");
		return qfalse;
	}

	return qtrue;
}
コード例 #25
0
/*
=================
S_AL_Init
=================
*/
qboolean S_AL_Init( soundInterface_t *si )
{
#ifdef USE_OPENAL

	qboolean enumsupport, founddev = qfalse;
	int i;

	if( !si ) {
		return qfalse;
	}

	for (i = 0; i < MAX_RAW_STREAMS; i++) {
		streamSourceHandles[i] = -1;
		streamPlaying[i] = qfalse;
		streamSources[i] = 0;
	}

	// New console variables
	s_alPrecache = Cvar_Get( "s_alPrecache", "1", CVAR_ARCHIVE );
	s_alGain = Cvar_Get( "s_alGain", "1.0", CVAR_ARCHIVE );
	s_alSources = Cvar_Get( "s_alSources", "96", CVAR_ARCHIVE );
	s_alDopplerFactor = Cvar_Get( "s_alDopplerFactor", "1.0", CVAR_ARCHIVE );
	s_alDopplerSpeed = Cvar_Get( "s_alDopplerSpeed", "2200", CVAR_ARCHIVE );
	s_alMinDistance = Cvar_Get( "s_alMinDistance", "120", CVAR_CHEAT );
	s_alMaxDistance = Cvar_Get("s_alMaxDistance", "1024", CVAR_CHEAT);
	s_alRolloff = Cvar_Get( "s_alRolloff", "2", CVAR_CHEAT);
	s_alGraceDistance = Cvar_Get("s_alGraceDistance", "512", CVAR_CHEAT);

	s_alDriver = Cvar_Get( "s_alDriver", ALDRIVER_DEFAULT, CVAR_ARCHIVE );

	// Load QAL
	if( !QAL_Init( s_alDriver->string ) )
	{
		Com_Printf( "Failed to load library: \"%s\".\n", s_alDriver->string );
		return qfalse;
	}

	// Device enumeration support (extension is implemented reasonably only on Windows right now).
	if((enumsupport = qalcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")))
	{
		char devicenames[1024] = "";
		const char *devicelist;
		const char *defaultdevice;
		int curlen;
		
		// get all available devices + the default device name.
		devicelist = qalcGetString(NULL, ALC_DEVICE_SPECIFIER);
		defaultdevice = qalcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);

#ifdef _WIN32
		// check whether the default device is generic hardware. If it is, change to
		// Generic Software as that one works more reliably with various sound systems.
		// If it's not, use OpenAL's default selection as we don't want to ignore
		// native hardware acceleration.
		if(!strcmp(defaultdevice, "Generic Hardware"))
			s_alDevice = Cvar_Get("s_alDevice", ALDEVICE_DEFAULT, CVAR_ARCHIVE | CVAR_LATCH);
		else
#endif
			s_alDevice = Cvar_Get("s_alDevice", defaultdevice, CVAR_ARCHIVE | CVAR_LATCH);

		// dump a list of available devices to a cvar for the user to see.
		while((curlen = strlen(devicelist)))
		{
			Q_strcat(devicenames, sizeof(devicenames), devicelist);
			Q_strcat(devicenames, sizeof(devicenames), "\n");

			// check whether the device we want to load is available at all.
			if(!strcmp(s_alDevice->string, devicelist))
				founddev = qtrue;

			devicelist += curlen + 1;
		}

		s_alAvailableDevices = Cvar_Get("s_alAvailableDevices", devicenames, CVAR_ROM | CVAR_NORESTART);
		
		if(!founddev)
		{
			Cvar_ForceReset("s_alDevice");
			founddev = 1;
		}
	}

	if(founddev)
		alDevice = qalcOpenDevice(s_alDevice->string);
	else
		alDevice = qalcOpenDevice(NULL);

	if( !alDevice )
	{
		QAL_Shutdown( );
		Com_Printf( "Failed to open OpenAL device.\n" );
		return qfalse;
	}

	if(enumsupport)
		Cvar_Set("s_alDevice", qalcGetString(alDevice, ALC_DEVICE_SPECIFIER));

	// Create OpenAL context
	alContext = qalcCreateContext( alDevice, NULL );
	if( !alContext )
	{
		QAL_Shutdown( );
		qalcCloseDevice( alDevice );
		Com_Printf( "Failed to create OpenAL context.\n" );
		return qfalse;
	}
	qalcMakeContextCurrent( alContext );

	// Initialize sources, buffers, music
	S_AL_BufferInit( );
	S_AL_SrcInit( );

	// Set up OpenAL parameters (doppler, etc)
	qalDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
	qalDopplerFactor( s_alDopplerFactor->value );
	qalDopplerVelocity( s_alDopplerSpeed->value );

#ifdef USE_VOIP
	// !!! FIXME: some of these alcCaptureOpenDevice() values should be cvars.
	// !!! FIXME: add support for capture device enumeration.
	// !!! FIXME: add some better error reporting.
	s_alCapture = Cvar_Get( "s_alCapture", "1", CVAR_ARCHIVE | CVAR_LATCH );
	if (!s_alCapture->integer)
	{
		Com_Printf("OpenAL capture support disabled by user ('+set s_alCapture 1' to enable)\n");
	}
#if USE_MUMBLE
	else if (cl_useMumble->integer)
	{
		Com_Printf("OpenAL capture support disabled for Mumble support\n");
	}
#endif
	else
	{
#ifdef MACOS_X
		// !!! FIXME: Apple has a 1.1-compliant OpenAL, which includes
		// !!! FIXME:  capture support, but they don't list it in the
		// !!! FIXME:  extension string. We need to check the version string,
		// !!! FIXME:  then the extension string, but that's too much trouble,
		// !!! FIXME:  so we'll just check the function pointer for now.
		if (qalcCaptureOpenDevice == NULL)
#else
		if (!qalcIsExtensionPresent(NULL, "ALC_EXT_capture"))
#endif
		{
			Com_Printf("No ALC_EXT_capture support, can't record audio.\n");
		}
		else
		{
			// !!! FIXME: 8000Hz is what Speex narrowband mode needs, but we
			// !!! FIXME:  should probably open the capture device after
			// !!! FIXME:  initializing Speex so we can change to wideband
			// !!! FIXME:  if we like.
			Com_Printf("OpenAL default capture device is '%s'\n",
			           qalcGetString(NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));
			alCaptureDevice = qalcCaptureOpenDevice(NULL, 8000, AL_FORMAT_MONO16, 4096);
			Com_Printf( "OpenAL capture device %s.\n",
			            (alCaptureDevice == NULL) ? "failed to open" : "opened");
		}
	}
#endif

	si->Shutdown = S_AL_Shutdown;
	si->StartSound = S_AL_StartSound;
	si->StartLocalSound = S_AL_StartLocalSound;
	si->StartBackgroundTrack = S_AL_StartBackgroundTrack;
	si->StopBackgroundTrack = S_AL_StopBackgroundTrack;
	si->RawSamples = S_AL_RawSamples;
	si->StopAllSounds = S_AL_StopAllSounds;
	si->ClearLoopingSounds = S_AL_ClearLoopingSounds;
	si->AddLoopingSound = S_AL_AddLoopingSound;
	si->AddRealLoopingSound = S_AL_AddRealLoopingSound;
	si->StopLoopingSound = S_AL_StopLoopingSound;
	si->Respatialize = S_AL_Respatialize;
	si->UpdateEntityPosition = S_AL_UpdateEntityPosition;
	si->Update = S_AL_Update;
	si->DisableSounds = S_AL_DisableSounds;
	si->BeginRegistration = S_AL_BeginRegistration;
	si->RegisterSound = S_AL_RegisterSound;
	si->SoundDuration = S_AL_SoundDuration;
	si->ClearSoundBuffer = S_AL_ClearSoundBuffer;
	si->SoundInfo = S_AL_SoundInfo;
	si->SoundList = S_AL_SoundList;

#ifdef USE_VOIP
	si->StartCapture = S_AL_StartCapture;
	si->AvailableCaptureSamples = S_AL_AvailableCaptureSamples;
	si->Capture = S_AL_Capture;
	si->StopCapture = S_AL_StopCapture;
	si->MasterGain = S_AL_MasterGain;
#endif

	return qtrue;
#else
	return qfalse;
#endif
}