wasapi: Remove code that sets thread priority
This is now handled directly in gstaudiosrc/sink, and we were setting
it in the wrong thread anyway. prepare() is not the same thread as
sink_write() or src_read().
diff --git a/sys/wasapi/gstwasapisink.c b/sys/wasapi/gstwasapisink.c
index 7bff5d1..9144301 100644
--- a/sys/wasapi/gstwasapisink.c
+++ b/sys/wasapi/gstwasapisink.c
@@ -561,9 +561,6 @@
gst_audio_ring_buffer_set_channel_positions (GST_AUDIO_BASE_SINK
(self)->ringbuffer, self->positions);
- /* Increase the thread priority to reduce glitches */
- self->thread_priority_handle = gst_wasapi_util_set_thread_characteristics ();
-
res = TRUE;
beach:
@@ -582,12 +579,6 @@
CoUninitialize ();
- if (self->thread_priority_handle != NULL) {
- gst_wasapi_util_revert_thread_characteristics
- (self->thread_priority_handle);
- self->thread_priority_handle = NULL;
- }
-
if (self->client != NULL) {
IAudioClient_Stop (self->client);
}
@@ -611,8 +602,8 @@
GST_OBJECT_LOCK (self);
if (self->client_needs_restart) {
hr = IAudioClient_Start (self->client);
- HR_FAILED_AND (hr, IAudioClient::Start,
- GST_OBJECT_UNLOCK (self); length = 0; goto beach);
+ HR_FAILED_AND (hr, IAudioClient::Start, GST_OBJECT_UNLOCK (self);
+ length = 0; goto beach);
self->client_needs_restart = FALSE;
}
GST_OBJECT_UNLOCK (self);
@@ -643,7 +634,8 @@
hr = IAudioRenderClient_GetBuffer (self->render_client, n_frames,
(BYTE **) & dst);
- HR_FAILED_AND (hr, IAudioRenderClient::GetBuffer, length = 0; goto beach);
+ HR_FAILED_AND (hr, IAudioRenderClient::GetBuffer, length = 0;
+ goto beach);
memcpy (dst, data, write_len);
diff --git a/sys/wasapi/gstwasapisink.h b/sys/wasapi/gstwasapisink.h
index e3b2101..7806fc3 100644
--- a/sys/wasapi/gstwasapisink.h
+++ b/sys/wasapi/gstwasapisink.h
@@ -44,7 +44,6 @@
IAudioClient *client;
IAudioRenderClient *render_client;
HANDLE event_handle;
- HANDLE thread_priority_handle;
/* Client was reset, so it needs to be started again */
gboolean client_needs_restart;
diff --git a/sys/wasapi/gstwasapisrc.c b/sys/wasapi/gstwasapisrc.c
index c0844f1..07f51aa 100644
--- a/sys/wasapi/gstwasapisrc.c
+++ b/sys/wasapi/gstwasapisrc.c
@@ -496,9 +496,6 @@
gst_audio_ring_buffer_set_channel_positions (GST_AUDIO_BASE_SRC
(self)->ringbuffer, self->positions);
- /* Increase the thread priority to reduce glitches */
- self->thread_priority_handle = gst_wasapi_util_set_thread_characteristics ();
-
res = TRUE;
beach:
/* unprepare() is not called if prepare() fails, but we want it to be, so call
@@ -516,12 +513,6 @@
CoUninitialize ();
- if (self->thread_priority_handle != NULL) {
- gst_wasapi_util_revert_thread_characteristics
- (self->thread_priority_handle);
- self->thread_priority_handle = NULL;
- }
-
if (self->client != NULL) {
IAudioClient_Stop (self->client);
}
diff --git a/sys/wasapi/gstwasapisrc.h b/sys/wasapi/gstwasapisrc.h
index 1cbd23c..6ba82b8 100644
--- a/sys/wasapi/gstwasapisrc.h
+++ b/sys/wasapi/gstwasapisrc.h
@@ -46,7 +46,6 @@
guint64 client_clock_freq;
IAudioCaptureClient *capture_client;
HANDLE event_handle;
- HANDLE thread_priority_handle;
/* Client was reset, so it needs to be started again */
gboolean client_needs_restart;
diff --git a/sys/wasapi/gstwasapiutil.c b/sys/wasapi/gstwasapiutil.c
index 02b9763..d630d6b 100644
--- a/sys/wasapi/gstwasapiutil.c
+++ b/sys/wasapi/gstwasapiutil.c
@@ -106,16 +106,6 @@
static int windows_major_version = 0;
-static struct
-{
- HMODULE dll;
- gboolean tried_loading;
-
- HANDLE (WINAPI * AvSetMmThreadCharacteristics) (LPCSTR, LPDWORD);
- BOOL (WINAPI * AvRevertMmThreadCharacteristics) (HANDLE);
-} gst_wasapi_avrt_tbl = {
-0};
-
gboolean
gst_wasapi_util_have_audioclient3 (void)
{
@@ -947,50 +937,3 @@
*ret_devicep_frames = devicep_frames;
return TRUE;
}
-
-static gboolean
-gst_wasapi_util_init_thread_priority (void)
-{
- if (gst_wasapi_avrt_tbl.tried_loading)
- return gst_wasapi_avrt_tbl.dll != NULL;
-
- if (!gst_wasapi_avrt_tbl.dll)
- gst_wasapi_avrt_tbl.dll = LoadLibrary (TEXT ("avrt.dll"));
-
- if (!gst_wasapi_avrt_tbl.dll) {
- GST_WARNING ("Failed to set thread priority, can't find avrt.dll");
- gst_wasapi_avrt_tbl.tried_loading = TRUE;
- return FALSE;
- }
-
- gst_wasapi_avrt_tbl.AvSetMmThreadCharacteristics =
- GetProcAddress (gst_wasapi_avrt_tbl.dll, "AvSetMmThreadCharacteristicsA");
- gst_wasapi_avrt_tbl.AvRevertMmThreadCharacteristics =
- GetProcAddress (gst_wasapi_avrt_tbl.dll,
- "AvRevertMmThreadCharacteristics");
-
- gst_wasapi_avrt_tbl.tried_loading = TRUE;
-
- return TRUE;
-}
-
-HANDLE
-gst_wasapi_util_set_thread_characteristics (void)
-{
- DWORD taskIndex = 0;
-
- if (!gst_wasapi_util_init_thread_priority ())
- return NULL;
-
- return gst_wasapi_avrt_tbl.AvSetMmThreadCharacteristics (TEXT ("Pro Audio"),
- &taskIndex);
-}
-
-void
-gst_wasapi_util_revert_thread_characteristics (HANDLE handle)
-{
- if (!gst_wasapi_util_init_thread_priority ())
- return;
-
- gst_wasapi_avrt_tbl.AvRevertMmThreadCharacteristics (handle);
-}
diff --git a/sys/wasapi/gstwasapiutil.h b/sys/wasapi/gstwasapiutil.h
index d525a92..b11d92b 100644
--- a/sys/wasapi/gstwasapiutil.h
+++ b/sys/wasapi/gstwasapiutil.h
@@ -113,8 +113,4 @@
GstAudioRingBufferSpec * spec, IAudioClient3 * client,
WAVEFORMATEX * format, gboolean low_latency, guint * ret_devicep_frames);
-HANDLE gst_wasapi_util_set_thread_characteristics (void);
-
-void gst_wasapi_util_revert_thread_characteristics (HANDLE handle);
-
#endif /* __GST_WASAPI_UTIL_H__ */