[PATCH 3/5] wineoss: Move get_position to the unixlib.

Huw Davies huw at codeweavers.com
Fri Apr 15 15:40:41 CDT 2022


Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/wineoss.drv/mmdevdrv.c | 45 +++++--------------------------------
 dlls/wineoss.drv/oss.c      | 45 +++++++++++++++++++++++++++++++++++++
 dlls/wineoss.drv/unixlib.h  |  9 ++++++++
 3 files changed, 60 insertions(+), 39 deletions(-)

diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c
index 6498a4750d4..c921b4975c9 100644
--- a/dlls/wineoss.drv/mmdevdrv.c
+++ b/dlls/wineoss.drv/mmdevdrv.c
@@ -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);
-
-    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;
-    }
+    params.stream = This->stream;
+    params.position = pos;
+    params.qpctime = qpctime;
+    OSS_CALL(get_position, &params);
 
-    return S_OK;
+    return params.result;
 }
 
 static HRESULT WINAPI AudioClock_GetCharacteristics(IAudioClock *iface,
diff --git a/dlls/wineoss.drv/oss.c b/dlls/wineoss.drv/oss.c
index 3a512c7cd9e..a39b0bc4f66 100644
--- a/dlls/wineoss.drv/oss.c
+++ b/dlls/wineoss.drv/oss.c
@@ -1272,6 +1272,50 @@ static NTSTATUS get_frequency(void *args)
     return oss_unlock_result(stream, &params->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, &params->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,
 };
diff --git a/dlls/wineoss.drv/unixlib.h b/dlls/wineoss.drv/unixlib.h
index 9a544ae7899..982b11ec44f 100644
--- a/dlls/wineoss.drv/unixlib.h
+++ b/dlls/wineoss.drv/unixlib.h
@@ -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,
 };
 
-- 
2.25.1




More information about the wine-devel mailing list