MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / SFXALDevice

Method SFXALDevice

Engine/source/sfx/openal/sfxALDevice.cpp:108–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106//-----------------------------------------------------------------------------
107
108SFXALDevice::SFXALDevice( SFXProvider *provider,
109 const OPENALFNTABLE &openal,
110 String name,
111 bool useHardware,
112 S32 maxBuffers )
113 : Parent( name, provider, useHardware, maxBuffers ),
114 mOpenAL( openal ),
115 mContext( NULL ),
116 mDevice( NULL ),
117 mDistanceModel(SFXDistanceModelLinear),
118 mDistanceFactor(1.0f),
119 mRolloffFactor( 1.0f ),
120 mUserRolloffFactor(1.0f)
121{
122 mMaxBuffers = getMax( maxBuffers, 8 );
123
124 // TODO: The OpenAL device doesn't set the primary buffer
125 // $pref::SFX::frequency or $pref::SFX::bitrate!
126 //check auxiliary device sends 4 and add them to the device
127 ALint attribs[4] = { 0 };
128#if defined(AL_ALEXT_PROTOTYPES)
129 ALCint iSends = 0;
130 attribs[0] = ALC_MAX_AUXILIARY_SENDS;
131#endif
132 attribs[1] = 4;
133
134 printALInfo(NULL);
135
136 mDevice = mOpenAL.alcOpenDevice( name );
137 U32 err = mOpenAL.alcGetError(mDevice);
138 if (err != ALC_NO_ERROR)
139 Con::errorf("SFXALDevice - Device Initialization Error: %s", mOpenAL.alcGetString(mDevice, err));
140
141 if( mDevice )
142 {
143 mContext = mOpenAL.alcCreateContext( mDevice, attribs );
144
145 if( mContext )
146 mOpenAL.alcMakeContextCurrent( mContext );
147
148#if defined(AL_ALEXT_PROTOTYPES)
149 mOpenAL.alcGetIntegerv(mDevice, ALC_MAX_AUXILIARY_SENDS, 1, &iSends);
150#endif
151 U32 err = mOpenAL.alcGetError( mDevice );
152
153 if( err != ALC_NO_ERROR )
154 Con::errorf( "SFXALDevice - Context Initialization Error: %s", mOpenAL.alcGetString( mDevice, err ) );
155 }
156
157 AssertFatal( mDevice != NULL && mContext != NULL, "Failed to create OpenAL device and/or context!" );
158
159 // Start the update thread.
160 // TODO AsyncPeriodicUpdateThread support for Linux/Mac
161#ifdef TORQUE_OS_WIN
162 if( !Con::getBoolVariable( "$_forceAllMainThread" ) )
163 {
164 SFXInternal::gUpdateThread = new AsyncPeriodicUpdateThread
165 ( "OpenAL Update Thread", SFXInternal::gBufferUpdateList,

Callers

nothing calls this directly

Calls 8

getMaxFunction · 0.85
printALInfoFunction · 0.85
getBoolVariableFunction · 0.85
getIntVariableFunction · 0.85
printfFunction · 0.85
errorfFunction · 0.50
dMemsetFunction · 0.50
startMethod · 0.45

Tested by

no test coverage detected