[MPlayer-dev-eng] [PATCH] #define __BSD_VISIBLE to 1

Alexander Strasser eclipse7 at gmx.net
Sun Feb 16 18:16:14 CET 2014


Hi!

On 2014-02-16 13:01 +0900, KO Myung-Hun wrote:
> Reimar Döffinger wrote:
> > On Sat, Feb 15, 2014 at 01:52:43PM +0900, KO Myung-Hun wrote:
> >> This fixes the following error,
> >>
> >> -----
> >> libmpcodecs/ad_liba52.c:86:5: error: implicit declaration of function
> >> 'swab' [-Werror=implicit-function-declaration]
> >> -----
[...]
> > 
> > swab is POSIX (see e.g. http://linux.die.net/man/3/swab ) if the
> > _XOPEN_SOURCE isn't enough that is a header bug.
> 
> Hmmm.. You're right, it seems to be a bug of kLIBC header of OS/2.
> 
> > In addition __BSD_VISIBLE is internal stuff, you should never
> > define something starting with two _ in a normal C file.
> 
> Ok. I didn't know that. Thanks.
> 
> > Possibly _BSD_SOURCE would work, but as said it should not be necessary.
> 
> You're right, _BSD_SOURCE did it.
> 
> > Also on e.g. Android it is not available at all, so avoiding it
> > completely would be better, though since I think there isn't much good reason
> > to use liba52 anyway it doesn't matter much.
> 
> Do you mean _BSD_SOURCE or liba52 ? And liba52 was deprecated ?
> Otherwise, I don't want not to use it.
> 
> Attach a new patch.

  Maybe something like I attached would be a little bit more like
what Reimar had in mind.

  But please give it some more inspection I did barely test beyond
compilation and probably overlooked something.

  Alexander

[...]
-------------- next part --------------
From f1cac8e42e67a7dbc6b686dcbc2ea11f32ae71c0 Mon Sep 17 00:00:00 2001
Message-Id: <f1cac8e42e67a7dbc6b686dcbc2ea11f32ae71c0.1392570538.git.eclipse7 at gmx.net>
From: Alexander Strasser <eclipse7 at gmx.net>
Date: Sun, 16 Feb 2014 18:07:18 +0100
Subject: [PATCH] ad_liba52: Use MPlayer bswap_16 instead of swab


Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
---
 libmpcodecs/ad_liba52.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/libmpcodecs/ad_liba52.c b/libmpcodecs/ad_liba52.c
index 89b3dc7..b18bd68 100644
--- a/libmpcodecs/ad_liba52.c
+++ b/libmpcodecs/ad_liba52.c
@@ -22,6 +22,7 @@
 #include <unistd.h>
 #include <math.h>
 #include <assert.h>
+#include <stdint.h>
 
 #include "config.h"
 
@@ -68,6 +69,17 @@ static const ad_info_t info =
 
 LIBAD_EXTERN(liba52)
 
+static void swap_bytes(uint8_t * buf, int size)
+{
+   uint16_t * p = (uint16_t *)buf;
+   size -= size & 1;
+   while (size > 0) {
+     *p = bswap_16(*p);
+     ++p;
+     size -= 2;
+   }
+}
+
 static int a52_fillbuff(sh_audio_t *sh_audio)
 {
 int length=0;
@@ -83,11 +95,11 @@ while(1){
 	if(c<0) return -1; /* EOF*/
         sh_audio->a_in_buffer[sh_audio->a_in_buffer_len++]=c;
     }
-    if(sh_audio->format==MKTAG('d','n','e','t')) swab(sh_audio->a_in_buffer,sh_audio->a_in_buffer,8);
+    if(sh_audio->format==MKTAG('d','n','e','t')) swap_bytes(sh_audio->a_in_buffer,8);
     length = a52_syncinfo (sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate);
     if(length>=7 && length<=3840) break; /* we're done.*/
     /* bad file => resync*/
-    if(sh_audio->format==MKTAG('d','n','e','t')) swab(sh_audio->a_in_buffer,sh_audio->a_in_buffer,8);
+    if(sh_audio->format==MKTAG('d','n','e','t')) swap_bytes(sh_audio->a_in_buffer,8);
     memmove(sh_audio->a_in_buffer,sh_audio->a_in_buffer+1,7);
     --sh_audio->a_in_buffer_len;
 }
@@ -97,7 +109,7 @@ while(1){
     sh_audio->samplesize=sh_audio->sample_format==AF_FORMAT_FLOAT_NE ? 4 : 2;
     demux_read_data(sh_audio->ds,sh_audio->a_in_buffer+8,length-8);
     if(sh_audio->format==MKTAG('d','n','e','t'))
-	swab(sh_audio->a_in_buffer+8,sh_audio->a_in_buffer+8,length-8);
+	swap_bytes(sh_audio->a_in_buffer+8,length-8);
 
 #ifdef CONFIG_LIBA52_INTERNAL
     if(crc16_block(sh_audio->a_in_buffer+2,length-2)!=0)
-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20140216/f038eb0f/attachment.asc>


More information about the MPlayer-dev-eng mailing list