aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-03-21 19:25:52 +0100
committerMax Kellermann <max@duempel.org>2012-03-21 19:31:04 +0100
commit8c5ebdff360021a25b43418d3cd60ea975f5e245 (patch)
tree5780d19719f2493741fd11777bc39baf5361935b /src
parent1c84f324a13bcc3d7fbd84f8d59398b1c801247a (diff)
downloadmpd-8c5ebdff360021a25b43418d3cd60ea975f5e245.tar.gz
mpd-8c5ebdff360021a25b43418d3cd60ea975f5e245.tar.xz
mpd-8c5ebdff360021a25b43418d3cd60ea975f5e245.zip
audio_format: remove the reverse_endian attribute
Eliminate support for reverse endian samples from the MPD core. This moves a lot of complexity to the plugins that really need it (only ALSA and CDIO currently).
Diffstat (limited to 'src')
-rw-r--r--src/audio_format.c9
-rw-r--r--src/audio_format.h12
-rw-r--r--src/decoder_api.c3
-rw-r--r--src/filter/convert_filter_plugin.c1
-rw-r--r--src/filter/normalize_filter_plugin.c1
-rw-r--r--src/filter/replay_gain_filter_plugin.c2
-rw-r--r--src/filter/volume_filter_plugin.c2
-rw-r--r--src/output/alsa_output_plugin.c4
-rw-r--r--src/pcm_convert.c41
-rw-r--r--src/pcm_convert.h3
-rw-r--r--src/pcm_format.c2
-rw-r--r--src/pcm_pack.c42
-rw-r--r--src/pcm_pack.h8
13 files changed, 20 insertions, 110 deletions
diff --git a/src/audio_format.c b/src/audio_format.c
index 06dee8e0f..5a12a299c 100644
--- a/src/audio_format.c
+++ b/src/audio_format.c
@@ -22,12 +22,6 @@
#include <assert.h>
#include <stdio.h>
-#if G_BYTE_ORDER == G_BIG_ENDIAN
-#define REVERSE_ENDIAN_SUFFIX "_le"
-#else
-#define REVERSE_ENDIAN_SUFFIX "_be"
-#endif
-
void
audio_format_mask_apply(struct audio_format *af,
const struct audio_format *mask)
@@ -100,9 +94,8 @@ audio_format_to_string(const struct audio_format *af,
assert(af != NULL);
assert(s != NULL);
- snprintf(s->buffer, sizeof(s->buffer), "%u:%s%s:%u",
+ snprintf(s->buffer, sizeof(s->buffer), "%u:%s:%u",
af->sample_rate, sample_format_to_string(af->format),
- af->reverse_endian ? REVERSE_ENDIAN_SUFFIX : "",
af->channels);
return s->buffer;
diff --git a/src/audio_format.h b/src/audio_format.h
index 293dee1c1..fc4b85880 100644
--- a/src/audio_format.h
+++ b/src/audio_format.h
@@ -88,13 +88,6 @@ struct audio_format {
* fully supported currently.
*/
uint8_t channels;
-
- /**
- * If zero, then samples are stored in host byte order. If
- * nonzero, then samples are stored in the reverse host byte
- * order.
- */
- bool reverse_endian;
};
/**
@@ -113,7 +106,6 @@ static inline void audio_format_clear(struct audio_format *af)
af->sample_rate = 0;
af->format = SAMPLE_FORMAT_UNDEFINED;
af->channels = 0;
- af->reverse_endian = false;
}
/**
@@ -127,7 +119,6 @@ static inline void audio_format_init(struct audio_format *af,
af->sample_rate = sample_rate;
af->format = (uint8_t)format;
af->channels = channels;
- af->reverse_endian = false;
}
/**
@@ -239,8 +230,7 @@ static inline bool audio_format_equals(const struct audio_format *a,
{
return a->sample_rate == b->sample_rate &&
a->format == b->format &&
- a->channels == b->channels &&
- a->reverse_endian == b->reverse_endian;
+ a->channels == b->channels;
}
void
diff --git a/src/decoder_api.c b/src/decoder_api.c
index 8f12d017a..a45d0f1e6 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -56,9 +56,6 @@ decoder_initialized(struct decoder *decoder,
dc->in_audio_format = *audio_format;
getOutputAudioFormat(audio_format, &dc->out_audio_format);
- /* force host byte order, even if the decoder supplies reverse
- endian */
- dc->out_audio_format.reverse_endian = false;
dc->seekable = seekable;
dc->total_time = total_time;
diff --git a/src/filter/convert_filter_plugin.c b/src/filter/convert_filter_plugin.c
index 7acfc3055..c55b69af2 100644
--- a/src/filter/convert_filter_plugin.c
+++ b/src/filter/convert_filter_plugin.c
@@ -141,7 +141,6 @@ convert_filter_set(struct filter *_filter,
assert(audio_format_valid(&filter->out_audio_format));
assert(out_audio_format != NULL);
assert(audio_format_valid(out_audio_format));
- assert(!filter->in_audio_format.reverse_endian);
filter->out_audio_format = *out_audio_format;
}
diff --git a/src/filter/normalize_filter_plugin.c b/src/filter/normalize_filter_plugin.c
index fa992f0d4..2151482e4 100644
--- a/src/filter/normalize_filter_plugin.c
+++ b/src/filter/normalize_filter_plugin.c
@@ -67,7 +67,6 @@ normalize_filter_open(struct filter *_filter,
struct normalize_filter *filter = (struct normalize_filter *)_filter;
audio_format->format = SAMPLE_FORMAT_S16;
- audio_format->reverse_endian = false;
filter->compressor = Compressor_new(0);
diff --git a/src/filter/replay_gain_filter_plugin.c b/src/filter/replay_gain_filter_plugin.c
index c21fe4eaf..583a09f90 100644
--- a/src/filter/replay_gain_filter_plugin.c
+++ b/src/filter/replay_gain_filter_plugin.c
@@ -140,8 +140,6 @@ replay_gain_filter_open(struct filter *_filter,
struct replay_gain_filter *filter =
(struct replay_gain_filter *)_filter;
- audio_format->reverse_endian = false;
-
filter->audio_format = *audio_format;
pcm_buffer_init(&filter->buffer);
diff --git a/src/filter/volume_filter_plugin.c b/src/filter/volume_filter_plugin.c
index f87a499ec..e52c0a463 100644
--- a/src/filter/volume_filter_plugin.c
+++ b/src/filter/volume_filter_plugin.c
@@ -74,8 +74,6 @@ volume_filter_open(struct filter *_filter, struct audio_format *audio_format,
{
struct volume_filter *filter = (struct volume_filter *)_filter;
- audio_format->reverse_endian = false;
-
filter->audio_format = *audio_format;
pcm_buffer_init(&filter->buffer);
diff --git a/src/output/alsa_output_plugin.c b/src/output/alsa_output_plugin.c
index c62ad2a46..00312c435 100644
--- a/src/output/alsa_output_plugin.c
+++ b/src/output/alsa_output_plugin.c
@@ -314,10 +314,8 @@ alsa_output_try_reverse(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
return -EINVAL;
int err = snd_pcm_hw_params_set_format(pcm, hwparams, alsa_format);
- if (err == 0) {
+ if (err == 0)
audio_format->format = sample_format;
- audio_format->reverse_endian = true;
- }
return err;
}
diff --git a/src/pcm_convert.c b/src/pcm_convert.c
index 4721d2496..fbdfe5e91 100644
--- a/src/pcm_convert.c
+++ b/src/pcm_convert.c
@@ -21,7 +21,6 @@
#include "pcm_convert.h"
#include "pcm_channels.h"
#include "pcm_format.h"
-#include "pcm_byteswap.h"
#include "pcm_pack.h"
#include "audio_format.h"
#include "glib_compat.h"
@@ -45,7 +44,6 @@ void pcm_convert_init(struct pcm_convert_state *state)
pcm_buffer_init(&state->format_buffer);
pcm_buffer_init(&state->pack_buffer);
pcm_buffer_init(&state->channels_buffer);
- pcm_buffer_init(&state->byteswap_buffer);
}
void pcm_convert_deinit(struct pcm_convert_state *state)
@@ -56,7 +54,6 @@ void pcm_convert_deinit(struct pcm_convert_state *state)
pcm_buffer_deinit(&state->format_buffer);
pcm_buffer_deinit(&state->pack_buffer);
pcm_buffer_deinit(&state->channels_buffer);
- pcm_buffer_deinit(&state->byteswap_buffer);
}
void
@@ -164,11 +161,6 @@ pcm_convert_16(struct pcm_convert_state *state,
return NULL;
}
- if (dest_format->reverse_endian) {
- buf = pcm_byteswap_16(&state->byteswap_buffer, buf, len);
- assert(buf != NULL);
- }
-
*dest_size_r = len;
return buf;
}
@@ -219,11 +211,6 @@ pcm_convert_24(struct pcm_convert_state *state,
return NULL;
}
- if (dest_format->reverse_endian) {
- buf = pcm_byteswap_32(&state->byteswap_buffer, buf, len);
- assert(buf != NULL);
- }
-
*dest_size_r = len;
return buf;
}
@@ -261,8 +248,7 @@ pcm_convert_24_packed(struct pcm_convert_state *state,
size_t dest_size = num_samples * 3;
uint8_t *dest = pcm_buffer_get(&state->pack_buffer, dest_size);
- pcm_pack_24(dest, buffer, buffer + num_samples,
- dest_format->reverse_endian);
+ pcm_pack_24(dest, buffer, buffer + num_samples);
*dest_size_r = dest_size;
return dest;
@@ -314,11 +300,6 @@ pcm_convert_32(struct pcm_convert_state *state,
return buf;
}
- if (dest_format->reverse_endian) {
- buf = pcm_byteswap_32(&state->byteswap_buffer, buf, len);
- assert(buf != NULL);
- }
-
*dest_size_r = len;
return buf;
}
@@ -335,12 +316,6 @@ pcm_convert_float(struct pcm_convert_state *state,
assert(dest_format->format == SAMPLE_FORMAT_FLOAT);
- if (src_format->reverse_endian || dest_format->reverse_endian) {
- g_set_error_literal(error_r, pcm_convert_quark(), 0,
- "Reverse endian not supported");
- return NULL;
- }
-
/* convert channels first, hoping the source format is
supported (float is not) */
@@ -392,20 +367,6 @@ pcm_convert(struct pcm_convert_state *state,
size_t *dest_size_r,
GError **error_r)
{
- if (src_format->reverse_endian) {
- /* convert to host byte order, because all of our
- conversion libraries assume host byte order */
-
- src = pcm_byteswap(&state->byteswap_buffer, src_format->format,
- src, src_size);
- if (src == NULL) {
- g_set_error(error_r, pcm_convert_quark(), 0,
- "PCM byte order change of format '%s' is not implemented",
- sample_format_to_string(src_format->format));
- return NULL;
- }
- }
-
struct audio_format float_format;
if (src_format->format == SAMPLE_FORMAT_DSD) {
size_t f_size;
diff --git a/src/pcm_convert.h b/src/pcm_convert.h
index 0a0f85681..2e69013ef 100644
--- a/src/pcm_convert.h
+++ b/src/pcm_convert.h
@@ -47,9 +47,6 @@ struct pcm_convert_state {
/** the buffer for converting the channel count */
struct pcm_buffer channels_buffer;
-
- /** the buffer for swapping the byte order */
- struct pcm_buffer byteswap_buffer;
};
static inline GQuark
diff --git a/src/pcm_format.c b/src/pcm_format.c
index 31de2200e..f6d6011d6 100644
--- a/src/pcm_format.c
+++ b/src/pcm_format.c
@@ -76,7 +76,7 @@ pcm_allocate_24_to_24p32(struct pcm_buffer *buffer, const uint8_t *src,
int32_t *dest;
*dest_size_r = src_size / 3 * sizeof(*dest);
dest = pcm_buffer_get(buffer, *dest_size_r);
- pcm_unpack_24(dest, src, pcm_end_pointer(src, src_size), false);
+ pcm_unpack_24(dest, src, pcm_end_pointer(src, src_size));
return dest;
}
diff --git a/src/pcm_pack.c b/src/pcm_pack.c
index 94fda5910..aa241f437 100644
--- a/src/pcm_pack.c
+++ b/src/pcm_pack.c
@@ -22,11 +22,11 @@
#include <glib.h>
static void
-pack_sample(uint8_t *dest, const int32_t *src0, bool reverse_endian)
+pack_sample(uint8_t *dest, const int32_t *src0)
{
const uint8_t *src = (const uint8_t *)src0;
- if ((G_BYTE_ORDER == G_BIG_ENDIAN) != reverse_endian)
+ if (G_BYTE_ORDER == G_BIG_ENDIAN)
++src;
*dest++ = *src++;
@@ -35,31 +35,23 @@ pack_sample(uint8_t *dest, const int32_t *src0, bool reverse_endian)
}
void
-pcm_pack_24(uint8_t *dest, const int32_t *src, const int32_t *src_end,
- bool reverse_endian)
+pcm_pack_24(uint8_t *dest, const int32_t *src, const int32_t *src_end)
{
/* duplicate loop to help the compiler's optimizer (constant
parameter to the pack_sample() inline function) */
- if (G_LIKELY(!reverse_endian)) {
- while (src < src_end) {
- pack_sample(dest, src++, false);
- dest += 3;
- }
- } else {
- while (src < src_end) {
- pack_sample(dest, src++, true);
- dest += 3;
- }
+ while (src < src_end) {
+ pack_sample(dest, src++);
+ dest += 3;
}
}
static void
-unpack_sample(int32_t *dest0, const uint8_t *src, bool reverse_endian)
+unpack_sample(int32_t *dest0, const uint8_t *src)
{
uint8_t *dest = (uint8_t *)dest0;
- if ((G_BYTE_ORDER == G_BIG_ENDIAN) != reverse_endian)
+ if (G_BYTE_ORDER == G_BIG_ENDIAN)
/* extend the sign bit to the most fourth byte */
*dest++ = *src & 0x80 ? 0xff : 0x00;
@@ -67,27 +59,19 @@ unpack_sample(int32_t *dest0, const uint8_t *src, bool reverse_endian)
*dest++ = *src++;
*dest++ = *src;
- if ((G_BYTE_ORDER == G_LITTLE_ENDIAN) != reverse_endian)
+ if (G_BYTE_ORDER != G_LITTLE_ENDIAN)
/* extend the sign bit to the most fourth byte */
*dest++ = *src & 0x80 ? 0xff : 0x00;
}
void
-pcm_unpack_24(int32_t *dest, const uint8_t *src, const uint8_t *src_end,
- bool reverse_endian)
+pcm_unpack_24(int32_t *dest, const uint8_t *src, const uint8_t *src_end)
{
/* duplicate loop to help the compiler's optimizer (constant
parameter to the unpack_sample() inline function) */
- if (G_LIKELY(!reverse_endian)) {
- while (src < src_end) {
- unpack_sample(dest++, src, false);
- src += 3;
- }
- } else {
- while (src < src_end) {
- unpack_sample(dest++, src, true);
- src += 3;
- }
+ while (src < src_end) {
+ unpack_sample(dest++, src);
+ src += 3;
}
}
diff --git a/src/pcm_pack.h b/src/pcm_pack.h
index 6f275608c..f3184b403 100644
--- a/src/pcm_pack.h
+++ b/src/pcm_pack.h
@@ -37,11 +37,9 @@
* @param dest the destination buffer (array of triples)
* @param src the source buffer
* @param num_samples the number of samples to convert
- * @param reverse_endian is src and dest in non-host byte order?
*/
void
-pcm_pack_24(uint8_t *dest, const int32_t *src, const int32_t *src_end,
- bool reverse_endian);
+pcm_pack_24(uint8_t *dest, const int32_t *src, const int32_t *src_end);
/**
* Converts packed 24 bit samples (3 bytes per sample) to padded 24
@@ -50,10 +48,8 @@ pcm_pack_24(uint8_t *dest, const int32_t *src, const int32_t *src_end,
* @param dest the destination buffer
* @param src the source buffer (array of triples)
* @param num_samples the number of samples to convert
- * @param reverse_endian is src and dest in non-host byte order?
*/
void
-pcm_unpack_24(int32_t *dest, const uint8_t *src, const uint8_t *src_end,
- bool reverse_endian);
+pcm_unpack_24(int32_t *dest, const uint8_t *src, const uint8_t *src_end);
#endif