~ubuntu-branches/ubuntu/quantal/openal-soft/quantal

« back to all changes in this revision

Viewing changes to OpenAL32/alListener.c

  • Committer: Package Import Robot
  • Author(s): Michael Terry
  • Date: 2012-05-22 10:14:53 UTC
  • mfrom: (7.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20120522101453-knsv1m1m8vl5ccfp
Tags: 1:1.14-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  - Add a symbols file for libopenal1
* debian/libopenal1.symbols:
  - Update for 1.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
AL_API ALvoid AL_APIENTRY alListenerf(ALenum eParam, ALfloat flValue)
30
30
{
31
 
    ALCcontext *pContext;
32
 
    ALboolean updateAll = AL_FALSE;
 
31
    ALCcontext *Context;
33
32
 
34
 
    pContext = GetContextSuspended();
35
 
    if(!pContext) return;
 
33
    Context = GetContextRef();
 
34
    if(!Context) return;
36
35
 
37
36
    switch(eParam)
38
37
    {
39
38
        case AL_GAIN:
40
 
            if(flValue >= 0.0f)
 
39
            if(flValue >= 0.0f && isfinite(flValue))
41
40
            {
42
 
                pContext->Listener.Gain = flValue;
43
 
                updateAll = AL_TRUE;
 
41
                Context->Listener.Gain = flValue;
 
42
                Context->UpdateSources = AL_TRUE;
44
43
            }
45
44
            else
46
 
                alSetError(pContext, AL_INVALID_VALUE);
 
45
                alSetError(Context, AL_INVALID_VALUE);
47
46
            break;
48
47
 
49
48
        case AL_METERS_PER_UNIT:
50
 
            if(flValue > 0.0f)
 
49
            if(flValue > 0.0f && isfinite(flValue))
51
50
            {
52
 
                pContext->Listener.MetersPerUnit = flValue;
53
 
                updateAll = AL_TRUE;
 
51
                Context->Listener.MetersPerUnit = flValue;
 
52
                Context->UpdateSources = AL_TRUE;
54
53
            }
55
54
            else
56
 
                alSetError(pContext, AL_INVALID_VALUE);
 
55
                alSetError(Context, AL_INVALID_VALUE);
57
56
            break;
58
57
 
59
58
        default:
60
 
            alSetError(pContext, AL_INVALID_ENUM);
 
59
            alSetError(Context, AL_INVALID_ENUM);
61
60
            break;
62
61
    }
63
62
 
64
 
    // Force updating the sources for these parameters, since even head-
65
 
    // relative sources are affected
66
 
    if(updateAll)
67
 
    {
68
 
        ALsizei pos;
69
 
        for(pos = 0;pos < pContext->SourceMap.size;pos++)
70
 
        {
71
 
            ALsource *source = pContext->SourceMap.array[pos].value;
72
 
            source->NeedsUpdate = AL_TRUE;
73
 
        }
74
 
    }
75
 
 
76
 
    ProcessContext(pContext);
 
63
    ALCcontext_DecRef(Context);
77
64
}
78
65
 
79
66
 
80
67
AL_API ALvoid AL_APIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat flValue2, ALfloat flValue3)
81
68
{
82
 
    ALCcontext *pContext;
83
 
    ALboolean updateWorld = AL_FALSE;
 
69
    ALCcontext *Context;
84
70
 
85
 
    pContext = GetContextSuspended();
86
 
    if(!pContext) return;
 
71
    Context = GetContextRef();
 
72
    if(!Context) return;
87
73
 
88
74
    switch(eParam)
89
75
    {
90
76
        case AL_POSITION:
91
 
            pContext->Listener.Position[0] = flValue1;
92
 
            pContext->Listener.Position[1] = flValue2;
93
 
            pContext->Listener.Position[2] = flValue3;
94
 
            updateWorld = AL_TRUE;
 
77
            if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3))
 
78
            {
 
79
                LockContext(Context);
 
80
                Context->Listener.Position[0] = flValue1;
 
81
                Context->Listener.Position[1] = flValue2;
 
82
                Context->Listener.Position[2] = flValue3;
 
83
                Context->UpdateSources = AL_TRUE;
 
84
                UnlockContext(Context);
 
85
            }
 
86
            else
 
87
                alSetError(Context, AL_INVALID_VALUE);
95
88
            break;
96
89
 
97
90
        case AL_VELOCITY:
98
 
            pContext->Listener.Velocity[0] = flValue1;
99
 
            pContext->Listener.Velocity[1] = flValue2;
100
 
            pContext->Listener.Velocity[2] = flValue3;
101
 
            updateWorld = AL_TRUE;
 
91
            if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3))
 
92
            {
 
93
                LockContext(Context);
 
94
                Context->Listener.Velocity[0] = flValue1;
 
95
                Context->Listener.Velocity[1] = flValue2;
 
96
                Context->Listener.Velocity[2] = flValue3;
 
97
                Context->UpdateSources = AL_TRUE;
 
98
                UnlockContext(Context);
 
99
            }
 
100
            else
 
101
                alSetError(Context, AL_INVALID_VALUE);
102
102
            break;
103
103
 
104
104
        default:
105
 
            alSetError(pContext, AL_INVALID_ENUM);
 
105
            alSetError(Context, AL_INVALID_ENUM);
106
106
            break;
107
107
    }
108
108
 
109
 
    if(updateWorld)
110
 
    {
111
 
        ALsizei pos;
112
 
        for(pos = 0;pos < pContext->SourceMap.size;pos++)
113
 
        {
114
 
            ALsource *source = pContext->SourceMap.array[pos].value;
115
 
            if(!source->bHeadRelative)
116
 
                source->NeedsUpdate = AL_TRUE;
117
 
        }
118
 
    }
119
 
 
120
 
    ProcessContext(pContext);
 
109
    ALCcontext_DecRef(Context);
121
110
}
122
111
 
123
112
 
124
113
AL_API ALvoid AL_APIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues)
125
114
{
126
 
    ALCcontext *pContext;
127
 
    ALboolean updateWorld = AL_FALSE;
128
 
 
129
 
    pContext = GetContextSuspended();
130
 
    if(!pContext) return;
 
115
    ALCcontext *Context;
131
116
 
132
117
    if(pflValues)
133
118
    {
136
121
            case AL_GAIN:
137
122
            case AL_METERS_PER_UNIT:
138
123
                alListenerf(eParam, pflValues[0]);
139
 
                break;
 
124
                return;
140
125
 
141
126
            case AL_POSITION:
142
127
            case AL_VELOCITY:
143
128
                alListener3f(eParam, pflValues[0], pflValues[1], pflValues[2]);
144
 
                break;
145
 
 
 
129
                return;
 
130
        }
 
131
    }
 
132
 
 
133
    Context = GetContextRef();
 
134
    if(!Context) return;
 
135
 
 
136
    if(pflValues)
 
137
    {
 
138
        switch(eParam)
 
139
        {
146
140
            case AL_ORIENTATION:
147
 
                // AT then UP
148
 
                pContext->Listener.Forward[0] = pflValues[0];
149
 
                pContext->Listener.Forward[1] = pflValues[1];
150
 
                pContext->Listener.Forward[2] = pflValues[2];
151
 
                pContext->Listener.Up[0] = pflValues[3];
152
 
                pContext->Listener.Up[1] = pflValues[4];
153
 
                pContext->Listener.Up[2] = pflValues[5];
154
 
                updateWorld = AL_TRUE;
 
141
                if(isfinite(pflValues[0]) && isfinite(pflValues[1]) &&
 
142
                   isfinite(pflValues[2]) && isfinite(pflValues[3]) &&
 
143
                   isfinite(pflValues[4]) && isfinite(pflValues[5]))
 
144
                {
 
145
                    ALfloat U[3], V[3], N[3];
 
146
 
 
147
                    /* AT then UP */
 
148
                    N[0] = pflValues[0];
 
149
                    N[1] = pflValues[1];
 
150
                    N[2] = pflValues[2];
 
151
                    aluNormalize(N);
 
152
                    V[0] = pflValues[3];
 
153
                    V[1] = pflValues[4];
 
154
                    V[2] = pflValues[5];
 
155
                    aluNormalize(V);
 
156
                    /* Build and normalize right-vector */
 
157
                    aluCrossproduct(N, V, U);
 
158
                    aluNormalize(U);
 
159
 
 
160
                    LockContext(Context);
 
161
                    Context->Listener.Forward[0] = pflValues[0];
 
162
                    Context->Listener.Forward[1] = pflValues[1];
 
163
                    Context->Listener.Forward[2] = pflValues[2];
 
164
                    Context->Listener.Up[0] = pflValues[3];
 
165
                    Context->Listener.Up[1] = pflValues[4];
 
166
                    Context->Listener.Up[2] = pflValues[5];
 
167
                    Context->Listener.Matrix[0][0] =  U[0];
 
168
                    Context->Listener.Matrix[0][1] =  V[0];
 
169
                    Context->Listener.Matrix[0][2] = -N[0];
 
170
                    Context->Listener.Matrix[0][3] =  0.0f;
 
171
                    Context->Listener.Matrix[1][0] =  U[1];
 
172
                    Context->Listener.Matrix[1][1] =  V[1];
 
173
                    Context->Listener.Matrix[1][2] = -N[1];
 
174
                    Context->Listener.Matrix[1][3] =  0.0f;
 
175
                    Context->Listener.Matrix[2][0] =  U[2];
 
176
                    Context->Listener.Matrix[2][1] =  V[2];
 
177
                    Context->Listener.Matrix[2][2] = -N[2];
 
178
                    Context->Listener.Matrix[2][3] =  0.0f;
 
179
                    Context->Listener.Matrix[3][0] =  0.0f;
 
180
                    Context->Listener.Matrix[3][1] =  0.0f;
 
181
                    Context->Listener.Matrix[3][2] =  0.0f;
 
182
                    Context->Listener.Matrix[3][3] =  1.0f;
 
183
                    Context->UpdateSources = AL_TRUE;
 
184
                    UnlockContext(Context);
 
185
                }
 
186
                else
 
187
                    alSetError(Context, AL_INVALID_VALUE);
155
188
                break;
156
189
 
157
190
            default:
158
 
                alSetError(pContext, AL_INVALID_ENUM);
 
191
                alSetError(Context, AL_INVALID_ENUM);
159
192
                break;
160
193
        }
161
194
    }
162
195
    else
163
 
        alSetError(pContext, AL_INVALID_VALUE);
164
 
 
165
 
    if(updateWorld)
166
 
    {
167
 
        ALsizei pos;
168
 
        for(pos = 0;pos < pContext->SourceMap.size;pos++)
169
 
        {
170
 
            ALsource *source = pContext->SourceMap.array[pos].value;
171
 
            if(!source->bHeadRelative)
172
 
                source->NeedsUpdate = AL_TRUE;
173
 
        }
174
 
    }
175
 
 
176
 
    ProcessContext(pContext);
 
196
        alSetError(Context, AL_INVALID_VALUE);
 
197
 
 
198
    ALCcontext_DecRef(Context);
177
199
}
178
200
 
179
201
 
180
202
AL_API ALvoid AL_APIENTRY alListeneri(ALenum eParam, ALint lValue)
181
203
{
182
 
    ALCcontext *pContext;
 
204
    ALCcontext *Context;
183
205
 
184
206
    (void)lValue;
185
207
 
186
 
    pContext = GetContextSuspended();
187
 
    if(!pContext) return;
 
208
    Context = GetContextRef();
 
209
    if(!Context) return;
188
210
 
189
211
    switch(eParam)
190
212
    {
191
213
        default:
192
 
            alSetError(pContext, AL_INVALID_ENUM);
 
214
            alSetError(Context, AL_INVALID_ENUM);
193
215
            break;
194
216
    }
195
217
 
196
 
    ProcessContext(pContext);
 
218
    ALCcontext_DecRef(Context);
197
219
}
198
220
 
199
221
 
200
222
AL_API void AL_APIENTRY alListener3i(ALenum eParam, ALint lValue1, ALint lValue2, ALint lValue3)
201
223
{
202
 
    ALCcontext *pContext;
203
 
 
204
 
    pContext = GetContextSuspended();
205
 
    if(!pContext) return;
 
224
    ALCcontext *Context;
206
225
 
207
226
    switch(eParam)
208
227
    {
209
228
        case AL_POSITION:
210
229
        case AL_VELOCITY:
211
230
            alListener3f(eParam, (ALfloat)lValue1, (ALfloat)lValue2, (ALfloat)lValue3);
212
 
            break;
213
 
 
 
231
            return;
 
232
    }
 
233
 
 
234
    Context = GetContextRef();
 
235
    if(!Context) return;
 
236
 
 
237
    switch(eParam)
 
238
    {
214
239
        default:
215
 
            alSetError(pContext, AL_INVALID_ENUM);
 
240
            alSetError(Context, AL_INVALID_ENUM);
216
241
            break;
217
242
    }
218
243
 
219
 
    ProcessContext(pContext);
 
244
    ALCcontext_DecRef(Context);
220
245
}
221
246
 
222
247
 
223
248
AL_API void AL_APIENTRY alListeneriv( ALenum eParam, const ALint* plValues )
224
249
{
225
 
    ALCcontext *pContext;
 
250
    ALCcontext *Context;
226
251
    ALfloat flValues[6];
227
252
 
228
 
    pContext = GetContextSuspended();
229
 
    if(!pContext) return;
230
 
 
231
253
    if(plValues)
232
254
    {
233
255
        switch(eParam)
234
256
        {
235
257
            case AL_POSITION:
236
258
            case AL_VELOCITY:
237
 
                flValues[0] = (ALfloat)plValues[0];
238
 
                flValues[1] = (ALfloat)plValues[1];
239
 
                flValues[2] = (ALfloat)plValues[2];
240
 
                alListenerfv(eParam, flValues);
241
 
                break;
 
259
                alListener3f(eParam, (ALfloat)plValues[0], (ALfloat)plValues[1], (ALfloat)plValues[2]);
 
260
                return;
242
261
 
243
262
            case AL_ORIENTATION:
244
263
                flValues[0] = (ALfloat)plValues[0];
248
267
                flValues[4] = (ALfloat)plValues[4];
249
268
                flValues[5] = (ALfloat)plValues[5];
250
269
                alListenerfv(eParam, flValues);
251
 
                break;
252
 
 
 
270
                return;
 
271
        }
 
272
    }
 
273
 
 
274
    Context = GetContextRef();
 
275
    if(!Context) return;
 
276
 
 
277
    if(plValues)
 
278
    {
 
279
        switch(eParam)
 
280
        {
253
281
            default:
254
 
                alSetError(pContext, AL_INVALID_ENUM);
 
282
                alSetError(Context, AL_INVALID_ENUM);
255
283
                break;
256
284
        }
257
285
    }
258
286
    else
259
 
        alSetError(pContext, AL_INVALID_VALUE);
 
287
        alSetError(Context, AL_INVALID_VALUE);
260
288
 
261
 
    ProcessContext(pContext);
 
289
    ALCcontext_DecRef(Context);
262
290
}
263
291
 
264
292
 
265
293
AL_API ALvoid AL_APIENTRY alGetListenerf(ALenum eParam, ALfloat *pflValue)
266
294
{
267
 
    ALCcontext *pContext;
 
295
    ALCcontext *Context;
268
296
 
269
 
    pContext = GetContextSuspended();
270
 
    if(!pContext) return;
 
297
    Context = GetContextRef();
 
298
    if(!Context) return;
271
299
 
272
300
    if(pflValue)
273
301
    {
274
302
        switch(eParam)
275
303
        {
276
304
            case AL_GAIN:
277
 
                *pflValue = pContext->Listener.Gain;
 
305
                *pflValue = Context->Listener.Gain;
278
306
                break;
279
307
 
280
308
            case AL_METERS_PER_UNIT:
281
 
                *pflValue = pContext->Listener.MetersPerUnit;
 
309
                *pflValue = Context->Listener.MetersPerUnit;
282
310
                break;
283
311
 
284
312
            default:
285
 
                alSetError(pContext, AL_INVALID_ENUM);
 
313
                alSetError(Context, AL_INVALID_ENUM);
286
314
                break;
287
315
        }
288
316
    }
289
317
    else
290
 
        alSetError(pContext, AL_INVALID_VALUE);
 
318
        alSetError(Context, AL_INVALID_VALUE);
291
319
 
292
 
    ProcessContext(pContext);
 
320
    ALCcontext_DecRef(Context);
293
321
}
294
322
 
