aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-10-10 08:11:04 +0200
committerMax Kellermann <max@duempel.org>2011-10-10 10:24:05 +0200
commit0847ca4ec2e137d0eaa235d653217e8a913187f8 (patch)
tree2d00b5b7e7700ee216890b83f86c6528090079a1 /src
parent572d8d0cc486dce64c0f6239cc27598068c1085d (diff)
pcm_{mix,volume}: pass only sample_format to pcm_mix()
The other audio_format attributes are not used.
Diffstat (limited to 'src')
-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
7 files changed, 19 insertions, 18 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