3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998 Rob Riggs
5 * Copyright 2000-2002 TransGaming Technologies, Inc.
6 * Copyright 2004 Robert Reif
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
39 #include "wine/debug.h"
41 #include "dsound_private.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(dsound
);
45 typedef struct IDirectSoundImpl
{
46 IUnknown IUnknown_inner
;
47 IDirectSound8 IDirectSound8_iface
;
48 IUnknown
*outer_unk
; /* internal */
49 LONG ref
, refds
, numIfaces
;
50 DirectSoundDevice
*device
;
54 static const char * dumpCooperativeLevel(DWORD level
)
56 #define LE(x) case x: return #x
61 LE(DSSCL_WRITEPRIMARY
);
64 return wine_dbg_sprintf("Unknown(%08x)", level
);
67 static void _dump_DSCAPS(DWORD xmask
) {
72 #define FE(x) { x, #x },
73 FE(DSCAPS_PRIMARYMONO
)
74 FE(DSCAPS_PRIMARYSTEREO
)
75 FE(DSCAPS_PRIMARY8BIT
)
76 FE(DSCAPS_PRIMARY16BIT
)
77 FE(DSCAPS_CONTINUOUSRATE
)
80 FE(DSCAPS_SECONDARYMONO
)
81 FE(DSCAPS_SECONDARYSTEREO
)
82 FE(DSCAPS_SECONDARY8BIT
)
83 FE(DSCAPS_SECONDARY16BIT
)
88 for (i
= 0; i
< ARRAY_SIZE(flags
); i
++)
89 if ((flags
[i
].mask
& xmask
) == flags
[i
].mask
)
90 TRACE("%s ",flags
[i
].name
);
93 static void _dump_DSBCAPS(DWORD xmask
) {
98 #define FE(x) { x, #x },
99 FE(DSBCAPS_PRIMARYBUFFER
)
101 FE(DSBCAPS_LOCHARDWARE
)
102 FE(DSBCAPS_LOCSOFTWARE
)
104 FE(DSBCAPS_CTRLFREQUENCY
)
106 FE(DSBCAPS_CTRLVOLUME
)
107 FE(DSBCAPS_CTRLPOSITIONNOTIFY
)
108 FE(DSBCAPS_STICKYFOCUS
)
109 FE(DSBCAPS_GLOBALFOCUS
)
110 FE(DSBCAPS_GETCURRENTPOSITION2
)
111 FE(DSBCAPS_MUTE3DATMAXDISTANCE
)
116 for (i
= 0; i
< ARRAY_SIZE(flags
); i
++)
117 if ((flags
[i
].mask
& xmask
) == flags
[i
].mask
)
118 TRACE("%s ",flags
[i
].name
);
121 /*******************************************************************************
124 static HRESULT
DirectSoundDevice_Create(DirectSoundDevice
** ppDevice
)
126 DirectSoundDevice
* device
;
127 TRACE("(%p)\n", ppDevice
);
129 /* Allocate memory */
130 device
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(DirectSoundDevice
));
131 if (device
== NULL
) {
132 WARN("out of memory\n");
133 return DSERR_OUTOFMEMORY
;
137 device
->priolevel
= DSSCL_NORMAL
;
139 device
->speaker_config
= DSSPEAKER_COMBINED(DSSPEAKER_STEREO
, DSSPEAKER_GEOMETRY_WIDE
);
141 DSOUND_ParseSpeakerConfig(device
);
143 /* 3D listener initial parameters */
144 device
->ds3dl
.dwSize
= sizeof(DS3DLISTENER
);
145 device
->ds3dl
.vPosition
.x
= 0.0;
146 device
->ds3dl
.vPosition
.y
= 0.0;
147 device
->ds3dl
.vPosition
.z
= 0.0;
148 device
->ds3dl
.vVelocity
.x
= 0.0;
149 device
->ds3dl
.vVelocity
.y
= 0.0;
150 device
->ds3dl
.vVelocity
.z
= 0.0;
151 device
->ds3dl
.vOrientFront
.x
= 0.0;
152 device
->ds3dl
.vOrientFront
.y
= 0.0;
153 device
->ds3dl
.vOrientFront
.z
= 1.0;
154 device
->ds3dl
.vOrientTop
.x
= 0.0;
155 device
->ds3dl
.vOrientTop
.y
= 1.0;
156 device
->ds3dl
.vOrientTop
.z
= 0.0;
157 device
->ds3dl
.flDistanceFactor
= DS3D_DEFAULTDISTANCEFACTOR
;
158 device
->ds3dl
.flRolloffFactor
= DS3D_DEFAULTROLLOFFFACTOR
;
159 device
->ds3dl
.flDopplerFactor
= DS3D_DEFAULTDOPPLERFACTOR
;
161 device
->guid
= GUID_NULL
;
163 /* Set default wave format (may need it for waveOutOpen) */
164 device
->primary_pwfx
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(WAVEFORMATEXTENSIBLE
));
165 if (!device
->primary_pwfx
) {
166 WARN("out of memory\n");
167 HeapFree(GetProcessHeap(),0,device
);
168 return DSERR_OUTOFMEMORY
;
171 device
->primary_pwfx
->wFormatTag
= WAVE_FORMAT_PCM
;
172 device
->primary_pwfx
->nSamplesPerSec
= 22050;
173 device
->primary_pwfx
->wBitsPerSample
= 8;
174 device
->primary_pwfx
->nChannels
= 2;
175 device
->primary_pwfx
->nBlockAlign
= device
->primary_pwfx
->wBitsPerSample
* device
->primary_pwfx
->nChannels
/ 8;
176 device
->primary_pwfx
->nAvgBytesPerSec
= device
->primary_pwfx
->nSamplesPerSec
* device
->primary_pwfx
->nBlockAlign
;
177 device
->primary_pwfx
->cbSize
= 0;
179 InitializeCriticalSection(&(device
->mixlock
));
180 device
->mixlock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": DirectSoundDevice.mixlock");
182 RtlInitializeResource(&(device
->buffer_list_lock
));
189 static ULONG
DirectSoundDevice_AddRef(DirectSoundDevice
* device
)
191 ULONG ref
= InterlockedIncrement(&(device
->ref
));
192 TRACE("(%p) ref was %d\n", device
, ref
- 1);
196 static ULONG
DirectSoundDevice_Release(DirectSoundDevice
* device
)
199 ULONG ref
= InterlockedDecrement(&(device
->ref
));
200 TRACE("(%p) ref was %u\n", device
, ref
+ 1);
204 SetEvent(device
->sleepev
);
205 if (device
->thread
) {
206 WaitForSingleObject(device
->thread_finished
, INFINITE
);
207 CloseHandle(device
->thread
);
208 CloseHandle(device
->thread_finished
);
210 CloseHandle(device
->sleepev
);
212 EnterCriticalSection(&DSOUND_renderers_lock
);
213 list_remove(&device
->entry
);
214 LeaveCriticalSection(&DSOUND_renderers_lock
);
216 /* It is allowed to release this object even when buffers are playing */
217 if (device
->buffers
) {
218 WARN("%d secondary buffers not released\n", device
->nrofbuffers
);
219 for( i
=0;i
<device
->nrofbuffers
;i
++)
220 secondarybuffer_destroy(device
->buffers
[i
]);
223 hr
= DSOUND_PrimaryDestroy(device
);
225 WARN("DSOUND_PrimaryDestroy failed\n");
228 IAudioClient_Stop(device
->client
);
229 IAudioClient_Release(device
->client
);
232 IAudioRenderClient_Release(device
->render
);
234 IAudioStreamVolume_Release(device
->volume
);
236 IMMDevice_Release(device
->mmdevice
);
237 HeapFree(GetProcessHeap(), 0, device
->tmp_buffer
);
238 HeapFree(GetProcessHeap(), 0, device
->cp_buffer
);
239 HeapFree(GetProcessHeap(), 0, device
->buffer
);
240 RtlDeleteResource(&device
->buffer_list_lock
);
241 device
->mixlock
.DebugInfo
->Spare
[0] = 0;
242 DeleteCriticalSection(&device
->mixlock
);
243 HeapFree(GetProcessHeap(),0,device
);
244 TRACE("(%p) released\n", device
);
249 BOOL
DSOUND_check_supported(IAudioClient
*client
, DWORD rate
,
250 DWORD depth
, WORD channels
)
252 WAVEFORMATEX fmt
, *junk
;
255 fmt
.wFormatTag
= WAVE_FORMAT_PCM
;
256 fmt
.nChannels
= channels
;
257 fmt
.nSamplesPerSec
= rate
;
258 fmt
.wBitsPerSample
= depth
;
259 fmt
.nBlockAlign
= (channels
* depth
) / 8;
260 fmt
.nAvgBytesPerSec
= rate
* fmt
.nBlockAlign
;
263 hr
= IAudioClient_IsFormatSupported(client
, AUDCLNT_SHAREMODE_SHARED
, &fmt
, &junk
);
270 static HRESULT
DirectSoundDevice_Initialize(DirectSoundDevice
** ppDevice
, LPCGUID lpcGUID
)
274 DirectSoundDevice
*device
;
277 TRACE("(%p,%s)\n",ppDevice
,debugstr_guid(lpcGUID
));
279 if (*ppDevice
!= NULL
) {
280 WARN("already initialized\n");
281 return DSERR_ALREADYINITIALIZED
;
284 /* Default device? */
285 if (!lpcGUID
|| IsEqualGUID(lpcGUID
, &GUID_NULL
))
286 lpcGUID
= &DSDEVID_DefaultPlayback
;
288 if(IsEqualGUID(lpcGUID
, &DSDEVID_DefaultCapture
) ||
289 IsEqualGUID(lpcGUID
, &DSDEVID_DefaultVoiceCapture
))
290 return DSERR_NODRIVER
;
292 if (GetDeviceID(lpcGUID
, &devGUID
) != DS_OK
) {
293 WARN("invalid parameter: lpcGUID\n");
294 return DSERR_INVALIDPARAM
;
297 hr
= get_mmdevice(eRender
, &devGUID
, &mmdevice
);
301 EnterCriticalSection(&DSOUND_renderers_lock
);
303 LIST_FOR_EACH_ENTRY(device
, &DSOUND_renderers
, DirectSoundDevice
, entry
){
304 if(IsEqualGUID(&device
->guid
, &devGUID
)){
305 IMMDevice_Release(mmdevice
);
306 DirectSoundDevice_AddRef(device
);
308 LeaveCriticalSection(&DSOUND_renderers_lock
);
313 hr
= DirectSoundDevice_Create(&device
);
315 WARN("DirectSoundDevice_Create failed\n");
316 IMMDevice_Release(mmdevice
);
317 LeaveCriticalSection(&DSOUND_renderers_lock
);
321 device
->mmdevice
= mmdevice
;
322 device
->guid
= devGUID
;
323 device
->sleepev
= CreateEventW(0, 0, 0, 0);
324 device
->buflen
= ds_hel_buflen
;
326 hr
= DSOUND_ReopenDevice(device
, FALSE
);
329 HeapFree(GetProcessHeap(), 0, device
);
330 LeaveCriticalSection(&DSOUND_renderers_lock
);
331 IMMDevice_Release(mmdevice
);
332 WARN("DSOUND_ReopenDevice failed: %08x\n", hr
);
336 ZeroMemory(&device
->drvcaps
, sizeof(device
->drvcaps
));
338 if(DSOUND_check_supported(device
->client
, 11025, 8, 1) ||
339 DSOUND_check_supported(device
->client
, 22050, 8, 1) ||
340 DSOUND_check_supported(device
->client
, 44100, 8, 1) ||
341 DSOUND_check_supported(device
->client
, 48000, 8, 1) ||
342 DSOUND_check_supported(device
->client
, 96000, 8, 1))
343 device
->drvcaps
.dwFlags
|= DSCAPS_PRIMARY8BIT
| DSCAPS_PRIMARYMONO
;
345 if(DSOUND_check_supported(device
->client
, 11025, 16, 1) ||
346 DSOUND_check_supported(device
->client
, 22050, 16, 1) ||
347 DSOUND_check_supported(device
->client
, 44100, 16, 1) ||
348 DSOUND_check_supported(device
->client
, 48000, 16, 1) ||
349 DSOUND_check_supported(device
->client
, 96000, 16, 1))
350 device
->drvcaps
.dwFlags
|= DSCAPS_PRIMARY16BIT
| DSCAPS_PRIMARYMONO
;
352 if(DSOUND_check_supported(device
->client
, 11025, 8, 2) ||
353 DSOUND_check_supported(device
->client
, 22050, 8, 2) ||
354 DSOUND_check_supported(device
->client
, 44100, 8, 2) ||
355 DSOUND_check_supported(device
->client
, 48000, 8, 2) ||
356 DSOUND_check_supported(device
->client
, 96000, 8, 2))
357 device
->drvcaps
.dwFlags
|= DSCAPS_PRIMARY8BIT
| DSCAPS_PRIMARYSTEREO
;
359 if(DSOUND_check_supported(device
->client
, 11025, 16, 2) ||
360 DSOUND_check_supported(device
->client
, 22050, 16, 2) ||
361 DSOUND_check_supported(device
->client
, 44100, 16, 2) ||
362 DSOUND_check_supported(device
->client
, 48000, 16, 2) ||
363 DSOUND_check_supported(device
->client
, 96000, 16, 2))
364 device
->drvcaps
.dwFlags
|= DSCAPS_PRIMARY16BIT
| DSCAPS_PRIMARYSTEREO
;
366 /* the dsound mixer supports all of the following */
367 device
->drvcaps
.dwFlags
|= DSCAPS_SECONDARY8BIT
| DSCAPS_SECONDARY16BIT
;
368 device
->drvcaps
.dwFlags
|= DSCAPS_SECONDARYMONO
| DSCAPS_SECONDARYSTEREO
;
369 device
->drvcaps
.dwFlags
|= DSCAPS_CONTINUOUSRATE
;
371 /* pretend that the driver is certified */
372 device
->drvcaps
.dwFlags
|= DSCAPS_CERTIFIED
;
374 device
->drvcaps
.dwPrimaryBuffers
= 1;
375 device
->drvcaps
.dwMinSecondarySampleRate
= DSBFREQUENCY_MIN
;
376 device
->drvcaps
.dwMaxSecondarySampleRate
= DSBFREQUENCY_MAX
;
377 device
->drvcaps
.dwMaxHwMixingAllBuffers
= 16;
378 device
->drvcaps
.dwMaxHwMixingStaticBuffers
= device
->drvcaps
.dwMaxHwMixingAllBuffers
;
379 device
->drvcaps
.dwMaxHwMixingStreamingBuffers
= device
->drvcaps
.dwMaxHwMixingAllBuffers
;
380 device
->drvcaps
.dwFreeHwMixingAllBuffers
= device
->drvcaps
.dwMaxHwMixingAllBuffers
;
381 device
->drvcaps
.dwFreeHwMixingStaticBuffers
= device
->drvcaps
.dwMaxHwMixingStaticBuffers
;
382 device
->drvcaps
.dwFreeHwMixingStreamingBuffers
= device
->drvcaps
.dwMaxHwMixingStreamingBuffers
;
384 ZeroMemory(&device
->volpan
, sizeof(device
->volpan
));
386 device
->thread_finished
= CreateEventW(0, 0, 0, 0);
387 device
->thread
= CreateThread(0, 0, DSOUND_mixthread
, device
, 0, 0);
388 SetThreadPriority(device
->thread
, THREAD_PRIORITY_TIME_CRITICAL
);
391 list_add_tail(&DSOUND_renderers
, &device
->entry
);
393 LeaveCriticalSection(&DSOUND_renderers_lock
);
398 static HRESULT
DirectSoundDevice_CreateSoundBuffer(
399 DirectSoundDevice
* device
,
400 LPCDSBUFFERDESC dsbd
,
401 LPLPDIRECTSOUNDBUFFER ppdsb
,
405 HRESULT hres
= DS_OK
;
406 TRACE("(%p,%p,%p,%p)\n",device
,dsbd
,ppdsb
,lpunk
);
408 if (device
== NULL
) {
409 WARN("not initialized\n");
410 return DSERR_UNINITIALIZED
;
414 WARN("invalid parameter: dsbd == NULL\n");
415 return DSERR_INVALIDPARAM
;
418 if (dsbd
->dwSize
!= sizeof(DSBUFFERDESC
) &&
419 dsbd
->dwSize
!= sizeof(DSBUFFERDESC1
)) {
420 WARN("invalid parameter: dsbd\n");
421 return DSERR_INVALIDPARAM
;
425 WARN("invalid parameter: ppdsb == NULL\n");
426 return DSERR_INVALIDPARAM
;
430 if (TRACE_ON(dsound
)) {
431 TRACE("(structsize=%d)\n",dsbd
->dwSize
);
432 TRACE("(flags=0x%08x:\n",dsbd
->dwFlags
);
433 _dump_DSBCAPS(dsbd
->dwFlags
);
435 TRACE("(bufferbytes=%d)\n",dsbd
->dwBufferBytes
);
436 TRACE("(lpwfxFormat=%p)\n",dsbd
->lpwfxFormat
);
439 if (!(dsbd
->dwFlags
& DSBCAPS_PRIMARYBUFFER
) &&
440 dsbd
->dwFlags
& DSBCAPS_LOCHARDWARE
&&
441 device
->drvcaps
.dwFreeHwMixingAllBuffers
== 0)
443 WARN("ran out of emulated hardware buffers\n");
444 return DSERR_ALLOCATED
;
447 if (dsbd
->dwFlags
& DSBCAPS_PRIMARYBUFFER
) {
448 if (dsbd
->lpwfxFormat
!= NULL
) {
449 WARN("invalid parameter: dsbd->lpwfxFormat must be NULL for "
451 return DSERR_INVALIDPARAM
;
454 if (device
->primary
) {
455 WARN("Primary Buffer already created\n");
456 IDirectSoundBuffer8_AddRef(&device
->primary
->IDirectSoundBuffer8_iface
);
457 *ppdsb
= (IDirectSoundBuffer
*)&device
->primary
->IDirectSoundBuffer8_iface
;
459 hres
= primarybuffer_create(device
, &device
->primary
, dsbd
);
460 if (device
->primary
) {
461 *ppdsb
= (IDirectSoundBuffer
*)&device
->primary
->IDirectSoundBuffer8_iface
;
462 device
->primary
->dsbd
.dwFlags
&= ~(DSBCAPS_LOCHARDWARE
| DSBCAPS_LOCSOFTWARE
);
463 device
->primary
->dsbd
.dwFlags
|= DSBCAPS_LOCSOFTWARE
;
465 WARN("primarybuffer_create() failed\n");
468 if (dsbd
->lpwfxFormat
== NULL
) {
469 WARN("invalid parameter: dsbd->lpwfxFormat can't be NULL for "
470 "secondary buffer\n");
471 return DSERR_INVALIDPARAM
;
474 if(dsbd
->lpwfxFormat
->wFormatTag
!= WAVE_FORMAT_PCM
&&
475 dsbd
->lpwfxFormat
->wFormatTag
!= WAVE_FORMAT_IEEE_FLOAT
&&
476 dsbd
->lpwfxFormat
->wFormatTag
!= WAVE_FORMAT_EXTENSIBLE
) {
477 WARN("We can't mix this format: 0x%x\n", dsbd
->lpwfxFormat
->wFormatTag
);
481 if(dsbd
->lpwfxFormat
->wBitsPerSample
< 8 || dsbd
->lpwfxFormat
->wBitsPerSample
% 8 != 0 ||
482 dsbd
->lpwfxFormat
->nChannels
== 0 || dsbd
->lpwfxFormat
->nSamplesPerSec
== 0 ||
483 dsbd
->lpwfxFormat
->nAvgBytesPerSec
== 0 ||
484 dsbd
->lpwfxFormat
->nBlockAlign
!= dsbd
->lpwfxFormat
->nChannels
* dsbd
->lpwfxFormat
->wBitsPerSample
/ 8) {
485 WARN("Format inconsistency\n");
486 return DSERR_INVALIDPARAM
;
489 if (dsbd
->lpwfxFormat
->wFormatTag
== WAVE_FORMAT_EXTENSIBLE
)
491 WAVEFORMATEXTENSIBLE
*pwfxe
= (WAVEFORMATEXTENSIBLE
*)dsbd
->lpwfxFormat
;
493 /* check if cbSize is at least 22 bytes */
494 if (pwfxe
->Format
.cbSize
< (sizeof(WAVEFORMATEXTENSIBLE
) - sizeof(WAVEFORMATEX
)))
496 WARN("Too small a cbSize %u\n", pwfxe
->Format
.cbSize
);
497 return DSERR_INVALIDPARAM
;
500 /* cbSize should be 22 bytes, with one possible exception */
501 if (pwfxe
->Format
.cbSize
> (sizeof(WAVEFORMATEXTENSIBLE
) - sizeof(WAVEFORMATEX
)) &&
502 !((IsEqualGUID(&pwfxe
->SubFormat
, &KSDATAFORMAT_SUBTYPE_PCM
) || IsEqualGUID(&pwfxe
->SubFormat
, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
)) &&
503 pwfxe
->Format
.cbSize
== sizeof(WAVEFORMATEXTENSIBLE
)))
505 WARN("Too big a cbSize %u\n", pwfxe
->Format
.cbSize
);
506 return DSERR_CONTROLUNAVAIL
;
509 if ((!IsEqualGUID(&pwfxe
->SubFormat
, &KSDATAFORMAT_SUBTYPE_PCM
)) && (!IsEqualGUID(&pwfxe
->SubFormat
, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
)))
511 if (!IsEqualGUID(&pwfxe
->SubFormat
, &GUID_NULL
))
512 FIXME("SubFormat %s not supported right now.\n", debugstr_guid(&pwfxe
->SubFormat
));
513 return DSERR_INVALIDPARAM
;
515 if (pwfxe
->Samples
.wValidBitsPerSample
> dsbd
->lpwfxFormat
->wBitsPerSample
)
517 WARN("Samples.wValidBitsPerSample(%d) > Format.wBitsPerSample (%d)\n", pwfxe
->Samples
.wValidBitsPerSample
, pwfxe
->Format
.wBitsPerSample
);
518 return DSERR_INVALIDPARAM
;
520 if (pwfxe
->Samples
.wValidBitsPerSample
&& pwfxe
->Samples
.wValidBitsPerSample
< dsbd
->lpwfxFormat
->wBitsPerSample
)
522 WARN("Non-packed formats may not function : %d/%d\n", pwfxe
->Samples
.wValidBitsPerSample
, dsbd
->lpwfxFormat
->wBitsPerSample
);
526 TRACE("(formattag=0x%04x,chans=%d,samplerate=%d,"
527 "bytespersec=%d,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
528 dsbd
->lpwfxFormat
->wFormatTag
, dsbd
->lpwfxFormat
->nChannels
,
529 dsbd
->lpwfxFormat
->nSamplesPerSec
,
530 dsbd
->lpwfxFormat
->nAvgBytesPerSec
,
531 dsbd
->lpwfxFormat
->nBlockAlign
,
532 dsbd
->lpwfxFormat
->wBitsPerSample
, dsbd
->lpwfxFormat
->cbSize
);
534 if (from8
&& (dsbd
->dwFlags
& DSBCAPS_CTRL3D
) && (dsbd
->lpwfxFormat
->nChannels
!= 1)) {
535 WARN("invalid parameter: 3D buffer format must be mono\n");
536 return DSERR_INVALIDPARAM
;
539 if (from8
&& (dsbd
->dwFlags
& DSBCAPS_CTRL3D
) && (dsbd
->dwFlags
& DSBCAPS_CTRLPAN
)) {
540 WARN("invalid parameter: DSBCAPS_CTRL3D and DSBCAPS_CTRLPAN cannot be used together\n");
541 return DSERR_INVALIDPARAM
;
544 hres
= secondarybuffer_create(device
, dsbd
, ppdsb
);
545 if (SUCCEEDED(hres
)) {
546 if (dsbd
->dwFlags
& DSBCAPS_LOCHARDWARE
)
547 device
->drvcaps
.dwFreeHwMixingAllBuffers
--;
549 WARN("IDirectSoundBufferImpl_Create failed\n");
555 static HRESULT
DirectSoundDevice_DuplicateSoundBuffer(
556 DirectSoundDevice
* device
,
557 LPDIRECTSOUNDBUFFER psb
,
558 LPLPDIRECTSOUNDBUFFER ppdsb
)
560 HRESULT hres
= DS_OK
;
561 IDirectSoundBufferImpl
* dsb
;
562 TRACE("(%p,%p,%p)\n",device
,psb
,ppdsb
);
564 if (device
== NULL
) {
565 WARN("not initialized\n");
566 return DSERR_UNINITIALIZED
;
570 WARN("invalid parameter: psb == NULL\n");
571 return DSERR_INVALIDPARAM
;
575 WARN("invalid parameter: ppdsb == NULL\n");
576 return DSERR_INVALIDPARAM
;
579 /* make sure we have a secondary buffer */
580 if (psb
== (IDirectSoundBuffer
*)&device
->primary
->IDirectSoundBuffer8_iface
) {
581 WARN("trying to duplicate primary buffer\n");
583 return DSERR_INVALIDCALL
;
586 /* duplicate the actual buffer implementation */
587 hres
= IDirectSoundBufferImpl_Duplicate(device
, &dsb
, (IDirectSoundBufferImpl
*)psb
);
589 *ppdsb
= (IDirectSoundBuffer
*)&dsb
->IDirectSoundBuffer8_iface
;
591 WARN("IDirectSoundBufferImpl_Duplicate failed\n");
597 * Add secondary buffer to buffer list.
598 * Gets exclusive access to buffer for writing.
600 HRESULT
DirectSoundDevice_AddBuffer(
601 DirectSoundDevice
* device
,
602 IDirectSoundBufferImpl
* pDSB
)
604 IDirectSoundBufferImpl
**newbuffers
;
607 TRACE("(%p, %p)\n", device
, pDSB
);
609 RtlAcquireResourceExclusive(&(device
->buffer_list_lock
), TRUE
);
612 newbuffers
= HeapReAlloc(GetProcessHeap(),0,device
->buffers
,sizeof(IDirectSoundBufferImpl
*)*(device
->nrofbuffers
+1));
614 newbuffers
= HeapAlloc(GetProcessHeap(),0,sizeof(IDirectSoundBufferImpl
*)*(device
->nrofbuffers
+1));
617 device
->buffers
= newbuffers
;
618 device
->buffers
[device
->nrofbuffers
] = pDSB
;
619 device
->nrofbuffers
++;
620 TRACE("buffer count is now %d\n", device
->nrofbuffers
);
622 ERR("out of memory for buffer list! Current buffer count is %d\n", device
->nrofbuffers
);
623 hr
= DSERR_OUTOFMEMORY
;
626 RtlReleaseResource(&(device
->buffer_list_lock
));
632 * Remove secondary buffer from buffer list.
633 * Gets exclusive access to buffer for writing.
635 void DirectSoundDevice_RemoveBuffer(DirectSoundDevice
* device
, IDirectSoundBufferImpl
* pDSB
)
639 TRACE("(%p, %p)\n", device
, pDSB
);
641 RtlAcquireResourceExclusive(&(device
->buffer_list_lock
), TRUE
);
643 if (device
->nrofbuffers
== 1) {
644 assert(device
->buffers
[0] == pDSB
);
645 HeapFree(GetProcessHeap(), 0, device
->buffers
);
646 device
->buffers
= NULL
;
648 for (i
= 0; i
< device
->nrofbuffers
; i
++) {
649 if (device
->buffers
[i
] == pDSB
) {
650 /* Put the last buffer of the list in the (now empty) position */
651 device
->buffers
[i
] = device
->buffers
[device
->nrofbuffers
- 1];
656 device
->nrofbuffers
--;
657 TRACE("buffer count is now %d\n", device
->nrofbuffers
);
659 RtlReleaseResource(&(device
->buffer_list_lock
));
662 /*******************************************************************************
663 * IUnknown Implementation for DirectSound
666 static void directsound_destroy(IDirectSoundImpl
*This
)
669 DirectSoundDevice_Release(This
->device
);
670 HeapFree(GetProcessHeap(),0,This
);
671 TRACE("(%p) released\n", This
);
674 static inline IDirectSoundImpl
*impl_from_IUnknown(IUnknown
*iface
)
676 return CONTAINING_RECORD(iface
, IDirectSoundImpl
, IUnknown_inner
);
679 static HRESULT WINAPI
IUnknownImpl_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
681 IDirectSoundImpl
*This
= impl_from_IUnknown(iface
);
683 TRACE("(%p,%s,%p)\n", This
, debugstr_guid(riid
), ppv
);
686 WARN("invalid parameter\n");
691 if (IsEqualIID(riid
, &IID_IUnknown
))
692 *ppv
= &This
->IUnknown_inner
;
693 else if (IsEqualIID(riid
, &IID_IDirectSound
) ||
694 (IsEqualIID(riid
, &IID_IDirectSound8
) && This
->has_ds8
))
695 *ppv
= &This
->IDirectSound8_iface
;
697 WARN("unknown IID %s\n", debugstr_guid(riid
));
698 return E_NOINTERFACE
;
701 IUnknown_AddRef((IUnknown
*)*ppv
);
705 static ULONG WINAPI
IUnknownImpl_AddRef(IUnknown
*iface
)
707 IDirectSoundImpl
*This
= impl_from_IUnknown(iface
);
708 ULONG ref
= InterlockedIncrement(&This
->ref
);
710 TRACE("(%p) ref=%d\n", This
, ref
);
713 InterlockedIncrement(&This
->numIfaces
);
718 static ULONG WINAPI
IUnknownImpl_Release(IUnknown
*iface
)
720 IDirectSoundImpl
*This
= impl_from_IUnknown(iface
);
721 ULONG ref
= InterlockedDecrement(&This
->ref
);
723 TRACE("(%p) ref=%d\n", This
, ref
);
725 if (!ref
&& !InterlockedDecrement(&This
->numIfaces
))
726 directsound_destroy(This
);
731 static const IUnknownVtbl unk_vtbl
=
733 IUnknownImpl_QueryInterface
,
738 /*******************************************************************************
739 * IDirectSound and IDirectSound8 Implementation
741 static inline IDirectSoundImpl
*impl_from_IDirectSound8(IDirectSound8
*iface
)
743 return CONTAINING_RECORD(iface
, IDirectSoundImpl
, IDirectSound8_iface
);
746 static HRESULT WINAPI
IDirectSound8Impl_QueryInterface(IDirectSound8
*iface
, REFIID riid
,
749 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
750 TRACE("(%p,%s,%p)\n", This
, debugstr_guid(riid
), ppv
);
751 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
754 static ULONG WINAPI
IDirectSound8Impl_AddRef(IDirectSound8
*iface
)
756 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
757 ULONG ref
= InterlockedIncrement(&This
->refds
);
759 TRACE("(%p) refds=%d\n", This
, ref
);
762 InterlockedIncrement(&This
->numIfaces
);
767 static ULONG WINAPI
IDirectSound8Impl_Release(IDirectSound8
*iface
)
769 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
770 ULONG ref
= InterlockedDecrement(&(This
->refds
));
772 TRACE("(%p) refds=%d\n", This
, ref
);
774 if (!ref
&& !InterlockedDecrement(&This
->numIfaces
))
775 directsound_destroy(This
);
780 static HRESULT WINAPI
IDirectSound8Impl_CreateSoundBuffer(IDirectSound8
*iface
,
781 const DSBUFFERDESC
*dsbd
, IDirectSoundBuffer
**ppdsb
, IUnknown
*lpunk
)
783 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
784 TRACE("(%p,%p,%p,%p)\n", This
, dsbd
, ppdsb
, lpunk
);
785 return DirectSoundDevice_CreateSoundBuffer(This
->device
, dsbd
, ppdsb
, lpunk
, This
->has_ds8
);
788 static HRESULT WINAPI
IDirectSound8Impl_GetCaps(IDirectSound8
*iface
, DSCAPS
*dscaps
)
790 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
792 TRACE("(%p, %p)\n", This
, dscaps
);
795 WARN("not initialized\n");
796 return DSERR_UNINITIALIZED
;
799 WARN("invalid parameter: dscaps = NULL\n");
800 return DSERR_INVALIDPARAM
;
802 if (dscaps
->dwSize
< sizeof(*dscaps
)) {
803 WARN("invalid parameter: dscaps->dwSize = %d\n", dscaps
->dwSize
);
804 return DSERR_INVALIDPARAM
;
807 dscaps
->dwFlags
= This
->device
->drvcaps
.dwFlags
;
808 dscaps
->dwMinSecondarySampleRate
= This
->device
->drvcaps
.dwMinSecondarySampleRate
;
809 dscaps
->dwMaxSecondarySampleRate
= This
->device
->drvcaps
.dwMaxSecondarySampleRate
;
810 dscaps
->dwPrimaryBuffers
= This
->device
->drvcaps
.dwPrimaryBuffers
;
811 dscaps
->dwMaxHwMixingAllBuffers
= This
->device
->drvcaps
.dwMaxHwMixingAllBuffers
;
812 dscaps
->dwMaxHwMixingStaticBuffers
= This
->device
->drvcaps
.dwMaxHwMixingStaticBuffers
;
813 dscaps
->dwMaxHwMixingStreamingBuffers
= This
->device
->drvcaps
.dwMaxHwMixingStreamingBuffers
;
814 dscaps
->dwFreeHwMixingAllBuffers
= This
->device
->drvcaps
.dwFreeHwMixingAllBuffers
;
815 dscaps
->dwFreeHwMixingStaticBuffers
= This
->device
->drvcaps
.dwFreeHwMixingAllBuffers
;
816 dscaps
->dwFreeHwMixingStreamingBuffers
= This
->device
->drvcaps
.dwFreeHwMixingAllBuffers
;
818 dscaps
->dwMaxHw3DAllBuffers
= This
->device
->drvcaps
.dwMaxHw3DAllBuffers
;
819 dscaps
->dwMaxHw3DStaticBuffers
= This
->device
->drvcaps
.dwMaxHw3DStaticBuffers
;
820 dscaps
->dwMaxHw3DStreamingBuffers
= This
->device
->drvcaps
.dwMaxHw3DStreamingBuffers
;
821 dscaps
->dwFreeHw3DAllBuffers
= This
->device
->drvcaps
.dwFreeHw3DAllBuffers
;
822 dscaps
->dwFreeHw3DStaticBuffers
= This
->device
->drvcaps
.dwFreeHw3DStaticBuffers
;
823 dscaps
->dwFreeHw3DStreamingBuffers
= This
->device
->drvcaps
.dwFreeHw3DStreamingBuffers
;
824 dscaps
->dwTotalHwMemBytes
= This
->device
->drvcaps
.dwTotalHwMemBytes
;
825 dscaps
->dwFreeHwMemBytes
= This
->device
->drvcaps
.dwFreeHwMemBytes
;
826 dscaps
->dwMaxContigFreeHwMemBytes
= This
->device
->drvcaps
.dwMaxContigFreeHwMemBytes
;
827 dscaps
->dwUnlockTransferRateHwBuffers
= This
->device
->drvcaps
.dwUnlockTransferRateHwBuffers
;
828 dscaps
->dwPlayCpuOverheadSwBuffers
= This
->device
->drvcaps
.dwPlayCpuOverheadSwBuffers
;
830 if (TRACE_ON(dsound
)) {
831 TRACE("(flags=0x%08x:\n", dscaps
->dwFlags
);
832 _dump_DSCAPS(dscaps
->dwFlags
);
839 static HRESULT WINAPI
IDirectSound8Impl_DuplicateSoundBuffer(IDirectSound8
*iface
,
840 IDirectSoundBuffer
*psb
, IDirectSoundBuffer
**ppdsb
)
842 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
843 TRACE("(%p,%p,%p)\n", This
, psb
, ppdsb
);
844 return DirectSoundDevice_DuplicateSoundBuffer(This
->device
, psb
, ppdsb
);
847 static HRESULT WINAPI
IDirectSound8Impl_SetCooperativeLevel(IDirectSound8
*iface
, HWND hwnd
,
850 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
851 DirectSoundDevice
*device
= This
->device
;
854 TRACE("(%p,%p,%s)\n", This
, hwnd
, dumpCooperativeLevel(level
));
857 WARN("not initialized\n");
858 return DSERR_UNINITIALIZED
;
861 if (level
== DSSCL_PRIORITY
|| level
== DSSCL_EXCLUSIVE
) {
862 WARN("level=%s not fully supported\n",
863 level
==DSSCL_PRIORITY
? "DSSCL_PRIORITY" : "DSSCL_EXCLUSIVE");
866 RtlAcquireResourceExclusive(&device
->buffer_list_lock
, TRUE
);
867 EnterCriticalSection(&device
->mixlock
);
868 if ((level
== DSSCL_WRITEPRIMARY
) != (device
->priolevel
== DSSCL_WRITEPRIMARY
))
869 hr
= DSOUND_ReopenDevice(device
, level
== DSSCL_WRITEPRIMARY
);
871 device
->priolevel
= level
;
872 LeaveCriticalSection(&device
->mixlock
);
873 RtlReleaseResource(&device
->buffer_list_lock
);
877 static HRESULT WINAPI
IDirectSound8Impl_Compact(IDirectSound8
*iface
)
879 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
881 TRACE("(%p)\n", This
);
884 WARN("not initialized\n");
885 return DSERR_UNINITIALIZED
;
888 if (This
->device
->priolevel
< DSSCL_PRIORITY
) {
889 WARN("incorrect priority level\n");
890 return DSERR_PRIOLEVELNEEDED
;
895 static HRESULT WINAPI
IDirectSound8Impl_GetSpeakerConfig(IDirectSound8
*iface
, DWORD
*config
)
897 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
899 TRACE("(%p, %p)\n", This
, config
);
902 WARN("not initialized\n");
903 return DSERR_UNINITIALIZED
;
906 WARN("invalid parameter: config == NULL\n");
907 return DSERR_INVALIDPARAM
;
910 WARN("not fully functional\n");
911 *config
= This
->device
->speaker_config
;
915 static HRESULT WINAPI
IDirectSound8Impl_SetSpeakerConfig(IDirectSound8
*iface
, DWORD config
)
917 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
919 TRACE("(%p,0x%08x)\n", This
, config
);
922 WARN("not initialized\n");
923 return DSERR_UNINITIALIZED
;
926 /* NOP on Vista and above */
931 static HRESULT WINAPI
IDirectSound8Impl_Initialize(IDirectSound8
*iface
, const GUID
*lpcGuid
)
933 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
934 TRACE("(%p, %s)\n", This
, debugstr_guid(lpcGuid
));
935 return DirectSoundDevice_Initialize(&This
->device
, lpcGuid
);
938 static HRESULT WINAPI
IDirectSound8Impl_VerifyCertification(IDirectSound8
*iface
, DWORD
*certified
)
940 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
942 TRACE("(%p, %p)\n", This
, certified
);
945 WARN("not initialized\n");
946 return DSERR_UNINITIALIZED
;
949 if (This
->device
->drvcaps
.dwFlags
& DSCAPS_CERTIFIED
)
950 *certified
= DS_CERTIFIED
;
952 *certified
= DS_UNCERTIFIED
;
957 static const IDirectSound8Vtbl ds8_vtbl
=
959 IDirectSound8Impl_QueryInterface
,
960 IDirectSound8Impl_AddRef
,
961 IDirectSound8Impl_Release
,
962 IDirectSound8Impl_CreateSoundBuffer
,
963 IDirectSound8Impl_GetCaps
,
964 IDirectSound8Impl_DuplicateSoundBuffer
,
965 IDirectSound8Impl_SetCooperativeLevel
,
966 IDirectSound8Impl_Compact
,
967 IDirectSound8Impl_GetSpeakerConfig
,
968 IDirectSound8Impl_SetSpeakerConfig
,
969 IDirectSound8Impl_Initialize
,
970 IDirectSound8Impl_VerifyCertification
973 HRESULT
IDirectSoundImpl_Create(IUnknown
*outer_unk
, REFIID riid
, void **ppv
, BOOL has_ds8
)
975 IDirectSoundImpl
*obj
;
978 TRACE("(%s, %p)\n", debugstr_guid(riid
), ppv
);
981 obj
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*obj
));
983 WARN("out of memory\n");
984 return DSERR_OUTOFMEMORY
;
987 setup_dsound_options();
989 obj
->IUnknown_inner
.lpVtbl
= &unk_vtbl
;
990 obj
->IDirectSound8_iface
.lpVtbl
= &ds8_vtbl
;
995 obj
->has_ds8
= has_ds8
;
997 /* COM aggregation supported only internally */
999 obj
->outer_unk
= outer_unk
;
1001 obj
->outer_unk
= &obj
->IUnknown_inner
;
1003 hr
= IUnknown_QueryInterface(&obj
->IUnknown_inner
, riid
, ppv
);
1004 IUnknown_Release(&obj
->IUnknown_inner
);
1009 HRESULT
DSOUND_Create(REFIID riid
, void **ppv
)
1011 return IDirectSoundImpl_Create(NULL
, riid
, ppv
, FALSE
);
1014 HRESULT
DSOUND_Create8(REFIID riid
, void **ppv
)
1016 return IDirectSoundImpl_Create(NULL
, riid
, ppv
, TRUE
);
1019 /*******************************************************************************
1020 * DirectSoundCreate (DSOUND.1)
1022 * Creates and initializes a DirectSound interface.
1025 * lpcGUID [I] Address of the GUID that identifies the sound device.
1026 * ppDS [O] Address of a variable to receive the interface pointer.
1027 * pUnkOuter [I] Must be NULL.
1031 * Failure: DSERR_ALLOCATED, DSERR_INVALIDPARAM, DSERR_NOAGGREGATION,
1032 * DSERR_NODRIVER, DSERR_OUTOFMEMORY
1034 HRESULT WINAPI
DirectSoundCreate(
1036 LPDIRECTSOUND
*ppDS
,
1037 IUnknown
*pUnkOuter
)
1042 TRACE("(%s,%p,%p)\n",debugstr_guid(lpcGUID
),ppDS
,pUnkOuter
);
1045 WARN("invalid parameter: ppDS == NULL\n");
1046 return DSERR_INVALIDPARAM
;
1049 if (pUnkOuter
!= NULL
) {
1050 WARN("invalid parameter: pUnkOuter != NULL\n");
1052 return DSERR_INVALIDPARAM
;
1055 hr
= DSOUND_Create(&IID_IDirectSound
, (void **)&pDS
);
1057 hr
= IDirectSound_Initialize(pDS
, lpcGUID
);
1059 if (hr
!= DSERR_ALREADYINITIALIZED
) {
1060 IDirectSound_Release(pDS
);
1072 /*******************************************************************************
1073 * DirectSoundCreate8 (DSOUND.11)
1075 * Creates and initializes a DirectSound8 interface.
1078 * lpcGUID [I] Address of the GUID that identifies the sound device.
1079 * ppDS [O] Address of a variable to receive the interface pointer.
1080 * pUnkOuter [I] Must be NULL.
1084 * Failure: DSERR_ALLOCATED, DSERR_INVALIDPARAM, DSERR_NOAGGREGATION,
1085 * DSERR_NODRIVER, DSERR_OUTOFMEMORY
1087 HRESULT WINAPI
DirectSoundCreate8(
1089 LPDIRECTSOUND8
*ppDS
,
1090 IUnknown
*pUnkOuter
)
1095 TRACE("(%s,%p,%p)\n",debugstr_guid(lpcGUID
),ppDS
,pUnkOuter
);
1098 WARN("invalid parameter: ppDS == NULL\n");
1099 return DSERR_INVALIDPARAM
;
1102 if (pUnkOuter
!= NULL
) {
1103 WARN("invalid parameter: pUnkOuter != NULL\n");
1105 return DSERR_INVALIDPARAM
;
1108 hr
= DSOUND_Create8(&IID_IDirectSound8
, (void **)&pDS
);
1110 hr
= IDirectSound8_Initialize(pDS
, lpcGUID
);
1112 if (hr
!= DSERR_ALREADYINITIALIZED
) {
1113 IDirectSound8_Release(pDS
);
1125 void DSOUND_ParseSpeakerConfig(DirectSoundDevice
*device
)
1127 switch (DSSPEAKER_CONFIG(device
->speaker_config
)) {
1128 case DSSPEAKER_MONO
:
1129 device
->speaker_angles
[0] = M_PI
/180.0f
* 0.0f
;
1130 device
->speaker_num
[0] = 0;
1131 device
->num_speakers
= 1;
1132 device
->lfe_channel
= -1;
1135 case DSSPEAKER_STEREO
:
1136 case DSSPEAKER_HEADPHONE
:
1137 device
->speaker_angles
[0] = M_PI
/180.0f
* -90.0f
;
1138 device
->speaker_angles
[1] = M_PI
/180.0f
* 90.0f
;
1139 device
->speaker_num
[0] = 0; /* Left */
1140 device
->speaker_num
[1] = 1; /* Right */
1141 device
->num_speakers
= 2;
1142 device
->lfe_channel
= -1;
1145 case DSSPEAKER_QUAD
:
1146 device
->speaker_angles
[0] = M_PI
/180.0f
* -135.0f
;
1147 device
->speaker_angles
[1] = M_PI
/180.0f
* -45.0f
;
1148 device
->speaker_angles
[2] = M_PI
/180.0f
* 45.0f
;
1149 device
->speaker_angles
[3] = M_PI
/180.0f
* 135.0f
;
1150 device
->speaker_num
[0] = 2; /* Rear left */
1151 device
->speaker_num
[1] = 0; /* Front left */
1152 device
->speaker_num
[2] = 1; /* Front right */
1153 device
->speaker_num
[3] = 3; /* Rear right */
1154 device
->num_speakers
= 4;
1155 device
->lfe_channel
= -1;
1158 case DSSPEAKER_5POINT1_BACK
:
1159 device
->speaker_angles
[0] = M_PI
/180.0f
* -135.0f
;
1160 device
->speaker_angles
[1] = M_PI
/180.0f
* -45.0f
;
1161 device
->speaker_angles
[2] = M_PI
/180.0f
* 0.0f
;
1162 device
->speaker_angles
[3] = M_PI
/180.0f
* 45.0f
;
1163 device
->speaker_angles
[4] = M_PI
/180.0f
* 135.0f
;
1164 device
->speaker_angles
[5] = 9999.0f
;
1165 device
->speaker_num
[0] = 4; /* Rear left */
1166 device
->speaker_num
[1] = 0; /* Front left */
1167 device
->speaker_num
[2] = 2; /* Front centre */
1168 device
->speaker_num
[3] = 1; /* Front right */
1169 device
->speaker_num
[4] = 5; /* Rear right */
1170 device
->speaker_num
[5] = 3; /* LFE */
1171 device
->num_speakers
= 6;
1172 device
->lfe_channel
= 3;
1175 case DSSPEAKER_5POINT1_SURROUND
:
1176 device
->speaker_angles
[0] = M_PI
/180.0f
* -90.0f
;
1177 device
->speaker_angles
[1] = M_PI
/180.0f
* -30.0f
;
1178 device
->speaker_angles
[2] = M_PI
/180.0f
* 0.0f
;
1179 device
->speaker_angles
[3] = M_PI
/180.0f
* 30.0f
;
1180 device
->speaker_angles
[4] = M_PI
/180.0f
* 90.0f
;
1181 device
->speaker_angles
[5] = 9999.0f
;
1182 device
->speaker_num
[0] = 4; /* Rear left */
1183 device
->speaker_num
[1] = 0; /* Front left */
1184 device
->speaker_num
[2] = 2; /* Front centre */
1185 device
->speaker_num
[3] = 1; /* Front right */
1186 device
->speaker_num
[4] = 5; /* Rear right */
1187 device
->speaker_num
[5] = 3; /* LFE */
1188 device
->num_speakers
= 6;
1189 device
->lfe_channel
= 3;
1193 WARN("unknown speaker_config %u\n", device
->speaker_config
);