winecoreaudio: Move get_capture_buffer to the unixlib.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e9b9229754
commit
d9a2ae562c
|
@ -1402,6 +1402,61 @@ static NTSTATUS release_render_buffer(void *args)
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS get_capture_buffer(void *args)
|
||||
{
|
||||
struct get_capture_buffer_params *params = args;
|
||||
struct coreaudio_stream *stream = params->stream;
|
||||
UINT32 chunk_bytes, chunk_frames;
|
||||
LARGE_INTEGER stamp, freq;
|
||||
|
||||
OSSpinLockLock(&stream->lock);
|
||||
|
||||
if(stream->getbuf_last){
|
||||
params->result = AUDCLNT_E_OUT_OF_ORDER;
|
||||
goto end;
|
||||
}
|
||||
|
||||
capture_resample(stream);
|
||||
|
||||
*params->frames = 0;
|
||||
|
||||
if(stream->held_frames < stream->period_frames){
|
||||
params->result = AUDCLNT_S_BUFFER_EMPTY;
|
||||
goto end;
|
||||
}
|
||||
|
||||
*params->flags = 0;
|
||||
chunk_frames = stream->bufsize_frames - stream->lcl_offs_frames;
|
||||
if(chunk_frames < stream->period_frames){
|
||||
chunk_bytes = chunk_frames * stream->fmt->nBlockAlign;
|
||||
if(!stream->tmp_buffer){
|
||||
stream->tmp_buffer_size = stream->period_frames * stream->fmt->nBlockAlign;
|
||||
NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, 0,
|
||||
&stream->tmp_buffer_size, MEM_COMMIT, PAGE_READWRITE);
|
||||
}
|
||||
*params->data = stream->tmp_buffer;
|
||||
memcpy(*params->data, stream->local_buffer + stream->lcl_offs_frames * stream->fmt->nBlockAlign,
|
||||
chunk_bytes);
|
||||
memcpy(*params->data + chunk_bytes, stream->local_buffer,
|
||||
stream->period_frames * stream->fmt->nBlockAlign - chunk_bytes);
|
||||
}else
|
||||
*params->data = stream->local_buffer + stream->lcl_offs_frames * stream->fmt->nBlockAlign;
|
||||
|
||||
stream->getbuf_last = *params->frames = stream->period_frames;
|
||||
|
||||
if(params->devpos)
|
||||
*params->devpos = stream->written_frames;
|
||||
if(params->qpcpos){ /* fixme: qpc of recording time */
|
||||
NtQueryPerformanceCounter(&stamp, &freq);
|
||||
*params->qpcpos = (stamp.QuadPart * (INT64)10000000) / freq.QuadPart;
|
||||
}
|
||||
params->result = S_OK;
|
||||
|
||||
end:
|
||||
OSSpinLockUnlock(&stream->lock);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
unixlib_entry_t __wine_unix_call_funcs[] =
|
||||
{
|
||||
get_endpoint_ids,
|
||||
|
@ -1412,6 +1467,7 @@ unixlib_entry_t __wine_unix_call_funcs[] =
|
|||
reset,
|
||||
get_render_buffer,
|
||||
release_render_buffer,
|
||||
get_capture_buffer,
|
||||
get_mix_format,
|
||||
is_format_supported,
|
||||
get_buffer_size,
|
||||
|
|
|
@ -1359,7 +1359,7 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface,
|
|||
UINT64 *qpcpos)
|
||||
{
|
||||
ACImpl *This = impl_from_IAudioCaptureClient(iface);
|
||||
UINT32 chunk_bytes, chunk_frames;
|
||||
struct get_capture_buffer_params params;
|
||||
|
||||
TRACE("(%p)->(%p, %p, %p, %p, %p)\n", This, data, frames, flags,
|
||||
devpos, qpcpos);
|
||||
|
@ -1372,51 +1372,14 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface,
|
|||
if(!frames || !flags)
|
||||
return E_POINTER;
|
||||
|
||||
OSSpinLockLock(&This->stream->lock);
|
||||
|
||||
if(This->stream->getbuf_last){
|
||||
OSSpinLockUnlock(&This->stream->lock);
|
||||
return AUDCLNT_E_OUT_OF_ORDER;
|
||||
}
|
||||
|
||||
capture_resample(This);
|
||||
|
||||
if(This->stream->held_frames < This->stream->period_frames){
|
||||
*frames = 0;
|
||||
OSSpinLockUnlock(&This->stream->lock);
|
||||
return AUDCLNT_S_BUFFER_EMPTY;
|
||||
}
|
||||
|
||||
*flags = 0;
|
||||
|
||||
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_size = This->stream->period_frames * This->stream->fmt->nBlockAlign;
|
||||
NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&This->stream->tmp_buffer, 0,
|
||||
&This->stream->tmp_buffer_size, MEM_COMMIT, PAGE_READWRITE);
|
||||
}
|
||||
*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->stream->local_buffer + This->stream->lcl_offs_frames * This->stream->fmt->nBlockAlign;
|
||||
|
||||
This->stream->getbuf_last = *frames = This->stream->period_frames;
|
||||
|
||||
if(devpos)
|
||||
*devpos = This->stream->written_frames;
|
||||
if(qpcpos){ /* fixme: qpc of recording time */
|
||||
LARGE_INTEGER stamp, freq;
|
||||
QueryPerformanceCounter(&stamp);
|
||||
QueryPerformanceFrequency(&freq);
|
||||
*qpcpos = (stamp.QuadPart * (INT64)10000000) / freq.QuadPart;
|
||||
}
|
||||
|
||||
OSSpinLockUnlock(&This->stream->lock);
|
||||
|
||||
return S_OK;
|
||||
params.stream = This->stream;
|
||||
params.data = data;
|
||||
params.frames = frames;
|
||||
params.flags = flags;
|
||||
params.devpos = devpos;
|
||||
params.qpcpos = qpcpos;
|
||||
UNIX_CALL(get_capture_buffer, ¶ms);
|
||||
return params.result;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer(
|
||||
|
|
|
@ -109,6 +109,17 @@ struct release_render_buffer_params
|
|||
HRESULT result;
|
||||
};
|
||||
|
||||
struct get_capture_buffer_params
|
||||
{
|
||||
struct coreaudio_stream *stream;
|
||||
HRESULT result;
|
||||
BYTE **data;
|
||||
UINT32 *frames;
|
||||
DWORD *flags;
|
||||
UINT64 *devpos;
|
||||
UINT64 *qpcpos;
|
||||
};
|
||||
|
||||
struct get_mix_format_params
|
||||
{
|
||||
EDataFlow flow;
|
||||
|
@ -158,6 +169,7 @@ enum unix_funcs
|
|||
unix_reset,
|
||||
unix_get_render_buffer,
|
||||
unix_release_render_buffer,
|
||||
unix_get_capture_buffer,
|
||||
unix_get_mix_format,
|
||||
unix_is_format_supported,
|
||||
unix_get_buffer_size,
|
||||
|
|
Loading…
Reference in New Issue