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
f0f3017a
Commit
f0f3017a
authored
Feb 26, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/export: move Open() parameters to struct Params
parent
d3f0b623
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
30 deletions
+58
-30
AlsaOutputPlugin.cxx
src/output/plugins/AlsaOutputPlugin.cxx
+9
-7
OssOutputPlugin.cxx
src/output/plugins/OssOutputPlugin.cxx
+7
-4
PcmExport.cxx
src/pcm/PcmExport.cxx
+7
-9
PcmExport.hxx
src/pcm/PcmExport.hxx
+9
-2
test_pcm_export.cxx
test/test_pcm_export.cxx
+26
-8
No files found.
src/output/plugins/AlsaOutputPlugin.cxx
View file @
f0f3017a
...
@@ -716,22 +716,24 @@ AlsaOutput::SetupDop(const AudioFormat audio_format,
...
@@ -716,22 +716,24 @@ AlsaOutput::SetupDop(const AudioFormat audio_format,
inline
bool
inline
bool
AlsaOutput
::
SetupOrDop
(
AudioFormat
&
audio_format
,
Error
&
error
)
AlsaOutput
::
SetupOrDop
(
AudioFormat
&
audio_format
,
Error
&
error
)
{
{
bool
shift8
=
false
,
packed
,
reverse_endian
;
PcmExport
::
Params
params
;
params
.
alsa_channel_order
=
true
;
const
bool
dop2
=
dop
&&
params
.
dop
=
dop
&&
audio_format
.
format
==
SampleFormat
::
DSD
;
audio_format
.
format
==
SampleFormat
::
DSD
;
const
bool
success
=
params
.
dop
const
bool
success
=
dop2
?
SetupDop
(
audio_format
,
?
SetupDop
(
audio_format
,
&
shift8
,
&
packed
,
&
reverse_endian
,
&
params
.
shift8
,
&
params
.
pack24
,
&
params
.
reverse_endian
,
error
)
error
)
:
alsa_setup
(
this
,
audio_format
,
&
packed
,
&
reverse_endian
,
:
alsa_setup
(
this
,
audio_format
,
&
params
.
pack24
,
&
params
.
reverse_endian
,
error
);
error
);
if
(
!
success
)
if
(
!
success
)
return
false
;
return
false
;
pcm_export
->
Open
(
audio_format
.
format
,
pcm_export
->
Open
(
audio_format
.
format
,
audio_format
.
channels
,
audio_format
.
channels
,
true
,
dop2
,
shift8
,
packed
,
reverse_endian
);
params
);
return
true
;
return
true
;
}
}
...
...
src/output/plugins/OssOutputPlugin.cxx
View file @
f0f3017a
...
@@ -537,10 +537,13 @@ oss_probe_sample_format(int fd, SampleFormat sample_format,
...
@@ -537,10 +537,13 @@ oss_probe_sample_format(int fd, SampleFormat sample_format,
*
oss_format_r
=
oss_format
;
*
oss_format_r
=
oss_format
;
#ifdef AFMT_S24_PACKED
#ifdef AFMT_S24_PACKED
pcm_export
.
Open
(
sample_format
,
0
,
true
,
false
,
false
,
PcmExport
::
Params
params
;
oss_format
==
AFMT_S24_PACKED
,
params
.
alsa_channel_order
=
true
;
oss_format
==
AFMT_S24_PACKED
&&
params
.
pack24
=
oss_format
==
AFMT_S24_PACKED
;
!
IsLittleEndian
());
params
.
reverse_endian
=
oss_format
==
AFMT_S24_PACKED
&&
!
IsLittleEndian
();
pcm_export
.
Open
(
sample_format
,
0
,
params
);
#endif
#endif
return
SUCCESS
;
return
SUCCESS
;
...
...
src/pcm/PcmExport.cxx
View file @
f0f3017a
...
@@ -32,35 +32,33 @@
...
@@ -32,35 +32,33 @@
void
void
PcmExport
::
Open
(
SampleFormat
sample_format
,
unsigned
_channels
,
PcmExport
::
Open
(
SampleFormat
sample_format
,
unsigned
_channels
,
bool
_alsa_channel_order
,
Params
params
)
bool
_dop
,
bool
_shift8
,
bool
_pack
,
bool
_reverse_endian
)
{
{
assert
(
audio_valid_sample_format
(
sample_format
));
assert
(
audio_valid_sample_format
(
sample_format
));
channels
=
_channels
;
channels
=
_channels
;
alsa_channel_order
=
_
alsa_channel_order
alsa_channel_order
=
params
.
alsa_channel_order
?
sample_format
?
sample_format
:
SampleFormat
::
UNDEFINED
;
:
SampleFormat
::
UNDEFINED
;
#ifdef ENABLE_DSD
#ifdef ENABLE_DSD
assert
(
!
_
dop
||
audio_valid_channel_count
(
_channels
));
assert
(
!
params
.
dop
||
audio_valid_channel_count
(
_channels
));
dop
=
_
dop
&&
sample_format
==
SampleFormat
::
DSD
;
dop
=
params
.
dop
&&
sample_format
==
SampleFormat
::
DSD
;
if
(
dop
)
if
(
dop
)
/* after the conversion to DoP, the DSD
/* after the conversion to DoP, the DSD
samples are stuffed inside fake 24 bit samples */
samples are stuffed inside fake 24 bit samples */
sample_format
=
SampleFormat
::
S24_P32
;
sample_format
=
SampleFormat
::
S24_P32
;
#else
#else
(
void
)
_channels
;
(
void
)
_channels
;
(
void
)
_dop
;
#endif
#endif
shift8
=
_
shift8
&&
sample_format
==
SampleFormat
::
S24_P32
;
shift8
=
params
.
shift8
&&
sample_format
==
SampleFormat
::
S24_P32
;
pack24
=
_pack
&&
sample_format
==
SampleFormat
::
S24_P32
;
pack24
=
params
.
pack24
&&
sample_format
==
SampleFormat
::
S24_P32
;
assert
(
!
shift8
||
!
pack24
);
assert
(
!
shift8
||
!
pack24
);
reverse_endian
=
0
;
reverse_endian
=
0
;
if
(
_
reverse_endian
)
{
if
(
params
.
reverse_endian
)
{
size_t
sample_size
=
pack24
size_t
sample_size
=
pack24
?
3
?
3
:
sample_format_size
(
sample_format
);
:
sample_format_size
(
sample_format
);
...
...
src/pcm/PcmExport.hxx
View file @
f0f3017a
...
@@ -33,6 +33,14 @@ template<typename T> struct ConstBuffer;
...
@@ -33,6 +33,14 @@ template<typename T> struct ConstBuffer;
* representation which are not supported by the pcm_convert library.
* representation which are not supported by the pcm_convert library.
*/
*/
struct
PcmExport
{
struct
PcmExport
{
struct
Params
{
bool
alsa_channel_order
=
false
;
bool
dop
=
false
;
bool
shift8
=
false
;
bool
pack24
=
false
;
bool
reverse_endian
=
false
;
};
/**
/**
* This buffer is used to reorder channels.
* This buffer is used to reorder channels.
*
*
...
@@ -117,8 +125,7 @@ struct PcmExport {
...
@@ -117,8 +125,7 @@ struct PcmExport {
* @param channels the number of channels; ignored unless dop is set
* @param channels the number of channels; ignored unless dop is set
*/
*/
void
Open
(
SampleFormat
sample_format
,
unsigned
channels
,
void
Open
(
SampleFormat
sample_format
,
unsigned
channels
,
bool
_alsa_channel_order
,
Params
params
);
bool
dop
,
bool
shift8
,
bool
pack
,
bool
reverse_endian
);
/**
/**
* Calculate the size of one output frame.
* Calculate the size of one output frame.
...
...
test/test_pcm_export.cxx
View file @
f0f3017a
...
@@ -32,8 +32,11 @@ PcmExportTest::TestShift8()
...
@@ -32,8 +32,11 @@ PcmExportTest::TestShift8()
static
constexpr
int32_t
src
[]
=
{
0x0
,
0x1
,
0x100
,
0x10000
,
0xffffff
};
static
constexpr
int32_t
src
[]
=
{
0x0
,
0x1
,
0x100
,
0x10000
,
0xffffff
};
static
constexpr
uint32_t
expected
[]
=
{
0x0
,
0x100
,
0x10000
,
0x1000000
,
0xffffff00
};
static
constexpr
uint32_t
expected
[]
=
{
0x0
,
0x100
,
0x10000
,
0x1000000
,
0xffffff00
};
PcmExport
::
Params
params
;
params
.
shift8
=
true
;
PcmExport
e
;
PcmExport
e
;
e
.
Open
(
SampleFormat
::
S24_P32
,
2
,
false
,
false
,
true
,
false
,
false
);
e
.
Open
(
SampleFormat
::
S24_P32
,
2
,
params
);
auto
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
auto
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected
),
dest
.
size
);
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected
),
dest
.
size
);
...
@@ -65,8 +68,11 @@ PcmExportTest::TestPack24()
...
@@ -65,8 +68,11 @@ PcmExportTest::TestPack24()
static
const
uint8_t
*
const
expected
=
IsBigEndian
()
static
const
uint8_t
*
const
expected
=
IsBigEndian
()
?
expected_be
:
expected_le
;
?
expected_be
:
expected_le
;
PcmExport
::
Params
params
;
params
.
pack24
=
true
;
PcmExport
e
;
PcmExport
e
;
e
.
Open
(
SampleFormat
::
S24_P32
,
2
,
false
,
false
,
false
,
true
,
false
);
e
.
Open
(
SampleFormat
::
S24_P32
,
2
,
params
);
auto
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
auto
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
CPPUNIT_ASSERT_EQUAL
(
expected_size
,
dest
.
size
);
CPPUNIT_ASSERT_EQUAL
(
expected_size
,
dest
.
size
);
...
@@ -88,19 +94,22 @@ PcmExportTest::TestReverseEndian()
...
@@ -88,19 +94,22 @@ PcmExportTest::TestReverseEndian()
4
,
3
,
2
,
1
,
8
,
7
,
6
,
5
,
12
,
11
,
10
,
9
,
4
,
3
,
2
,
1
,
8
,
7
,
6
,
5
,
12
,
11
,
10
,
9
,
};
};
PcmExport
::
Params
params
;
params
.
reverse_endian
=
true
;
PcmExport
e
;
PcmExport
e
;
e
.
Open
(
SampleFormat
::
S8
,
2
,
false
,
false
,
false
,
false
,
true
);
e
.
Open
(
SampleFormat
::
S8
,
2
,
params
);
auto
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
auto
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
src
),
dest
.
size
);
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
src
),
dest
.
size
);
CPPUNIT_ASSERT
(
memcmp
(
dest
.
data
,
src
,
dest
.
size
)
==
0
);
CPPUNIT_ASSERT
(
memcmp
(
dest
.
data
,
src
,
dest
.
size
)
==
0
);
e
.
Open
(
SampleFormat
::
S16
,
2
,
false
,
false
,
false
,
false
,
true
);
e
.
Open
(
SampleFormat
::
S16
,
2
,
params
);
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected2
),
dest
.
size
);
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected2
),
dest
.
size
);
CPPUNIT_ASSERT
(
memcmp
(
dest
.
data
,
expected2
,
dest
.
size
)
==
0
);
CPPUNIT_ASSERT
(
memcmp
(
dest
.
data
,
expected2
,
dest
.
size
)
==
0
);
e
.
Open
(
SampleFormat
::
S32
,
2
,
false
,
false
,
false
,
false
,
true
);
e
.
Open
(
SampleFormat
::
S32
,
2
,
params
);
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected4
),
dest
.
size
);
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected4
),
dest
.
size
);
CPPUNIT_ASSERT
(
memcmp
(
dest
.
data
,
expected4
,
dest
.
size
)
==
0
);
CPPUNIT_ASSERT
(
memcmp
(
dest
.
data
,
expected4
,
dest
.
size
)
==
0
);
...
@@ -121,8 +130,11 @@ PcmExportTest::TestDop()
...
@@ -121,8 +130,11 @@ PcmExportTest::TestDop()
0xfffaabef
,
0xfffaabef
,
};
};
PcmExport
::
Params
params
;
params
.
dop
=
true
;
PcmExport
e
;
PcmExport
e
;
e
.
Open
(
SampleFormat
::
DSD
,
2
,
false
,
true
,
false
,
false
,
false
);
e
.
Open
(
SampleFormat
::
DSD
,
2
,
params
);
auto
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
auto
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected
),
dest
.
size
);
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected
),
dest
.
size
);
...
@@ -145,8 +157,11 @@ TestAlsaChannelOrder51()
...
@@ -145,8 +157,11 @@ TestAlsaChannelOrder51()
6
,
7
,
10
,
11
,
8
,
9
,
6
,
7
,
10
,
11
,
8
,
9
,
};
};
PcmExport
::
Params
params
;
params
.
alsa_channel_order
=
true
;
PcmExport
e
;
PcmExport
e
;
e
.
Open
(
F
,
6
,
true
,
false
,
false
,
false
,
false
);
e
.
Open
(
F
,
6
,
params
);
auto
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
auto
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected
),
dest
.
size
);
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected
),
dest
.
size
);
...
@@ -169,8 +184,11 @@ TestAlsaChannelOrder71()
...
@@ -169,8 +184,11 @@ TestAlsaChannelOrder71()
8
,
9
,
12
,
13
,
10
,
11
,
14
,
15
,
8
,
9
,
12
,
13
,
10
,
11
,
14
,
15
,
};
};
PcmExport
::
Params
params
;
params
.
alsa_channel_order
=
true
;
PcmExport
e
;
PcmExport
e
;
e
.
Open
(
F
,
8
,
true
,
false
,
false
,
false
,
false
);
e
.
Open
(
F
,
8
,
params
);
auto
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
auto
dest
=
e
.
Export
({
src
,
sizeof
(
src
)});
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected
),
dest
.
size
);
CPPUNIT_ASSERT_EQUAL
(
sizeof
(
expected
),
dest
.
size
);
...
...
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