Commit 7a5a2db1 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

wineoss: Move get_render_buffer to the unixlib.

parent 9ced8cc9
......@@ -1251,9 +1251,7 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
UINT32 frames, BYTE **data)
{
ACImpl *This = impl_from_IAudioRenderClient(iface);
struct oss_stream *stream = This->stream;
UINT32 write_pos;
SIZE_T size;
struct get_render_buffer_params params;
TRACE("(%p)->(%u, %p)\n", This, frames, data);
......@@ -1262,53 +1260,12 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
*data = NULL;
oss_lock(stream);
if(stream->getbuf_last){
oss_unlock(stream);
return AUDCLNT_E_OUT_OF_ORDER;
}
if(!frames){
oss_unlock(stream);
return S_OK;
}
if(stream->held_frames + frames > stream->bufsize_frames){
oss_unlock(stream);
return AUDCLNT_E_BUFFER_TOO_LARGE;
}
write_pos =
(stream->lcl_offs_frames + stream->held_frames) % stream->bufsize_frames;
if(write_pos + frames > stream->bufsize_frames){
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;
stream->getbuf_last = -frames;
}else{
*data = stream->local_buffer + write_pos * stream->fmt->nBlockAlign;
stream->getbuf_last = frames;
}
silence_buffer(stream, *data, frames);
oss_unlock(stream);
params.stream = This->stream;
params.frames = frames;
params.data = data;
OSS_CALL(get_render_buffer, &params);
return S_OK;
return params.result;
}
static void oss_wrap_buffer(struct oss_stream *stream, BYTE *buffer, UINT32 written_frames)
......
......@@ -876,6 +876,54 @@ static NTSTATUS timer_loop(void *args)
return STATUS_SUCCESS;
}
static NTSTATUS get_render_buffer(void *args)
{
struct get_render_buffer_params *params = args;
struct oss_stream *stream = params->stream;
UINT32 write_pos, frames = params->frames;
BYTE **data = params->data;
SIZE_T size;
oss_lock(stream);
if(stream->getbuf_last)
return oss_unlock_result(stream, &params->result, AUDCLNT_E_OUT_OF_ORDER);
if(!frames)
return oss_unlock_result(stream, &params->result, S_OK);
if(stream->held_frames + frames > stream->bufsize_frames)
return oss_unlock_result(stream, &params->result, AUDCLNT_E_BUFFER_TOO_LARGE);
write_pos =
(stream->lcl_offs_frames + stream->held_frames) % stream->bufsize_frames;
if(write_pos + frames > stream->bufsize_frames){
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, &params->result, E_OUTOFMEMORY);
}
stream->tmp_buffer_frames = frames;
}
*data = stream->tmp_buffer;
stream->getbuf_last = -frames;
}else{
*data = stream->local_buffer + write_pos * stream->fmt->nBlockAlign;
stream->getbuf_last = frames;
}
silence_buffer(stream, *data, frames);
return oss_unlock_result(stream, &params->result, S_OK);
}
static NTSTATUS is_format_supported(void *args)
{
struct is_format_supported_params *params = args;
......@@ -1073,6 +1121,7 @@ unixlib_entry_t __wine_unix_call_funcs[] =
stop,
reset,
timer_loop,
get_render_buffer,
is_format_supported,
get_mix_format,
get_buffer_size,
......
......@@ -113,6 +113,14 @@ struct timer_loop_params
struct oss_stream *stream;
};
struct get_render_buffer_params
{
struct oss_stream *stream;
UINT32 frames;
HRESULT result;
BYTE **data;
};
struct is_format_supported_params
{
const char *device;
......@@ -169,6 +177,7 @@ enum oss_funcs
oss_stop,
oss_reset,
oss_timer_loop,
oss_get_render_buffer,
oss_is_format_supported,
oss_get_mix_format,
oss_get_buffer_size,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment