winealsa: Move get_render_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
4ed93b5380
commit
d6633f54ab
|
@ -1587,6 +1587,53 @@ static NTSTATUS timer_loop(void *args)
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NTSTATUS get_render_buffer(void *args)
|
||||||
|
{
|
||||||
|
struct get_render_buffer_params *params = args;
|
||||||
|
struct alsa_stream *stream = params->stream;
|
||||||
|
UINT32 write_pos, frames = params->frames;
|
||||||
|
SIZE_T size;
|
||||||
|
|
||||||
|
alsa_lock(stream);
|
||||||
|
|
||||||
|
if(stream->getbuf_last)
|
||||||
|
return alsa_unlock_result(stream, ¶ms->result, AUDCLNT_E_OUT_OF_ORDER);
|
||||||
|
|
||||||
|
if(!frames)
|
||||||
|
return alsa_unlock_result(stream, ¶ms->result, S_OK);
|
||||||
|
|
||||||
|
/* held_frames == GetCurrentPadding_nolock(); */
|
||||||
|
if(stream->held_frames + frames > stream->bufsize_frames)
|
||||||
|
return alsa_unlock_result(stream, ¶ms->result, AUDCLNT_E_BUFFER_TOO_LARGE);
|
||||||
|
|
||||||
|
write_pos = stream->wri_offs_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 alsa_unlock_result(stream, ¶ms->result, E_OUTOFMEMORY);
|
||||||
|
}
|
||||||
|
stream->tmp_buffer_frames = frames;
|
||||||
|
}
|
||||||
|
*params->data = stream->tmp_buffer;
|
||||||
|
stream->getbuf_last = -frames;
|
||||||
|
}else{
|
||||||
|
*params->data = stream->local_buffer + write_pos * stream->fmt->nBlockAlign;
|
||||||
|
stream->getbuf_last = frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
silence_buffer(stream, *params->data, frames);
|
||||||
|
|
||||||
|
return alsa_unlock_result(stream, ¶ms->result, S_OK);
|
||||||
|
}
|
||||||
|
|
||||||
static NTSTATUS is_format_supported(void *args)
|
static NTSTATUS is_format_supported(void *args)
|
||||||
{
|
{
|
||||||
struct is_format_supported_params *params = args;
|
struct is_format_supported_params *params = args;
|
||||||
|
@ -1918,6 +1965,7 @@ unixlib_entry_t __wine_unix_call_funcs[] =
|
||||||
stop,
|
stop,
|
||||||
reset,
|
reset,
|
||||||
timer_loop,
|
timer_loop,
|
||||||
|
get_render_buffer,
|
||||||
is_format_supported,
|
is_format_supported,
|
||||||
get_mix_format,
|
get_mix_format,
|
||||||
get_buffer_size,
|
get_buffer_size,
|
||||||
|
|
|
@ -1297,9 +1297,7 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
|
||||||
UINT32 frames, BYTE **data)
|
UINT32 frames, BYTE **data)
|
||||||
{
|
{
|
||||||
ACImpl *This = impl_from_IAudioRenderClient(iface);
|
ACImpl *This = impl_from_IAudioRenderClient(iface);
|
||||||
struct alsa_stream *stream = This->stream;
|
struct get_render_buffer_params params;
|
||||||
UINT32 write_pos;
|
|
||||||
SIZE_T size;
|
|
||||||
|
|
||||||
TRACE("(%p)->(%u, %p)\n", This, frames, data);
|
TRACE("(%p)->(%u, %p)\n", This, frames, data);
|
||||||
|
|
||||||
|
@ -1307,53 +1305,13 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
|
||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
*data = NULL;
|
*data = NULL;
|
||||||
|
|
||||||
alsa_lock(stream);
|
params.stream = This->stream;
|
||||||
|
params.frames = frames;
|
||||||
|
params.data = data;
|
||||||
|
|
||||||
if(stream->getbuf_last){
|
ALSA_CALL(get_render_buffer, ¶ms);
|
||||||
alsa_unlock(stream);
|
|
||||||
return AUDCLNT_E_OUT_OF_ORDER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!frames){
|
return params.result;
|
||||||
alsa_unlock(stream);
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* held_frames == GetCurrentPadding_nolock(); */
|
|
||||||
if(stream->held_frames + frames > stream->bufsize_frames){
|
|
||||||
alsa_unlock(stream);
|
|
||||||
return AUDCLNT_E_BUFFER_TOO_LARGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
write_pos = stream->wri_offs_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;
|
|
||||||
alsa_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);
|
|
||||||
|
|
||||||
alsa_unlock(stream);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void alsa_wrap_buffer(struct alsa_stream *stream, BYTE *buffer, UINT32 written_frames)
|
static void alsa_wrap_buffer(struct alsa_stream *stream, BYTE *buffer, UINT32 written_frames)
|
||||||
|
|
|
@ -114,6 +114,14 @@ struct timer_loop_params
|
||||||
struct alsa_stream *stream;
|
struct alsa_stream *stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct get_render_buffer_params
|
||||||
|
{
|
||||||
|
struct alsa_stream *stream;
|
||||||
|
UINT32 frames;
|
||||||
|
HRESULT result;
|
||||||
|
BYTE **data;
|
||||||
|
};
|
||||||
|
|
||||||
struct is_format_supported_params
|
struct is_format_supported_params
|
||||||
{
|
{
|
||||||
const char *alsa_name;
|
const char *alsa_name;
|
||||||
|
@ -169,6 +177,7 @@ enum alsa_funcs
|
||||||
alsa_stop,
|
alsa_stop,
|
||||||
alsa_reset,
|
alsa_reset,
|
||||||
alsa_timer_loop,
|
alsa_timer_loop,
|
||||||
|
alsa_get_render_buffer,
|
||||||
alsa_is_format_supported,
|
alsa_is_format_supported,
|
||||||
alsa_get_mix_format,
|
alsa_get_mix_format,
|
||||||
alsa_get_buffer_size,
|
alsa_get_buffer_size,
|
||||||
|
|
Loading…
Reference in New Issue