2 * Copyright (c) 2015 Andrew Eikum for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/list.h"
26 #include "xaudio2fx.h"
29 #include "mmdeviceapi.h"
30 #include "audioclient.h"
36 typedef struct _XA2Buffer
{
37 XAUDIO2_BUFFER xa2buffer
;
39 UINT32 latest_al_buf
, looped
, loop_end_bytes
, play_end_bytes
, cur_end_bytes
;
42 typedef struct _IXAudio2Impl IXAudio2Impl
;
44 typedef struct _XA2SourceImpl
{
45 IXAudio2SourceVoice IXAudio2SourceVoice_iface
;
48 IXAudio20SourceVoice IXAudio20SourceVoice_iface
;
49 #elif XAUDIO2_VER <= 3
50 IXAudio23SourceVoice IXAudio23SourceVoice_iface
;
51 #elif XAUDIO2_VER <= 7
52 IXAudio27SourceVoice IXAudio27SourceVoice_iface
;
59 CRITICAL_SECTION lock
;
63 UINT32 submit_blocksize
;
65 IXAudio2VoiceCallback
*cb
;
68 XAUDIO2_SEND_DESCRIPTOR
*sends
;
74 XA2Buffer buffers
[XAUDIO2_MAX_QUEUED_BUFFERS
];
75 UINT32 first_buf
, cur_buf
, nbufs
, in_al_bytes
;
77 UINT32 scratch_bytes
, convert_bytes
;
78 BYTE
*scratch_buf
, *convert_buf
;
81 /* most cases will only need about 4 AL buffers, but some corner cases
82 * could require up to MAX_QUEUED_BUFFERS */
83 ALuint al_bufs
[XAUDIO2_MAX_QUEUED_BUFFERS
];
84 DWORD first_al_buf
, al_bufs_used
, abandoned_albufs
;
89 typedef struct _XA2SubmixImpl
{
90 IXAudio2SubmixVoice IXAudio2SubmixVoice_iface
;
93 IXAudio20SubmixVoice IXAudio20SubmixVoice_iface
;
94 #elif XAUDIO2_VER <= 3
95 IXAudio23SubmixVoice IXAudio23SubmixVoice_iface
;
96 #elif XAUDIO2_VER <= 7
97 IXAudio27SubmixVoice IXAudio27SubmixVoice_iface
;
102 XAUDIO2_VOICE_DETAILS details
;
104 CRITICAL_SECTION lock
;
109 struct _IXAudio2Impl
{
110 IXAudio2 IXAudio2_iface
;
111 IXAudio2MasteringVoice IXAudio2MasteringVoice_iface
;
114 IXAudio20 IXAudio20_iface
;
115 #elif XAUDIO2_VER <= 2
116 IXAudio22 IXAudio22_iface
;
117 #elif XAUDIO2_VER <= 7
118 IXAudio27 IXAudio27_iface
;
122 IXAudio20MasteringVoice IXAudio20MasteringVoice_iface
;
123 #elif XAUDIO2_VER <= 3
124 IXAudio23MasteringVoice IXAudio23MasteringVoice_iface
;
125 #elif XAUDIO2_VER <= 7
126 IXAudio27MasteringVoice IXAudio27MasteringVoice_iface
;
131 CRITICAL_SECTION lock
;
133 HANDLE engine
, mmevt
;
136 struct list source_voices
;
137 struct list submix_voices
;
139 IMMDeviceEnumerator
*devenum
;
144 UINT32 last_query_glitches
;
146 IAudioClient
*aclient
;
147 IAudioRenderClient
*render
;
149 UINT32 period_frames
;
151 WAVEFORMATEXTENSIBLE fmt
;
153 ALCdevice
*al_device
;
157 IXAudio2EngineCallback
**cbs
;
163 extern const IXAudio20SourceVoiceVtbl XAudio20SourceVoice_Vtbl DECLSPEC_HIDDEN
;
164 extern const IXAudio20SubmixVoiceVtbl XAudio20SubmixVoice_Vtbl DECLSPEC_HIDDEN
;
165 extern const IXAudio20MasteringVoiceVtbl XAudio20MasteringVoice_Vtbl DECLSPEC_HIDDEN
;
166 #elif XAUDIO2_VER <= 3
167 extern const IXAudio23SourceVoiceVtbl XAudio23SourceVoice_Vtbl DECLSPEC_HIDDEN
;
168 extern const IXAudio23SubmixVoiceVtbl XAudio23SubmixVoice_Vtbl DECLSPEC_HIDDEN
;
169 extern const IXAudio23MasteringVoiceVtbl XAudio23MasteringVoice_Vtbl DECLSPEC_HIDDEN
;
170 #elif XAUDIO2_VER <= 7
171 extern const IXAudio27SourceVoiceVtbl XAudio27SourceVoice_Vtbl DECLSPEC_HIDDEN
;
172 extern const IXAudio27SubmixVoiceVtbl XAudio27SubmixVoice_Vtbl DECLSPEC_HIDDEN
;
173 extern const IXAudio27MasteringVoiceVtbl XAudio27MasteringVoice_Vtbl DECLSPEC_HIDDEN
;
177 extern const IXAudio20Vtbl XAudio20_Vtbl DECLSPEC_HIDDEN
;
178 #elif XAUDIO2_VER <= 2
179 extern const IXAudio22Vtbl XAudio22_Vtbl DECLSPEC_HIDDEN
;
180 #elif XAUDIO2_VER <= 7
181 extern const IXAudio27Vtbl XAudio27_Vtbl DECLSPEC_HIDDEN
;
184 extern HRESULT
make_xapo_factory(REFCLSID clsid
, REFIID riid
, void **ppv
) DECLSPEC_HIDDEN
;
185 extern HRESULT
xaudio2_initialize(IXAudio2Impl
*This
, UINT32 flags
, XAUDIO2_PROCESSOR proc
) DECLSPEC_HIDDEN
;