mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-09 13:29:59 -05:00
Make sure the data gets endianness conversion.
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/ossman@424 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
067c00ff5d
commit
8a323571a4
2 changed files with 16 additions and 5 deletions
|
|
@ -239,11 +239,14 @@ static void* connection_write(struct connection *c, size_t length) {
|
||||||
return (uint8_t*) c->write_data+i;
|
return (uint8_t*) c->write_data+i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void format_esd2native(int format, struct pa_sample_spec *ss) {
|
static void format_esd2native(int format, int swap_bytes, struct pa_sample_spec *ss) {
|
||||||
assert(ss);
|
assert(ss);
|
||||||
|
|
||||||
ss->channels = ((format & ESD_MASK_CHAN) == ESD_STEREO) ? 2 : 1;
|
ss->channels = ((format & ESD_MASK_CHAN) == ESD_STEREO) ? 2 : 1;
|
||||||
ss->format = ((format & ESD_MASK_BITS) == ESD_BITS16) ? PA_SAMPLE_S16NE : PA_SAMPLE_U8;
|
if ((format & ESD_MASK_BITS) == ESD_BITS16)
|
||||||
|
ss->format = swap_bytes ? PA_SAMPLE_S16RE : PA_SAMPLE_S16NE;
|
||||||
|
else
|
||||||
|
ss->format = PA_SAMPLE_U8;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int format_native2esd(struct pa_sample_spec *ss) {
|
static int format_native2esd(struct pa_sample_spec *ss) {
|
||||||
|
|
@ -303,7 +306,7 @@ static int esd_proto_stream_play(struct connection *c, esd_proto_t request, cons
|
||||||
rate = maybe_swap_endian_32(c->swap_byte_order, *((int*)data + 1));
|
rate = maybe_swap_endian_32(c->swap_byte_order, *((int*)data + 1));
|
||||||
|
|
||||||
ss.rate = rate;
|
ss.rate = rate;
|
||||||
format_esd2native(format, &ss);
|
format_esd2native(format, c->swap_byte_order, &ss);
|
||||||
|
|
||||||
if (!pa_sample_spec_valid(&ss)) {
|
if (!pa_sample_spec_valid(&ss)) {
|
||||||
pa_log(__FILE__": invalid sample specification\n");
|
pa_log(__FILE__": invalid sample specification\n");
|
||||||
|
|
@ -359,7 +362,7 @@ static int esd_proto_stream_record(struct connection *c, esd_proto_t request, co
|
||||||
rate = maybe_swap_endian_32(c->swap_byte_order, *((int*)data + 1));
|
rate = maybe_swap_endian_32(c->swap_byte_order, *((int*)data + 1));
|
||||||
|
|
||||||
ss.rate = rate;
|
ss.rate = rate;
|
||||||
format_esd2native(format, &ss);
|
format_esd2native(format, c->swap_byte_order, &ss);
|
||||||
|
|
||||||
if (!pa_sample_spec_valid(&ss)) {
|
if (!pa_sample_spec_valid(&ss)) {
|
||||||
pa_log(__FILE__": invalid sample specification.\n");
|
pa_log(__FILE__": invalid sample specification.\n");
|
||||||
|
|
@ -602,7 +605,7 @@ static int esd_proto_sample_cache(struct connection *c, esd_proto_t request, con
|
||||||
rate = maybe_swap_endian_32(c->swap_byte_order, *((int*)data + 1));
|
rate = maybe_swap_endian_32(c->swap_byte_order, *((int*)data + 1));
|
||||||
|
|
||||||
ss.rate = rate;
|
ss.rate = rate;
|
||||||
format_esd2native(format, &ss);
|
format_esd2native(format, c->swap_byte_order, &ss);
|
||||||
|
|
||||||
sc_length = (size_t) maybe_swap_endian_32(c->swap_byte_order, (*((int*)data + 2)));
|
sc_length = (size_t) maybe_swap_endian_32(c->swap_byte_order, (*((int*)data + 2)));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,11 +51,19 @@ enum pa_sample_format {
|
||||||
#define PA_SAMPLE_S16NE PA_SAMPLE_S16BE
|
#define PA_SAMPLE_S16NE PA_SAMPLE_S16BE
|
||||||
/** 32 Bit IEEE floating point, native endian */
|
/** 32 Bit IEEE floating point, native endian */
|
||||||
#define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32BE
|
#define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32BE
|
||||||
|
/** Signed 16 Bit PCM reverse endian */
|
||||||
|
#define PA_SAMPLE_S16RE PA_SAMPLE_S16LE
|
||||||
|
/** 32 Bit IEEE floating point, reverse endian */
|
||||||
|
#define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32LE
|
||||||
#else
|
#else
|
||||||
/** Signed 16 Bit PCM, native endian */
|
/** Signed 16 Bit PCM, native endian */
|
||||||
#define PA_SAMPLE_S16NE PA_SAMPLE_S16LE
|
#define PA_SAMPLE_S16NE PA_SAMPLE_S16LE
|
||||||
/** 32 Bit IEEE floating point, native endian */
|
/** 32 Bit IEEE floating point, native endian */
|
||||||
#define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32LE
|
#define PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32LE
|
||||||
|
/** Signed 16 Bit PCM reverse endian */
|
||||||
|
#define PA_SAMPLE_S16RE PA_SAMPLE_S16BE
|
||||||
|
/** 32 Bit IEEE floating point, reverse endian */
|
||||||
|
#define PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32BE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** A Shortcut for PA_SAMPLE_FLOAT32NE */
|
/** A Shortcut for PA_SAMPLE_FLOAT32NE */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue