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
38 #include "wine/debug.h"
40 #include "dsound_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(dsound
);
44 typedef struct IDirectSoundImpl
{
45 IUnknown IUnknown_inner
;
46 IDirectSound8 IDirectSound8_iface
;
47 IUnknown
*outer_unk
; /* internal */
48 LONG ref
, refds
, numIfaces
;
49 DirectSoundDevice
*device
;
53 static const char * dumpCooperativeLevel(DWORD level
)
55 #define LE(x) case x: return #x
60 LE(DSSCL_WRITEPRIMARY
);
63 return wine_dbg_sprintf("Unknown(%08x)", level
);
66 static void _dump_DSCAPS(DWORD xmask
) {
71 #define FE(x) { x, #x },
72 FE(DSCAPS_PRIMARYMONO
)
73 FE(DSCAPS_PRIMARYSTEREO
)
74 FE(DSCAPS_PRIMARY8BIT
)
75 FE(DSCAPS_PRIMARY16BIT
)
76 FE(DSCAPS_CONTINUOUSRATE
)
79 FE(DSCAPS_SECONDARYMONO
)
80 FE(DSCAPS_SECONDARYSTEREO
)
81 FE(DSCAPS_SECONDARY8BIT
)
82 FE(DSCAPS_SECONDARY16BIT
)
87 for (i
= 0; i
< ARRAY_SIZE(flags
); i
++)
88 if ((flags
[i
].mask
& xmask
) == flags
[i
].mask
)
89 TRACE("%s ",flags
[i
].name
);
92 static void _dump_DSBCAPS(DWORD xmask
) {
97 #define FE(x) { x, #x },
98 FE(DSBCAPS_PRIMARYBUFFER
)
100 FE(DSBCAPS_LOCHARDWARE
)
101 FE(DSBCAPS_LOCSOFTWARE
)
103 FE(DSBCAPS_CTRLFREQUENCY
)
105 FE(DSBCAPS_CTRLVOLUME
)
106 FE(DSBCAPS_CTRLPOSITIONNOTIFY
)
108 FE(DSBCAPS_STICKYFOCUS
)
109 FE(DSBCAPS_GLOBALFOCUS
)
110 FE(DSBCAPS_GETCURRENTPOSITION2
)
111 FE(DSBCAPS_MUTE3DATMAXDISTANCE
)
117 for (i
= 0; i
< ARRAY_SIZE(flags
); i
++)
118 if ((flags
[i
].mask
& xmask
) == flags
[i
].mask
)
119 TRACE("%s ",flags
[i
].name
);
122 /*******************************************************************************
125 static HRESULT
DirectSoundDevice_Create(DirectSoundDevice
** ppDevice
)
127 DirectSoundDevice
* device
;
128 TRACE("(%p)\n", ppDevice
);
130 /* Allocate memory */
131 device
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(DirectSoundDevice
));
132 if (device
== NULL
) {
133 WARN("out of memory\n");
134 return DSERR_OUTOFMEMORY
;
138 device
->priolevel
= DSSCL_NORMAL
;
140 device
->speaker_config
= DSSPEAKER_COMBINED(DSSPEAKER_STEREO
, DSSPEAKER_GEOMETRY_WIDE
);
142 DSOUND_ParseSpeakerConfig(device
);
144 /* 3D listener initial parameters */
145 device
->ds3dl
.dwSize
= sizeof(DS3DLISTENER
);
146 device
->ds3dl
.vPosition
.x
= 0.0;
147 device
->ds3dl
.vPosition
.y
= 0.0;
148 device
->ds3dl
.vPosition
.z
= 0.0;
149 device
->ds3dl
.vVelocity
.x
= 0.0;
150 device
->ds3dl
.vVelocity
.y
= 0.0;
151 device
->ds3dl
.vVelocity
.z
= 0.0;
152 device
->ds3dl
.vOrientFront
.x
= 0.0;
153 device
->ds3dl
.vOrientFront
.y
= 0.0;
154 device
->ds3dl
.vOrientFront
.z
= 1.0;
155 device
->ds3dl
.vOrientTop
.x
= 0.0;
156 device
->ds3dl
.vOrientTop
.y
= 1.0;
157 device
->ds3dl
.vOrientTop
.z
= 0.0;
158 device
->ds3dl
.flDistanceFactor
= DS3D_DEFAULTDISTANCEFACTOR
;
159 device
->ds3dl
.flRolloffFactor
= DS3D_DEFAULTROLLOFFFACTOR
;
160 device
->ds3dl
.flDopplerFactor
= DS3D_DEFAULTDOPPLERFACTOR
;
162 device
->guid
= GUID_NULL
;
164 /* Set default wave format (may need it for waveOutOpen) */
165 device
->primary_pwfx
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(WAVEFORMATEXTENSIBLE
));
166 if (!device
->primary_pwfx
) {
167 WARN("out of memory\n");
168 HeapFree(GetProcessHeap(),0,device
);
169 return DSERR_OUTOFMEMORY
;
172 device
->primary_pwfx
->wFormatTag
= WAVE_FORMAT_PCM
;
173 device
->primary_pwfx
->nSamplesPerSec
= 22050;
174 device
->primary_pwfx
->wBitsPerSample
= 8;
175 device
->primary_pwfx
->nChannels
= 2;
176 device
->primary_pwfx
->nBlockAlign
= device
->primary_pwfx
->wBitsPerSample
* device
->primary_pwfx
->nChannels
/ 8;
177 device
->primary_pwfx
->nAvgBytesPerSec
= device
->primary_pwfx
->nSamplesPerSec
* device
->primary_pwfx
->nBlockAlign
;
178 device
->primary_pwfx
->cbSize
= 0;
180 InitializeCriticalSection(&(device
->mixlock
));
181 device
->mixlock
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": DirectSoundDevice.mixlock");
183 InitializeSRWLock(&device
->buffer_list_lock
);
190 static ULONG
DirectSoundDevice_AddRef(DirectSoundDevice
* device
)
192 ULONG ref
= InterlockedIncrement(&(device
->ref
));
193 TRACE("(%p) ref %d\n", device
, ref
);
197 static ULONG
DirectSoundDevice_Release(DirectSoundDevice
* device
)
200 ULONG ref
= InterlockedDecrement(&(device
->ref
));
201 TRACE("(%p) ref %d\n", device
, ref
);
205 SetEvent(device
->sleepev
);
206 if (device
->thread
) {
207 WaitForSingleObject(device
->thread
, INFINITE
);
208 CloseHandle(device
->thread
);
211 EnterCriticalSection(&DSOUND_renderers_lock
);
212 list_remove(&device
->entry
);
213 LeaveCriticalSection(&DSOUND_renderers_lock
);
215 /* It is allowed to release this object even when buffers are playing */
216 if (device
->buffers
) {
217 WARN("%d secondary buffers not released\n", device
->nrofbuffers
);
218 for( i
=0;i
<device
->nrofbuffers
;i
++)
219 secondarybuffer_destroy(device
->buffers
[i
]);
222 hr
= DSOUND_PrimaryDestroy(device
);
224 WARN("DSOUND_PrimaryDestroy failed\n");
227 IAudioClient_Stop(device
->client
);
228 IAudioClient_Release(device
->client
);
231 IAudioRenderClient_Release(device
->render
);
233 IAudioStreamVolume_Release(device
->volume
);
235 IMMDevice_Release(device
->mmdevice
);
236 CloseHandle(device
->sleepev
);
237 HeapFree(GetProcessHeap(), 0, device
->tmp_buffer
);
238 HeapFree(GetProcessHeap(), 0, device
->cp_buffer
);
239 HeapFree(GetProcessHeap(), 0, device
->buffer
);
240 device
->mixlock
.DebugInfo
->Spare
[0] = 0;
241 DeleteCriticalSection(&device
->mixlock
);
242 HeapFree(GetProcessHeap(),0,device
);
243 TRACE("(%p) released\n", device
);
248 BOOL
DSOUND_check_supported(IAudioClient
*client
, DWORD rate
,
249 DWORD depth
, WORD channels
)
251 WAVEFORMATEX fmt
, *junk
;
254 fmt
.wFormatTag
= WAVE_FORMAT_PCM
;
255 fmt
.nChannels
= channels
;
256 fmt
.nSamplesPerSec
= rate
;
257 fmt
.wBitsPerSample
= depth
;
258 fmt
.nBlockAlign
= (channels
* depth
) / 8;
259 fmt
.nAvgBytesPerSec
= rate
* fmt
.nBlockAlign
;
262 hr
= IAudioClient_IsFormatSupported(client
, AUDCLNT_SHAREMODE_SHARED
, &fmt
, &junk
);
269 static HRESULT
DirectSoundDevice_Initialize(DirectSoundDevice
** ppDevice
, LPCGUID lpcGUID
)
273 DirectSoundDevice
*device
;
276 TRACE("(%p,%s)\n",ppDevice
,debugstr_guid(lpcGUID
));
278 if (*ppDevice
!= NULL
) {
279 WARN("already initialized\n");
280 return DSERR_ALREADYINITIALIZED
;
283 /* Default device? */
284 if (!lpcGUID
|| IsEqualGUID(lpcGUID
, &GUID_NULL
))
285 lpcGUID
= &DSDEVID_DefaultPlayback
;
287 if(IsEqualGUID(lpcGUID
, &DSDEVID_DefaultCapture
) ||
288 IsEqualGUID(lpcGUID
, &DSDEVID_DefaultVoiceCapture
))
289 return DSERR_NODRIVER
;
291 if (GetDeviceID(lpcGUID
, &devGUID
) != DS_OK
) {
292 WARN("invalid parameter: lpcGUID\n");
293 return DSERR_INVALIDPARAM
;
296 hr
= get_mmdevice(eRender
, &devGUID
, &mmdevice
);
300 EnterCriticalSection(&DSOUND_renderers_lock
);
302 LIST_FOR_EACH_ENTRY(device
, &DSOUND_renderers
, DirectSoundDevice
, entry
){
303 if(IsEqualGUID(&device
->guid
, &devGUID
)){
304 IMMDevice_Release(mmdevice
);
305 DirectSoundDevice_AddRef(device
);
307 LeaveCriticalSection(&DSOUND_renderers_lock
);
312 hr
= DirectSoundDevice_Create(&device
);
314 WARN("DirectSoundDevice_Create failed\n");
315 IMMDevice_Release(mmdevice
);
316 LeaveCriticalSection(&DSOUND_renderers_lock
);
320 device
->mmdevice
= mmdevice
;
321 device
->guid
= devGUID
;
322 device
->sleepev
= CreateEventW(0, 0, 0, 0);
323 device
->buflen
= ds_hel_buflen
;
325 hr
= DSOUND_ReopenDevice(device
, FALSE
);
328 HeapFree(GetProcessHeap(), 0, device
);
329 LeaveCriticalSection(&DSOUND_renderers_lock
);
330 IMMDevice_Release(mmdevice
);
331 WARN("DSOUND_ReopenDevice failed: %08x\n", hr
);
335 ZeroMemory(&device
->drvcaps
, sizeof(device
->drvcaps
));
337 if(DSOUND_check_supported(device
->client
, 11025, 8, 1) ||
338 DSOUND_check_supported(device
->client
, 22050, 8, 1) ||
339 DSOUND_check_supported(device
->client
, 44100, 8, 1) ||
340 DSOUND_check_supported(device
->client
, 48000, 8, 1) ||
341 DSOUND_check_supported(device
->client
, 96000, 8, 1))
342 device
->drvcaps
.dwFlags
|= DSCAPS_PRIMARY8BIT
| DSCAPS_PRIMARYMONO
;
344 if(DSOUND_check_supported(device
->client
, 11025, 16, 1) ||
345 DSOUND_check_supported(device
->client
, 22050, 16, 1) ||
346 DSOUND_check_supported(device
->client
, 44100, 16, 1) ||
347 DSOUND_check_supported(device
->client
, 48000, 16, 1) ||
348 DSOUND_check_supported(device
->client
, 96000, 16, 1))
349 device
->drvcaps
.dwFlags
|= DSCAPS_PRIMARY16BIT
| DSCAPS_PRIMARYMONO
;
351 if(DSOUND_check_supported(device
->client
, 11025, 8, 2) ||
352 DSOUND_check_supported(device
->client
, 22050, 8, 2) ||
353 DSOUND_check_supported(device
->client
, 44100, 8, 2) ||
354 DSOUND_check_supported(device
->client
, 48000, 8, 2) ||
355 DSOUND_check_supported(device
->client
, 96000, 8, 2))
356 device
->drvcaps
.dwFlags
|= DSCAPS_PRIMARY8BIT
| DSCAPS_PRIMARYSTEREO
;
358 if(DSOUND_check_supported(device
->client
, 11025, 16, 2) ||
359 DSOUND_check_supported(device
->client
, 22050, 16, 2) ||
360 DSOUND_check_supported(device
->client
, 44100, 16, 2) ||
361 DSOUND_check_supported(device
->client
, 48000, 16, 2) ||
362 DSOUND_check_supported(device
->client
, 96000, 16, 2))
363 device
->drvcaps
.dwFlags
|= DSCAPS_PRIMARY16BIT
| DSCAPS_PRIMARYSTEREO
;
365 /* the dsound mixer supports all of the following */
366 device
->drvcaps
.dwFlags
|= DSCAPS_SECONDARY8BIT
| DSCAPS_SECONDARY16BIT
;
367 device
->drvcaps
.dwFlags
|= DSCAPS_SECONDARYMONO
| DSCAPS_SECONDARYSTEREO
;
368 device
->drvcaps
.dwFlags
|= DSCAPS_CONTINUOUSRATE
;
370 /* pretend that the driver is certified */
371 device
->drvcaps
.dwFlags
|= DSCAPS_CERTIFIED
;
373 device
->drvcaps
.dwPrimaryBuffers
= 1;
374 device
->drvcaps
.dwMinSecondarySampleRate
= DSBFREQUENCY_MIN
;
375 device
->drvcaps
.dwMaxSecondarySampleRate
= DSBFREQUENCY_MAX
;
376 device
->drvcaps
.dwMaxHwMixingAllBuffers
= 16;
377 device
->drvcaps
.dwMaxHwMixingStaticBuffers
= device
->drvcaps
.dwMaxHwMixingAllBuffers
;
378 device
->drvcaps
.dwMaxHwMixingStreamingBuffers
= device
->drvcaps
.dwMaxHwMixingAllBuffers
;
379 device
->drvcaps
.dwFreeHwMixingAllBuffers
= device
->drvcaps
.dwMaxHwMixingAllBuffers
;
380 device
->drvcaps
.dwFreeHwMixingStaticBuffers
= device
->drvcaps
.dwMaxHwMixingStaticBuffers
;
381 device
->drvcaps
.dwFreeHwMixingStreamingBuffers
= device
->drvcaps
.dwMaxHwMixingStreamingBuffers
;
383 ZeroMemory(&device
->volpan
, sizeof(device
->volpan
));
385 device
->thread
= CreateThread(0, 0, DSOUND_mixthread
, device
, 0, 0);
386 SetThreadPriority(device
->thread
, THREAD_PRIORITY_TIME_CRITICAL
);
389 list_add_tail(&DSOUND_renderers
, &device
->entry
);
391 LeaveCriticalSection(&DSOUND_renderers_lock
);
396 static HRESULT
DirectSoundDevice_CreateSoundBuffer(
397 DirectSoundDevice
* device
,
398 LPCDSBUFFERDESC dsbd
,
399 LPLPDIRECTSOUNDBUFFER ppdsb
,
403 HRESULT hres
= DS_OK
;
404 TRACE("(%p,%p,%p,%p)\n",device
,dsbd
,ppdsb
,lpunk
);
406 if (device
== NULL
) {
407 WARN("not initialized\n");
408 return DSERR_UNINITIALIZED
;
412 WARN("invalid parameter: dsbd == NULL\n");
413 return DSERR_INVALIDPARAM
;
416 if (dsbd
->dwSize
!= sizeof(DSBUFFERDESC
) &&
417 dsbd
->dwSize
!= sizeof(DSBUFFERDESC1
)) {
418 WARN("invalid parameter: dsbd\n");
419 return DSERR_INVALIDPARAM
;
423 WARN("invalid parameter: ppdsb == NULL\n");
424 return DSERR_INVALIDPARAM
;
428 if (TRACE_ON(dsound
)) {
429 TRACE("(structsize=%d)\n",dsbd
->dwSize
);
430 TRACE("(flags=0x%08x:\n",dsbd
->dwFlags
);
431 _dump_DSBCAPS(dsbd
->dwFlags
);
433 TRACE("(bufferbytes=%d)\n",dsbd
->dwBufferBytes
);
434 TRACE("(lpwfxFormat=%p)\n",dsbd
->lpwfxFormat
);
437 if (!(dsbd
->dwFlags
& DSBCAPS_PRIMARYBUFFER
) &&
438 dsbd
->dwFlags
& DSBCAPS_LOCHARDWARE
&&
439 device
->drvcaps
.dwFreeHwMixingAllBuffers
== 0)
441 WARN("ran out of emulated hardware buffers\n");
442 return DSERR_ALLOCATED
;
445 if (dsbd
->dwFlags
& DSBCAPS_PRIMARYBUFFER
) {
446 if (dsbd
->lpwfxFormat
!= NULL
) {
447 WARN("invalid parameter: dsbd->lpwfxFormat must be NULL for "
449 return DSERR_INVALIDPARAM
;
452 if (dsbd
->dwFlags
& DSBCAPS_CTRLFX
)
454 WARN("Invalid parameter DSBCAPS_CTRLFX\n");
455 return DSERR_INVALIDPARAM
;
458 if (device
->primary
) {
459 WARN("Primary Buffer already created\n");
460 IDirectSoundBuffer8_AddRef(&device
->primary
->IDirectSoundBuffer8_iface
);
461 *ppdsb
= (IDirectSoundBuffer
*)&device
->primary
->IDirectSoundBuffer8_iface
;
463 hres
= primarybuffer_create(device
, &device
->primary
, dsbd
);
464 if (device
->primary
) {
465 *ppdsb
= (IDirectSoundBuffer
*)&device
->primary
->IDirectSoundBuffer8_iface
;
466 device
->primary
->dsbd
.dwFlags
&= ~(DSBCAPS_LOCHARDWARE
| DSBCAPS_LOCSOFTWARE
);
467 device
->primary
->dsbd
.dwFlags
|= DSBCAPS_LOCSOFTWARE
;
469 WARN("primarybuffer_create() failed\n");
472 if (dsbd
->lpwfxFormat
== NULL
) {
473 WARN("invalid parameter: dsbd->lpwfxFormat can't be NULL for "
474 "secondary buffer\n");
475 return DSERR_INVALIDPARAM
;
478 if(dsbd
->lpwfxFormat
->wFormatTag
!= WAVE_FORMAT_PCM
&&
479 dsbd
->lpwfxFormat
->wFormatTag
!= WAVE_FORMAT_IEEE_FLOAT
&&
480 dsbd
->lpwfxFormat
->wFormatTag
!= WAVE_FORMAT_EXTENSIBLE
) {
481 WARN("We can't mix this format: 0x%x\n", dsbd
->lpwfxFormat
->wFormatTag
);
485 if(dsbd
->lpwfxFormat
->wBitsPerSample
< 8 || dsbd
->lpwfxFormat
->wBitsPerSample
% 8 != 0 ||
486 dsbd
->lpwfxFormat
->nChannels
== 0 || dsbd
->lpwfxFormat
->nSamplesPerSec
== 0 ||
487 dsbd
->lpwfxFormat
->nAvgBytesPerSec
== 0 ||
488 dsbd
->lpwfxFormat
->nBlockAlign
!= dsbd
->lpwfxFormat
->nChannels
* dsbd
->lpwfxFormat
->wBitsPerSample
/ 8) {
489 WARN("Format inconsistency\n");
490 return DSERR_INVALIDPARAM
;
493 if (dsbd
->lpwfxFormat
->wFormatTag
== WAVE_FORMAT_EXTENSIBLE
)
495 WAVEFORMATEXTENSIBLE
*pwfxe
= (WAVEFORMATEXTENSIBLE
*)dsbd
->lpwfxFormat
;
497 /* check if cbSize is at least 22 bytes */
498 if (pwfxe
->Format
.cbSize
< (sizeof(WAVEFORMATEXTENSIBLE
) - sizeof(WAVEFORMATEX
)))
500 WARN("Too small a cbSize %u\n", pwfxe
->Format
.cbSize
);
501 return DSERR_INVALIDPARAM
;
504 /* cbSize should be 22 bytes, with one possible exception */
505 if (pwfxe
->Format
.cbSize
> (sizeof(WAVEFORMATEXTENSIBLE
) - sizeof(WAVEFORMATEX
)) &&
506 !((IsEqualGUID(&pwfxe
->SubFormat
, &KSDATAFORMAT_SUBTYPE_PCM
) || IsEqualGUID(&pwfxe
->SubFormat
, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
)) &&
507 pwfxe
->Format
.cbSize
== sizeof(WAVEFORMATEXTENSIBLE
)))
509 WARN("Too big a cbSize %u\n", pwfxe
->Format
.cbSize
);
510 return DSERR_CONTROLUNAVAIL
;
513 if ((!IsEqualGUID(&pwfxe
->SubFormat
, &KSDATAFORMAT_SUBTYPE_PCM
)) && (!IsEqualGUID(&pwfxe
->SubFormat
, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
)))
515 if (!IsEqualGUID(&pwfxe
->SubFormat
, &GUID_NULL
))
516 FIXME("SubFormat %s not supported right now.\n", debugstr_guid(&pwfxe
->SubFormat
));
517 return DSERR_INVALIDPARAM
;
519 if (pwfxe
->Samples
.wValidBitsPerSample
> dsbd
->lpwfxFormat
->wBitsPerSample
)
521 WARN("Samples.wValidBitsPerSample(%d) > Format.wBitsPerSample (%d)\n", pwfxe
->Samples
.wValidBitsPerSample
, pwfxe
->Format
.wBitsPerSample
);
522 return DSERR_INVALIDPARAM
;
524 if (pwfxe
->Samples
.wValidBitsPerSample
&& pwfxe
->Samples
.wValidBitsPerSample
< dsbd
->lpwfxFormat
->wBitsPerSample
)
526 WARN("Non-packed formats may not function : %d/%d\n", pwfxe
->Samples
.wValidBitsPerSample
, dsbd
->lpwfxFormat
->wBitsPerSample
);
530 TRACE("(formattag=0x%04x,chans=%d,samplerate=%d,"
531 "bytespersec=%d,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
532 dsbd
->lpwfxFormat
->wFormatTag
, dsbd
->lpwfxFormat
->nChannels
,
533 dsbd
->lpwfxFormat
->nSamplesPerSec
,
534 dsbd
->lpwfxFormat
->nAvgBytesPerSec
,
535 dsbd
->lpwfxFormat
->nBlockAlign
,
536 dsbd
->lpwfxFormat
->wBitsPerSample
, dsbd
->lpwfxFormat
->cbSize
);
538 if (from8
&& (dsbd
->dwFlags
& DSBCAPS_CTRL3D
) && (dsbd
->lpwfxFormat
->nChannels
!= 1)) {
539 WARN("invalid parameter: 3D buffer format must be mono\n");
540 return DSERR_INVALIDPARAM
;
543 if (from8
&& (dsbd
->dwFlags
& DSBCAPS_CTRL3D
) && (dsbd
->dwFlags
& DSBCAPS_CTRLPAN
)) {
544 WARN("invalid parameter: DSBCAPS_CTRL3D and DSBCAPS_CTRLPAN cannot be used together\n");
545 return DSERR_INVALIDPARAM
;
548 hres
= secondarybuffer_create(device
, dsbd
, ppdsb
);
549 if (SUCCEEDED(hres
)) {
550 if (dsbd
->dwFlags
& DSBCAPS_LOCHARDWARE
)
551 device
->drvcaps
.dwFreeHwMixingAllBuffers
--;
553 WARN("IDirectSoundBufferImpl_Create failed\n");
559 static HRESULT
DirectSoundDevice_DuplicateSoundBuffer(
560 DirectSoundDevice
* device
,
561 LPDIRECTSOUNDBUFFER psb
,
562 LPLPDIRECTSOUNDBUFFER ppdsb
)
564 HRESULT hres
= DS_OK
;
565 IDirectSoundBufferImpl
* dsb
;
566 TRACE("(%p,%p,%p)\n",device
,psb
,ppdsb
);
568 if (device
== NULL
) {
569 WARN("not initialized\n");
570 return DSERR_UNINITIALIZED
;
574 WARN("invalid parameter: psb == NULL\n");
575 return DSERR_INVALIDPARAM
;
579 WARN("invalid parameter: ppdsb == NULL\n");
580 return DSERR_INVALIDPARAM
;
583 /* make sure we have a secondary buffer */
584 if (psb
== (IDirectSoundBuffer
*)&device
->primary
->IDirectSoundBuffer8_iface
) {
585 WARN("trying to duplicate primary buffer\n");
587 return DSERR_INVALIDCALL
;
590 /* duplicate the actual buffer implementation */
591 hres
= IDirectSoundBufferImpl_Duplicate(device
, &dsb
, (IDirectSoundBufferImpl
*)psb
);
593 *ppdsb
= (IDirectSoundBuffer
*)&dsb
->IDirectSoundBuffer8_iface
;
595 WARN("IDirectSoundBufferImpl_Duplicate failed\n");
601 * Add secondary buffer to buffer list.
602 * Gets exclusive access to buffer for writing.
604 HRESULT
DirectSoundDevice_AddBuffer(
605 DirectSoundDevice
* device
,
606 IDirectSoundBufferImpl
* pDSB
)
608 IDirectSoundBufferImpl
**newbuffers
;
611 TRACE("(%p, %p)\n", device
, pDSB
);
613 AcquireSRWLockExclusive(&device
->buffer_list_lock
);
616 newbuffers
= HeapReAlloc(GetProcessHeap(),0,device
->buffers
,sizeof(IDirectSoundBufferImpl
*)*(device
->nrofbuffers
+1));
618 newbuffers
= HeapAlloc(GetProcessHeap(),0,sizeof(IDirectSoundBufferImpl
*)*(device
->nrofbuffers
+1));
621 device
->buffers
= newbuffers
;
622 device
->buffers
[device
->nrofbuffers
] = pDSB
;
623 device
->nrofbuffers
++;
624 TRACE("buffer count is now %d\n", device
->nrofbuffers
);
626 ERR("out of memory for buffer list! Current buffer count is %d\n", device
->nrofbuffers
);
627 hr
= DSERR_OUTOFMEMORY
;
630 ReleaseSRWLockExclusive(&device
->buffer_list_lock
);
636 * Remove secondary buffer from buffer list.
637 * Gets exclusive access to buffer for writing.
639 void DirectSoundDevice_RemoveBuffer(DirectSoundDevice
* device
, IDirectSoundBufferImpl
* pDSB
)
643 TRACE("(%p, %p)\n", device
, pDSB
);
645 AcquireSRWLockExclusive(&device
->buffer_list_lock
);
647 if (device
->nrofbuffers
== 1) {
648 assert(device
->buffers
[0] == pDSB
);
649 HeapFree(GetProcessHeap(), 0, device
->buffers
);
650 device
->buffers
= NULL
;
652 for (i
= 0; i
< device
->nrofbuffers
; i
++) {
653 if (device
->buffers
[i
] == pDSB
) {
654 /* Put the last buffer of the list in the (now empty) position */
655 device
->buffers
[i
] = device
->buffers
[device
->nrofbuffers
- 1];
660 device
->nrofbuffers
--;
661 TRACE("buffer count is now %d\n", device
->nrofbuffers
);
663 ReleaseSRWLockExclusive(&device
->buffer_list_lock
);
666 /*******************************************************************************
667 * IUnknown Implementation for DirectSound
670 static void directsound_destroy(IDirectSoundImpl
*This
)
673 DirectSoundDevice_Release(This
->device
);
674 HeapFree(GetProcessHeap(),0,This
);
675 TRACE("(%p) released\n", This
);
678 static inline IDirectSoundImpl
*impl_from_IUnknown(IUnknown
*iface
)
680 return CONTAINING_RECORD(iface
, IDirectSoundImpl
, IUnknown_inner
);
683 static HRESULT WINAPI
IUnknownImpl_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
685 IDirectSoundImpl
*This
= impl_from_IUnknown(iface
);
687 TRACE("(%p,%s,%p)\n", This
, debugstr_guid(riid
), ppv
);
690 WARN("invalid parameter\n");
695 if (IsEqualIID(riid
, &IID_IUnknown
))
696 *ppv
= &This
->IUnknown_inner
;
697 else if (IsEqualIID(riid
, &IID_IDirectSound
) ||
698 (IsEqualIID(riid
, &IID_IDirectSound8
) && This
->has_ds8
))
699 *ppv
= &This
->IDirectSound8_iface
;
701 WARN("unknown IID %s\n", debugstr_guid(riid
));
702 return E_NOINTERFACE
;
705 IUnknown_AddRef((IUnknown
*)*ppv
);
709 static ULONG WINAPI
IUnknownImpl_AddRef(IUnknown
*iface
)
711 IDirectSoundImpl
*This
= impl_from_IUnknown(iface
);
712 ULONG ref
= InterlockedIncrement(&This
->ref
);
714 TRACE("(%p) ref=%d\n", This
, ref
);
717 InterlockedIncrement(&This
->numIfaces
);
722 static ULONG WINAPI
IUnknownImpl_Release(IUnknown
*iface
)
724 IDirectSoundImpl
*This
= impl_from_IUnknown(iface
);
725 ULONG ref
= InterlockedDecrement(&This
->ref
);
727 TRACE("(%p) ref=%d\n", This
, ref
);
729 if (!ref
&& !InterlockedDecrement(&This
->numIfaces
))
730 directsound_destroy(This
);
735 static const IUnknownVtbl unk_vtbl
=
737 IUnknownImpl_QueryInterface
,
742 /*******************************************************************************
743 * IDirectSound and IDirectSound8 Implementation
745 static inline IDirectSoundImpl
*impl_from_IDirectSound8(IDirectSound8
*iface
)
747 return CONTAINING_RECORD(iface
, IDirectSoundImpl
, IDirectSound8_iface
);
750 static HRESULT WINAPI
IDirectSound8Impl_QueryInterface(IDirectSound8
*iface
, REFIID riid
,
753 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
754 TRACE("(%p,%s,%p)\n", This
, debugstr_guid(riid
), ppv
);
755 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
758 static ULONG WINAPI
IDirectSound8Impl_AddRef(IDirectSound8
*iface
)
760 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
761 ULONG ref
= InterlockedIncrement(&This
->refds
);
763 TRACE("(%p) refds=%d\n", This
, ref
);
766 InterlockedIncrement(&This
->numIfaces
);
771 static ULONG WINAPI
IDirectSound8Impl_Release(IDirectSound8
*iface
)
773 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
774 ULONG ref
= InterlockedDecrement(&(This
->refds
));
776 TRACE("(%p) refds=%d\n", This
, ref
);
778 if (!ref
&& !InterlockedDecrement(&This
->numIfaces
))
779 directsound_destroy(This
);
784 static HRESULT WINAPI
IDirectSound8Impl_CreateSoundBuffer(IDirectSound8
*iface
,
785 const DSBUFFERDESC
*dsbd
, IDirectSoundBuffer
**ppdsb
, IUnknown
*lpunk
)
787 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
788 TRACE("(%p,%p,%p,%p)\n", This
, dsbd
, ppdsb
, lpunk
);
789 return DirectSoundDevice_CreateSoundBuffer(This
->device
, dsbd
, ppdsb
, lpunk
, This
->has_ds8
);
792 static HRESULT WINAPI
IDirectSound8Impl_GetCaps(IDirectSound8
*iface
, DSCAPS
*dscaps
)
794 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
796 TRACE("(%p, %p)\n", This
, dscaps
);
799 WARN("not initialized\n");
800 return DSERR_UNINITIALIZED
;
803 WARN("invalid parameter: dscaps = NULL\n");
804 return DSERR_INVALIDPARAM
;
806 if (dscaps
->dwSize
< sizeof(*dscaps
)) {
807 WARN("invalid parameter: dscaps->dwSize = %d\n", dscaps
->dwSize
);
808 return DSERR_INVALIDPARAM
;
811 dscaps
->dwFlags
= This
->device
->drvcaps
.dwFlags
;
812 dscaps
->dwMinSecondarySampleRate
= This
->device
->drvcaps
.dwMinSecondarySampleRate
;
813 dscaps
->dwMaxSecondarySampleRate
= This
->device
->drvcaps
.dwMaxSecondarySampleRate
;
814 dscaps
->dwPrimaryBuffers
= This
->device
->drvcaps
.dwPrimaryBuffers
;
815 dscaps
->dwMaxHwMixingAllBuffers
= This
->device
->drvcaps
.dwMaxHwMixingAllBuffers
;
816 dscaps
->dwMaxHwMixingStaticBuffers
= This
->device
->drvcaps
.dwMaxHwMixingStaticBuffers
;
817 dscaps
->dwMaxHwMixingStreamingBuffers
= This
->device
->drvcaps
.dwMaxHwMixingStreamingBuffers
;
818 dscaps
->dwFreeHwMixingAllBuffers
= This
->device
->drvcaps
.dwFreeHwMixingAllBuffers
;
819 dscaps
->dwFreeHwMixingStaticBuffers
= This
->device
->drvcaps
.dwFreeHwMixingAllBuffers
;
820 dscaps
->dwFreeHwMixingStreamingBuffers
= This
->device
->drvcaps
.dwFreeHwMixingAllBuffers
;
822 dscaps
->dwMaxHw3DAllBuffers
= This
->device
->drvcaps
.dwMaxHw3DAllBuffers
;
823 dscaps
->dwMaxHw3DStaticBuffers
= This
->device
->drvcaps
.dwMaxHw3DStaticBuffers
;
824 dscaps
->dwMaxHw3DStreamingBuffers
= This
->device
->drvcaps
.dwMaxHw3DStreamingBuffers
;
825 dscaps
->dwFreeHw3DAllBuffers
= This
->device
->drvcaps
.dwFreeHw3DAllBuffers
;
826 dscaps
->dwFreeHw3DStaticBuffers
= This
->device
->drvcaps
.dwFreeHw3DStaticBuffers
;
827 dscaps
->dwFreeHw3DStreamingBuffers
= This
->device
->drvcaps
.dwFreeHw3DStreamingBuffers
;
828 dscaps
->dwTotalHwMemBytes
= This
->device
->drvcaps
.dwTotalHwMemBytes
;
829 dscaps
->dwFreeHwMemBytes
= This
->device
->drvcaps
.dwFreeHwMemBytes
;
830 dscaps
->dwMaxContigFreeHwMemBytes
= This
->device
->drvcaps
.dwMaxContigFreeHwMemBytes
;
831 dscaps
->dwUnlockTransferRateHwBuffers
= This
->device
->drvcaps
.dwUnlockTransferRateHwBuffers
;
832 dscaps
->dwPlayCpuOverheadSwBuffers
= This
->device
->drvcaps
.dwPlayCpuOverheadSwBuffers
;
834 if (TRACE_ON(dsound
)) {
835 TRACE("(flags=0x%08x:\n", dscaps
->dwFlags
);
836 _dump_DSCAPS(dscaps
->dwFlags
);
843 static HRESULT WINAPI
IDirectSound8Impl_DuplicateSoundBuffer(IDirectSound8
*iface
,
844 IDirectSoundBuffer
*psb
, IDirectSoundBuffer
**ppdsb
)
846 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
847 TRACE("(%p,%p,%p)\n", This
, psb
, ppdsb
);
848 return DirectSoundDevice_DuplicateSoundBuffer(This
->device
, psb
, ppdsb
);
851 static HRESULT WINAPI
IDirectSound8Impl_SetCooperativeLevel(IDirectSound8
*iface
, HWND hwnd
,
854 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
855 DirectSoundDevice
*device
= This
->device
;
858 TRACE("(%p,%p,%s)\n", This
, hwnd
, dumpCooperativeLevel(level
));
861 WARN("not initialized\n");
862 return DSERR_UNINITIALIZED
;
865 if (level
== DSSCL_PRIORITY
|| level
== DSSCL_EXCLUSIVE
) {
866 WARN("level=%s not fully supported\n",
867 level
==DSSCL_PRIORITY
? "DSSCL_PRIORITY" : "DSSCL_EXCLUSIVE");
870 AcquireSRWLockExclusive(&device
->buffer_list_lock
);
871 EnterCriticalSection(&device
->mixlock
);
872 if ((level
== DSSCL_WRITEPRIMARY
) != (device
->priolevel
== DSSCL_WRITEPRIMARY
))
873 hr
= DSOUND_ReopenDevice(device
, level
== DSSCL_WRITEPRIMARY
);
875 device
->priolevel
= level
;
876 LeaveCriticalSection(&device
->mixlock
);
877 ReleaseSRWLockExclusive(&device
->buffer_list_lock
);
881 static HRESULT WINAPI
IDirectSound8Impl_Compact(IDirectSound8
*iface
)
883 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
885 TRACE("(%p)\n", This
);
888 WARN("not initialized\n");
889 return DSERR_UNINITIALIZED
;
892 if (This
->device
->priolevel
< DSSCL_PRIORITY
) {
893 WARN("incorrect priority level\n");
894 return DSERR_PRIOLEVELNEEDED
;
899 static HRESULT WINAPI
IDirectSound8Impl_GetSpeakerConfig(IDirectSound8
*iface
, DWORD
*config
)
901 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
903 TRACE("(%p, %p)\n", This
, config
);
906 WARN("not initialized\n");
907 return DSERR_UNINITIALIZED
;
910 WARN("invalid parameter: config == NULL\n");
911 return DSERR_INVALIDPARAM
;
914 WARN("not fully functional\n");
915 *config
= This
->device
->speaker_config
;
919 static HRESULT WINAPI
IDirectSound8Impl_SetSpeakerConfig(IDirectSound8
*iface
, DWORD config
)
921 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
923 TRACE("(%p,0x%08x)\n", This
, config
);
926 WARN("not initialized\n");
927 return DSERR_UNINITIALIZED
;
930 /* NOP on Vista and above */
935 static HRESULT WINAPI
IDirectSound8Impl_Initialize(IDirectSound8
*iface
, const GUID
*lpcGuid
)
937 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
938 TRACE("(%p, %s)\n", This
, debugstr_guid(lpcGuid
));
939 return DirectSoundDevice_Initialize(&This
->device
, lpcGuid
);
942 static HRESULT WINAPI
IDirectSound8Impl_VerifyCertification(IDirectSound8
*iface
, DWORD
*certified
)
944 IDirectSoundImpl
*This
= impl_from_IDirectSound8(iface
);
946 TRACE("(%p, %p)\n", This
, certified
);
949 WARN("not initialized\n");
950 return DSERR_UNINITIALIZED
;
953 if (This
->device
->drvcaps
.dwFlags
& DSCAPS_CERTIFIED
)
954 *certified
= DS_CERTIFIED
;
956 *certified
= DS_UNCERTIFIED
;
961 static const IDirectSound8Vtbl ds8_vtbl
=
963 IDirectSound8Impl_QueryInterface
,
964 IDirectSound8Impl_AddRef
,
965 IDirectSound8Impl_Release
,
966 IDirectSound8Impl_CreateSoundBuffer
,
967 IDirectSound8Impl_GetCaps
,
968 IDirectSound8Impl_DuplicateSoundBuffer
,
969 IDirectSound8Impl_SetCooperativeLevel
,
970 IDirectSound8Impl_Compact
,
971 IDirectSound8Impl_GetSpeakerConfig
,
972 IDirectSound8Impl_SetSpeakerConfig
,
973 IDirectSound8Impl_Initialize
,
974 IDirectSound8Impl_VerifyCertification
977 HRESULT
IDirectSoundImpl_Create(IUnknown
*outer_unk
, REFIID riid
, void **ppv
, BOOL has_ds8
)
979 IDirectSoundImpl
*obj
;
982 TRACE("(%s, %p)\n", debugstr_guid(riid
), ppv
);
985 obj
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*obj
));
987 WARN("out of memory\n");
988 return DSERR_OUTOFMEMORY
;
991 setup_dsound_options();
993 obj
->IUnknown_inner
.lpVtbl
= &unk_vtbl
;
994 obj
->IDirectSound8_iface
.lpVtbl
= &ds8_vtbl
;
999 obj
->has_ds8
= has_ds8
;
1001 /* COM aggregation supported only internally */
1003 obj
->outer_unk
= outer_unk
;
1005 obj
->outer_unk
= &obj
->IUnknown_inner
;
1007 hr
= IUnknown_QueryInterface(&obj
->IUnknown_inner
, riid
, ppv
);
1008 IUnknown_Release(&obj
->IUnknown_inner
);
1013 HRESULT
DSOUND_Create(REFIID riid
, void **ppv
)
1015 return IDirectSoundImpl_Create(NULL
, riid
, ppv
, FALSE
);
1018 HRESULT
DSOUND_Create8(REFIID riid
, void **ppv
)
1020 return IDirectSoundImpl_Create(NULL
, riid
, ppv
, TRUE
);
1023 /*******************************************************************************
1024 * DirectSoundCreate (DSOUND.1)
1026 * Creates and initializes a DirectSound interface.
1029 * lpcGUID [I] Address of the GUID that identifies the sound device.
1030 * ppDS [O] Address of a variable to receive the interface pointer.
1031 * pUnkOuter [I] Must be NULL.
1035 * Failure: DSERR_ALLOCATED, DSERR_INVALIDPARAM, DSERR_NOAGGREGATION,
1036 * DSERR_NODRIVER, DSERR_OUTOFMEMORY
1038 HRESULT WINAPI
DirectSoundCreate(
1040 LPDIRECTSOUND
*ppDS
,
1041 IUnknown
*pUnkOuter
)
1046 TRACE("(%s,%p,%p)\n",debugstr_guid(lpcGUID
),ppDS
,pUnkOuter
);
1049 WARN("invalid parameter: ppDS == NULL\n");
1050 return DSERR_INVALIDPARAM
;
1053 if (pUnkOuter
!= NULL
) {
1054 WARN("invalid parameter: pUnkOuter != NULL\n");
1056 return DSERR_INVALIDPARAM
;
1059 hr
= DSOUND_Create(&IID_IDirectSound
, (void **)&pDS
);
1061 hr
= IDirectSound_Initialize(pDS
, lpcGUID
);
1063 if (hr
!= DSERR_ALREADYINITIALIZED
) {
1064 IDirectSound_Release(pDS
);
1076 /*******************************************************************************
1077 * DirectSoundCreate8 (DSOUND.11)
1079 * Creates and initializes a DirectSound8 interface.
1082 * lpcGUID [I] Address of the GUID that identifies the sound device.
1083 * ppDS [O] Address of a variable to receive the interface pointer.
1084 * pUnkOuter [I] Must be NULL.
1088 * Failure: DSERR_ALLOCATED, DSERR_INVALIDPARAM, DSERR_NOAGGREGATION,
1089 * DSERR_NODRIVER, DSERR_OUTOFMEMORY
1091 HRESULT WINAPI
DirectSoundCreate8(
1093 LPDIRECTSOUND8
*ppDS
,
1094 IUnknown
*pUnkOuter
)
1099 TRACE("(%s,%p,%p)\n",debugstr_guid(lpcGUID
),ppDS
,pUnkOuter
);
1102 WARN("invalid parameter: ppDS == NULL\n");
1103 return DSERR_INVALIDPARAM
;
1106 if (pUnkOuter
!= NULL
) {
1107 WARN("invalid parameter: pUnkOuter != NULL\n");
1109 return DSERR_INVALIDPARAM
;
1112 hr
= DSOUND_Create8(&IID_IDirectSound8
, (void **)&pDS
);
1114 hr
= IDirectSound8_Initialize(pDS
, lpcGUID
);
1116 if (hr
!= DSERR_ALREADYINITIALIZED
) {
1117 IDirectSound8_Release(pDS
);
1129 void DSOUND_ParseSpeakerConfig(DirectSoundDevice
*device
)
1131 switch (DSSPEAKER_CONFIG(device
->speaker_config
)) {
1132 case DSSPEAKER_MONO
:
1133 device
->speaker_angles
[0] = M_PI
/180.0f
* 0.0f
;
1134 device
->speaker_num
[0] = 0;
1135 device
->num_speakers
= 1;
1136 device
->lfe_channel
= -1;
1139 case DSSPEAKER_STEREO
:
1140 case DSSPEAKER_HEADPHONE
:
1141 device
->speaker_angles
[0] = M_PI
/180.0f
* -90.0f
;
1142 device
->speaker_angles
[1] = M_PI
/180.0f
* 90.0f
;
1143 device
->speaker_num
[0] = 0; /* Left */
1144 device
->speaker_num
[1] = 1; /* Right */
1145 device
->num_speakers
= 2;
1146 device
->lfe_channel
= -1;
1149 case DSSPEAKER_QUAD
:
1150 device
->speaker_angles
[0] = M_PI
/180.0f
* -135.0f
;
1151 device
->speaker_angles
[1] = M_PI
/180.0f
* -45.0f
;
1152 device
->speaker_angles
[2] = M_PI
/180.0f
* 45.0f
;
1153 device
->speaker_angles
[3] = M_PI
/180.0f
* 135.0f
;
1154 device
->speaker_num
[0] = 2; /* Rear left */
1155 device
->speaker_num
[1] = 0; /* Front left */
1156 device
->speaker_num
[2] = 1; /* Front right */
1157 device
->speaker_num
[3] = 3; /* Rear right */
1158 device
->num_speakers
= 4;
1159 device
->lfe_channel
= -1;
1162 case DSSPEAKER_5POINT1_BACK
:
1163 device
->speaker_angles
[0] = M_PI
/180.0f
* -135.0f
;
1164 device
->speaker_angles
[1] = M_PI
/180.0f
* -45.0f
;
1165 device
->speaker_angles
[2] = M_PI
/180.0f
* 0.0f
;
1166 device
->speaker_angles
[3] = M_PI
/180.0f
* 45.0f
;
1167 device
->speaker_angles
[4] = M_PI
/180.0f
* 135.0f
;
1168 device
->speaker_angles
[5] = 9999.0f
;
1169 device
->speaker_num
[0] = 4; /* Rear left */
1170 device
->speaker_num
[1] = 0; /* Front left */
1171 device
->speaker_num
[2] = 2; /* Front centre */
1172 device
->speaker_num
[3] = 1; /* Front right */
1173 device
->speaker_num
[4] = 5; /* Rear right */
1174 device
->speaker_num
[5] = 3; /* LFE */
1175 device
->num_speakers
= 6;
1176 device
->lfe_channel
= 3;
1179 case DSSPEAKER_5POINT1_SURROUND
:
1180 device
->speaker_angles
[0] = M_PI
/180.0f
* -90.0f
;
1181 device
->speaker_angles
[1] = M_PI
/180.0f
* -30.0f
;
1182 device
->speaker_angles
[2] = M_PI
/180.0f
* 0.0f
;
1183 device
->speaker_angles
[3] = M_PI
/180.0f
* 30.0f
;
1184 device
->speaker_angles
[4] = M_PI
/180.0f
* 90.0f
;
1185 device
->speaker_angles
[5] = 9999.0f
;
1186 device
->speaker_num
[0] = 4; /* Rear left */
1187 device
->speaker_num
[1] = 0; /* Front left */
1188 device
->speaker_num
[2] = 2; /* Front centre */
1189 device
->speaker_num
[3] = 1; /* Front right */
1190 device
->speaker_num
[4] = 5; /* Rear right */
1191 device
->speaker_num
[5] = 3; /* LFE */
1192 device
->num_speakers
= 6;
1193 device
->lfe_channel
= 3;
1197 WARN("unknown speaker_config %u\n", device
->speaker_config
);