Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
0847ca4e
Commit
0847ca4e
authored
Oct 10, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm_{mix,volume}: pass only sample_format to pcm_mix()
The other audio_format attributes are not used.
parent
572d8d0c
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
23 additions
and
22 deletions
+23
-22
replay_gain_filter_plugin.c
src/filter/replay_gain_filter_plugin.c
+1
-1
volume_filter_plugin.c
src/filter/volume_filter_plugin.c
+1
-1
output_thread.c
src/output_thread.c
+1
-1
pcm_mix.c
src/pcm_mix.c
+7
-7
pcm_mix.h
src/pcm_mix.h
+4
-4
pcm_volume.c
src/pcm_volume.c
+2
-2
pcm_volume.h
src/pcm_volume.h
+3
-2
read_mixer.c
test/read_mixer.c
+1
-1
read_tags.c
test/read_tags.c
+1
-1
run_decoder.c
test/run_decoder.c
+1
-1
software_volume.c
test/software_volume.c
+1
-1
No files found.
src/filter/replay_gain_filter_plugin.c
View file @
0847ca4e
...
...
@@ -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
,
...
...
src/filter/volume_filter_plugin.c
View file @
0847ca4e
...
...
@@ -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
,
...
...
src/output_thread.c
View file @
0847ca4e
...
...
@@ -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
;
...
...
src/pcm_mix.c
View file @
0847ca4e
...
...
@@ -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
;
...
...
src/pcm_mix.h
View file @
0847ca4e
...
...
@@ -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
src/pcm_volume.c
View file @
0847ca4e
...
...
@@ -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
;
...
...
src/pcm_volume.h
View file @
0847ca4e
...
...
@@ -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
test/read_mixer.c
View file @
0847ca4e
...
...
@@ -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
);
...
...
test/read_tags.c
View file @
0847ca4e
...
...
@@ -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
;
...
...
test/run_decoder.c
View file @
0847ca4e
...
...
@@ -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
;
...
...
test/software_volume.c
View file @
0847ca4e
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment