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
5fa76102
Commit
5fa76102
authored
Jul 05, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/Volume: Open() returns output sample format
Prepare for a new mode which may convert to a different sample format when applying volume, to reduce dithering.
parent
1c757f8c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
8 deletions
+13
-8
ReplayGainFilterPlugin.cxx
src/filter/plugins/ReplayGainFilterPlugin.cxx
+1
-1
VolumeFilterPlugin.cxx
src/filter/plugins/VolumeFilterPlugin.cxx
+1
-1
Volume.cxx
src/pcm/Volume.cxx
+2
-2
Volume.hxx
src/pcm/Volume.hxx
+3
-2
software_volume.cxx
test/software_volume.cxx
+5
-1
test_pcm_volume.cxx
test/test_pcm_volume.cxx
+1
-1
No files found.
src/filter/plugins/ReplayGainFilterPlugin.cxx
View file @
5fa76102
...
@@ -77,7 +77,7 @@ public:
...
@@ -77,7 +77,7 @@ public:
mixer
(
_mixer
),
base
(
_base
)
{
mixer
(
_mixer
),
base
(
_base
)
{
info
.
Clear
();
info
.
Clear
();
pv
.
Open
(
out_audio_format
.
format
);
out_audio_format
.
format
=
pv
.
Open
(
out_audio_format
.
format
);
}
}
void
SetInfo
(
const
ReplayGainInfo
*
_info
)
{
void
SetInfo
(
const
ReplayGainInfo
*
_info
)
{
...
...
src/filter/plugins/VolumeFilterPlugin.cxx
View file @
5fa76102
...
@@ -30,7 +30,7 @@ class VolumeFilter final : public Filter {
...
@@ -30,7 +30,7 @@ class VolumeFilter final : public Filter {
public
:
public
:
explicit
VolumeFilter
(
const
AudioFormat
&
audio_format
)
explicit
VolumeFilter
(
const
AudioFormat
&
audio_format
)
:
Filter
(
audio_format
)
{
:
Filter
(
audio_format
)
{
pv
.
Open
(
out_audio_format
.
format
);
out_audio_format
.
format
=
pv
.
Open
(
out_audio_format
.
format
);
}
}
unsigned
GetVolume
()
const
noexcept
{
unsigned
GetVolume
()
const
noexcept
{
...
...
src/pcm/Volume.cxx
View file @
5fa76102
...
@@ -96,7 +96,7 @@ pcm_volume_change_float(float *dest, const float *src, size_t n,
...
@@ -96,7 +96,7 @@ pcm_volume_change_float(float *dest, const float *src, size_t n,
dest
[
i
]
=
src
[
i
]
*
volume
;
dest
[
i
]
=
src
[
i
]
*
volume
;
}
}
void
SampleFormat
PcmVolume
::
Open
(
SampleFormat
_format
)
PcmVolume
::
Open
(
SampleFormat
_format
)
{
{
assert
(
format
==
SampleFormat
::
UNDEFINED
);
assert
(
format
==
SampleFormat
::
UNDEFINED
);
...
@@ -118,7 +118,7 @@ PcmVolume::Open(SampleFormat _format)
...
@@ -118,7 +118,7 @@ PcmVolume::Open(SampleFormat _format)
break
;
break
;
}
}
format
=
_format
;
return
format
=
_format
;
}
}
ConstBuffer
<
void
>
ConstBuffer
<
void
>
...
...
src/pcm/Volume.hxx
View file @
5fa76102
...
@@ -94,9 +94,10 @@ public:
...
@@ -94,9 +94,10 @@ public:
*
*
* Throws on error.
* Throws on error.
*
*
* @param format the sample format
* @param format the input sample format
* @return the output sample format
*/
*/
void
Open
(
SampleFormat
format
);
SampleFormat
Open
(
SampleFormat
format
);
/**
/**
* Closes the object. After that, you may call Open() again.
* Closes the object. After that, you may call Open() again.
...
...
test/software_volume.cxx
View file @
5fa76102
...
@@ -50,7 +50,11 @@ try {
...
@@ -50,7 +50,11 @@ try {
audio_format
=
ParseAudioFormat
(
argv
[
1
],
false
);
audio_format
=
ParseAudioFormat
(
argv
[
1
],
false
);
PcmVolume
pv
;
PcmVolume
pv
;
pv
.
Open
(
audio_format
.
format
);
const
auto
out_sample_format
=
pv
.
Open
(
audio_format
.
format
);
if
(
out_sample_format
!=
audio_format
.
format
)
fprintf
(
stderr
,
"Converting to %s
\n
"
,
sample_format_to_string
(
out_sample_format
));
while
((
nbytes
=
read
(
0
,
buffer
,
sizeof
(
buffer
)))
>
0
)
{
while
((
nbytes
=
read
(
0
,
buffer
,
sizeof
(
buffer
)))
>
0
)
{
auto
dest
=
pv
.
Apply
({
buffer
,
size_t
(
nbytes
)});
auto
dest
=
pv
.
Apply
({
buffer
,
size_t
(
nbytes
)});
...
...
test/test_pcm_volume.cxx
View file @
5fa76102
...
@@ -36,7 +36,7 @@ TestVolume(G g=G())
...
@@ -36,7 +36,7 @@ TestVolume(G g=G())
typedef
typename
Traits
::
value_type
value_type
;
typedef
typename
Traits
::
value_type
value_type
;
PcmVolume
pv
;
PcmVolume
pv
;
pv
.
Open
(
F
);
EXPECT_EQ
(
pv
.
Open
(
F
),
F
);
constexpr
size_t
N
=
509
;
constexpr
size_t
N
=
509
;
static
value_type
zero
[
N
];
static
value_type
zero
[
N
];
...
...
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