pcm_{mix,volume}: pass only sample_format to pcm_mix()
The other audio_format attributes are not used.
This commit is contained in:
parent
572d8d0cc4
commit
0847ca4ec2
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user