295
323
 
296
324
AL_API ALvoid AL_APIENTRY alGetListener3f(ALenum eParam, ALfloat *pflValue1, ALfloat *pflValue2, ALfloat *pflValue3)
297
325
{
298
 
    ALCcontext *pContext;
 
326
    ALCcontext *Context;
299
327
 
300
 
    pContext = GetContextSuspended();
301
 
    if(!pContext) return;
 
328
    Context = GetContextRef();
 
329
    if(!Context) return;
302
330
 
303
331
    if(pflValue1 && pflValue2 && pflValue3)
304
332
    {
305
333
        switch(eParam)
306
334
        {
307
335
            case AL_POSITION:
308
 
                *pflValue1 = pContext->Listener.Position[0];
309
 
                *pflValue2 = pContext->Listener.Position[1];
310
 
                *pflValue3 = pContext->Listener.Position[2];
 
336
                LockContext(Context);
 
337
                *pflValue1 = Context->Listener.Position[0];
 
338
                *pflValue2 = Context->Listener.Position[1];
 
339
                *pflValue3 = Context->Listener.Position[2];
 
340
                UnlockContext(Context);
311
341
                break;
312
342
 
313
343
            case AL_VELOCITY:
314
 
                *pflValue1 = pContext->Listener.Velocity[0];
315
 
                *pflValue2 = pContext->Listener.Velocity[1];
316
 
                *pflValue3 = pContext->Listener.Velocity[2];
 
344
                LockContext(Context);
 
345
                *pflValue1 = Context->Listener.Velocity[0];
 
346
                *pflValue2 = Context->Listener.Velocity[1];
 
347
                *pflValue3 = Context->Listener.Velocity[2];
 
348
                UnlockContext(Context);
317
349
                break;
318
350
 
319
351
            default:
320
 
                alSetError(pContext, AL_INVALID_ENUM);
 
352
                alSetError(Context, AL_INVALID_ENUM);
321
353
                break;
322
354
        }
323
355
    }
324
356
    else
325
 
        alSetError(pContext, AL_INVALID_VALUE);
 
357
        alSetError(Context, AL_INVALID_VALUE);
326
358
 
327
 
    ProcessContext(pContext);
 
359
    ALCcontext_DecRef(Context);
328
360
}
329
361
 
330
362
 
