wineoss: Move get_position 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
4e32993717
commit
9fa0544819
|
@ -1442,52 +1442,19 @@ static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
|
|||
UINT64 *qpctime)
|
||||
{
|
||||
ACImpl *This = impl_from_IAudioClock(iface);
|
||||
struct oss_stream *stream = This->stream;
|
||||
struct get_position_params params;
|
||||
|
||||
TRACE("(%p)->(%p, %p)\n", This, pos, qpctime);
|
||||
|
||||
if(!pos)
|
||||
return E_POINTER;
|
||||
|
||||
oss_lock(stream);
|
||||
params.stream = This->stream;
|
||||
params.position = pos;
|
||||
params.qpctime = qpctime;
|
||||
OSS_CALL(get_position, ¶ms);
|
||||
|
||||
if(stream->flow == eRender){
|
||||
*pos = stream->written_frames - stream->held_frames;
|
||||
if(*pos < stream->last_pos_frames)
|
||||
*pos = stream->last_pos_frames;
|
||||
}else if(stream->flow == eCapture){
|
||||
audio_buf_info bi;
|
||||
UINT32 held;
|
||||
|
||||
if(ioctl(stream->fd, SNDCTL_DSP_GETISPACE, &bi) < 0){
|
||||
TRACE("GETISPACE failed: %d (%s)\n", errno, strerror(errno));
|
||||
held = 0;
|
||||
}else{
|
||||
if(bi.bytes <= bi.fragsize)
|
||||
held = 0;
|
||||
else
|
||||
held = bi.bytes / stream->fmt->nBlockAlign;
|
||||
}
|
||||
|
||||
*pos = stream->written_frames + held;
|
||||
}
|
||||
|
||||
stream->last_pos_frames = *pos;
|
||||
|
||||
TRACE("returning: %s\n", wine_dbgstr_longlong(*pos));
|
||||
if(stream->share == AUDCLNT_SHAREMODE_SHARED)
|
||||
*pos *= stream->fmt->nBlockAlign;
|
||||
|
||||
oss_unlock(stream);
|
||||
|
||||
if(qpctime){
|
||||
LARGE_INTEGER stamp, freq;
|
||||
QueryPerformanceCounter(&stamp);
|
||||
QueryPerformanceFrequency(&freq);
|
||||
*qpctime = (stamp.QuadPart * (INT64)10000000) / freq.QuadPart;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
return params.result;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI AudioClock_GetCharacteristics(IAudioClock *iface,
|
||||
|
|
|
@ -1272,6 +1272,50 @@ static NTSTATUS get_frequency(void *args)
|
|||
return oss_unlock_result(stream, ¶ms->result, S_OK);
|
||||
}
|
||||
|
||||
static NTSTATUS get_position(void *args)
|
||||
{
|
||||
struct get_position_params *params = args;
|
||||
struct oss_stream *stream = params->stream;
|
||||
UINT64 *pos = params->position, *qpctime = params->qpctime;
|
||||
|
||||
oss_lock(stream);
|
||||
|
||||
if(stream->flow == eRender){
|
||||
*pos = stream->written_frames - stream->held_frames;
|
||||
if(*pos < stream->last_pos_frames)
|
||||
*pos = stream->last_pos_frames;
|
||||
}else if(stream->flow == eCapture){
|
||||
audio_buf_info bi;
|
||||
UINT32 held;
|
||||
|
||||
if(ioctl(stream->fd, SNDCTL_DSP_GETISPACE, &bi) < 0){
|
||||
TRACE("GETISPACE failed: %d (%s)\n", errno, strerror(errno));
|
||||
held = 0;
|
||||
}else{
|
||||
if(bi.bytes <= bi.fragsize)
|
||||
held = 0;
|
||||
else
|
||||
held = bi.bytes / stream->fmt->nBlockAlign;
|
||||
}
|
||||
|
||||
*pos = stream->written_frames + held;
|
||||
}
|
||||
|
||||
stream->last_pos_frames = *pos;
|
||||
|
||||
TRACE("returning: %s\n", wine_dbgstr_longlong(*pos));
|
||||
if(stream->share == AUDCLNT_SHAREMODE_SHARED)
|
||||
*pos *= stream->fmt->nBlockAlign;
|
||||
|
||||
if(qpctime){
|
||||
LARGE_INTEGER stamp, freq;
|
||||
NtQueryPerformanceCounter(&stamp, &freq);
|
||||
*qpctime = (stamp.QuadPart * (INT64)10000000) / freq.QuadPart;
|
||||
}
|
||||
|
||||
return oss_unlock_result(stream, ¶ms->result, S_OK);
|
||||
}
|
||||
|
||||
static NTSTATUS set_event_handle(void *args)
|
||||
{
|
||||
struct set_event_handle_params *params = args;
|
||||
|
@ -1313,5 +1357,6 @@ unixlib_entry_t __wine_unix_call_funcs[] =
|
|||
get_current_padding,
|
||||
get_next_packet_size,
|
||||
get_frequency,
|
||||
get_position,
|
||||
set_event_handle,
|
||||
};
|
||||
|
|
|
@ -200,6 +200,14 @@ struct get_frequency_params
|
|||
UINT64 *frequency;
|
||||
};
|
||||
|
||||
struct get_position_params
|
||||
{
|
||||
struct oss_stream *stream;
|
||||
HRESULT result;
|
||||
UINT64 *position;
|
||||
UINT64 *qpctime;
|
||||
};
|
||||
|
||||
struct set_event_handle_params
|
||||
{
|
||||
struct oss_stream *stream;
|
||||
|
@ -228,6 +236,7 @@ enum oss_funcs
|
|||
oss_get_current_padding,
|
||||
oss_get_next_packet_size,
|
||||
oss_get_frequency,
|
||||
oss_get_position,
|
||||
oss_set_event_handle,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue