Wine-Devel
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 8 participants
- 84547 discussions
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/winecoreaudio.drv/mmdevdrv.c | 637 +++++++++++++++---------------
dlls/winecoreaudio.drv/unixlib.h | 23 ++
2 files changed, 339 insertions(+), 321 deletions(-)
diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c
index f8b538971f2..11be188d110 100644
--- a/dlls/winecoreaudio.drv/mmdevdrv.c
+++ b/dlls/winecoreaudio.drv/mmdevdrv.c
@@ -125,35 +125,21 @@ struct ACImpl {
IMMDevice *parent;
IUnknown *pUnkFTMarshal;
- WAVEFORMATEX *fmt;
-
EDataFlow dataflow;
DWORD flags;
- AUDCLNT_SHAREMODE share;
HANDLE event;
float *vols;
BOOL initted;
AudioDeviceID adevid;
AudioObjectPropertyScope scope;
- AudioConverterRef converter;
- AudioComponentInstance unit;
- AudioStreamBasicDescription dev_desc; /* audio unit format, not necessarily the same as fmt */
HANDLE timer;
- UINT32 period_ms, bufsize_frames, period_frames;
- UINT64 written_frames;
- UINT32 lcl_offs_frames, wri_offs_frames, held_frames, tmp_buffer_frames;
- UINT32 cap_bufsize_frames, cap_offs_frames, cap_held_frames, wrap_bufsize_frames, resamp_bufsize_frames;
- INT32 getbuf_last;
- BOOL playing;
- BYTE *cap_buffer, *wrap_buffer, *resamp_buffer, *local_buffer, *tmp_buffer;
AudioSession *session;
AudioSessionWrapper *session_wrapper;
+ struct coreaudio_stream *stream;
struct list entry;
-
- OSSpinLock lock;
};
static const IAudioClient3Vtbl AudioClient3_Vtbl;
@@ -556,6 +542,11 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ACImpl));
if(!This)
return E_OUTOFMEMORY;
+ This->stream = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This->stream));
+ if(!This->stream){
+ HeapFree(GetProcessHeap(), 0, This);
+ return E_OUTOFMEMORY;
+ }
This->IAudioClient3_iface.lpVtbl = &AudioClient3_Vtbl;
This->IAudioRenderClient_iface.lpVtbl = &AudioRenderClient_Vtbl;
@@ -571,14 +562,16 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient
else if(dataflow == eCapture)
This->scope = kAudioDevicePropertyScopeInput;
else{
+ HeapFree(GetProcessHeap(), 0, This->stream);
HeapFree(GetProcessHeap(), 0, This);
return E_INVALIDARG;
}
- This->lock = 0;
+ This->stream->lock = 0;
hr = CoCreateFreeThreadedMarshaler((IUnknown *)&This->IAudioClient3_iface, &This->pUnkFTMarshal);
if (FAILED(hr)) {
+ HeapFree(GetProcessHeap(), 0, This->stream);
HeapFree(GetProcessHeap(), 0, This);
return hr;
}
@@ -588,7 +581,8 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient
This->adevid = adevid;
- if(!(This->unit = get_audiounit(This->dataflow, This->adevid))){
+ if(!(This->stream->unit = get_audiounit(This->dataflow, This->adevid))){
+ HeapFree(GetProcessHeap(), 0, This->stream);
HeapFree(GetProcessHeap(), 0, This);
return AUDCLNT_E_DEVICE_INVALIDATED;
}
@@ -650,24 +644,25 @@ static ULONG WINAPI AudioClient_Release(IAudioClient3 *iface)
WaitForSingleObject(event, INFINITE);
CloseHandle(event);
}
- AudioOutputUnitStop(This->unit);
- AudioComponentInstanceDispose(This->unit);
- if(This->converter)
- AudioConverterDispose(This->converter);
+ AudioOutputUnitStop(This->stream->unit);
+ AudioComponentInstanceDispose(This->stream->unit);
+ if(This->stream->converter)
+ AudioConverterDispose(This->stream->converter);
if(This->session){
EnterCriticalSection(&g_sessions_lock);
list_remove(&This->entry);
LeaveCriticalSection(&g_sessions_lock);
}
HeapFree(GetProcessHeap(), 0, This->vols);
- HeapFree(GetProcessHeap(), 0, This->tmp_buffer);
- HeapFree(GetProcessHeap(), 0, This->cap_buffer);
- HeapFree(GetProcessHeap(), 0, This->local_buffer);
- free(This->wrap_buffer);
- HeapFree(GetProcessHeap(), 0, This->resamp_buffer);
- CoTaskMemFree(This->fmt);
+ HeapFree(GetProcessHeap(), 0, This->stream->tmp_buffer);
+ HeapFree(GetProcessHeap(), 0, This->stream->cap_buffer);
+ HeapFree(GetProcessHeap(), 0, This->stream->local_buffer);
+ free(This->stream->wrap_buffer);
+ HeapFree(GetProcessHeap(), 0, This->stream->resamp_buffer);
+ CoTaskMemFree(This->stream->fmt);
IMMDevice_Release(This->parent);
IUnknown_Release(This->pUnkFTMarshal);
+ HeapFree(GetProcessHeap(), 0, This->stream);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
@@ -890,14 +885,14 @@ static void ca_wrap_buffer(BYTE *dst, UINT32 dst_offs, UINT32 dst_bytes,
static void silence_buffer(ACImpl *This, BYTE *buffer, UINT32 frames)
{
- WAVEFORMATEXTENSIBLE *fmtex = (WAVEFORMATEXTENSIBLE*)This->fmt;
- if((This->fmt->wFormatTag == WAVE_FORMAT_PCM ||
- (This->fmt->wFormatTag == WAVE_FORMAT_EXTENSIBLE &&
+ WAVEFORMATEXTENSIBLE *fmtex = (WAVEFORMATEXTENSIBLE*)This->stream->fmt;
+ if((This->stream->fmt->wFormatTag == WAVE_FORMAT_PCM ||
+ (This->stream->fmt->wFormatTag == WAVE_FORMAT_EXTENSIBLE &&
IsEqualGUID(&fmtex->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM))) &&
- This->fmt->wBitsPerSample == 8)
- memset(buffer, 128, frames * This->fmt->nBlockAlign);
+ This->stream->fmt->wBitsPerSample == 8)
+ memset(buffer, 128, frames * This->stream->fmt->nBlockAlign);
else
- memset(buffer, 0, frames * This->fmt->nBlockAlign);
+ memset(buffer, 0, frames * This->stream->fmt->nBlockAlign);
}
/* CA is pulling data from us */
@@ -908,31 +903,31 @@ static OSStatus ca_render_cb(void *user, AudioUnitRenderActionFlags *flags,
ACImpl *This = user;
UINT32 to_copy_bytes, to_copy_frames, chunk_bytes, lcl_offs_bytes;
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
- if(This->playing){
- lcl_offs_bytes = This->lcl_offs_frames * This->fmt->nBlockAlign;
- to_copy_frames = min(nframes, This->held_frames);
- to_copy_bytes = to_copy_frames * This->fmt->nBlockAlign;
+ if(This->stream->playing){
+ lcl_offs_bytes = This->stream->lcl_offs_frames * This->stream->fmt->nBlockAlign;
+ to_copy_frames = min(nframes, This->stream->held_frames);
+ to_copy_bytes = to_copy_frames * This->stream->fmt->nBlockAlign;
- chunk_bytes = (This->bufsize_frames - This->lcl_offs_frames) * This->fmt->nBlockAlign;
+ chunk_bytes = (This->stream->bufsize_frames - This->stream->lcl_offs_frames) * This->stream->fmt->nBlockAlign;
if(to_copy_bytes > chunk_bytes){
- memcpy(data->mBuffers[0].mData, This->local_buffer + lcl_offs_bytes, chunk_bytes);
- memcpy(((BYTE *)data->mBuffers[0].mData) + chunk_bytes, This->local_buffer, to_copy_bytes - chunk_bytes);
+ memcpy(data->mBuffers[0].mData, This->stream->local_buffer + lcl_offs_bytes, chunk_bytes);
+ memcpy(((BYTE *)data->mBuffers[0].mData) + chunk_bytes, This->stream->local_buffer, to_copy_bytes - chunk_bytes);
}else
- memcpy(data->mBuffers[0].mData, This->local_buffer + lcl_offs_bytes, to_copy_bytes);
+ memcpy(data->mBuffers[0].mData, This->stream->local_buffer + lcl_offs_bytes, to_copy_bytes);
- This->lcl_offs_frames += to_copy_frames;
- This->lcl_offs_frames %= This->bufsize_frames;
- This->held_frames -= to_copy_frames;
+ This->stream->lcl_offs_frames += to_copy_frames;
+ This->stream->lcl_offs_frames %= This->stream->bufsize_frames;
+ This->stream->held_frames -= to_copy_frames;
}else
to_copy_bytes = to_copy_frames = 0;
if(nframes > to_copy_frames)
silence_buffer(This, ((BYTE *)data->mBuffers[0].mData) + to_copy_bytes, nframes - to_copy_frames);
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return noErr;
}
@@ -950,38 +945,38 @@ static OSStatus feed_cb(AudioConverterRef converter, UInt32 *nframes, AudioBuffe
{
ACImpl *This = user;
- *nframes = min(*nframes, This->cap_held_frames);
+ *nframes = min(*nframes, This->stream->cap_held_frames);
if(!*nframes){
data->mBuffers[0].mData = NULL;
data->mBuffers[0].mDataByteSize = 0;
- data->mBuffers[0].mNumberChannels = This->fmt->nChannels;
+ data->mBuffers[0].mNumberChannels = This->stream->fmt->nChannels;
return noErr;
}
- data->mBuffers[0].mDataByteSize = *nframes * This->fmt->nBlockAlign;
- data->mBuffers[0].mNumberChannels = This->fmt->nChannels;
+ data->mBuffers[0].mDataByteSize = *nframes * This->stream->fmt->nBlockAlign;
+ data->mBuffers[0].mNumberChannels = This->stream->fmt->nChannels;
- if(This->cap_offs_frames + *nframes > This->cap_bufsize_frames){
- UINT32 chunk_frames = This->cap_bufsize_frames - This->cap_offs_frames;
+ if(This->stream->cap_offs_frames + *nframes > This->stream->cap_bufsize_frames){
+ UINT32 chunk_frames = This->stream->cap_bufsize_frames - This->stream->cap_offs_frames;
- if(This->wrap_bufsize_frames < *nframes){
- free(This->wrap_buffer);
- This->wrap_buffer = malloc(data->mBuffers[0].mDataByteSize);
- This->wrap_bufsize_frames = *nframes;
+ if(This->stream->wrap_bufsize_frames < *nframes){
+ free(This->stream->wrap_buffer);
+ This->stream->wrap_buffer = malloc(data->mBuffers[0].mDataByteSize);
+ This->stream->wrap_bufsize_frames = *nframes;
}
- memcpy(This->wrap_buffer, This->cap_buffer + This->cap_offs_frames * This->fmt->nBlockAlign,
- chunk_frames * This->fmt->nBlockAlign);
- memcpy(This->wrap_buffer + chunk_frames * This->fmt->nBlockAlign, This->cap_buffer,
- (*nframes - chunk_frames) * This->fmt->nBlockAlign);
+ memcpy(This->stream->wrap_buffer, This->stream->cap_buffer + This->stream->cap_offs_frames * This->stream->fmt->nBlockAlign,
+ chunk_frames * This->stream->fmt->nBlockAlign);
+ memcpy(This->stream->wrap_buffer + chunk_frames * This->stream->fmt->nBlockAlign, This->stream->cap_buffer,
+ (*nframes - chunk_frames) * This->stream->fmt->nBlockAlign);
- data->mBuffers[0].mData = This->wrap_buffer;
+ data->mBuffers[0].mData = This->stream->wrap_buffer;
}else
- data->mBuffers[0].mData = This->cap_buffer + This->cap_offs_frames * This->fmt->nBlockAlign;
+ data->mBuffers[0].mData = This->stream->cap_buffer + This->stream->cap_offs_frames * This->stream->fmt->nBlockAlign;
- This->cap_offs_frames += *nframes;
- This->cap_offs_frames %= This->cap_bufsize_frames;
- This->cap_held_frames -= *nframes;
+ This->stream->cap_offs_frames += *nframes;
+ This->stream->cap_offs_frames %= This->stream->cap_bufsize_frames;
+ This->stream->cap_held_frames -= *nframes;
if(packets)
*packets = NULL;
@@ -991,48 +986,48 @@ static OSStatus feed_cb(AudioConverterRef converter, UInt32 *nframes, AudioBuffe
static void capture_resample(ACImpl *This)
{
- UINT32 resamp_period_frames = MulDiv(This->period_frames, This->dev_desc.mSampleRate, This->fmt->nSamplesPerSec);
+ UINT32 resamp_period_frames = MulDiv(This->stream->period_frames, This->stream->dev_desc.mSampleRate, This->stream->fmt->nSamplesPerSec);
OSStatus sc;
/* the resampling process often needs more source frames than we'd
* guess from a straight conversion using the sample rate ratio. so
* only convert if we have extra source data. */
- while(This->cap_held_frames > resamp_period_frames * 2){
+ while(This->stream->cap_held_frames > resamp_period_frames * 2){
AudioBufferList converted_list;
- UInt32 wanted_frames = This->period_frames;
+ UInt32 wanted_frames = This->stream->period_frames;
converted_list.mNumberBuffers = 1;
- converted_list.mBuffers[0].mNumberChannels = This->fmt->nChannels;
- converted_list.mBuffers[0].mDataByteSize = wanted_frames * This->fmt->nBlockAlign;
+ converted_list.mBuffers[0].mNumberChannels = This->stream->fmt->nChannels;
+ converted_list.mBuffers[0].mDataByteSize = wanted_frames * This->stream->fmt->nBlockAlign;
- if(This->resamp_bufsize_frames < wanted_frames){
- HeapFree(GetProcessHeap(), 0, This->resamp_buffer);
- This->resamp_buffer = HeapAlloc(GetProcessHeap(), 0, converted_list.mBuffers[0].mDataByteSize);
- This->resamp_bufsize_frames = wanted_frames;
+ if(This->stream->resamp_bufsize_frames < wanted_frames){
+ HeapFree(GetProcessHeap(), 0, This->stream->resamp_buffer);
+ This->stream->resamp_buffer = HeapAlloc(GetProcessHeap(), 0, converted_list.mBuffers[0].mDataByteSize);
+ This->stream->resamp_bufsize_frames = wanted_frames;
}
- converted_list.mBuffers[0].mData = This->resamp_buffer;
+ converted_list.mBuffers[0].mData = This->stream->resamp_buffer;
- sc = AudioConverterFillComplexBuffer(This->converter, feed_cb,
+ sc = AudioConverterFillComplexBuffer(This->stream->converter, feed_cb,
This, &wanted_frames, &converted_list, NULL);
if(sc != noErr){
WARN("AudioConverterFillComplexBuffer failed: %x\n", (int)sc);
break;
}
- ca_wrap_buffer(This->local_buffer,
- This->wri_offs_frames * This->fmt->nBlockAlign,
- This->bufsize_frames * This->fmt->nBlockAlign,
- This->resamp_buffer, wanted_frames * This->fmt->nBlockAlign);
-
- This->wri_offs_frames += wanted_frames;
- This->wri_offs_frames %= This->bufsize_frames;
- if(This->held_frames + wanted_frames > This->bufsize_frames){
- This->lcl_offs_frames += buf_ptr_diff(This->lcl_offs_frames,
- This->wri_offs_frames, This->bufsize_frames);
- This->held_frames = This->bufsize_frames;
+ ca_wrap_buffer(This->stream->local_buffer,
+ This->stream->wri_offs_frames * This->stream->fmt->nBlockAlign,
+ This->stream->bufsize_frames * This->stream->fmt->nBlockAlign,
+ This->stream->resamp_buffer, wanted_frames * This->stream->fmt->nBlockAlign);
+
+ This->stream->wri_offs_frames += wanted_frames;
+ This->stream->wri_offs_frames %= This->stream->bufsize_frames;
+ if(This->stream->held_frames + wanted_frames > This->stream->bufsize_frames){
+ This->stream->lcl_offs_frames += buf_ptr_diff(This->stream->lcl_offs_frames,
+ This->stream->wri_offs_frames, This->stream->bufsize_frames);
+ This->stream->held_frames = This->stream->bufsize_frames;
}else
- This->held_frames += wanted_frames;
+ This->stream->held_frames += wanted_frames;
}
}
@@ -1052,48 +1047,48 @@ static OSStatus ca_capture_cb(void *user, AudioUnitRenderActionFlags *flags,
OSStatus sc;
UINT32 cap_wri_offs_frames;
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
- cap_wri_offs_frames = (This->cap_offs_frames + This->cap_held_frames) % This->cap_bufsize_frames;
+ cap_wri_offs_frames = (This->stream->cap_offs_frames + This->stream->cap_held_frames) % This->stream->cap_bufsize_frames;
list.mNumberBuffers = 1;
- list.mBuffers[0].mNumberChannels = This->fmt->nChannels;
- list.mBuffers[0].mDataByteSize = nframes * This->fmt->nBlockAlign;
-
- if(!This->playing || cap_wri_offs_frames + nframes > This->cap_bufsize_frames){
- if(This->wrap_bufsize_frames < nframes){
- free(This->wrap_buffer);
- This->wrap_buffer = malloc(list.mBuffers[0].mDataByteSize);
- This->wrap_bufsize_frames = nframes;
+ list.mBuffers[0].mNumberChannels = This->stream->fmt->nChannels;
+ list.mBuffers[0].mDataByteSize = nframes * This->stream->fmt->nBlockAlign;
+
+ if(!This->stream->playing || cap_wri_offs_frames + nframes > This->stream->cap_bufsize_frames){
+ if(This->stream->wrap_bufsize_frames < nframes){
+ free(This->stream->wrap_buffer);
+ This->stream->wrap_buffer = malloc(list.mBuffers[0].mDataByteSize);
+ This->stream->wrap_bufsize_frames = nframes;
}
- list.mBuffers[0].mData = This->wrap_buffer;
+ list.mBuffers[0].mData = This->stream->wrap_buffer;
}else
- list.mBuffers[0].mData = This->cap_buffer + cap_wri_offs_frames * This->fmt->nBlockAlign;
+ list.mBuffers[0].mData = This->stream->cap_buffer + cap_wri_offs_frames * This->stream->fmt->nBlockAlign;
- sc = AudioUnitRender(This->unit, flags, ts, bus, nframes, &list);
+ sc = AudioUnitRender(This->stream->unit, flags, ts, bus, nframes, &list);
if(sc != noErr){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return sc;
}
- if(This->playing){
- if(list.mBuffers[0].mData == This->wrap_buffer){
- ca_wrap_buffer(This->cap_buffer,
- cap_wri_offs_frames * This->fmt->nBlockAlign,
- This->cap_bufsize_frames * This->fmt->nBlockAlign,
- This->wrap_buffer, list.mBuffers[0].mDataByteSize);
+ if(This->stream->playing){
+ if(list.mBuffers[0].mData == This->stream->wrap_buffer){
+ ca_wrap_buffer(This->stream->cap_buffer,
+ cap_wri_offs_frames * This->stream->fmt->nBlockAlign,
+ This->stream->cap_bufsize_frames * This->stream->fmt->nBlockAlign,
+ This->stream->wrap_buffer, list.mBuffers[0].mDataByteSize);
}
- This->cap_held_frames += list.mBuffers[0].mDataByteSize / This->fmt->nBlockAlign;
- if(This->cap_held_frames > This->cap_bufsize_frames){
- This->cap_offs_frames += This->cap_held_frames % This->cap_bufsize_frames;
- This->cap_offs_frames %= This->cap_bufsize_frames;
- This->cap_held_frames = This->cap_bufsize_frames;
+ This->stream->cap_held_frames += list.mBuffers[0].mDataByteSize / This->stream->fmt->nBlockAlign;
+ if(This->stream->cap_held_frames > This->stream->cap_bufsize_frames){
+ This->stream->cap_offs_frames += This->stream->cap_held_frames % This->stream->cap_bufsize_frames;
+ This->stream->cap_offs_frames %= This->stream->cap_bufsize_frames;
+ This->stream->cap_held_frames = This->stream->cap_bufsize_frames;
}
}
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return noErr;
}
@@ -1244,31 +1239,31 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
}
}
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
if(This->initted){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_ALREADY_INITIALIZED;
}
- This->fmt = clone_format(fmt);
- if(!This->fmt){
- OSSpinLockUnlock(&This->lock);
+ This->stream->fmt = clone_format(fmt);
+ if(!This->stream->fmt){
+ OSSpinLockUnlock(&This->stream->lock);
return E_OUTOFMEMORY;
}
- This->period_ms = period / 10000;
- This->period_frames = MulDiv(period, This->fmt->nSamplesPerSec, 10000000);
+ This->stream->period_ms = period / 10000;
+ This->stream->period_frames = MulDiv(period, This->stream->fmt->nSamplesPerSec, 10000000);
- This->bufsize_frames = MulDiv(duration, fmt->nSamplesPerSec, 10000000);
+ This->stream->bufsize_frames = MulDiv(duration, fmt->nSamplesPerSec, 10000000);
if(mode == AUDCLNT_SHAREMODE_EXCLUSIVE)
- This->bufsize_frames -= This->bufsize_frames % This->period_frames;
+ This->stream->bufsize_frames -= This->stream->bufsize_frames % This->stream->period_frames;
- hr = ca_setup_audiounit(This->dataflow, This->unit, This->fmt, &This->dev_desc, &This->converter);
+ hr = ca_setup_audiounit(This->dataflow, This->stream->unit, This->stream->fmt, &This->stream->dev_desc, &This->stream->converter);
if(FAILED(hr)){
- CoTaskMemFree(This->fmt);
- This->fmt = NULL;
- OSSpinLockUnlock(&This->lock);
+ CoTaskMemFree(This->stream->fmt);
+ This->stream->fmt = NULL;
+ OSSpinLockUnlock(&This->stream->lock);
return hr;
}
@@ -1279,15 +1274,15 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
input.inputProc = &ca_capture_cb;
input.inputProcRefCon = This;
- sc = AudioUnitSetProperty(This->unit, kAudioOutputUnitProperty_SetInputCallback,
+ sc = AudioUnitSetProperty(This->stream->unit, kAudioOutputUnitProperty_SetInputCallback,
kAudioUnitScope_Output, 1, &input, sizeof(input));
if(sc != noErr){
WARN("Couldn't set callback: %x\n", (int)sc);
- AudioConverterDispose(This->converter);
- This->converter = NULL;
- CoTaskMemFree(This->fmt);
- This->fmt = NULL;
- OSSpinLockUnlock(&This->lock);
+ AudioConverterDispose(This->stream->converter);
+ This->stream->converter = NULL;
+ CoTaskMemFree(This->stream->fmt);
+ This->stream->fmt = NULL;
+ OSSpinLockUnlock(&This->stream->lock);
return osstatus_to_hresult(sc);
}
}else{
@@ -1297,65 +1292,65 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
input.inputProc = &ca_render_cb;
input.inputProcRefCon = This;
- sc = AudioUnitSetProperty(This->unit, kAudioUnitProperty_SetRenderCallback,
+ sc = AudioUnitSetProperty(This->stream->unit, kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input, 0, &input, sizeof(input));
if(sc != noErr){
WARN("Couldn't set callback: %x\n", (int)sc);
- CoTaskMemFree(This->fmt);
- This->fmt = NULL;
- OSSpinLockUnlock(&This->lock);
+ CoTaskMemFree(This->stream->fmt);
+ This->stream->fmt = NULL;
+ OSSpinLockUnlock(&This->stream->lock);
return osstatus_to_hresult(sc);
}
}
- sc = AudioUnitInitialize(This->unit);
+ sc = AudioUnitInitialize(This->stream->unit);
if(sc != noErr){
WARN("Couldn't initialize: %x\n", (int)sc);
- if(This->converter){
- AudioConverterDispose(This->converter);
- This->converter = NULL;
+ if(This->stream->converter){
+ AudioConverterDispose(This->stream->converter);
+ This->stream->converter = NULL;
}
- CoTaskMemFree(This->fmt);
- This->fmt = NULL;
- OSSpinLockUnlock(&This->lock);
+ CoTaskMemFree(This->stream->fmt);
+ This->stream->fmt = NULL;
+ OSSpinLockUnlock(&This->stream->lock);
return osstatus_to_hresult(sc);
}
/* we play audio continuously because AudioOutputUnitStart sometimes takes
* a while to return */
- sc = AudioOutputUnitStart(This->unit);
+ sc = AudioOutputUnitStart(This->stream->unit);
if(sc != noErr){
WARN("Unit failed to start: %x\n", (int)sc);
- if(This->converter){
- AudioConverterDispose(This->converter);
- This->converter = NULL;
+ if(This->stream->converter){
+ AudioConverterDispose(This->stream->converter);
+ This->stream->converter = NULL;
}
- CoTaskMemFree(This->fmt);
- This->fmt = NULL;
- OSSpinLockUnlock(&This->lock);
+ CoTaskMemFree(This->stream->fmt);
+ This->stream->fmt = NULL;
+ OSSpinLockUnlock(&This->stream->lock);
return osstatus_to_hresult(sc);
}
- This->local_buffer = HeapAlloc(GetProcessHeap(), 0, This->bufsize_frames * fmt->nBlockAlign);
- silence_buffer(This, This->local_buffer, This->bufsize_frames);
+ This->stream->local_buffer = HeapAlloc(GetProcessHeap(), 0, This->stream->bufsize_frames * fmt->nBlockAlign);
+ silence_buffer(This, This->stream->local_buffer, This->stream->bufsize_frames);
if(This->dataflow == eCapture){
- This->cap_bufsize_frames = MulDiv(duration, This->dev_desc.mSampleRate, 10000000);
- This->cap_buffer = HeapAlloc(GetProcessHeap(), 0, This->cap_bufsize_frames * This->fmt->nBlockAlign);
+ This->stream->cap_bufsize_frames = MulDiv(duration, This->stream->dev_desc.mSampleRate, 10000000);
+ This->stream->cap_buffer = HeapAlloc(GetProcessHeap(), 0, This->stream->cap_bufsize_frames * This->stream->fmt->nBlockAlign);
}
This->vols = HeapAlloc(GetProcessHeap(), 0, fmt->nChannels * sizeof(float));
if(!This->vols){
- CoTaskMemFree(This->fmt);
- This->fmt = NULL;
- OSSpinLockUnlock(&This->lock);
+ CoTaskMemFree(This->stream->fmt);
+ This->stream->fmt = NULL;
+ OSSpinLockUnlock(&This->stream->lock);
return E_OUTOFMEMORY;
}
for(i = 0; i < fmt->nChannels; ++i)
This->vols[i] = 1.f;
- This->share = mode;
+ This->stream->share = mode;
This->flags = flags;
EnterCriticalSection(&g_sessions_lock);
@@ -1364,11 +1359,11 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
&This->session);
if(FAILED(hr)){
LeaveCriticalSection(&g_sessions_lock);
- CoTaskMemFree(This->fmt);
- This->fmt = NULL;
+ CoTaskMemFree(This->stream->fmt);
+ This->stream->fmt = NULL;
HeapFree(GetProcessHeap(), 0, This->vols);
This->vols = NULL;
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return E_INVALIDARG;
}
@@ -1380,7 +1375,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
This->initted = TRUE;
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
@@ -1395,16 +1390,16 @@ static HRESULT WINAPI AudioClient_GetBufferSize(IAudioClient3 *iface,
if(!frames)
return E_POINTER;
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
if(!This->initted){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_NOT_INITIALIZED;
}
- *frames = This->bufsize_frames;
+ *frames = This->stream->bufsize_frames;
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
@@ -1477,10 +1472,10 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient3 *iface,
if(!out)
return E_POINTER;
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
if(!This->initted){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_NOT_INITIALIZED;
}
@@ -1493,23 +1488,23 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient3 *iface,
&size, &latency);
if(sc != noErr){
WARN("Couldn't get _Latency property: %x\n", (int)sc);
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return osstatus_to_hresult(sc);
}
hr = ca_get_max_stream_latency(This, &stream_latency);
if(FAILED(hr)){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return hr;
}
latency += stream_latency;
/* pretend we process audio in Period chunks, so max latency includes
* the period time */
- *out = MulDiv(latency, 10000000, This->fmt->nSamplesPerSec)
- + This->period_ms * 10000;
+ *out = MulDiv(latency, 10000000, This->stream->fmt->nSamplesPerSec)
+ + This->stream->period_ms * 10000;
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
@@ -1523,7 +1518,7 @@ static HRESULT AudioClient_GetCurrentPadding_nolock(ACImpl *This,
if(This->dataflow == eCapture)
capture_resample(This);
- *numpad = This->held_frames;
+ *numpad = This->stream->held_frames;
return S_OK;
}
@@ -1539,11 +1534,11 @@ static HRESULT WINAPI AudioClient_GetCurrentPadding(IAudioClient3 *iface,
if(!numpad)
return E_POINTER;
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
hr = AudioClient_GetCurrentPadding_nolock(This, numpad);
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return hr;
}
@@ -1891,35 +1886,35 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient3 *iface)
TRACE("(%p)\n", This);
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
if(!This->initted){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_NOT_INITIALIZED;
}
- if(This->playing){
- OSSpinLockUnlock(&This->lock);
+ if(This->stream->playing){
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_NOT_STOPPED;
}
if((This->flags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) && !This->event){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_EVENTHANDLE_NOT_SET;
}
if(This->event && !This->timer)
if(!CreateTimerQueueTimer(&This->timer, g_timer_q, ca_period_cb,
- This, 0, This->period_ms, WT_EXECUTEINTIMERTHREAD)){
+ This, 0, This->stream->period_ms, WT_EXECUTEINTIMERTHREAD)){
This->timer = NULL;
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
WARN("Unable to create timer: %u\n", GetLastError());
return E_OUTOFMEMORY;
}
- This->playing = TRUE;
+ This->stream->playing = TRUE;
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
@@ -1930,21 +1925,21 @@ static HRESULT WINAPI AudioClient_Stop(IAudioClient3 *iface)
TRACE("(%p)\n", This);
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
if(!This->initted){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_NOT_INITIALIZED;
}
- if(!This->playing){
- OSSpinLockUnlock(&This->lock);
+ if(!This->stream->playing){
+ OSSpinLockUnlock(&This->stream->lock);
return S_FALSE;
}
- This->playing = FALSE;
+ This->stream->playing = FALSE;
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
@@ -1955,36 +1950,36 @@ static HRESULT WINAPI AudioClient_Reset(IAudioClient3 *iface)
TRACE("(%p)\n", This);
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
if(!This->initted){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_NOT_INITIALIZED;
}
- if(This->playing){
- OSSpinLockUnlock(&This->lock);
+ if(This->stream->playing){
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_NOT_STOPPED;
}
- if(This->getbuf_last){
- OSSpinLockUnlock(&This->lock);
+ if(This->stream->getbuf_last){
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_BUFFER_OPERATION_PENDING;
}
if(This->dataflow == eRender){
- This->written_frames = 0;
+ This->stream->written_frames = 0;
}else{
- This->written_frames += This->held_frames;
+ This->stream->written_frames += This->stream->held_frames;
}
- This->held_frames = 0;
- This->lcl_offs_frames = 0;
- This->wri_offs_frames = 0;
- This->cap_offs_frames = 0;
- This->cap_held_frames = 0;
+ This->stream->held_frames = 0;
+ This->stream->lcl_offs_frames = 0;
+ This->stream->wri_offs_frames = 0;
+ This->stream->cap_offs_frames = 0;
+ This->stream->cap_held_frames = 0;
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
@@ -1999,27 +1994,27 @@ static HRESULT WINAPI AudioClient_SetEventHandle(IAudioClient3 *iface,
if(!event)
return E_INVALIDARG;
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
if(!This->initted){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_NOT_INITIALIZED;
}
if(!(This->flags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK)){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED;
}
if (This->event){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
FIXME("called twice\n");
return HRESULT_FROM_WIN32(ERROR_INVALID_NAME);
}
This->event = event;
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
@@ -2035,23 +2030,23 @@ static HRESULT WINAPI AudioClient_GetService(IAudioClient3 *iface, REFIID riid,
return E_POINTER;
*ppv = NULL;
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
if(!This->initted){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_NOT_INITIALIZED;
}
if(IsEqualIID(riid, &IID_IAudioRenderClient)){
if(This->dataflow != eRender){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_WRONG_ENDPOINT_TYPE;
}
IAudioRenderClient_AddRef(&This->IAudioRenderClient_iface);
*ppv = &This->IAudioRenderClient_iface;
}else if(IsEqualIID(riid, &IID_IAudioCaptureClient)){
if(This->dataflow != eCapture){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_WRONG_ENDPOINT_TYPE;
}
IAudioCaptureClient_AddRef(&This->IAudioCaptureClient_iface);
@@ -2066,7 +2061,7 @@ static HRESULT WINAPI AudioClient_GetService(IAudioClient3 *iface, REFIID riid,
if(!This->session_wrapper){
This->session_wrapper = AudioSessionWrapper_Create(This);
if(!This->session_wrapper){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return E_OUTOFMEMORY;
}
}else
@@ -2077,7 +2072,7 @@ static HRESULT WINAPI AudioClient_GetService(IAudioClient3 *iface, REFIID riid,
if(!This->session_wrapper){
This->session_wrapper = AudioSessionWrapper_Create(This);
if(!This->session_wrapper){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return E_OUTOFMEMORY;
}
}else
@@ -2088,7 +2083,7 @@ static HRESULT WINAPI AudioClient_GetService(IAudioClient3 *iface, REFIID riid,
if(!This->session_wrapper){
This->session_wrapper = AudioSessionWrapper_Create(This);
if(!This->session_wrapper){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return E_OUTOFMEMORY;
}
}else
@@ -2098,11 +2093,11 @@ static HRESULT WINAPI AudioClient_GetService(IAudioClient3 *iface, REFIID riid,
}
if(*ppv){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
FIXME("stub %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
@@ -2274,49 +2269,49 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
return E_POINTER;
*data = NULL;
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
- if(This->getbuf_last){
- OSSpinLockUnlock(&This->lock);
+ if(This->stream->getbuf_last){
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_OUT_OF_ORDER;
}
if(!frames){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
hr = AudioClient_GetCurrentPadding_nolock(This, &pad);
if(FAILED(hr)){
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return hr;
}
- if(pad + frames > This->bufsize_frames){
- OSSpinLockUnlock(&This->lock);
+ if(pad + frames > This->stream->bufsize_frames){
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_BUFFER_TOO_LARGE;
}
- if(This->wri_offs_frames + frames > This->bufsize_frames){
- if(This->tmp_buffer_frames < frames){
- HeapFree(GetProcessHeap(), 0, This->tmp_buffer);
- This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, frames * This->fmt->nBlockAlign);
- if(!This->tmp_buffer){
- OSSpinLockUnlock(&This->lock);
+ if(This->stream->wri_offs_frames + frames > This->stream->bufsize_frames){
+ if(This->stream->tmp_buffer_frames < frames){
+ HeapFree(GetProcessHeap(), 0, This->stream->tmp_buffer);
+ This->stream->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, frames * This->stream->fmt->nBlockAlign);
+ if(!This->stream->tmp_buffer){
+ OSSpinLockUnlock(&This->stream->lock);
return E_OUTOFMEMORY;
}
- This->tmp_buffer_frames = frames;
+ This->stream->tmp_buffer_frames = frames;
}
- *data = This->tmp_buffer;
- This->getbuf_last = -frames;
+ *data = This->stream->tmp_buffer;
+ This->stream->getbuf_last = -frames;
}else{
- *data = This->local_buffer + This->wri_offs_frames * This->fmt->nBlockAlign;
- This->getbuf_last = frames;
+ *data = This->stream->local_buffer + This->stream->wri_offs_frames * This->stream->fmt->nBlockAlign;
+ This->stream->getbuf_last = frames;
}
silence_buffer(This, *data, frames);
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
@@ -2329,46 +2324,46 @@ static HRESULT WINAPI AudioRenderClient_ReleaseBuffer(
TRACE("(%p)->(%u, %x)\n", This, frames, flags);
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
if(!frames){
- This->getbuf_last = 0;
- OSSpinLockUnlock(&This->lock);
+ This->stream->getbuf_last = 0;
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
- if(!This->getbuf_last){
- OSSpinLockUnlock(&This->lock);
+ if(!This->stream->getbuf_last){
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_OUT_OF_ORDER;
}
- if(frames > (This->getbuf_last >= 0 ? This->getbuf_last : -This->getbuf_last)){
- OSSpinLockUnlock(&This->lock);
+ if(frames > (This->stream->getbuf_last >= 0 ? This->stream->getbuf_last : -This->stream->getbuf_last)){
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_INVALID_SIZE;
}
- if(This->getbuf_last >= 0)
- buffer = This->local_buffer + This->wri_offs_frames * This->fmt->nBlockAlign;
+ if(This->stream->getbuf_last >= 0)
+ buffer = This->stream->local_buffer + This->stream->wri_offs_frames * This->stream->fmt->nBlockAlign;
else
- buffer = This->tmp_buffer;
+ buffer = This->stream->tmp_buffer;
if(flags & AUDCLNT_BUFFERFLAGS_SILENT)
silence_buffer(This, buffer, frames);
- if(This->getbuf_last < 0)
- ca_wrap_buffer(This->local_buffer,
- This->wri_offs_frames * This->fmt->nBlockAlign,
- This->bufsize_frames * This->fmt->nBlockAlign,
- buffer, frames * This->fmt->nBlockAlign);
+ if(This->stream->getbuf_last < 0)
+ ca_wrap_buffer(This->stream->local_buffer,
+ This->stream->wri_offs_frames * This->stream->fmt->nBlockAlign,
+ This->stream->bufsize_frames * This->stream->fmt->nBlockAlign,
+ buffer, frames * This->stream->fmt->nBlockAlign);
- This->wri_offs_frames += frames;
- This->wri_offs_frames %= This->bufsize_frames;
- This->held_frames += frames;
- This->written_frames += frames;
- This->getbuf_last = 0;
+ This->stream->wri_offs_frames += frames;
+ This->stream->wri_offs_frames %= This->stream->bufsize_frames;
+ This->stream->held_frames += frames;
+ This->stream->written_frames += frames;
+ This->stream->getbuf_last = 0;
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
@@ -2436,38 +2431,38 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface,
if(!frames || !flags)
return E_POINTER;
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
- if(This->getbuf_last){
- OSSpinLockUnlock(&This->lock);
+ if(This->stream->getbuf_last){
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_OUT_OF_ORDER;
}
capture_resample(This);
- if(This->held_frames < This->period_frames){
+ if(This->stream->held_frames < This->stream->period_frames){
*frames = 0;
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_S_BUFFER_EMPTY;
}
*flags = 0;
- chunk_frames = This->bufsize_frames - This->lcl_offs_frames;
- if(chunk_frames < This->period_frames){
- chunk_bytes = chunk_frames * This->fmt->nBlockAlign;
- if(!This->tmp_buffer)
- This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, This->period_frames * This->fmt->nBlockAlign);
- *data = This->tmp_buffer;
- memcpy(*data, This->local_buffer + This->lcl_offs_frames * This->fmt->nBlockAlign, chunk_bytes);
- memcpy((*data) + chunk_bytes, This->local_buffer, This->period_frames * This->fmt->nBlockAlign - chunk_bytes);
+ chunk_frames = This->stream->bufsize_frames - This->stream->lcl_offs_frames;
+ if(chunk_frames < This->stream->period_frames){
+ chunk_bytes = chunk_frames * This->stream->fmt->nBlockAlign;
+ if(!This->stream->tmp_buffer)
+ This->stream->tmp_buffer = HeapAlloc(GetProcessHeap(), 0, This->stream->period_frames * This->stream->fmt->nBlockAlign);
+ *data = This->stream->tmp_buffer;
+ memcpy(*data, This->stream->local_buffer + This->stream->lcl_offs_frames * This->stream->fmt->nBlockAlign, chunk_bytes);
+ memcpy((*data) + chunk_bytes, This->stream->local_buffer, This->stream->period_frames * This->stream->fmt->nBlockAlign - chunk_bytes);
}else
- *data = This->local_buffer + This->lcl_offs_frames * This->fmt->nBlockAlign;
+ *data = This->stream->local_buffer + This->stream->lcl_offs_frames * This->stream->fmt->nBlockAlign;
- This->getbuf_last = *frames = This->period_frames;
+ This->stream->getbuf_last = *frames = This->stream->period_frames;
if(devpos)
- *devpos = This->written_frames;
+ *devpos = This->stream->written_frames;
if(qpcpos){ /* fixme: qpc of recording time */
LARGE_INTEGER stamp, freq;
QueryPerformanceCounter(&stamp);
@@ -2475,7 +2470,7 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface,
*qpcpos = (stamp.QuadPart * (INT64)10000000) / freq.QuadPart;
}
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
@@ -2487,31 +2482,31 @@ static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer(
TRACE("(%p)->(%u)\n", This, done);
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
if(!done){
- This->getbuf_last = 0;
- OSSpinLockUnlock(&This->lock);
+ This->stream->getbuf_last = 0;
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
- if(!This->getbuf_last){
- OSSpinLockUnlock(&This->lock);
+ if(!This->stream->getbuf_last){
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_OUT_OF_ORDER;
}
- if(This->getbuf_last != done){
- OSSpinLockUnlock(&This->lock);
+ if(This->stream->getbuf_last != done){
+ OSSpinLockUnlock(&This->stream->lock);
return AUDCLNT_E_INVALID_SIZE;
}
- This->written_frames += done;
- This->held_frames -= done;
- This->lcl_offs_frames += done;
- This->lcl_offs_frames %= This->bufsize_frames;
- This->getbuf_last = 0;
+ This->stream->written_frames += done;
+ This->stream->held_frames -= done;
+ This->stream->lcl_offs_frames += done;
+ This->stream->lcl_offs_frames %= This->stream->bufsize_frames;
+ This->stream->getbuf_last = 0;
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
@@ -2526,16 +2521,16 @@ static HRESULT WINAPI AudioCaptureClient_GetNextPacketSize(
if(!frames)
return E_POINTER;
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
capture_resample(This);
- if(This->held_frames >= This->period_frames)
- *frames = This->period_frames;
+ if(This->stream->held_frames >= This->stream->period_frames)
+ *frames = This->stream->period_frames;
else
*frames = 0;
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
@@ -2592,10 +2587,10 @@ static HRESULT WINAPI AudioClock_GetFrequency(IAudioClock *iface, UINT64 *freq)
TRACE("(%p)->(%p)\n", This, freq);
- if(This->share == AUDCLNT_SHAREMODE_SHARED)
- *freq = (UINT64)This->fmt->nSamplesPerSec * This->fmt->nBlockAlign;
+ if(This->stream->share == AUDCLNT_SHAREMODE_SHARED)
+ *freq = (UINT64)This->stream->fmt->nSamplesPerSec * This->stream->fmt->nBlockAlign;
else
- *freq = This->fmt->nSamplesPerSec;
+ *freq = This->stream->fmt->nSamplesPerSec;
return S_OK;
}
@@ -2603,10 +2598,10 @@ static HRESULT WINAPI AudioClock_GetFrequency(IAudioClock *iface, UINT64 *freq)
static HRESULT AudioClock_GetPosition_nolock(ACImpl *This,
UINT64 *pos, UINT64 *qpctime)
{
- *pos = This->written_frames - This->held_frames;
+ *pos = This->stream->written_frames - This->stream->held_frames;
- if(This->share == AUDCLNT_SHAREMODE_SHARED)
- *pos *= This->fmt->nBlockAlign;
+ if(This->stream->share == AUDCLNT_SHAREMODE_SHARED)
+ *pos *= This->stream->fmt->nBlockAlign;
if(qpctime){
LARGE_INTEGER stamp, freq;
@@ -2629,11 +2624,11 @@ static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
if(!pos)
return E_POINTER;
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
hr = AudioClock_GetPosition_nolock(This, pos, qpctime);
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return hr;
}
@@ -2763,9 +2758,9 @@ static ULONG WINAPI AudioSessionControl_Release(IAudioSessionControl2 *iface)
TRACE("(%p) Refcount now %u\n", This, ref);
if(!ref){
if(This->client){
- OSSpinLockLock(&This->client->lock);
+ OSSpinLockLock(&This->client->stream->lock);
This->client->session_wrapper = NULL;
- OSSpinLockUnlock(&This->client->lock);
+ OSSpinLockUnlock(&This->client->stream->lock);
AudioClient_Release(&This->client->IAudioClient3_iface);
}
HeapFree(GetProcessHeap(), 0, This);
@@ -2793,14 +2788,14 @@ static HRESULT WINAPI AudioSessionControl_GetState(IAudioSessionControl2 *iface,
}
LIST_FOR_EACH_ENTRY(client, &This->session->clients, ACImpl, entry){
- OSSpinLockLock(&client->lock);
- if(client->playing){
+ OSSpinLockLock(&client->stream->lock);
+ if(client->stream->playing){
*state = AudioSessionStateActive;
- OSSpinLockUnlock(&client->lock);
+ OSSpinLockUnlock(&client->stream->lock);
LeaveCriticalSection(&g_sessions_lock);
return S_OK;
}
- OSSpinLockUnlock(&client->lock);
+ OSSpinLockUnlock(&client->stream->lock);
}
LeaveCriticalSection(&g_sessions_lock);
@@ -2979,7 +2974,7 @@ static HRESULT ca_setvol(ACImpl *This, UINT32 index)
if(index == (UINT32)-1){
UINT32 i;
level = 1.;
- for(i = 0; i < This->fmt->nChannels; ++i){
+ for(i = 0; i < This->stream->fmt->nChannels; ++i){
Float32 tmp;
tmp = This->session->master_vol *
This->session->channel_vols[i] * This->vols[i];
@@ -2990,7 +2985,7 @@ static HRESULT ca_setvol(ACImpl *This, UINT32 index)
This->session->channel_vols[index] * This->vols[index];
}
- sc = AudioUnitSetParameter(This->unit, kHALOutputParam_Volume,
+ sc = AudioUnitSetParameter(This->stream->unit, kHALOutputParam_Volume,
kAudioUnitScope_Global, 0, level, 0);
if(sc != noErr)
WARN("Couldn't set volume: %x\n", (int)sc);
@@ -3180,7 +3175,7 @@ static HRESULT WINAPI AudioStreamVolume_GetChannelCount(
if(!out)
return E_POINTER;
- *out = This->fmt->nChannels;
+ *out = This->stream->fmt->nChannels;
return S_OK;
}
@@ -3196,17 +3191,17 @@ static HRESULT WINAPI AudioStreamVolume_SetChannelVolume(
if(level < 0.f || level > 1.f)
return E_INVALIDARG;
- if(index >= This->fmt->nChannels)
+ if(index >= This->stream->fmt->nChannels)
return E_INVALIDARG;
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
This->vols[index] = level;
WARN("CoreAudio doesn't support per-channel volume control\n");
ret = ca_setvol(This, index);
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return ret;
}
@@ -3221,7 +3216,7 @@ static HRESULT WINAPI AudioStreamVolume_GetChannelVolume(
if(!level)
return E_POINTER;
- if(index >= This->fmt->nChannels)
+ if(index >= This->stream->fmt->nChannels)
return E_INVALIDARG;
*level = This->vols[index];
@@ -3241,17 +3236,17 @@ static HRESULT WINAPI AudioStreamVolume_SetAllVolumes(
if(!levels)
return E_POINTER;
- if(count != This->fmt->nChannels)
+ if(count != This->stream->fmt->nChannels)
return E_INVALIDARG;
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
for(i = 0; i < count; ++i)
This->vols[i] = levels[i];
ret = ca_setvol(This, -1);
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return ret;
}
@@ -3267,15 +3262,15 @@ static HRESULT WINAPI AudioStreamVolume_GetAllVolumes(
if(!levels)
return E_POINTER;
- if(count != This->fmt->nChannels)
+ if(count != This->stream->fmt->nChannels)
return E_INVALIDARG;
- OSSpinLockLock(&This->lock);
+ OSSpinLockLock(&This->stream->lock);
for(i = 0; i < count; ++i)
levels[i] = This->vols[i];
- OSSpinLockUnlock(&This->lock);
+ OSSpinLockUnlock(&This->stream->lock);
return S_OK;
}
diff --git a/dlls/winecoreaudio.drv/unixlib.h b/dlls/winecoreaudio.drv/unixlib.h
index 7c1200464b9..6a991f1de98 100644
--- a/dlls/winecoreaudio.drv/unixlib.h
+++ b/dlls/winecoreaudio.drv/unixlib.h
@@ -18,6 +18,29 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+struct coreaudio_stream /* To be made private */
+{
+ OSSpinLock lock;
+ AudioComponentInstance unit;
+ AudioConverterRef converter;
+ AudioStreamBasicDescription dev_desc; /* audio unit format, not necessarily the same as fmt */
+ AudioDeviceID dev_id;
+ EDataFlow flow;
+ AUDCLNT_SHAREMODE share;
+
+ BOOL playing;
+ SIZE_T local_buffer_size, tmp_buffer_size;
+ UINT32 period_ms, period_frames;
+ UINT32 bufsize_frames, resamp_bufsize_frames;
+ UINT32 lcl_offs_frames, held_frames, wri_offs_frames, tmp_buffer_frames;
+ UINT32 cap_bufsize_frames, cap_offs_frames, cap_held_frames;
+ UINT32 wrap_bufsize_frames;
+ UINT64 written_frames;
+ INT32 getbuf_last;
+ WAVEFORMATEX *fmt;
+ BYTE *local_buffer, *cap_buffer, *wrap_buffer, *resamp_buffer, *tmp_buffer;
+};
+
struct endpoint
{
WCHAR *name;
--
2.23.0
1
0
Nov. 15, 2021
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/winecoreaudio.drv/Makefile.in | 1 +
dlls/winecoreaudio.drv/coreaudio.c | 229 ++++++++++++++++++++++++++++-
dlls/winecoreaudio.drv/mmdevdrv.c | 203 +++++++------------------
dlls/winecoreaudio.drv/unixlib.h | 44 ++++++
4 files changed, 322 insertions(+), 155 deletions(-)
create mode 100644 dlls/winecoreaudio.drv/unixlib.h
diff --git a/dlls/winecoreaudio.drv/Makefile.in b/dlls/winecoreaudio.drv/Makefile.in
index afbc50c7148..b6bf5bd4587 100644
--- a/dlls/winecoreaudio.drv/Makefile.in
+++ b/dlls/winecoreaudio.drv/Makefile.in
@@ -1,4 +1,5 @@
MODULE = winecoreaudio.drv
+UNIXLIB = winecoreaudio.so
IMPORTS = uuid ole32 user32 advapi32
DELAYIMPORTS = winmm
EXTRALIBS = $(COREAUDIO_LIBS)
diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c
index 1f222367bed..f3af24f80fb 100644
--- a/dlls/winecoreaudio.drv/coreaudio.c
+++ b/dlls/winecoreaudio.drv/coreaudio.c
@@ -1,5 +1,8 @@
/*
- * Wine Driver for CoreAudio
+ * Unixlib for winecoreaudio driver.
+ *
+ * Copyright 2011 Andrew Eikum for CodeWeavers
+ * Copyright 2021 Huw Davies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -15,16 +18,230 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-
+#if 0
+#pragma makedep unix
+#endif
#include "config.h"
+#define LoadResource __carbon_LoadResource
+#define CompareString __carbon_CompareString
+#define GetCurrentThread __carbon_GetCurrentThread
+#define GetCurrentProcess __carbon_GetCurrentProcess
+
#include <stdarg.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <fenv.h>
+#include <unistd.h>
+
+#include <libkern/OSAtomic.h>
+#include <CoreAudio/CoreAudio.h>
+#include <AudioToolbox/AudioFormat.h>
+#include <AudioToolbox/AudioConverter.h>
+#include <AudioUnit/AudioUnit.h>
+
+#undef LoadResource
+#undef CompareString
+#undef GetCurrentThread
+#undef GetCurrentProcess
+#undef _CDECL
+
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
-#include "wingdi.h"
-#include "winuser.h"
-#include "mmddk.h"
-#include "coreaudio.h"
+#include "winnls.h"
+#include "winreg.h"
+#include "mmdeviceapi.h"
+#include "initguid.h"
+#include "audioclient.h"
#include "wine/debug.h"
+#include "wine/unicode.h"
+#include "wine/unixlib.h"
+
+#include "unixlib.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(coreaudio);
+
+static HRESULT osstatus_to_hresult(OSStatus sc)
+{
+ switch(sc){
+ case kAudioFormatUnsupportedDataFormatError:
+ case kAudioFormatUnknownFormatError:
+ case kAudioDeviceUnsupportedFormatError:
+ return AUDCLNT_E_UNSUPPORTED_FORMAT;
+ case kAudioHardwareBadDeviceError:
+ return AUDCLNT_E_DEVICE_INVALIDATED;
+ }
+ return E_FAIL;
+}
+
+static AudioObjectPropertyScope get_scope(EDataFlow flow)
+{
+ return (flow == eRender) ? kAudioDevicePropertyScopeOutput : kAudioDevicePropertyScopeInput;
+}
+
+static BOOL device_has_channels(AudioDeviceID device, EDataFlow flow)
+{
+ AudioObjectPropertyAddress addr;
+ AudioBufferList *buffers;
+ BOOL ret = FALSE;
+ OSStatus sc;
+ UInt32 size;
+ int i;
+
+ addr.mSelector = kAudioDevicePropertyStreamConfiguration;
+ addr.mScope = get_scope(flow);
+ addr.mElement = 0;
+
+ sc = AudioObjectGetPropertyDataSize(device, &addr, 0, NULL, &size);
+ if(sc != noErr){
+ WARN("Unable to get _StreamConfiguration property size for device %u: %x\n",
+ (unsigned int)device, (int)sc);
+ return FALSE;
+ }
+
+ buffers = malloc(size);
+ if(!buffers) return FALSE;
+
+ sc = AudioObjectGetPropertyData(device, &addr, 0, NULL, &size, buffers);
+ if(sc != noErr){
+ WARN("Unable to get _StreamConfiguration property for device %u: %x\n",
+ (unsigned int)device, (int)sc);
+ free(buffers);
+ return FALSE;
+ }
+
+ for(i = 0; i < buffers->mNumberBuffers; i++){
+ if(buffers->mBuffers[i].mNumberChannels > 0){
+ ret = TRUE;
+ break;
+ }
+ }
+ free(buffers);
+ return ret;
+}
+
+static NTSTATUS get_endpoint_ids(void *args)
+{
+ struct get_endpoint_ids_params *params = args;
+ unsigned int num_devices, i, needed;
+ AudioDeviceID *devices, default_id;
+ AudioObjectPropertyAddress addr;
+ struct endpoint *endpoint;
+ UInt32 devsize, size;
+ struct endpoint_info
+ {
+ CFStringRef name;
+ AudioDeviceID id;
+ } *info;
+ OSStatus sc;
+ WCHAR *ptr;
+
+ params->num = 0;
+ params->default_idx = 0;
+
+ addr.mScope = kAudioObjectPropertyScopeGlobal;
+ addr.mElement = kAudioObjectPropertyElementMaster;
+ if(params->flow == eRender) addr.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
+ else if(params->flow == eCapture) addr.mSelector = kAudioHardwarePropertyDefaultInputDevice;
+ else{
+ params->result = E_INVALIDARG;
+ return STATUS_SUCCESS;
+ }
+
+ size = sizeof(default_id);
+ sc = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0, NULL, &size, &default_id);
+ if(sc != noErr){
+ WARN("Getting _DefaultInputDevice property failed: %x\n", (int)sc);
+ default_id = -1;
+ }
+
+ addr.mSelector = kAudioHardwarePropertyDevices;
+ sc = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &addr, 0, NULL, &devsize);
+ if(sc != noErr){
+ WARN("Getting _Devices property size failed: %x\n", (int)sc);
+ params->result = osstatus_to_hresult(sc);
+ return STATUS_SUCCESS;
+ }
+
+ num_devices = devsize / sizeof(AudioDeviceID);
+ devices = malloc(devsize);
+ info = malloc(num_devices * sizeof(*info));
+ if(!devices || !info){
+ free(info);
+ free(devices);
+ params->result = E_OUTOFMEMORY;
+ return STATUS_SUCCESS;
+ }
+
+ sc = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0, NULL, &devsize, devices);
+ if(sc != noErr){
+ WARN("Getting _Devices property failed: %x\n", (int)sc);
+ free(info);
+ free(devices);
+ params->result = osstatus_to_hresult(sc);
+ return STATUS_SUCCESS;
+ }
+
+ addr.mSelector = kAudioObjectPropertyName;
+ addr.mScope = get_scope(params->flow);
+ addr.mElement = 0;
+
+ for(i = 0; i < num_devices; i++){
+ if(!device_has_channels(devices[i], params->flow)) continue;
+
+ size = sizeof(CFStringRef);
+ sc = AudioObjectGetPropertyData(devices[i], &addr, 0, NULL, &size, &info[params->num].name);
+ if(sc != noErr){
+ WARN("Unable to get _Name property for device %u: %x\n",
+ (unsigned int)devices[i], (int)sc);
+ continue;
+ }
+ info[params->num++].id = devices[i];
+ }
+ free(devices);
+
+ needed = sizeof(*endpoint) * params->num;
+ endpoint = params->endpoints;
+ ptr = (WCHAR *)(endpoint + params->num);
+
+ for(i = 0; i < params->num; i++){
+ SIZE_T len = CFStringGetLength(info[i].name);
+ needed += (len + 1) * sizeof(WCHAR);
+
+ if(needed <= params->size){
+ endpoint->name = ptr;
+ CFStringGetCharacters(info[i].name, CFRangeMake(0, len), (UniChar*)endpoint->name);
+ ptr[len] = 0;
+ endpoint->id = info[i].id;
+ endpoint++;
+ ptr += len + 1;
+ }
+ CFRelease(info[i].name);
+ if(info[i].id == default_id) params->default_idx = i;
+ }
+ free(info);
+
+ if(needed > params->size){
+ params->size = needed;
+ params->result = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
+ }
+ else params->result = S_OK;
+
+ return STATUS_SUCCESS;
+}
+
+unixlib_entry_t __wine_unix_call_funcs[] =
+{
+ get_endpoint_ids,
+};
diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c
index f07f4bae5fb..f8b538971f2 100644
--- a/dlls/winecoreaudio.drv/mmdevdrv.c
+++ b/dlls/winecoreaudio.drv/mmdevdrv.c
@@ -56,8 +56,10 @@
#include "winnls.h"
#include "winreg.h"
#include "wine/debug.h"
+#include "wine/heap.h"
#include "wine/unicode.h"
#include "wine/list.h"
+#include "wine/unixlib.h"
#include "ole2.h"
#include "mmdeviceapi.h"
@@ -69,9 +71,12 @@
#include "endpointvolume.h"
#include "audioclient.h"
#include "audiopolicy.h"
+#include "unixlib.h"
WINE_DEFAULT_DEBUG_CHANNEL(coreaudio);
+unixlib_handle_t coreaudio_handle = 0;
+
#define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER)
static const REFERENCE_TIME DefaultPeriod = 100000;
@@ -245,6 +250,9 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved)
switch (reason)
{
case DLL_PROCESS_ATTACH:
+ if(NtQueryVirtualMemory(GetCurrentProcess(), dll, MemoryWineUnixFuncs,
+ &coreaudio_handle, sizeof(coreaudio_handle), NULL))
+ return FALSE;
g_timer_q = CreateTimerQueue();
if(!g_timer_q)
return FALSE;
@@ -319,7 +327,7 @@ exit:
RegCloseKey(drv_key);
}
-static void get_device_guid(EDataFlow flow, AudioDeviceID device, GUID *guid)
+static void get_device_guid(EDataFlow flow, DWORD device_id, GUID *guid)
{
HKEY key = NULL, dev_key;
DWORD type, size = sizeof(*guid);
@@ -333,7 +341,7 @@ static void get_device_guid(EDataFlow flow, AudioDeviceID device, GUID *guid)
key_name[0] = '0';
key_name[1] = ',';
- sprintfW(key_name + 2, key_fmt, device);
+ sprintfW(key_name + 2, key_fmt, device_id);
if(RegOpenKeyExW(HKEY_CURRENT_USER, drv_key_devicesW, 0, KEY_WRITE|KEY_READ, &key) == ERROR_SUCCESS){
if(RegOpenKeyExW(key, key_name, 0, KEY_READ, &dev_key) == ERROR_SUCCESS){
@@ -359,164 +367,61 @@ static void get_device_guid(EDataFlow flow, AudioDeviceID device, GUID *guid)
RegCloseKey(key);
}
-HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
- GUID **guids, UINT *num, UINT *def_index)
+HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out,
+ GUID **guids_out, UINT *num, UINT *def_index)
{
- UInt32 devsize, size;
- AudioDeviceID *devices;
- AudioDeviceID default_id;
- AudioObjectPropertyAddress addr;
- OSStatus sc;
- int i, ndevices;
-
- TRACE("%d %p %p %p\n", flow, ids, num, def_index);
-
- addr.mScope = kAudioObjectPropertyScopeGlobal;
- addr.mElement = kAudioObjectPropertyElementMaster;
- if(flow == eRender)
- addr.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
- else if(flow == eCapture)
- addr.mSelector = kAudioHardwarePropertyDefaultInputDevice;
- else
- return E_INVALIDARG;
-
- size = sizeof(default_id);
- sc = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0,
- NULL, &size, &default_id);
- if(sc != noErr){
- WARN("Getting _DefaultInputDevice property failed: %x\n", (int)sc);
- default_id = -1;
- }
-
- addr.mSelector = kAudioHardwarePropertyDevices;
- sc = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &addr, 0,
- NULL, &devsize);
- if(sc != noErr){
- WARN("Getting _Devices property size failed: %x\n", (int)sc);
- return osstatus_to_hresult(sc);
- }
+ struct get_endpoint_ids_params params;
+ unsigned int i;
+ GUID *guids;
+ WCHAR **ids;
- devices = HeapAlloc(GetProcessHeap(), 0, devsize);
- if(!devices)
- return E_OUTOFMEMORY;
-
- sc = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0, NULL,
- &devsize, devices);
- if(sc != noErr){
- WARN("Getting _Devices property failed: %x\n", (int)sc);
- HeapFree(GetProcessHeap(), 0, devices);
- return osstatus_to_hresult(sc);
- }
+ TRACE("%d %p %p %p\n", flow, ids_out, num, def_index);
- ndevices = devsize / sizeof(AudioDeviceID);
+ params.flow = flow;
+ params.size = 1000;
+ params.endpoints = NULL;
+ do{
+ heap_free(params.endpoints);
+ params.endpoints = heap_alloc(params.size);
+ UNIX_CALL(get_endpoint_ids, ¶ms);
+ }while(params.result == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER));
- *ids = HeapAlloc(GetProcessHeap(), 0, ndevices * sizeof(WCHAR *));
- if(!*ids){
- HeapFree(GetProcessHeap(), 0, devices);
- return E_OUTOFMEMORY;
- }
+ if(FAILED(params.result)) goto end;
- *guids = HeapAlloc(GetProcessHeap(), 0, ndevices * sizeof(GUID));
- if(!*guids){
- HeapFree(GetProcessHeap(), 0, *ids);
- HeapFree(GetProcessHeap(), 0, devices);
- return E_OUTOFMEMORY;
+ ids = heap_alloc_zero(params.num * sizeof(*ids));
+ guids = heap_alloc(params.num * sizeof(*guids));
+ if(!ids || !guids){
+ params.result = E_OUTOFMEMORY;
+ goto end;
}
- *num = 0;
- *def_index = (UINT)-1;
- for(i = 0; i < ndevices; ++i){
- AudioBufferList *buffers;
- CFStringRef name;
- SIZE_T len;
- int j;
-
- addr.mSelector = kAudioDevicePropertyStreamConfiguration;
- if(flow == eRender)
- addr.mScope = kAudioDevicePropertyScopeOutput;
- else
- addr.mScope = kAudioDevicePropertyScopeInput;
- addr.mElement = 0;
- sc = AudioObjectGetPropertyDataSize(devices[i], &addr, 0, NULL, &size);
- if(sc != noErr){
- WARN("Unable to get _StreamConfiguration property size for "
- "device %u: %x\n", (unsigned int)devices[i], (int)sc);
- continue;
- }
-
- buffers = HeapAlloc(GetProcessHeap(), 0, size);
- if(!buffers){
- HeapFree(GetProcessHeap(), 0, devices);
- for(j = 0; j < *num; ++j)
- HeapFree(GetProcessHeap(), 0, (*ids)[j]);
- HeapFree(GetProcessHeap(), 0, *guids);
- HeapFree(GetProcessHeap(), 0, *ids);
- return E_OUTOFMEMORY;
- }
-
- sc = AudioObjectGetPropertyData(devices[i], &addr, 0, NULL,
- &size, buffers);
- if(sc != noErr){
- WARN("Unable to get _StreamConfiguration property for "
- "device %u: %x\n", (unsigned int)devices[i], (int)sc);
- HeapFree(GetProcessHeap(), 0, buffers);
- continue;
- }
-
- /* check that there's at least one channel in this device before
- * we claim it as usable */
- for(j = 0; j < buffers->mNumberBuffers; ++j)
- if(buffers->mBuffers[j].mNumberChannels > 0)
- break;
- if(j >= buffers->mNumberBuffers){
- HeapFree(GetProcessHeap(), 0, buffers);
- continue;
- }
-
- HeapFree(GetProcessHeap(), 0, buffers);
-
- size = sizeof(name);
- addr.mSelector = kAudioObjectPropertyName;
- sc = AudioObjectGetPropertyData(devices[i], &addr, 0, NULL,
- &size, &name);
- if(sc != noErr){
- WARN("Unable to get _Name property for device %u: %x\n",
- (unsigned int)devices[i], (int)sc);
- continue;
+ for(i = 0; i < params.num; i++){
+ int size = (strlenW(params.endpoints[i].name) + 1) * sizeof(WCHAR);
+ ids[i] = heap_alloc(size);
+ if(!ids[i]){
+ params.result = E_OUTOFMEMORY;
+ goto end;
}
-
- len = CFStringGetLength(name) + 1;
- (*ids)[*num] = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
- if(!(*ids)[*num]){
- CFRelease(name);
- HeapFree(GetProcessHeap(), 0, devices);
- for(j = 0; j < *num; ++j)
- HeapFree(GetProcessHeap(), 0, (*ids)[j]);
- HeapFree(GetProcessHeap(), 0, *ids);
- HeapFree(GetProcessHeap(), 0, *guids);
- return E_OUTOFMEMORY;
+ memcpy(ids[i], params.endpoints[i].name, size);
+ get_device_guid(flow, params.endpoints[i].id, guids + i);
+ }
+ *def_index = params.default_idx;
+
+end:
+ heap_free(params.endpoints);
+ if(FAILED(params.result)){
+ heap_free(guids);
+ if(ids){
+ for(i = 0; i < params.num; i++) heap_free(ids[i]);
+ heap_free(ids);
}
- CFStringGetCharacters(name, CFRangeMake(0, len - 1), (UniChar*)(*ids)[*num]);
- ((*ids)[*num])[len - 1] = 0;
- CFRelease(name);
-
- get_device_guid(flow, devices[i], &(*guids)[*num]);
-
- if(*def_index == (UINT)-1 && devices[i] == default_id)
- *def_index = *num;
-
- TRACE("device %u: id %s key %u%s\n", *num, debugstr_w((*ids)[*num]),
- (unsigned int)devices[i], (*def_index == *num) ? " (default)" : "");
-
- (*num)++;
+ }else{
+ *ids_out = ids;
+ *guids_out = guids;
+ *num = params.num;
}
- if(*def_index == (UINT)-1)
- *def_index = 0;
-
- HeapFree(GetProcessHeap(), 0, devices);
-
- return S_OK;
+ return params.result;
}
static BOOL get_deviceid_by_guid(GUID *guid, AudioDeviceID *id, EDataFlow *flow)
diff --git a/dlls/winecoreaudio.drv/unixlib.h b/dlls/winecoreaudio.drv/unixlib.h
new file mode 100644
index 00000000000..7c1200464b9
--- /dev/null
+++ b/dlls/winecoreaudio.drv/unixlib.h
@@ -0,0 +1,44 @@
+/*
+ * Unixlib header file for winecoreaudio driver.
+ *
+ * Copyright 2021 Huw Davies
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+struct endpoint
+{
+ WCHAR *name;
+ DWORD id;
+};
+
+struct get_endpoint_ids_params
+{
+ EDataFlow flow;
+ struct endpoint *endpoints;
+ unsigned int size;
+ HRESULT result;
+ unsigned int num;
+ unsigned int default_idx;
+};
+
+enum unix_funcs
+{
+ unix_get_endpoint_ids,
+};
+
+extern unixlib_handle_t coreaudio_handle;
+
+#define UNIX_CALL( func, params ) __wine_unix_call( coreaudio_handle, unix_ ## func, params )
--
2.23.0
1
0
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/winecoreaudio.drv/coreaudio.c | 81 ------------------------------
dlls/winecoreaudio.drv/coreaudio.h | 9 ----
dlls/winecoreaudio.drv/midi.c | 78 +++++++++++++++++++++++++++-
3 files changed, 77 insertions(+), 91 deletions(-)
diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c
index 321c24b477c..1f222367bed 100644
--- a/dlls/winecoreaudio.drv/coreaudio.c
+++ b/dlls/winecoreaudio.drv/coreaudio.c
@@ -1,8 +1,6 @@
/*
* Wine Driver for CoreAudio
*
- * Copyright 2005 Emmanuel Maillard
- *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -30,82 +28,3 @@
#include "mmddk.h"
#include "coreaudio.h"
#include "wine/debug.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(coreaudio);
-
-
-/**************************************************************************
- * CoreAudio_drvLoad [internal]
- */
-static LRESULT CoreAudio_drvLoad(void)
-{
- TRACE("()\n");
-
- if (CoreAudio_MIDIInit() != DRV_SUCCESS)
- return DRV_FAILURE;
-
- return DRV_SUCCESS;
-}
-
-/**************************************************************************
- * CoreAudio_drvFree [internal]
- */
-static LRESULT CoreAudio_drvFree(void)
-{
- TRACE("()\n");
- CoreAudio_MIDIRelease();
- return DRV_SUCCESS;
-}
-
-/**************************************************************************
- * CoreAudio_drvOpen [internal]
- */
-static LRESULT CoreAudio_drvOpen(LPSTR str)
-{
- TRACE("(%s)\n", str);
- return 1;
-}
-
-/**************************************************************************
- * CoreAudio_drvClose [internal]
- */
-static DWORD CoreAudio_drvClose(DWORD dwDevID)
-{
- TRACE("(%08x)\n", dwDevID);
- return 1;
-}
-
-/**************************************************************************
- * DriverProc (WINECOREAUDIO.1)
- */
-LRESULT CALLBACK CoreAudio_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
- LPARAM dwParam1, LPARAM dwParam2)
-{
- TRACE("(%08lX, %p, %s (%08X), %08lX, %08lX)\n",
- dwDevID, hDriv, wMsg == DRV_LOAD ? "DRV_LOAD" :
- wMsg == DRV_FREE ? "DRV_FREE" :
- wMsg == DRV_OPEN ? "DRV_OPEN" :
- wMsg == DRV_CLOSE ? "DRV_CLOSE" :
- wMsg == DRV_ENABLE ? "DRV_ENABLE" :
- wMsg == DRV_DISABLE ? "DRV_DISABLE" :
- wMsg == DRV_QUERYCONFIGURE ? "DRV_QUERYCONFIGURE" :
- wMsg == DRV_CONFIGURE ? "DRV_CONFIGURE" :
- wMsg == DRV_INSTALL ? "DRV_INSTALL" :
- wMsg == DRV_REMOVE ? "DRV_REMOVE" : "UNKNOWN",
- wMsg, dwParam1, dwParam2);
-
- switch(wMsg) {
- case DRV_LOAD: return CoreAudio_drvLoad();
- case DRV_FREE: return CoreAudio_drvFree();
- case DRV_OPEN: return CoreAudio_drvOpen((LPSTR)dwParam1);
- case DRV_CLOSE: return CoreAudio_drvClose(dwDevID);
- case DRV_ENABLE: return 1;
- case DRV_DISABLE: return 1;
- case DRV_QUERYCONFIGURE: return 1;
- case DRV_CONFIGURE: MessageBoxA(0, "CoreAudio driver!", "CoreAudio driver", MB_OK); return 1;
- case DRV_INSTALL: return DRVCNF_RESTART;
- case DRV_REMOVE: return DRVCNF_RESTART;
- default:
- return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
- }
-}
diff --git a/dlls/winecoreaudio.drv/coreaudio.h b/dlls/winecoreaudio.drv/coreaudio.h
index 68b52502333..e04043c4010 100644
--- a/dlls/winecoreaudio.drv/coreaudio.h
+++ b/dlls/winecoreaudio.drv/coreaudio.h
@@ -22,15 +22,6 @@
#include "wine/debug.h"
-extern LONG CoreAudio_WaveInit(void);
-extern void CoreAudio_WaveRelease(void);
-
-extern LONG CoreAudio_MIDIInit(void);
-extern LONG CoreAudio_MIDIRelease(void);
-
-extern LONG CoreAudio_MixerInit(void);
-extern void CoreAudio_MixerRelease(void);
-
/* fourcc is in native order, where MSB is the first character. */
static inline const char* wine_dbgstr_fourcc(INT32 fourcc)
{
diff --git a/dlls/winecoreaudio.drv/midi.c b/dlls/winecoreaudio.drv/midi.c
index c299d116f12..92e4f50f620 100644
--- a/dlls/winecoreaudio.drv/midi.c
+++ b/dlls/winecoreaudio.drv/midi.c
@@ -8,7 +8,7 @@
* current support is limited to MIDI ports of OSS systems
* 98/9 rewriting MCI code for MIDI
* 98/11 split in midi.c and mcimidi.c
- * Copyright 2006 Emmanuel Maillard
+ * Copyright 2005, 2005 Emmanuel Maillard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1033,3 +1033,79 @@ DWORD WINAPI CoreAudio_midMessage(UINT wDevID, UINT wMsg, DWORD dwUser, DWORD dw
}
return MMSYSERR_NOTSUPPORTED;
}
+
+/**************************************************************************
+ * CoreAudio_drvLoad [internal]
+ */
+static LRESULT CoreAudio_drvLoad(void)
+{
+ TRACE("()\n");
+
+ if (CoreAudio_MIDIInit() != DRV_SUCCESS)
+ return DRV_FAILURE;
+
+ return DRV_SUCCESS;
+}
+
+/**************************************************************************
+ * CoreAudio_drvFree [internal]
+ */
+static LRESULT CoreAudio_drvFree(void)
+{
+ TRACE("()\n");
+ CoreAudio_MIDIRelease();
+ return DRV_SUCCESS;
+}
+
+/**************************************************************************
+ * CoreAudio_drvOpen [internal]
+ */
+static LRESULT CoreAudio_drvOpen(LPSTR str)
+{
+ TRACE("(%s)\n", str);
+ return 1;
+}
+
+/**************************************************************************
+ * CoreAudio_drvClose [internal]
+ */
+static DWORD CoreAudio_drvClose(DWORD dwDevID)
+{
+ TRACE("(%08x)\n", dwDevID);
+ return 1;
+}
+
+/**************************************************************************
+ * DriverProc (WINECOREAUDIO.1)
+ */
+LRESULT CALLBACK CoreAudio_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
+ LPARAM dwParam1, LPARAM dwParam2)
+{
+ TRACE("(%08lX, %p, %s (%08X), %08lX, %08lX)\n",
+ dwDevID, hDriv, wMsg == DRV_LOAD ? "DRV_LOAD" :
+ wMsg == DRV_FREE ? "DRV_FREE" :
+ wMsg == DRV_OPEN ? "DRV_OPEN" :
+ wMsg == DRV_CLOSE ? "DRV_CLOSE" :
+ wMsg == DRV_ENABLE ? "DRV_ENABLE" :
+ wMsg == DRV_DISABLE ? "DRV_DISABLE" :
+ wMsg == DRV_QUERYCONFIGURE ? "DRV_QUERYCONFIGURE" :
+ wMsg == DRV_CONFIGURE ? "DRV_CONFIGURE" :
+ wMsg == DRV_INSTALL ? "DRV_INSTALL" :
+ wMsg == DRV_REMOVE ? "DRV_REMOVE" : "UNKNOWN",
+ wMsg, dwParam1, dwParam2);
+
+ switch(wMsg) {
+ case DRV_LOAD: return CoreAudio_drvLoad();
+ case DRV_FREE: return CoreAudio_drvFree();
+ case DRV_OPEN: return CoreAudio_drvOpen((LPSTR)dwParam1);
+ case DRV_CLOSE: return CoreAudio_drvClose(dwDevID);
+ case DRV_ENABLE: return 1;
+ case DRV_DISABLE: return 1;
+ case DRV_QUERYCONFIGURE: return 1;
+ case DRV_CONFIGURE: MessageBoxA(0, "CoreAudio driver!", "CoreAudio driver", MB_OK); return 1;
+ case DRV_INSTALL: return DRVCNF_RESTART;
+ case DRV_REMOVE: return DRVCNF_RESTART;
+ default:
+ return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
+ }
+}
--
2.23.0
1
0
[PATCH 1/3] wined3d: Make the "buffer_object" field of struct wined3d_bo_address a wined3d_bo pointer.
by Zebediah Figura Nov. 15, 2021
by Zebediah Figura Nov. 15, 2021
Nov. 15, 2021
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/wined3d/adapter_vk.c | 16 +++++++++-------
dlls/wined3d/buffer.c | 8 ++++----
dlls/wined3d/context_gl.c | 13 +++++++------
dlls/wined3d/directx.c | 8 ++++----
dlls/wined3d/surface.c | 4 ++--
dlls/wined3d/texture.c | 22 +++++++++++-----------
dlls/wined3d/view.c | 6 +++---
dlls/wined3d/wined3d_private.h | 7 ++++---
8 files changed, 44 insertions(+), 40 deletions(-)
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c
index db94187e774..fa0097cd8fa 100644
--- a/dlls/wined3d/adapter_vk.c
+++ b/dlls/wined3d/adapter_vk.c
@@ -960,8 +960,9 @@ static void *adapter_vk_map_bo_address(struct wined3d_context *context,
VkMappedMemoryRange range;
void *map_ptr;
- if (!(bo = (struct wined3d_bo_vk *)data->buffer_object))
+ if (!data->buffer_object)
return data->addr;
+ bo = wined3d_bo_vk(data->buffer_object);
vk_info = context_vk->vk_info;
device_vk = wined3d_device_vk(context->device);
@@ -1065,8 +1066,9 @@ static void adapter_vk_unmap_bo_address(struct wined3d_context *context,
struct wined3d_bo_vk *bo;
unsigned int i;
- if (!(bo = (struct wined3d_bo_vk *)data->buffer_object))
+ if (!data->buffer_object)
return;
+ bo = wined3d_bo_vk(data->buffer_object);
if (!bo->b.coherent)
{
@@ -1092,8 +1094,8 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context,
void *dst_ptr, *src_ptr;
VkBufferCopy region;
- src_bo = (struct wined3d_bo_vk *)src->buffer_object;
- dst_bo = (struct wined3d_bo_vk *)dst->buffer_object;
+ src_bo = src->buffer_object ? wined3d_bo_vk(src->buffer_object) : NULL;
+ dst_bo = dst->buffer_object ? wined3d_bo_vk(dst->buffer_object) : NULL;
if (dst_bo && !dst->addr && size == dst_bo->size)
map_flags |= WINED3D_MAP_DISCARD;
@@ -1164,7 +1166,7 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context,
return;
}
- staging.buffer_object = (uintptr_t)&staging_bo;
+ staging.buffer_object = &staging_bo.b;
staging.addr = NULL;
adapter_vk_copy_bo_address(context, &staging, src, size);
adapter_vk_copy_bo_address(context, dst, &staging, size);
@@ -1184,7 +1186,7 @@ void adapter_vk_copy_bo_address(struct wined3d_context *context,
return;
}
- staging.buffer_object = (uintptr_t)&staging_bo;
+ staging.buffer_object = &staging_bo.b;
staging.addr = NULL;
adapter_vk_copy_bo_address(context, &staging, src, size);
adapter_vk_copy_bo_address(context, dst, &staging, size);
@@ -1251,7 +1253,7 @@ static bool adapter_vk_alloc_bo(struct wined3d_device *device, struct wined3d_re
ERR("Failed to map bo.\n");
}
- addr->buffer_object = (uintptr_t)bo_vk;
+ addr->buffer_object = &bo_vk->b;
addr->addr = NULL;
return true;
}
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index d5840a488b5..b07f1510b74 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -665,7 +665,7 @@ DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_co
}
if (locations & WINED3D_LOCATION_BUFFER)
{
- data->buffer_object = (uintptr_t)buffer->buffer_object;
+ data->buffer_object = buffer->buffer_object;
data->addr = NULL;
return WINED3D_LOCATION_BUFFER;
}
@@ -977,7 +977,7 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
if (count == 1)
{
- addr.buffer_object = (uintptr_t)buffer->buffer_object;
+ addr.buffer_object = buffer->buffer_object;
addr.addr = 0;
buffer->map_ptr = wined3d_context_map_bo_address(context, &addr, resource->size, flags);
/* We are accessing buffer->resource.client from the CS thread,
@@ -1057,7 +1057,7 @@ static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resou
context = context_acquire(device, NULL, 0);
- addr.buffer_object = (uintptr_t)buffer->buffer_object;
+ addr.buffer_object = buffer->buffer_object;
addr.addr = 0;
wined3d_context_unmap_bo_address(context, &addr, range_count, buffer->maps);
@@ -1587,7 +1587,7 @@ static void wined3d_buffer_vk_upload_ranges(struct wined3d_buffer *buffer, struc
if (!range_count)
return;
- dst.buffer_object = (uintptr_t)buffer->buffer_object;
+ dst.buffer_object = buffer->buffer_object;
dst.addr = NULL;
flags = WINED3D_MAP_WRITE;
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c
index 210d8e0b925..e91bff9328b 100644
--- a/dlls/wined3d/context_gl.c
+++ b/dlls/wined3d/context_gl.c
@@ -2729,13 +2729,13 @@ map:
void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl *context_gl,
const struct wined3d_bo_address *data, size_t size, uint32_t flags)
{
- struct wined3d_bo_gl *bo;
+ struct wined3d_bo *bo;
void *map_ptr;
- if (!(bo = (struct wined3d_bo_gl *)data->buffer_object))
+ if (!(bo = data->buffer_object))
return data->addr;
- if (!(map_ptr = wined3d_bo_gl_map(bo, context_gl, (uintptr_t)data->addr, size, flags)))
+ if (!(map_ptr = wined3d_bo_gl_map(wined3d_bo_gl(bo), context_gl, (uintptr_t)data->addr, size, flags)))
ERR("Failed to map bo.\n");
return map_ptr;
@@ -2782,8 +2782,9 @@ void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl *context_gl,
const struct wined3d_gl_info *gl_info;
struct wined3d_bo_gl *bo;
- if (!(bo = (struct wined3d_bo_gl *)data->buffer_object))
+ if (!data->buffer_object)
return;
+ bo = wined3d_bo_gl(data->buffer_object);
flush_bo_ranges(context_gl, wined3d_const_bo_address(data), range_count, ranges);
@@ -2816,8 +2817,8 @@ void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl,
BYTE *dst_ptr, *src_ptr;
gl_info = context_gl->gl_info;
- src_bo = (struct wined3d_bo_gl *)src->buffer_object;
- dst_bo = (struct wined3d_bo_gl *)dst->buffer_object;
+ src_bo = src->buffer_object ? wined3d_bo_gl(src->buffer_object) : NULL;
+ dst_bo = dst->buffer_object ? wined3d_bo_gl(dst->buffer_object) : NULL;
if (dst_bo && src_bo)
{
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 06387452b89..40567cf1a2c 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -2774,7 +2774,7 @@ static void *adapter_no3d_map_bo_address(struct wined3d_context *context,
{
if (data->buffer_object)
{
- ERR("Unsupported buffer object %#lx.\n", data->buffer_object);
+ ERR("Unsupported buffer object %p.\n", data->buffer_object);
return NULL;
}
@@ -2785,16 +2785,16 @@ static void adapter_no3d_unmap_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *data, unsigned int range_count, const struct wined3d_range *ranges)
{
if (data->buffer_object)
- ERR("Unsupported buffer object %#lx.\n", data->buffer_object);
+ ERR("Unsupported buffer object %p.\n", data->buffer_object);
}
static void adapter_no3d_copy_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size)
{
if (dst->buffer_object)
- ERR("Unsupported dst buffer object %#lx.\n", dst->buffer_object);
+ ERR("Unsupported dst buffer object %p.\n", dst->buffer_object);
if (src->buffer_object)
- ERR("Unsupported src buffer object %#lx.\n", src->buffer_object);
+ ERR("Unsupported src buffer object %p.\n", src->buffer_object);
if (dst->buffer_object || src->buffer_object)
return;
memcpy(dst->addr, src->addr, size);
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 8a4ca4f5781..79dc0bd06b6 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -469,7 +469,7 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i
if (data.buffer_object)
{
- GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, ((struct wined3d_bo_gl *)data.buffer_object)->id));
+ GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, wined3d_bo_gl(data.buffer_object)->id));
checkGLcall("glBindBuffer");
}
@@ -527,7 +527,7 @@ error:
if (data.buffer_object)
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
- wined3d_context_gl_reference_bo(context_gl, (struct wined3d_bo_gl *)data.buffer_object);
+ wined3d_context_gl_reference_bo(context_gl, wined3d_bo_gl(data.buffer_object));
checkGLcall("glBindBuffer");
}
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index df42f2d766b..370eaaf08e5 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -830,7 +830,7 @@ void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int su
if (locations & WINED3D_LOCATION_BUFFER)
{
data->addr = NULL;
- data->buffer_object = (uintptr_t)&sub_resource->bo;
+ data->buffer_object = &sub_resource->bo.b;
return;
}
@@ -2476,7 +2476,7 @@ static void wined3d_texture_gl_upload_data(struct wined3d_context *context,
return;
}
- bo.buffer_object = src_bo_addr->buffer_object;
+ bo.buffer_object = (struct wined3d_bo *)src_bo_addr->buffer_object;
bo.addr = (BYTE *)src_bo_addr->addr + src_box->front * src_slice_pitch;
if (dst_texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS)
{
@@ -2555,7 +2555,7 @@ static void wined3d_texture_gl_upload_data(struct wined3d_context *context,
{
if (bo.buffer_object)
{
- GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, ((struct wined3d_bo_gl *)bo.buffer_object)->id));
+ GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, wined3d_bo_gl(bo.buffer_object)->id));
checkGLcall("glBindBuffer");
}
@@ -2565,7 +2565,7 @@ static void wined3d_texture_gl_upload_data(struct wined3d_context *context,
if (bo.buffer_object)
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
- wined3d_context_gl_reference_bo(context_gl, (struct wined3d_bo_gl *)bo.buffer_object);
+ wined3d_context_gl_reference_bo(context_gl, wined3d_bo_gl(bo.buffer_object));
checkGLcall("glBindBuffer");
}
}
@@ -2585,7 +2585,7 @@ static void wined3d_texture_gl_upload_data(struct wined3d_context *context,
static void wined3d_texture_gl_download_data_slow_path(struct wined3d_texture_gl *texture_gl,
unsigned int sub_resource_idx, struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *data)
{
- struct wined3d_bo_gl *bo = (struct wined3d_bo_gl *)data->buffer_object;
+ struct wined3d_bo_gl *bo = wined3d_bo_gl(data->buffer_object);
const struct wined3d_gl_info *gl_info = context_gl->gl_info;
struct wined3d_texture_sub_resource *sub_resource;
unsigned int dst_row_pitch, dst_slice_pitch;
@@ -2824,7 +2824,7 @@ static void wined3d_texture_gl_download_data(struct wined3d_context *context,
unsigned int src_level, src_width, src_height, src_depth;
unsigned int src_row_pitch, src_slice_pitch;
const struct wined3d_format_gl *format_gl;
- struct wined3d_bo_gl *dst_bo;
+ struct wined3d_bo *dst_bo;
BOOL srgb = FALSE;
GLenum target;
@@ -2899,9 +2899,9 @@ static void wined3d_texture_gl_download_data(struct wined3d_context *context,
return;
}
- if ((dst_bo = (struct wined3d_bo_gl *)dst_bo_addr->buffer_object))
+ if ((dst_bo = dst_bo_addr->buffer_object))
{
- GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, dst_bo->id));
+ GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, wined3d_bo_gl(dst_bo)->id));
checkGLcall("glBindBuffer");
}
@@ -2925,7 +2925,7 @@ static void wined3d_texture_gl_download_data(struct wined3d_context *context,
if (dst_bo)
{
GL_EXTCALL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));
- wined3d_context_gl_reference_bo(context_gl, dst_bo);
+ wined3d_context_gl_reference_bo(context_gl, wined3d_bo_gl(dst_bo));
checkGLcall("glBindBuffer");
}
}
@@ -4729,7 +4729,7 @@ static void wined3d_texture_vk_upload_data(struct wined3d_context *context,
return;
}
- staging_bo_addr.buffer_object = (uintptr_t)&staging_bo;
+ staging_bo_addr.buffer_object = &staging_bo.b;
staging_bo_addr.addr = NULL;
if (!(map_ptr = wined3d_context_map_bo_address(context, &staging_bo_addr,
sub_resource->size, WINED3D_MAP_DISCARD | WINED3D_MAP_WRITE)))
@@ -4992,7 +4992,7 @@ static void wined3d_texture_vk_download_data(struct wined3d_context *context,
wined3d_context_vk_submit_command_buffer(context_vk, 0, NULL, NULL, 0, NULL);
wined3d_context_vk_wait_command_buffer(context_vk, src_texture_vk->image.command_buffer_id);
- staging_bo_addr.buffer_object = (uintptr_t)&staging_bo;
+ staging_bo_addr.buffer_object = &staging_bo.b;
staging_bo_addr.addr = NULL;
if (!(map_ptr = wined3d_context_map_bo_address(context, &staging_bo_addr,
sub_resource->size, WINED3D_MAP_READ)))
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c
index cbcfed4a21e..0d8001f5cbe 100644
--- a/dlls/wined3d/view.c
+++ b/dlls/wined3d/view.c
@@ -1616,7 +1616,7 @@ void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_v
src.buffer_object = 0;
src.addr = (void *)&value;
- dst.buffer_object = view->counter_bo;
+ dst.buffer_object = (struct wined3d_bo *)view->counter_bo;
dst.addr = NULL;
wined3d_context_copy_bo_address(context, &dst, &src, sizeof(uint32_t));
@@ -2092,9 +2092,9 @@ void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view
goto out;
}
- cb_source_address.buffer_object = 0;
+ cb_source_address.buffer_object = NULL;
cb_source_address.addr = (BYTE *)&constants;
- cb_destination_address.buffer_object = (UINT_PTR)&constants_bo;
+ cb_destination_address.buffer_object = &constants_bo.b;
cb_destination_address.addr = 0;
adapter_vk_copy_bo_address(&context_vk->c, &cb_destination_address, &cb_source_address, sizeof(constants));
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index a0cc553c829..c2b56a6e60c 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1621,9 +1621,9 @@ static inline struct wined3d_bo_gl *wined3d_bo_gl(struct wined3d_bo *bo)
return CONTAINING_RECORD(bo, struct wined3d_bo_gl, b);
}
-static inline GLuint wined3d_bo_gl_id(uintptr_t bo)
+static inline GLuint wined3d_bo_gl_id(struct wined3d_bo *bo)
{
- return bo ? ((struct wined3d_bo_gl *)bo)->id : 0;
+ return bo ? wined3d_bo_gl(bo)->id : 0;
}
struct wined3d_bo_user
@@ -1681,7 +1681,7 @@ void wined3d_bo_slab_vk_unmap(struct wined3d_bo_slab_vk *slab_vk,
struct wined3d_bo_address
{
- UINT_PTR buffer_object;
+ struct wined3d_bo *buffer_object;
BYTE *addr;
};
@@ -4411,6 +4411,7 @@ struct wined3d_texture
DWORD locations;
union
{
+ struct wined3d_bo b;
struct wined3d_bo_gl gl;
struct wined3d_bo_vk vk;
} bo;
--
2.33.0
2
3
[PATCH 1/2] kernel32/tests: Add tests for the current console font size
by Hugh McMaster Nov. 15, 2021
by Hugh McMaster Nov. 15, 2021
Nov. 15, 2021
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
---
dlls/kernel32/tests/console.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 0bce88716d0..7c74ddf195a 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -3437,6 +3437,7 @@ static void test_GetCurrentConsoleFontEx(HANDLE std_output)
BOOL ret;
HANDLE std_input = GetStdHandle(STD_INPUT_HANDLE);
HANDLE pipe1, pipe2;
+ COORD c;
hmod = GetModuleHandleA("kernel32.dll");
pGetCurrentConsoleFontEx = (void *)GetProcAddress(hmod, "GetCurrentConsoleFontEx");
@@ -3521,6 +3522,21 @@ static void test_GetCurrentConsoleFontEx(HANDLE std_output)
ok(cfix.dwFontSize.X == cfi.dwFontSize.X, "expected values to match\n");
ok(cfix.dwFontSize.Y == cfi.dwFontSize.Y, "expected values to match\n");
+ SetLastError(0xdeadbeef);
+ c = GetConsoleFontSize(std_output, cfix.nFont);
+ ok(c.X && c.Y, "GetConsoleFontSize failed; err = %u\n", GetLastError());
+ ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+
+ todo_wine ok(cfix.dwFontSize.X == c.X, "Font width doesn't match; got %u, expected %u\n",
+ cfix.dwFontSize.X, c.X);
+ todo_wine ok(cfix.dwFontSize.Y == c.Y, "Font height doesn't match; got %u, expected %u\n",
+ cfix.dwFontSize.Y, c.Y);
+
+ todo_wine ok(cfi.dwFontSize.X == c.X, "Font width doesn't match; got %u, expected %u\n",
+ cfi.dwFontSize.X, c.X);
+ todo_wine ok(cfi.dwFontSize.Y == c.Y, "Font height doesn't match; got %u, expected %u\n",
+ cfi.dwFontSize.Y, c.Y);
+
SetLastError(0xdeadbeef);
ret = pGetCurrentConsoleFontEx(std_output, TRUE, &cfix);
ok(ret, "got %d, expected non-zero\n", ret);
--
2.33.1
1
1
Nov. 15, 2021
Reducing verbosity and fixing typos and potentially interleaved lines.
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
v2: Only send the first patches, reduce tests verbosity even more.
dlls/dinput8/tests/driver_hid.c | 16 +++++++++-------
dlls/dinput8/tests/driver_hid.h | 11 +++++++++--
dlls/dinput8/tests/hid.c | 21 +++++++++------------
3 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/dlls/dinput8/tests/driver_hid.c b/dlls/dinput8/tests/driver_hid.c
index 45c9f3e14ab..d6f085e4f30 100644
--- a/dlls/dinput8/tests/driver_hid.c
+++ b/dlls/dinput8/tests/driver_hid.c
@@ -479,7 +479,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, TRUE );
winetest_push_context( "%s expect[%d]", expect.context, index );
- ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code );
+ ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code );
ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId );
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
ok( RtlCompareMemory( packet->reportBuffer, expect.report_buf, expect.report_len ) == expect.report_len,
@@ -503,7 +503,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, FALSE );
winetest_push_context( "%s expect[%d]", expect.context, index );
- ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code );
+ ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code );
ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId );
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
winetest_pop_context();
@@ -526,7 +526,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, TRUE );
winetest_push_context( "%s expect[%d]", expect.context, index );
- ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code );
+ ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code );
ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId );
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
ok( RtlCompareMemory( packet->reportBuffer, expect.report_buf, expect.report_len ) == expect.report_len,
@@ -550,7 +550,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, FALSE );
winetest_push_context( "%s expect[%d]", expect.context, index );
- ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code );
+ ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code );
ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId );
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
winetest_pop_context();
@@ -573,7 +573,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, TRUE );
winetest_push_context( "%s expect[%d]", expect.context, index );
- ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code );
+ ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code );
ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId );
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
ok( RtlCompareMemory( packet->reportBuffer, expect.report_buf, expect.report_len ) == expect.report_len,
@@ -586,12 +586,14 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
}
case IOCTL_HID_GET_STRING:
- todo_wine
- ok( 0, "unexpected IOCTL_HID_GET_STRING\n" );
+ {
+ static unsigned int once;
+ if (!once++) todo_wine ok( 0, "unexpected IOCTL_HID_GET_STRING\n" );
memcpy( irp->UserBuffer, L"Wine Test", sizeof(L"Wine Test") );
irp->IoStatus.Information = sizeof(L"Wine Test");
ret = STATUS_SUCCESS;
break;
+ }
default:
ok( 0, "unexpected ioctl %#x\n", code );
diff --git a/dlls/dinput8/tests/driver_hid.h b/dlls/dinput8/tests/driver_hid.h
index 4fec0e99e47..6c355760171 100644
--- a/dlls/dinput8/tests/driver_hid.h
+++ b/dlls/dinput8/tests/driver_hid.h
@@ -147,8 +147,15 @@ static inline void kvprintf( const char *format, va_list ap )
{
struct tls_data *data = get_tls_data();
IO_STATUS_BLOCK io;
- int len = vsnprintf( data->strings, sizeof(data->strings), format, ap );
- ZwWriteFile( okfile, NULL, NULL, NULL, &io, data->strings, len, NULL, NULL );
+ int len = vsnprintf( data->str_pos, sizeof(data->strings) - (data->str_pos - data->strings), format, ap );
+ data->str_pos += len;
+
+ if (len && data->str_pos[-1] == '\n')
+ {
+ ZwWriteFile( okfile, NULL, NULL, NULL, &io, data->strings,
+ strlen( data->strings ), NULL, NULL );
+ data->str_pos = data->strings;
+ }
}
static inline void WINAPIV kprintf( const char *format, ... ) __WINE_PRINTF_ATTR( 1, 2 );
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index 66e8c7c0b0d..a4721b246eb 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -594,22 +594,19 @@ static BOOL pnp_driver_start( const WCHAR *resource )
return ret || GetLastError() == ERROR_SERVICE_ALREADY_RUNNING;
}
-#define check_member_( file, line, val, exp, fmt, member ) \
- ok_( file, line )((val).member == (exp).member, "got " #member " " fmt ", expected " fmt "\n", \
- (val).member, (exp).member)
-#define check_member( val, exp, fmt, member ) \
+#define check_member_( file, line, val, exp, fmt, member ) \
+ ok_(file, line)( (val).member == (exp).member, "got " #member " " fmt "\n", (val).member )
+#define check_member( val, exp, fmt, member ) \
check_member_( __FILE__, __LINE__, val, exp, fmt, member )
-#define check_member_guid_( file, line, val, exp, member ) \
- ok_( file, line )(IsEqualGUID( &(val).member, &(exp).member ), "got " #member " %s, expected %s\n", \
- debugstr_guid( &(val).member ), debugstr_guid( &(exp).member ))
-#define check_member_guid( val, exp, member ) \
+#define check_member_guid_( file, line, val, exp, member ) \
+ ok_(file, line)( IsEqualGUID( &(val).member, &(exp).member ), "got " #member " %s\n", debugstr_guid(&(val).member) )
+#define check_member_guid( val, exp, member ) \
check_member_guid_( __FILE__, __LINE__, val, exp, member )
-#define check_member_wstr_( file, line, val, exp, member ) \
- ok_( file, line )(!wcscmp( (val).member, (exp).member ), "got " #member " %s, expected %s\n", \
- debugstr_w((val).member), debugstr_w((exp).member))
-#define check_member_wstr( val, exp, member ) \
+#define check_member_wstr_( file, line, val, exp, member ) \
+ ok_(file, line)( !wcscmp( (val).member, (exp).member ), "got " #member " %s\n", debugstr_w((val).member) )
+#define check_member_wstr( val, exp, member ) \
check_member_wstr_( __FILE__, __LINE__, val, exp, member )
#define check_hidp_caps( a, b ) check_hidp_caps_( __LINE__, a, b )
--
2.33.1
2
8
[PATCH vkd3d 1/5] vkd3d-shader/hlsl: Use "false" instead of "0" as a bool immediate.
by Giovanni Mascellani Nov. 15, 2021
by Giovanni Mascellani Nov. 15, 2021
Nov. 15, 2021
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
libs/vkd3d-shader/hlsl_codegen.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c
index 24b8205c..0ee8ab55 100644
--- a/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d-shader/hlsl_codegen.c
@@ -204,7 +204,7 @@ static bool transform_ir(struct hlsl_ctx *ctx, bool (*func)(struct hlsl_ctx *ctx
struct hlsl_block *block, void *context)
{
struct hlsl_ir_node *instr, *next;
- bool progress = 0;
+ bool progress = false;
LIST_FOR_EACH_ENTRY_SAFE(instr, next, &block->instrs, struct hlsl_ir_node, entry)
{
--
2.33.1
6
27
Nov. 15, 2021
Reducing verbosity and fixing typos and potentially interleaved lines.
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/dinput8/tests/driver_hid.c | 16 +++++++++-------
dlls/dinput8/tests/driver_hid.h | 11 +++++++++--
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/dlls/dinput8/tests/driver_hid.c b/dlls/dinput8/tests/driver_hid.c
index 45c9f3e14ab..d6f085e4f30 100644
--- a/dlls/dinput8/tests/driver_hid.c
+++ b/dlls/dinput8/tests/driver_hid.c
@@ -479,7 +479,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, TRUE );
winetest_push_context( "%s expect[%d]", expect.context, index );
- ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code );
+ ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code );
ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId );
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
ok( RtlCompareMemory( packet->reportBuffer, expect.report_buf, expect.report_len ) == expect.report_len,
@@ -503,7 +503,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, FALSE );
winetest_push_context( "%s expect[%d]", expect.context, index );
- ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code );
+ ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code );
ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId );
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
winetest_pop_context();
@@ -526,7 +526,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, TRUE );
winetest_push_context( "%s expect[%d]", expect.context, index );
- ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code );
+ ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code );
ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId );
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
ok( RtlCompareMemory( packet->reportBuffer, expect.report_buf, expect.report_len ) == expect.report_len,
@@ -550,7 +550,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, FALSE );
winetest_push_context( "%s expect[%d]", expect.context, index );
- ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code );
+ ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code );
ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId );
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
winetest_pop_context();
@@ -573,7 +573,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
expect_queue_next( &expect_queue, code, packet, &index, &expect, TRUE );
winetest_push_context( "%s expect[%d]", expect.context, index );
- ok( expect.code == code, "got %#x, expected %#x\n", expect.code, code );
+ ok( code == expect.code, "got %#x, expected %#x\n", code, expect.code );
ok( packet->reportId == expect.report_id, "got id %u\n", packet->reportId );
ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
ok( RtlCompareMemory( packet->reportBuffer, expect.report_buf, expect.report_len ) == expect.report_len,
@@ -586,12 +586,14 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
}
case IOCTL_HID_GET_STRING:
- todo_wine
- ok( 0, "unexpected IOCTL_HID_GET_STRING\n" );
+ {
+ static unsigned int once;
+ if (!once++) todo_wine ok( 0, "unexpected IOCTL_HID_GET_STRING\n" );
memcpy( irp->UserBuffer, L"Wine Test", sizeof(L"Wine Test") );
irp->IoStatus.Information = sizeof(L"Wine Test");
ret = STATUS_SUCCESS;
break;
+ }
default:
ok( 0, "unexpected ioctl %#x\n", code );
diff --git a/dlls/dinput8/tests/driver_hid.h b/dlls/dinput8/tests/driver_hid.h
index 4fec0e99e47..6c355760171 100644
--- a/dlls/dinput8/tests/driver_hid.h
+++ b/dlls/dinput8/tests/driver_hid.h
@@ -147,8 +147,15 @@ static inline void kvprintf( const char *format, va_list ap )
{
struct tls_data *data = get_tls_data();
IO_STATUS_BLOCK io;
- int len = vsnprintf( data->strings, sizeof(data->strings), format, ap );
- ZwWriteFile( okfile, NULL, NULL, NULL, &io, data->strings, len, NULL, NULL );
+ int len = vsnprintf( data->str_pos, sizeof(data->strings) - (data->str_pos - data->strings), format, ap );
+ data->str_pos += len;
+
+ if (len && data->str_pos[-1] == '\n')
+ {
+ ZwWriteFile( okfile, NULL, NULL, NULL, &io, data->strings,
+ strlen( data->strings ), NULL, NULL );
+ data->str_pos = data->strings;
+ }
}
static inline void WINAPIV kprintf( const char *format, ... ) __WINE_PRINTF_ATTR( 1, 2 );
--
2.33.1
2
13
Nov. 14, 2021
1
3
Nov. 14, 2021
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/msdasql/session.c | 18 ++++++++++++++++--
dlls/msdasql/tests/provider.c | 16 ++++++++++++++--
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/dlls/msdasql/session.c b/dlls/msdasql/session.c
index 6e9c4b680e9..7c5e102c122 100644
--- a/dlls/msdasql/session.c
+++ b/dlls/msdasql/session.c
@@ -426,6 +426,7 @@ struct msdasql_rowset
IColumnsInfo IColumnsInfo_iface;
IAccessor IAccessor_iface;
IColumnsRowset IColumnsRowset_iface;
+ IUnknown *caller;
LONG refs;
};
@@ -524,6 +525,10 @@ static ULONG WINAPI msdasql_rowset_Release(IRowset *iface)
if (!refs)
{
TRACE( "destroying %p\n", rowset );
+
+ if (rowset->caller)
+ IUnknown_Release(rowset->caller);
+
heap_free( rowset );
}
return refs;
@@ -618,8 +623,16 @@ static HRESULT WINAPI rowset_info_GetSpecification(IRowsetInfo *iface, REFIID ri
IUnknown **specification)
{
struct msdasql_rowset *rowset = impl_from_IRowsetInfo( iface );
- FIXME("%p, %s, %p\n", rowset, debugstr_guid(riid), specification);
- return E_NOTIMPL;
+
+ TRACE("%p, %s, %p\n", rowset, debugstr_guid(riid), specification);
+
+ if (!specification)
+ return E_INVALIDARG;
+
+ if (!rowset->caller)
+ return S_FALSE;
+
+ return IUnknown_QueryInterface(rowset->caller, riid, (void**)specification);;
}
struct IRowsetInfoVtbl rowset_info_vtbl =
@@ -798,6 +811,7 @@ static HRESULT WINAPI command_Execute(ICommandText *iface, IUnknown *outer, REFI
msrowset->IAccessor_iface.lpVtbl = &accessor_vtbl;
msrowset->IColumnsRowset_iface.lpVtbl = &columnrs_rs_vtbl;
msrowset->refs = 1;
+ ICommandText_QueryInterface(iface, &IID_IUnknown, (void**)&msrowset->caller);
if (affected)
*affected = 0; /* FIXME */
diff --git a/dlls/msdasql/tests/provider.c b/dlls/msdasql/tests/provider.c
index 353e2ec58c8..b0e13b72589 100644
--- a/dlls/msdasql/tests/provider.c
+++ b/dlls/msdasql/tests/provider.c
@@ -293,17 +293,29 @@ static void test_command_dbsession(IUnknown *cmd, IUnknown *session)
ICommandText_Release(comand_text);
}
-static void test_rowset_interfaces(IRowset *rowset)
+static void test_rowset_interfaces(IRowset *rowset, ICommandText *commandtext)
{
IRowsetInfo *info;
IColumnsInfo *col_info;
IColumnsRowset *col_rs;
IAccessor *accessor;
+ ICommandText *specification = NULL;
IUnknown *unk;
HRESULT hr;
hr = IRowset_QueryInterface(rowset, &IID_IRowsetInfo, (void**)&info);
ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IRowsetInfo_GetSpecification(info, &IID_ICommandText, NULL);
+ ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+
+ hr = IRowsetInfo_GetSpecification(info, &IID_ICommandText, (IUnknown**)&specification);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ if (specification)
+ {
+ ok(commandtext == specification, "got 0x%08x\n", hr);
+ ICommandText_Release(specification);
+ }
IRowsetInfo_Release(info);
hr = IRowset_QueryInterface(rowset, &IID_IColumnsInfo, (void**)&col_info);
@@ -364,7 +376,7 @@ static void test_command_rowset(IUnknown *cmd)
hr = IUnknown_QueryInterface(unk, &IID_IRowset, (void**)&rowset);
ok(hr == S_OK, "got 0x%08x\n", hr);
- test_rowset_interfaces(rowset);
+ test_rowset_interfaces(rowset, comand_text);
IRowset_Release(rowset);
IUnknown_Release(unk);
--
2.33.0
1
0