[vlc-devel] [PATCH] fix swab calls with different prototypes in mingw32

Steve Lhomme robux4 at ycbcr.xyz
Fri Jul 12 08:20:47 CEST 2019


It expects an input 'char *' instead of 'const char *' even though it's not
writing on the source.

Given there's no versioning on mingw32 we can't rely on such a header version
to do this trick or not
---
 modules/audio_filter/converter/tospdif.c | 4 ++++
 modules/codec/araw.c                     | 4 ++++
 modules/demux/mpeg/es.c                  | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/modules/audio_filter/converter/tospdif.c b/modules/audio_filter/converter/tospdif.c
index 5b11cace29..282eff9b1e 100644
--- a/modules/audio_filter/converter/tospdif.c
+++ b/modules/audio_filter/converter/tospdif.c
@@ -148,7 +148,11 @@ static void write_data( filter_t *p_filter, const void *p_buf, size_t i_size,
     assert( p_sys->p_out_buf->i_buffer - p_sys->i_out_offset >= i_size );
 
     if( b_input_big_endian != b_output_big_endian )
+#ifdef _WIN32
+        swab( (char*)p_in, p_out, i_size & ~1 );
+#else /* !_WIN32 */
         swab( p_in, p_out, i_size & ~1 );
+#endif /* !_WIN32 */
     else
         memcpy( p_out, p_in, i_size & ~1 );
     p_sys->i_out_offset += ( i_size & ~1 );
diff --git a/modules/codec/araw.c b/modules/codec/araw.c
index c73deded85..167e602a9e 100644
--- a/modules/codec/araw.c
+++ b/modules/codec/araw.c
@@ -400,7 +400,11 @@ static void U16LDecode( void *outp, const uint8_t *in, unsigned samples )
 
 static void S16IDecode( void *out, const uint8_t *in, unsigned samples )
 {
+#ifdef _WIN32
+    swab( (char*)in, out, samples * 2 );
+#else /* !_WIN32 */
     swab( in, out, samples * 2 );
+#endif /* !_WIN32 */
 }
 
 static void S20BDecode( void *outp, const uint8_t *in, unsigned samples )
diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c
index 427685c68b..50f59a6e0c 100644
--- a/modules/demux/mpeg/es.c
+++ b/modules/demux/mpeg/es.c
@@ -1301,7 +1301,11 @@ static int A52CheckSync( const uint8_t *p_peek, bool *p_big_endian, unsigned *pi
     *p_big_endian =  p_peek[0] == 0x0b && p_peek[1] == 0x77;
     if( !*p_big_endian )
     {
+#ifdef _WIN32
+        swab( (char*) p_peek, p_tmp, VLC_A52_MIN_HEADER_SIZE );
+#else /* !_WIN32 */
         swab( p_peek, p_tmp, VLC_A52_MIN_HEADER_SIZE );
+#endif /* !_WIN32 */
         p_peek = p_tmp;
     }
 
-- 
2.17.1



More information about the vlc-devel mailing list