[PATCH 4/5] wineoss: Move get_capture_buffer to the unixlib.
Huw Davies
huw at codeweavers.com
Fri Apr 15 01:59:57 CDT 2022
Signed-off-by: Huw Davies <huw at codeweavers.com>
---
dlls/wineoss.drv/mmdevdrv.c | 71 +++++--------------------------------
dlls/wineoss.drv/oss.c | 67 ++++++++++++++++++++++++++++++++++
dlls/wineoss.drv/unixlib.h | 12 +++++++
3 files changed, 88 insertions(+), 62 deletions(-)
diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c
index d719922c2b7..cc9d22d21d0 100644
--- a/dlls/wineoss.drv/mmdevdrv.c
+++ b/dlls/wineoss.drv/mmdevdrv.c
@@ -1321,8 +1321,7 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface,
UINT64 *qpcpos)
{
ACImpl *This = impl_from_IAudioCaptureClient(iface);
- struct oss_stream *stream = This->stream;
- SIZE_T size;
+ struct get_capture_buffer_params params;
TRACE("(%p)->(%p, %p, %p, %p, %p)\n", This, data, frames, flags,
devpos, qpcpos);
@@ -1335,67 +1334,15 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface,
if(!frames || !flags)
return E_POINTER;
- oss_lock(stream);
-
- if(stream->getbuf_last){
- oss_unlock(stream);
- return AUDCLNT_E_OUT_OF_ORDER;
- }
-
- if(stream->held_frames < stream->period_frames){
- *frames = 0;
- oss_unlock(stream);
- return AUDCLNT_S_BUFFER_EMPTY;
- }
-
- *flags = 0;
-
- *frames = stream->period_frames;
-
- if(stream->lcl_offs_frames + *frames > stream->bufsize_frames){
- UINT32 chunk_bytes, offs_bytes, frames_bytes;
- if(stream->tmp_buffer_frames < *frames){
- if(stream->tmp_buffer){
- size = 0;
- NtFreeVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, &size, MEM_RELEASE);
- stream->tmp_buffer = NULL;
- }
- size = *frames * stream->fmt->nBlockAlign;
- if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, 0, &size,
- MEM_COMMIT, PAGE_READWRITE)){
- stream->tmp_buffer_frames = 0;
- oss_unlock(stream);
- return E_OUTOFMEMORY;
- }
- stream->tmp_buffer_frames = *frames;
- }
-
- *data = stream->tmp_buffer;
- chunk_bytes = (stream->bufsize_frames - stream->lcl_offs_frames) *
- stream->fmt->nBlockAlign;
- offs_bytes = stream->lcl_offs_frames * stream->fmt->nBlockAlign;
- frames_bytes = *frames * stream->fmt->nBlockAlign;
- memcpy(stream->tmp_buffer, stream->local_buffer + offs_bytes, chunk_bytes);
- memcpy(stream->tmp_buffer + chunk_bytes, stream->local_buffer,
- frames_bytes - chunk_bytes);
- }else
- *data = stream->local_buffer +
- stream->lcl_offs_frames * stream->fmt->nBlockAlign;
-
- stream->getbuf_last = *frames;
-
- if(devpos)
- *devpos = stream->written_frames;
- if(qpcpos){
- LARGE_INTEGER stamp, freq;
- QueryPerformanceCounter(&stamp);
- QueryPerformanceFrequency(&freq);
- *qpcpos = (stamp.QuadPart * (INT64)10000000) / freq.QuadPart;
- }
-
- oss_unlock(stream);
+ params.stream = This->stream;
+ params.data = data;
+ params.frames = frames;
+ params.flags = flags;
+ params.devpos = devpos;
+ params.qpcpos = qpcpos;
+ OSS_CALL(get_capture_buffer, ¶ms);
- return *frames ? S_OK : AUDCLNT_S_BUFFER_EMPTY;
+ return params.result;
}
static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer(
diff --git a/dlls/wineoss.drv/oss.c b/dlls/wineoss.drv/oss.c
index 4a568f51667..2e811f9b424 100644
--- a/dlls/wineoss.drv/oss.c
+++ b/dlls/wineoss.drv/oss.c
@@ -982,6 +982,72 @@ static NTSTATUS release_render_buffer(void *args)
return oss_unlock_result(stream, ¶ms->result, S_OK);
}
+static NTSTATUS get_capture_buffer(void *args)
+{
+ struct get_capture_buffer_params *params = args;
+ struct oss_stream *stream = params->stream;
+ UINT64 *devpos = params->devpos, *qpcpos = params->qpcpos;
+ UINT32 *frames = params->frames;
+ UINT *flags = params->flags;
+ BYTE **data = params->data;
+ SIZE_T size;
+
+ oss_lock(stream);
+
+ if(stream->getbuf_last)
+ return oss_unlock_result(stream, ¶ms->result, AUDCLNT_E_OUT_OF_ORDER);
+
+ if(stream->held_frames < stream->period_frames){
+ *frames = 0;
+ return oss_unlock_result(stream, ¶ms->result, AUDCLNT_S_BUFFER_EMPTY);
+ }
+
+ *flags = 0;
+
+ *frames = stream->period_frames;
+
+ if(stream->lcl_offs_frames + *frames > stream->bufsize_frames){
+ UINT32 chunk_bytes, offs_bytes, frames_bytes;
+ if(stream->tmp_buffer_frames < *frames){
+ if(stream->tmp_buffer){
+ size = 0;
+ NtFreeVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, &size, MEM_RELEASE);
+ stream->tmp_buffer = NULL;
+ }
+ size = *frames * stream->fmt->nBlockAlign;
+ if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, 0, &size,
+ MEM_COMMIT, PAGE_READWRITE)){
+ stream->tmp_buffer_frames = 0;
+ return oss_unlock_result(stream, ¶ms->result, E_OUTOFMEMORY);
+ }
+ stream->tmp_buffer_frames = *frames;
+ }
+
+ *data = stream->tmp_buffer;
+ chunk_bytes = (stream->bufsize_frames - stream->lcl_offs_frames) *
+ stream->fmt->nBlockAlign;
+ offs_bytes = stream->lcl_offs_frames * stream->fmt->nBlockAlign;
+ frames_bytes = *frames * stream->fmt->nBlockAlign;
+ memcpy(stream->tmp_buffer, stream->local_buffer + offs_bytes, chunk_bytes);
+ memcpy(stream->tmp_buffer + chunk_bytes, stream->local_buffer,
+ frames_bytes - chunk_bytes);
+ }else
+ *data = stream->local_buffer +
+ stream->lcl_offs_frames * stream->fmt->nBlockAlign;
+
+ stream->getbuf_last = *frames;
+
+ if(devpos)
+ *devpos = stream->written_frames;
+ if(qpcpos){
+ LARGE_INTEGER stamp, freq;
+ NtQueryPerformanceCounter(&stamp, &freq);
+ *qpcpos = (stamp.QuadPart * (INT64)10000000) / freq.QuadPart;
+ }
+
+ return oss_unlock_result(stream, ¶ms->result, *frames ? S_OK : AUDCLNT_S_BUFFER_EMPTY);
+}
+
static NTSTATUS is_format_supported(void *args)
{
struct is_format_supported_params *params = args;
@@ -1181,6 +1247,7 @@ unixlib_entry_t __wine_unix_call_funcs[] =
timer_loop,
get_render_buffer,
release_render_buffer,
+ get_capture_buffer,
is_format_supported,
get_mix_format,
get_buffer_size,
diff --git a/dlls/wineoss.drv/unixlib.h b/dlls/wineoss.drv/unixlib.h
index e7c3a91691d..ca6d1d69de3 100644
--- a/dlls/wineoss.drv/unixlib.h
+++ b/dlls/wineoss.drv/unixlib.h
@@ -129,6 +129,17 @@ struct release_render_buffer_params
HRESULT result;
};
+struct get_capture_buffer_params
+{
+ struct oss_stream *stream;
+ HRESULT result;
+ BYTE **data;
+ UINT32 *frames;
+ UINT *flags;
+ UINT64 *devpos;
+ UINT64 *qpcpos;
+};
+
struct is_format_supported_params
{
const char *device;
@@ -187,6 +198,7 @@ enum oss_funcs
oss_timer_loop,
oss_get_render_buffer,
oss_release_render_buffer,
+ oss_get_capture_buffer,
oss_is_format_supported,
oss_get_mix_format,
oss_get_buffer_size,
--
2.25.1
More information about the wine-devel
mailing list