Fix endian issues in OSS driver.

This commit is contained in:
Themaister 2011-07-26 00:53:24 +02:00
parent 033860ceb9
commit f3cdb95b04
4 changed files with 15 additions and 25 deletions

View File

@ -20,6 +20,7 @@
#endif
#include "driver.h"
#include "general.h"
#include <stdlib.h>
#ifdef HAVE_OSS_BSD
@ -68,7 +69,8 @@ static void* __oss_init(const char* device, unsigned rate, unsigned latency)
}
int channels = 2;
int format = AFMT_S16_LE;
int format = is_little_endian() ?
AFMT_S16_LE : AFMT_S16_BE;
if (ioctl(*fd, SNDCTL_DSP_CHANNELS, &channels) < 0)
{

View File

@ -59,18 +59,6 @@ static void __pulse_free(void *data)
}
}
static inline uint8_t is_little_endian(void)
{
union
{
uint16_t x;
uint8_t y[2];
} u;
u.x = 1;
return u.y[0];
}
static void context_state_cb(pa_context *c, void *data)
{
pa_t *pa = data;

View File

@ -305,6 +305,18 @@ static inline uint32_t next_pow2(uint32_t v)
return v;
}
static inline uint8_t is_little_endian(void)
{
union
{
uint16_t x;
uint8_t y[2];
} u;
u.x = 1;
return u.y[0];
}
#endif

12
movie.c
View File

@ -107,18 +107,6 @@ struct bsv_movie
#define CRC_INDEX 2
#define STATE_SIZE_INDEX 3
static inline uint8_t is_little_endian(void)
{
union
{
uint16_t u16;
uint8_t u8[2];
} u;
u.u16 = 1;
return u.u8[0];
}
// Convert to big-endian if needed
static inline uint32_t swap_if_big32(uint32_t val)
{