aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/filter/replay_gain_filter_plugin.c2
-rw-r--r--src/filter/volume_filter_plugin.c2
-rw-r--r--src/output_thread.c2
-rw-r--r--src/pcm_mix.c14
-rw-r--r--src/pcm_mix.h8
-rw-r--r--src/pcm_volume.c4
-rw-r--r--src/pcm_volume.h5
-rw-r--r--test/read_mixer.c2
-rw-r--r--test/read_tags.c2
-rw-r--r--test/run_decoder.c2
-rw-r--r--test/software_volume.c2
11 files changed, 23 insertions, 22 deletions
diff --git a/src/filter/replay_gain_filter_plugin.c b/src/filter/replay_gain_filter_plugin.c
index 656e464e..c21fe4ea 100644
--- a/src/filter/replay_gain_filter_plugin.c
+++ b/src/filter/replay_gain_filter_plugin.c
@@ -195,7 +195,7 @@ replay_gain_filter_filter(struct filter *_filter,
memcpy(dest, src, src_size);
- success = pcm_volume(dest, src_size, &filter->audio_format,
+ success = pcm_volume(dest, src_size, filter->audio_format.format,
filter->volume);
if (!success) {
g_set_error(error_r, replay_gain_quark(), 0,
diff --git a/src/filter/volume_filter_plugin.c b/src/filter/volume_filter_plugin.c
index 8c50e3cd..f87a499e 100644
--- a/src/filter/volume_filter_plugin.c
+++ b/src/filter/volume_filter_plugin.c
@@ -116,7 +116,7 @@ volume_filter_filter(struct filter *_filter, const void *src, size_t src_size,
memcpy(dest, src, src_size);
- success = pcm_volume(dest, src_size, &filter->audio_format,
+ success = pcm_volume(dest, src_size, filter->audio_format.format,
filter->volume);
if (!success) {
g_set_error(error_r, volume_quark(), 0,
diff --git a/src/output_thread.c b/src/output_thread.c
index e194edc9..e6b815ce 100644
--- a/src/output_thread.c
+++ b/src/output_thread.c
@@ -401,7 +401,7 @@ ao_filter_chunk(struct audio_output *ao, const struct music_chunk *chunk,
char *dest = pcm_buffer_get(&ao->cross_fade_buffer,
other_length);
memcpy(dest, other_data, other_length);
- pcm_mix(dest, data, length, &ao->in_audio_format,
+ pcm_mix(dest, data, length, ao->in_audio_format.format,
1.0 - chunk->mix_ratio);
data = dest;
diff --git a/src/pcm_mix.c b/src/pcm_mix.c
index 8cdad2c1..b1b4f4f2 100644
--- a/src/pcm_mix.c
+++ b/src/pcm_mix.c
@@ -102,9 +102,9 @@ pcm_add_vol_32(int32_t *buffer1, const int32_t *buffer2,
static void
pcm_add_vol(void *buffer1, const void *buffer2, size_t size,
int vol1, int vol2,
- const struct audio_format *format)
+ enum sample_format format)
{
- switch (format->format) {
+ switch (format) {
case SAMPLE_FORMAT_S8:
pcm_add_vol_8((int8_t *)buffer1, (const int8_t *)buffer2,
size, vol1, vol2);
@@ -127,7 +127,7 @@ pcm_add_vol(void *buffer1, const void *buffer2, size_t size,
default:
MPD_ERROR("format %s not supported by pcm_add_vol",
- sample_format_to_string(format->format));
+ sample_format_to_string(format));
}
}
@@ -189,9 +189,9 @@ pcm_add_32(int32_t *buffer1, const int32_t *buffer2, unsigned num_samples)
static void
pcm_add(void *buffer1, const void *buffer2, size_t size,
- const struct audio_format *format)
+ enum sample_format format)
{
- switch (format->format) {
+ switch (format) {
case SAMPLE_FORMAT_S8:
pcm_add_8((int8_t *)buffer1, (const int8_t *)buffer2, size);
break;
@@ -210,13 +210,13 @@ pcm_add(void *buffer1, const void *buffer2, size_t size,
default:
MPD_ERROR("format %s not supported by pcm_add",
- sample_format_to_string(format->format));
+ sample_format_to_string(format));
}
}
void
pcm_mix(void *buffer1, const void *buffer2, size_t size,
- const struct audio_format *format, float portion1)
+ enum sample_format format, float portion1)
{
int vol1;
float s;
diff --git a/src/pcm_mix.h b/src/pcm_mix.h
index 9b576f40..10a07168 100644
--- a/src/pcm_mix.h
+++ b/src/pcm_mix.h
@@ -20,9 +20,9 @@
#ifndef PCM_MIX_H
#define PCM_MIX_H
-#include <stddef.h>
+#include "audio_format.h"
-struct audio_format;
+#include <stddef.h>
/*
* Linearly mixes two PCM buffers. Both must have the same length and
@@ -33,13 +33,13 @@ struct audio_format;
* @param buffer1 the first PCM buffer, and the destination buffer
* @param buffer2 the second PCM buffer
* @param size the size of both buffers in bytes
- * @param format the audio format of both buffers
+ * @param format the sample format of both buffers
* @param portion1 a number between 0.0 and 1.0 specifying the portion
* of the first buffer in the mix; portion2 = (1.0 - portion1). The value
* NaN is used by the MixRamp code to specify that simple addition is required.
*/
void
pcm_mix(void *buffer1, const void *buffer2, size_t size,
- const struct audio_format *format, float portion1);
+ enum sample_format format, float portion1);
#endif
diff --git a/src/pcm_volume.c b/src/pcm_volume.c
index 69c239cb..7d9d2fe4 100644
--- a/src/pcm_volume.c
+++ b/src/pcm_volume.c
@@ -139,7 +139,7 @@ pcm_volume_change_32(int32_t *buffer, unsigned num_samples, int volume)
bool
pcm_volume(void *buffer, int length,
- const struct audio_format *format,
+ enum sample_format format,
int volume)
{
if (volume == PCM_VOLUME_1)
@@ -150,7 +150,7 @@ pcm_volume(void *buffer, int length,
return true;
}
- switch (format->format) {
+ switch (format) {
case SAMPLE_FORMAT_S8:
pcm_volume_change_8((int8_t *)buffer, length, volume);
return true;
diff --git a/src/pcm_volume.h b/src/pcm_volume.h
index b389dee3..3fd722e7 100644
--- a/src/pcm_volume.h
+++ b/src/pcm_volume.h
@@ -21,6 +21,7 @@
#define PCM_VOLUME_H
#include "pcm_prng.h"
+#include "audio_format.h"
#include <stdint.h>
#include <stdbool.h>
@@ -62,13 +63,13 @@ pcm_volume_dither(void)
*
* @param buffer the PCM buffer
* @param length the length of the PCM buffer
- * @param format the audio format of the PCM buffer
+ * @param format the sample format of the PCM buffer
* @param volume the volume between 0 and #PCM_VOLUME_1
* @return true on success, false if the audio format is not supported
*/
bool
pcm_volume(void *buffer, int length,
- const struct audio_format *format,
+ enum sample_format format,
int volume);
#endif
diff --git a/test/read_mixer.c b/test/read_mixer.c
index 6d7ec345..bf17e8f6 100644
--- a/test/read_mixer.c
+++ b/test/read_mixer.c
@@ -116,7 +116,7 @@ filter_plugin_by_name(G_GNUC_UNUSED const char *name)
bool
pcm_volume(G_GNUC_UNUSED void *buffer, G_GNUC_UNUSED int length,
- G_GNUC_UNUSED const struct audio_format *format,
+ G_GNUC_UNUSED enum sample_format format,
G_GNUC_UNUSED int volume)
{
assert(false);
diff --git a/test/read_tags.c b/test/read_tags.c
index 1d742e9e..30981994 100644
--- a/test/read_tags.c
+++ b/test/read_tags.c
@@ -53,7 +53,7 @@ idle_add(G_GNUC_UNUSED unsigned flags)
*/
bool
pcm_volume(G_GNUC_UNUSED void *buffer, G_GNUC_UNUSED int length,
- G_GNUC_UNUSED const struct audio_format *format,
+ G_GNUC_UNUSED enum sample_format format,
G_GNUC_UNUSED int volume)
{
return true;
diff --git a/test/run_decoder.c b/test/run_decoder.c
index 87dffa63..9959b6de 100644
--- a/test/run_decoder.c
+++ b/test/run_decoder.c
@@ -57,7 +57,7 @@ idle_add(G_GNUC_UNUSED unsigned flags)
*/
bool
pcm_volume(G_GNUC_UNUSED void *buffer, G_GNUC_UNUSED int length,
- G_GNUC_UNUSED const struct audio_format *format,
+ G_GNUC_UNUSED enum sample_format format,
G_GNUC_UNUSED int volume)
{
return true;
diff --git a/test/software_volume.c b/test/software_volume.c
index 67dd1808..1e068be4 100644
--- a/test/software_volume.c
+++ b/test/software_volume.c
@@ -59,7 +59,7 @@ int main(int argc, char **argv)
audio_format_init(&audio_format, 48000, SAMPLE_FORMAT_S16, 2);
while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) {
- if (!pcm_volume(buffer, nbytes, &audio_format,
+ if (!pcm_volume(buffer, nbytes, audio_format.format,
PCM_VOLUME_1 / 2)) {
g_printerr("pcm_volume() has failed\n");
return 2;