gstaudioutilsprivate: Fix warnings while setting thread priority

Also use G_OS_WIN32 instead of _WIN32 for clarity.
This commit is contained in:
Nirbheek Chauhan 2018-09-24 19:25:28 +05:30
parent dc29bc4e13
commit d002cd33d3
2 changed files with 17 additions and 14 deletions

@ -23,11 +23,11 @@
#include "config.h" #include "config.h"
#endif #endif
#ifdef _WIN32 #include <gst/audio/audio.h>
#ifdef G_OS_WIN32
#include <windows.h> #include <windows.h>
#endif #endif
#include <gst/audio/audio.h>
#include "gstaudioutilsprivate.h" #include "gstaudioutilsprivate.h"
/* /*
@ -217,15 +217,15 @@ exit:
return res; return res;
} }
#ifdef _WIN32 #ifdef G_OS_WIN32
/* *INDENT-OFF* */ /* *INDENT-OFF* */
static struct static struct
{ {
HMODULE dll; HMODULE dll;
gboolean tried_loading; gboolean tried_loading;
HANDLE (WINAPI * AvSetMmThreadCharacteristics) (LPCSTR, LPDWORD); FARPROC AvSetMmThreadCharacteristics;
BOOL (WINAPI * AvRevertMmThreadCharacteristics) (HANDLE); FARPROC AvRevertMmThreadCharacteristics;
} _gst_audio_avrt_tbl = { 0 }; } _gst_audio_avrt_tbl = { 0 };
/* *INDENT-ON* */ /* *INDENT-ON* */
#endif #endif
@ -233,7 +233,7 @@ static struct
static gboolean static gboolean
__gst_audio_init_thread_priority (void) __gst_audio_init_thread_priority (void)
{ {
#ifdef _WIN32 #ifdef G_OS_WIN32
if (_gst_audio_avrt_tbl.tried_loading) if (_gst_audio_avrt_tbl.tried_loading)
return _gst_audio_avrt_tbl.dll != NULL; return _gst_audio_avrt_tbl.dll != NULL;
@ -261,19 +261,22 @@ __gst_audio_init_thread_priority (void)
/* /*
* Increases the priority of the thread it's called from * Increases the priority of the thread it's called from
*/ */
gpointer gboolean
__gst_audio_set_thread_priority (void) __gst_audio_set_thread_priority (void)
{ {
if (!__gst_audio_init_thread_priority ()) #ifdef G_OS_WIN32
return NULL;
#ifdef _WIN32
DWORD taskIndex = 0; DWORD taskIndex = 0;
#endif
if (!__gst_audio_init_thread_priority ())
return FALSE;
#ifdef G_OS_WIN32
/* This is only used from ringbuffer thread functions, so we don't need to /* This is only used from ringbuffer thread functions, so we don't need to
* ever need to revert the thread priorities. */ * ever need to revert the thread priorities. */
return _gst_audio_avrt_tbl.AvSetMmThreadCharacteristics (TEXT ("Pro Audio"), return _gst_audio_avrt_tbl.AvSetMmThreadCharacteristics (TEXT ("Pro Audio"),
&taskIndex); &taskIndex) != 0;
#else #else
return NULL; return TRUE;
#endif #endif
} }

@ -43,7 +43,7 @@ gboolean __gst_audio_encoded_audio_convert (GstAudioInfo * fmt, gint64 bytes,
gint64 * dest_value); gint64 * dest_value);
G_GNUC_INTERNAL G_GNUC_INTERNAL
gpointer __gst_audio_set_thread_priority (void); gboolean __gst_audio_set_thread_priority (void);
G_END_DECLS G_END_DECLS