mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-12 10:25:33 +00:00
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().
This commit is contained in:
parent
8875fe49ec
commit
f62b7fd712
6 changed files with 4 additions and 84 deletions
|
@ -561,9 +561,6 @@ gst_wasapi_sink_prepare (GstAudioSink * asink, GstAudioRingBufferSpec * spec)
|
||||||
gst_audio_ring_buffer_set_channel_positions (GST_AUDIO_BASE_SINK
|
gst_audio_ring_buffer_set_channel_positions (GST_AUDIO_BASE_SINK
|
||||||
(self)->ringbuffer, self->positions);
|
(self)->ringbuffer, self->positions);
|
||||||
|
|
||||||
/* Increase the thread priority to reduce glitches */
|
|
||||||
self->thread_priority_handle = gst_wasapi_util_set_thread_characteristics ();
|
|
||||||
|
|
||||||
res = TRUE;
|
res = TRUE;
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
|
@ -582,12 +579,6 @@ gst_wasapi_sink_unprepare (GstAudioSink * asink)
|
||||||
|
|
||||||
CoUninitialize ();
|
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) {
|
if (self->client != NULL) {
|
||||||
IAudioClient_Stop (self->client);
|
IAudioClient_Stop (self->client);
|
||||||
}
|
}
|
||||||
|
@ -614,7 +605,8 @@ gst_wasapi_sink_write (GstAudioSink * asink, gpointer data, guint length)
|
||||||
GST_OBJECT_LOCK (self);
|
GST_OBJECT_LOCK (self);
|
||||||
if (self->client_needs_restart) {
|
if (self->client_needs_restart) {
|
||||||
hr = IAudioClient_Start (self->client);
|
hr = IAudioClient_Start (self->client);
|
||||||
HR_FAILED_AND (hr, IAudioClient::Start, GST_OBJECT_UNLOCK (self); goto beach);
|
HR_FAILED_AND (hr, IAudioClient::Start, GST_OBJECT_UNLOCK (self);
|
||||||
|
goto beach);
|
||||||
self->client_needs_restart = FALSE;
|
self->client_needs_restart = FALSE;
|
||||||
}
|
}
|
||||||
GST_OBJECT_UNLOCK (self);
|
GST_OBJECT_UNLOCK (self);
|
||||||
|
@ -636,8 +628,8 @@ gst_wasapi_sink_write (GstAudioSink * asink, gpointer data, guint length)
|
||||||
* GetBuffer will error out */
|
* GetBuffer will error out */
|
||||||
if (can_frames != have_frames) {
|
if (can_frames != have_frames) {
|
||||||
GST_ERROR_OBJECT (self,
|
GST_ERROR_OBJECT (self,
|
||||||
"Need at %i frames to write for exclusive mode, but got %i",
|
"Need at %i frames to write for exclusive mode, but got %i",
|
||||||
can_frames, have_frames);
|
can_frames, have_frames);
|
||||||
written_len = -1;
|
written_len = -1;
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@ struct _GstWasapiSink
|
||||||
IAudioClient *client;
|
IAudioClient *client;
|
||||||
IAudioRenderClient *render_client;
|
IAudioRenderClient *render_client;
|
||||||
HANDLE event_handle;
|
HANDLE event_handle;
|
||||||
HANDLE thread_priority_handle;
|
|
||||||
/* Client was reset, so it needs to be started again */
|
/* Client was reset, so it needs to be started again */
|
||||||
gboolean client_needs_restart;
|
gboolean client_needs_restart;
|
||||||
|
|
||||||
|
|
|
@ -512,9 +512,6 @@ gst_wasapi_src_prepare (GstAudioSrc * asrc, GstAudioRingBufferSpec * spec)
|
||||||
gst_audio_ring_buffer_set_channel_positions (GST_AUDIO_BASE_SRC
|
gst_audio_ring_buffer_set_channel_positions (GST_AUDIO_BASE_SRC
|
||||||
(self)->ringbuffer, self->positions);
|
(self)->ringbuffer, self->positions);
|
||||||
|
|
||||||
/* Increase the thread priority to reduce glitches */
|
|
||||||
self->thread_priority_handle = gst_wasapi_util_set_thread_characteristics ();
|
|
||||||
|
|
||||||
res = TRUE;
|
res = TRUE;
|
||||||
beach:
|
beach:
|
||||||
/* unprepare() is not called if prepare() fails, but we want it to be, so call
|
/* unprepare() is not called if prepare() fails, but we want it to be, so call
|
||||||
|
@ -530,12 +527,6 @@ gst_wasapi_src_unprepare (GstAudioSrc * asrc)
|
||||||
{
|
{
|
||||||
GstWasapiSrc *self = GST_WASAPI_SRC (asrc);
|
GstWasapiSrc *self = GST_WASAPI_SRC (asrc);
|
||||||
|
|
||||||
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) {
|
if (self->client != NULL) {
|
||||||
IAudioClient_Stop (self->client);
|
IAudioClient_Stop (self->client);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,6 @@ struct _GstWasapiSrc
|
||||||
guint64 client_clock_freq;
|
guint64 client_clock_freq;
|
||||||
IAudioCaptureClient *capture_client;
|
IAudioCaptureClient *capture_client;
|
||||||
HANDLE event_handle;
|
HANDLE event_handle;
|
||||||
HANDLE thread_priority_handle;
|
|
||||||
/* Client was reset, so it needs to be started again */
|
/* Client was reset, so it needs to be started again */
|
||||||
gboolean client_needs_restart;
|
gboolean client_needs_restart;
|
||||||
|
|
||||||
|
|
|
@ -106,16 +106,6 @@ static struct
|
||||||
|
|
||||||
static int windows_major_version = 0;
|
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
|
gboolean
|
||||||
gst_wasapi_util_have_audioclient3 (void)
|
gst_wasapi_util_have_audioclient3 (void)
|
||||||
{
|
{
|
||||||
|
@ -956,50 +946,3 @@ gst_wasapi_util_initialize_audioclient3 (GstElement * self,
|
||||||
*ret_devicep_frames = devicep_frames;
|
*ret_devicep_frames = devicep_frames;
|
||||||
return TRUE;
|
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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -114,8 +114,4 @@ gboolean gst_wasapi_util_initialize_audioclient3 (GstElement * element,
|
||||||
WAVEFORMATEX * format, gboolean low_latency, gboolean loopback,
|
WAVEFORMATEX * format, gboolean low_latency, gboolean loopback,
|
||||||
guint * ret_devicep_frames);
|
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__ */
|
#endif /* __GST_WASAPI_UTIL_H__ */
|
||||||
|
|
Loading…
Reference in a new issue