331
363
AL_API ALvoid AL_APIENTRY alGetListenerfv(ALenum eParam, ALfloat *pflValues)
332
364
{
333
 
    ALCcontext *pContext;
334
 
 
335
 
    pContext = GetContextSuspended();
336
 
    if(!pContext) return;
 
365
    ALCcontext *Context;
 
366
 
 
367
    switch(eParam)
 
368
    {
 
369
        case AL_GAIN:
 
370
        case AL_METERS_PER_UNIT:
 
371
            alGetListenerf(eParam, pflValues);
 
372
            return;
 
373
 
 
374
        case AL_POSITION:
 
375
        case AL_VELOCITY:
 
376
            alGetListener3f(eParam, pflValues+0, pflValues+1, pflValues+2);
 
377
            return;
 
378
    }
 
379
 
 
380
    Context = GetContextRef();
 
381
    if(!Context) return;
337
382
 
338
383
    if(pflValues)
339
384
    {
340
385
        switch(eParam)
341
386
        {
342
 
            case AL_GAIN:
343
 
                pflValues[0] = pContext->Listener.Gain;
344
 
                break;
345
 
 
346
 
            case AL_METERS_PER_UNIT:
347
 
                pflValues[0] = pContext->Listener.MetersPerUnit;
348
 
                break;
349
 
 
350
 
            case AL_POSITION:
351
 
                pflValues[0] = pContext->Listener.Position[0];
352
 
                pflValues[1] = pContext->Listener.Position[1];
353
 
                pflValues[2] = pContext->Listener.Position[2];
354
 
                break;
355
 
 
356
 
            case AL_VELOCITY:
357
 
                pflValues[0] = pContext->Listener.Velocity[0];
358
 
                pflValues[1] = pContext->Listener.Velocity[1];
359
 
                pflValues[2] = pContext->Listener.Velocity[2];
360
 
                break;
361
 
 
362
387
            case AL_ORIENTATION:
 
388
                LockContext(Context);
363
389
                // AT then UP
364
 
                pflValues[0] = pContext->Listener.Forward[0];
365
 
                pflValues[1] = pContext->Listener.Forward[1];
366
 
                pflValues[2] = pContext->Listener.Forward[2];
367
 
                pflValues[3] = pContext->Listener.Up[0];
368
 
                pflValues[4] = pContext->Listener.Up[1];
369
 
                pflValues[5] = pContext->Listener.Up[2];
 
390
                pflValues[0] = Context->Listener.Forward[0];
 
391
                pflValues[1] = Context->Listener.Forward[1];
 
392
                pflValues[2] = Context->Listener.Forward[2];
 
393
                pflValues[3] = Context->Listener.Up[0];
 
394
                pflValues[4] = Context->Listener.Up[1];
 
395
                pflValues[5] = Context->Listener.Up[2];
 
396
                UnlockContext(Context);
370
397
                break;
371
398
 
372
399
            default:
373
 
                alSetError(pContext, AL_INVALID_ENUM);
 
400
                alSetError(Context, AL_INVALID_ENUM);
374
401
                break;
375
402
        }
376
403
    }
377
404
    else
378
 
        alSetError(pContext, AL_INVALID_VALUE);
 
405
        alSetError(Context, AL_INVALID_VALUE);
379
406
 
380
 
    ProcessContext(pContext);
 
407
    ALCcontext_DecRef(Context);
381
408
}
382
409
 
383
410
 
384
411
AL_API ALvoid AL_APIENTRY alGetListeneri(ALenum eParam, ALint *plValue)
385
412
{
386
 
    ALCcontext *pContext;
 
413
    ALCcontext *Context;
387
414
 
388
 
    pContext = GetContextSuspended();
389
 
    if(!pContext) return;
 
415
    Context = GetContextRef();
 
416
    if(!Context) return;
390
417
 
391
418
    if(plValue)
392
419
    {
393
420
        switch(eParam)
394
421
        {
395
422
            default:
396
 
                alSetError(pContext, AL_INVALID_ENUM);
 
423
                alSetError(Context, AL_INVALID_ENUM);
397
424
                break;
398
425
        }
399
426
    }
400
427
    else
401
 
        alSetError(pContext, AL_INVALID_VALUE);
 
428
        alSetError(Context, AL_INVALID_VALUE);
402
429
 
403
 
    ProcessContext(pContext);
 
430
    ALCcontext_DecRef(Context);
404
431
}
405
432
 
406
433
 
407
434
AL_API void AL_APIENTRY alGetListener3i(ALenum eParam, ALint *plValue1, ALint *plValue2, ALint *plValue3)
408
435
{
409
 
    ALCcontext *pContext;
 
436
    ALCcontext *Context;
410
437
 
411
 
    pContext = GetContextSuspended();
412
 
    if(!pContext) return;
 
438
    Context = GetContextRef();
 
439
    if(!Context) return;
413
440
 
414
441
    if(plValue1 && plValue2 && plValue3)
415
442
    {
416
443
        switch (eParam)
417
444
        {
418
445
            case AL_POSITION:
419
 
                *plValue1 = (ALint)pContext->Listener.Position[0];
420
 
                *plValue2 = (ALint)pContext->Listener.Position[1];
421
 
                *plValue3 = (ALint)pContext->Listener.Position[2];
 
446
                LockContext(Context);
 
447
                *plValue1 = (ALint)Context->Listener.Position[0];
 
448
                *plValue2 = (ALint)Context->Listener.Position[1];
 
449
                *plValue3 = (ALint)Context->Listener.Position[2];
 
450
                UnlockContext(Context);
422
451
                break;
423
452
 
424
453
            case AL_VELOCITY:
425
 
                *plValue1 = (ALint)pContext->Listener.Velocity[0];
426
 
                *plValue2 = (ALint)pContext->Listener.Velocity[1];
427
 
                *plValue3 = (ALint)pContext->Listener.Velocity[2];
 
454
                LockContext(Context);
 
455
                *plValue1 = (ALint)Context->Listener.Velocity[0];
 
456
                *plValue2 = (ALint)Context->Listener.Velocity[1];
 
457
                *plValue3 = (ALint)Context->Listener.Velocity[2];
 
458
                UnlockContext(Context);
428
459
                break;
429
460
 
430
461
            default:
431
 
                alSetError(pContext, AL_INVALID_ENUM);
 
462
                alSetError(Context, AL_INVALID_ENUM);
432
463
                break;
433
464
        }
434
465
    }
435
466
    else
436
 
        alSetError(pContext, AL_INVALID_VALUE);
 
467
        alSetError(Context, AL_INVALID_VALUE);
437
468
 
438
 
    ProcessContext(pContext);
 
469
    ALCcontext_DecRef(Context);
439
470
}
440
471
 
441
472
 
442
473
AL_API void AL_APIENTRY alGetListeneriv(ALenum eParam, ALint* plValues)
443
474
{
444
 
    ALCcontext *pContext;
445
 
 
446
 
    pContext = GetContextSuspended();
447
 
    if(!pContext) return;
 
475
    ALCcontext *Context;
 
476
 
 
477
    switch(eParam)
 
478
    {
 
479
        case AL_POSITION:
 
480
        case AL_VELOCITY:
 
481
            alGetListener3i(eParam, plValues+0, plValues+1, plValues+2);
 
482
            return;
 
483
    }
 
484
 
 
485
    Context = GetContextRef();
 
486
    if(!Context) return;
448
487
 
449
488
    if(plValues)
450
489
    {
451
490
        switch(eParam)
452
491
        {
453
 
            case AL_POSITION:
454
 
                plValues[0] = (ALint)pContext->Listener.Position[0];
455
 
                plValues[1] = (ALint)pContext->Listener.Position[1];
456
 
                plValues[2] = (ALint)pContext->Listener.Position[2];
457
 
                break;
458
 
 
459
 
            case AL_VELOCITY:
460
 
                plValues[0] = (ALint)pContext->Listener.Velocity[0];
461
 
                plValues[1] = (ALint)pContext->Listener.Velocity[1];
462
 
                plValues[2] = (ALint)pContext->Listener.Velocity[2];
463
 
                break;
464
 
 
465
492
            case AL_ORIENTATION:
 
493
                LockContext(Context);
466
494
                // AT then UP
467
 
                plValues[0] = (ALint)pContext->Listener.Forward[0];
468
 
                plValues[1] = (ALint)pContext->Listener.Forward[1];
469
 
                plValues[2] = (ALint)pContext->Listener.Forward[2];
470
 
                plValues[3] = (ALint)pContext->Listener.Up[0];
471
 
                plValues[4] = (ALint)pContext->Listener.Up[1];
472
 
                plValues[5] = (ALint)pContext->Listener.Up[2];
 
495
                plValues[0] = (ALint)Context->Listener.Forward[0];
 
496
                plValues[1] = (ALint)Context->Listener.Forward[1];
 
497
                plValues[2] = (ALint)Context->Listener.Forward[2];
 
498
                plValues[3] = (ALint)Context->Listener.Up[0];
 
499
                plValues[4] = (ALint)Context->Listener.Up[1];
 
500
                plValues[5] = (ALint)Context->Listener.Up[2];
 
501
                UnlockContext(Context);
473
502
                break;
474
503
 
475
504
            default:
476
 
                alSetError(pContext, AL_INVALID_ENUM);
 
505
                alSetError(Context, AL_INVALID_ENUM);
477
506
                break;
478
507
        }
479
508
    }
480
509
    else
481
 
        alSetError(pContext, AL_INVALID_VALUE);
 
510
        alSetError(Context, AL_INVALID_VALUE);
482
511
 
483
 
    ProcessContext(pContext);
 
512
    ALCcontext_DecRef(Context);
484
513
}