mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-18 01:30:07 +02:00
147 lines
3.4 KiB
Plaintext
147 lines
3.4 KiB
Plaintext
From 6d238064d1df3161a1bd43236ac3d29ea9b595c9 Mon Sep 17 00:00:00 2001
|
|
From: Jerome Duval <jerome.duval@gmail.com>
|
|
Date: Tue, 13 Jan 2015 20:57:54 +0000
|
|
Subject: Haiku patch
|
|
|
|
|
|
diff --git a/sbc/sbc.c b/sbc/sbc.c
|
|
index 606f11c..6bee729 100644
|
|
--- a/sbc/sbc.c
|
|
+++ b/sbc/sbc.c
|
|
@@ -29,6 +29,7 @@
|
|
#include <config.h>
|
|
#endif
|
|
|
|
+#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
diff --git a/src/formats.h b/src/formats.h
|
|
index 3050b25..dd7aba2 100644
|
|
--- a/src/formats.h
|
|
+++ b/src/formats.h
|
|
@@ -21,18 +21,32 @@
|
|
*
|
|
*/
|
|
|
|
+#ifdef __HAIKU__
|
|
+#include <ByteOrder.h>
|
|
+#else
|
|
#include <byteswap.h>
|
|
+#endif
|
|
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
#define COMPOSE_ID(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24))
|
|
#define LE_SHORT(v) (v)
|
|
#define LE_INT(v) (v)
|
|
+#ifdef __HAIKU__
|
|
+#define BE_SHORT(v) B_SWAP_INT16(v)
|
|
+#define BE_INT(v) B_SWAP_INT32(v)
|
|
+#else
|
|
#define BE_SHORT(v) bswap_16(v)
|
|
#define BE_INT(v) bswap_32(v)
|
|
+#endif
|
|
#elif __BYTE_ORDER == __BIG_ENDIAN
|
|
#define COMPOSE_ID(a,b,c,d) ((d) | ((c)<<8) | ((b)<<16) | ((a)<<24))
|
|
+#ifdef __HAIKU__
|
|
+#define LE_SHORT(v) B_SWAP_INT16(v)
|
|
+#define LE_INT(v) B_SWAP_INT32(v)
|
|
+#else
|
|
#define LE_SHORT(v) bswap_16(v)
|
|
#define LE_INT(v) bswap_32(v)
|
|
+#endif
|
|
#define BE_SHORT(v) (v)
|
|
#define BE_INT(v) (v)
|
|
#else
|
|
diff --git a/src/sbcdec.c b/src/sbcdec.c
|
|
index ba17f7a..9cda0c4 100644
|
|
--- a/src/sbcdec.c
|
|
+++ b/src/sbcdec.c
|
|
@@ -37,7 +37,9 @@
|
|
#include <getopt.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/ioctl.h>
|
|
+#ifndef __HAIKU__
|
|
#include <sys/soundcard.h>
|
|
+#endif
|
|
|
|
#include "sbc/sbc.h"
|
|
#include "formats.h"
|
|
@@ -53,7 +55,11 @@ static void decode(char *filename, char *output, int tofile, bool msbc)
|
|
sbc_t sbc;
|
|
int fd, ad, pos, streamlen, framelen, count;
|
|
size_t len;
|
|
+#ifndef __HAIKU__
|
|
int format = AFMT_S16_BE, frequency, channels;
|
|
+#else
|
|
+ int frequency, channels;
|
|
+#endif
|
|
ssize_t written;
|
|
|
|
if (stat(filename, &st) < 0) {
|
|
@@ -154,6 +160,7 @@ static void decode(char *filename, char *output, int tofile, bool msbc)
|
|
goto close;
|
|
}
|
|
} else {
|
|
+#ifndef __HAIKU__
|
|
if (ioctl(ad, SNDCTL_DSP_SETFMT, &format) < 0) {
|
|
fprintf(stderr, "Can't set audio format on %s: %s\n",
|
|
output, strerror(errno));
|
|
@@ -171,6 +178,7 @@ static void decode(char *filename, char *output, int tofile, bool msbc)
|
|
output, strerror(errno));
|
|
goto close;
|
|
}
|
|
+#endif
|
|
}
|
|
|
|
count = len;
|
|
@@ -233,7 +241,9 @@ static void usage(void)
|
|
|
|
printf("Options:\n"
|
|
"\t-h, --help Display help\n"
|
|
+#ifndef __HAIKU__
|
|
"\t-d, --device <dsp> Sound device\n"
|
|
+#endif
|
|
"\t-v, --verbose Verbose mode\n"
|
|
"\t-m, --msbc mSBC codec\n"
|
|
"\t-f, --file <file> Decode to a file\n"
|
|
@@ -243,7 +253,9 @@ static void usage(void)
|
|
static struct option main_options[] = {
|
|
{ "help", 0, 0, 'h' },
|
|
{ "msbc", 0, 0, 'm' },
|
|
+#ifndef __HAIKU__
|
|
{ "device", 1, 0, 'd' },
|
|
+#endif
|
|
{ "verbose", 0, 0, 'v' },
|
|
{ "file", 1, 0, 'f' },
|
|
{ 0, 0, 0, 0 }
|
|
@@ -252,7 +264,11 @@ static struct option main_options[] = {
|
|
int main(int argc, char *argv[])
|
|
{
|
|
char *output = NULL;
|
|
+#ifndef __HAIKU__
|
|
int i, opt, tofile = 0;
|
|
+#else
|
|
+ int i, opt, tofile = 1;
|
|
+#endif
|
|
bool msbc = false;
|
|
|
|
while ((opt = getopt_long(argc, argv, "+hmvd:f:",
|
|
@@ -270,11 +286,13 @@ int main(int argc, char *argv[])
|
|
msbc = true;
|
|
break;
|
|
|
|
+#ifndef __HAIKU__
|
|
case 'd':
|
|
free(output);
|
|
output = strdup(optarg);
|
|
tofile = 0;
|
|
break;
|
|
+#endif
|
|
|
|
case 'f' :
|
|
free(output);
|
|
--
|
|
1.8.3.4
|
|
|