From e321b403322c3fc0e60a0f43e2eb3b8bbb07fbd0 Mon Sep 17 00:00:00 2001
From: Logarithmus <logarithmus.ddev@gmail.com>
Date: Sun, 23 Feb 2020 05:04:24 +0300
Subject: [PATCH] Fix error: unknown type name "pthread_mutex_t" Fix error:
 implicit declaration of clock_gettime Fix error: use of undeclared identifier
 'M_PI'

---
 src/object_heap.h |  3 +++
 src/utils.c       | 16 ++++++++++------
 src/vdpau_mixer.c |  3 +++
 src/vdpau_video.h |  1 +
 4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/object_heap.h b/src/object_heap.h
index b37fc6a..b95fca6 100644
--- a/src/object_heap.h
+++ b/src/object_heap.h
@@ -21,6 +21,9 @@
 #ifndef VA_OBJECT_HEAP_H
 #define VA_OBJECT_HEAP_H
 
+#include <sys/types.h>
+#include <pthread.h>
+
 #define OBJECT_HEAP_OFFSET_MASK 0x7f000000
 #define OBJECT_HEAP_ID_MASK     0x00ffffff
 
diff --git a/src/utils.c b/src/utils.c
index 1dac15c..7b58070 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -18,10 +18,17 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  */
 
+#if __STDC_VERSION__ >= 199901L
+#define _XOPEN_SOURCE 700
+#else
+#define _XOPEN_SOURCE 500
+#endif /* __STDC_VERSION__ */
+
 #include "sysdeps.h"
 #include "utils.h"
 #include <time.h>
 #include <errno.h>
+#include <sys/time.h>
 
 #define DEBUG 1
 #include "debug.h"
@@ -186,16 +193,13 @@ realloc_buffer(
 // Lookup for substring NAME in string EXT using SEP as separators
 int find_string(const char *name, const char *ext, const char *sep)
 {
-    const char *end;
-    int name_len, n;
-
     if (name == NULL || ext == NULL)
         return 0;
 
-    end = ext + strlen(ext);
-    name_len = strlen(name);
+    const char *end = ext + strlen(ext);
+    int name_len = strlen(name);
     while (ext < end) {
-        n = strcspn(ext, sep);
+        int n = strcspn(ext, sep);
         if (n == name_len && strncmp(name, ext, n) == 0)
             return 1;
         ext += (n + 1);
diff --git a/src/vdpau_mixer.c b/src/vdpau_mixer.c
index 0fcec9c..c94dcb5 100644
--- a/src/vdpau_mixer.c
+++ b/src/vdpau_mixer.c
@@ -21,6 +21,9 @@
 #include "sysdeps.h"
 #include "vdpau_mixer.h"
 #include "vdpau_video.h"
+#ifndef M_PI
+    #define M_PI 3.14159265358979323846
+#endif
 #include <math.h>
 
 #define VDPAU_MAX_VIDEO_MIXER_PARAMS    4
diff --git a/src/vdpau_video.h b/src/vdpau_video.h
index e7a137d..e7ca439 100644
--- a/src/vdpau_video.h
+++ b/src/vdpau_video.h
@@ -23,6 +23,7 @@
 
 #include "vdpau_driver.h"
 #include "vdpau_decode.h"
+#include <linux/videodev2.h>
 
 typedef struct SubpictureAssociation *SubpictureAssociationP;
 struct SubpictureAssociation {