mpg123: fix build with msvc
authorTim-Philipp Müller <tim@centricular.com>
Fri, 15 Apr 2016 18:55:03 +0000 (19:55 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 15 Apr 2016 18:55:03 +0000 (19:55 +0100)
Fix syntax errors when compiling against cerbero-provided libmpg123
headers. We do the same as the libmpg123 internal visual studio
build here.

mpg123.h(1378): error C2143: syntax error: missing ')' before '('
mpg123.h(1378): error C2081: 'ssize_t': name in formal parameter list illegal
mpg123.h(1378): error C2143: syntax error: missing ')' before '*'
mpg123.h(1378): error C2091: function returns function
mpg123.h(1378): error C2143: syntax error: missing '{' before '*'
mpg123.h(1378): error C2059: syntax error: ')'
mpg123.h(1379): error C2143: syntax error: missing ')' before '*'
mpg123.h(1379): error C2365: 'off_t': redefinition; previous definition was 'typedef'
...

ext/mpg123/gstmpg123audiodec.h

index e837a56..b865c41 100644 (file)
 #ifndef __GST_MPG123_AUDIO_DEC_H__
 #define __GST_MPG123_AUDIO_DEC_H__
 
+/* This is what the visual studio build in mpg123 does before including the
+ * original header file. Without this we get syntax errors in the
+ * replace_reader function declarations because it doesn't know ssize_t etc.
+ * It doesn't realy matter for us if the ssize_t typedef here is correct. */
+#ifdef _MSC_VER
+#include <tchar.h>
+#include <stdlib.h>
+#include <sys/types.h>
+typedef long ssize_t;
+#include <stdint.h>
+#endif
+
 #include <gst/gst.h>
 #include <gst/audio/gstaudiodecoder.h>
 #include <mpg123.h>