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
e3f9e96e
Commit
e3f9e96e
authored
Jun 17, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/Dop: convert public function to stateful class
Preparing to add more state.
parent
8f9b3cbf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
16 deletions
+44
-16
Dop.cxx
src/pcm/Dop.cxx
+9
-3
Dop.hxx
src/pcm/Dop.hxx
+15
-4
Export.cxx
src/pcm/Export.cxx
+14
-3
Export.hxx
src/pcm/Export.hxx
+6
-6
No files found.
src/pcm/Dop.cxx
View file @
e3f9e96e
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
*/
*/
#include "Dop.hxx"
#include "Dop.hxx"
#include "Buffer.hxx"
#include "ChannelDefs.hxx"
#include "ChannelDefs.hxx"
#include "util/ConstBuffer.hxx"
#include "util/ConstBuffer.hxx"
...
@@ -78,9 +77,16 @@ DsdToDop(uint32_t *dest, const uint8_t *src,
...
@@ -78,9 +77,16 @@ DsdToDop(uint32_t *dest, const uint8_t *src,
}
}
}
}
void
DsdToDopConverter
::
Open
(
unsigned
_channels
)
noexcept
{
assert
(
audio_valid_channel_count
(
_channels
));
channels
=
_channels
;
}
ConstBuffer
<
uint32_t
>
ConstBuffer
<
uint32_t
>
pcm_dsd_to_dop
(
PcmBuffer
&
buffer
,
unsigned
channels
,
DsdToDopConverter
::
Convert
(
ConstBuffer
<
uint8_t
>
src
)
noexcept
ConstBuffer
<
uint8_t
>
src
)
noexcept
{
{
assert
(
audio_valid_channel_count
(
channels
));
assert
(
audio_valid_channel_count
(
channels
));
assert
(
src
.
size
%
channels
==
0
);
assert
(
src
.
size
%
channels
==
0
);
...
...
src/pcm/Dop.hxx
View file @
e3f9e96e
...
@@ -20,9 +20,10 @@
...
@@ -20,9 +20,10 @@
#ifndef MPD_PCM_DOP_HXX
#ifndef MPD_PCM_DOP_HXX
#define MPD_PCM_DOP_HXX
#define MPD_PCM_DOP_HXX
#include "Buffer.hxx"
#include <stdint.h>
#include <stdint.h>
class
PcmBuffer
;
template
<
typename
T
>
struct
ConstBuffer
;
template
<
typename
T
>
struct
ConstBuffer
;
/**
/**
...
@@ -30,8 +31,18 @@ template<typename T> struct ConstBuffer;
...
@@ -30,8 +31,18 @@ template<typename T> struct ConstBuffer;
* playback over USB, according to the DoP standard:
* playback over USB, according to the DoP standard:
* http://dsd-guide.com/dop-open-standard
* http://dsd-guide.com/dop-open-standard
*/
*/
ConstBuffer
<
uint32_t
>
class
DsdToDopConverter
{
pcm_dsd_to_dop
(
PcmBuffer
&
buffer
,
unsigned
channels
,
unsigned
channels
;
ConstBuffer
<
uint8_t
>
src
)
noexcept
;
PcmBuffer
buffer
;
public
:
void
Open
(
unsigned
_channels
)
noexcept
;
void
Reset
()
noexcept
{
}
ConstBuffer
<
uint32_t
>
Convert
(
ConstBuffer
<
uint8_t
>
src
)
noexcept
;
};
#endif
#endif
src/pcm/Export.cxx
View file @
e3f9e96e
...
@@ -61,10 +61,13 @@ PcmExport::Open(SampleFormat sample_format, unsigned _channels,
...
@@ -61,10 +61,13 @@ PcmExport::Open(SampleFormat sample_format, unsigned _channels,
sample_format
=
SampleFormat
::
S32
;
sample_format
=
SampleFormat
::
S32
;
dop
=
params
.
dop
&&
sample_format
==
SampleFormat
::
DSD
;
dop
=
params
.
dop
&&
sample_format
==
SampleFormat
::
DSD
;
if
(
dop
)
if
(
dop
)
{
dop_converter
.
Open
(
_channels
);
/* 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
;
}
#endif
#endif
shift8
=
params
.
shift8
&&
sample_format
==
SampleFormat
::
S24_P32
;
shift8
=
params
.
shift8
&&
sample_format
==
SampleFormat
::
S24_P32
;
...
@@ -84,6 +87,15 @@ PcmExport::Open(SampleFormat sample_format, unsigned _channels,
...
@@ -84,6 +87,15 @@ PcmExport::Open(SampleFormat sample_format, unsigned _channels,
}
}
}
}
void
PcmExport
::
Reset
()
noexcept
{
#ifdef ENABLE_DSD
if
(
dop
)
dop_converter
.
Reset
();
#endif
}
size_t
size_t
PcmExport
::
GetFrameSize
(
const
AudioFormat
&
audio_format
)
const
noexcept
PcmExport
::
GetFrameSize
(
const
AudioFormat
&
audio_format
)
const
noexcept
{
{
...
@@ -168,8 +180,7 @@ PcmExport::Export(ConstBuffer<void> data) noexcept
...
@@ -168,8 +180,7 @@ PcmExport::Export(ConstBuffer<void> data) noexcept
.
ToVoid
();
.
ToVoid
();
if
(
dop
)
if
(
dop
)
data
=
pcm_dsd_to_dop
(
dop_buffer
,
channels
,
data
=
dop_converter
.
Convert
(
ConstBuffer
<
uint8_t
>::
FromVoid
(
data
))
ConstBuffer
<
uint8_t
>::
FromVoid
(
data
))
.
ToVoid
();
.
ToVoid
();
#endif
#endif
...
...
src/pcm/Export.hxx
View file @
e3f9e96e
...
@@ -24,6 +24,10 @@
...
@@ -24,6 +24,10 @@
#include "Buffer.hxx"
#include "Buffer.hxx"
#include "config.h"
#include "config.h"
#ifdef ENABLE_DSD
#include "Dop.hxx"
#endif
template
<
typename
T
>
struct
ConstBuffer
;
template
<
typename
T
>
struct
ConstBuffer
;
struct
AudioFormat
;
struct
AudioFormat
;
...
@@ -49,12 +53,9 @@ class PcmExport {
...
@@ -49,12 +53,9 @@ class PcmExport {
PcmBuffer
dsd_buffer
;
PcmBuffer
dsd_buffer
;
/**
/**
* The buffer is used to convert DSD samples to the
* DoP format.
*
* @see #dop
* @see #dop
*/
*/
PcmBuffer
dop_buff
er
;
DsdToDopConverter
dop_convert
er
;
#endif
#endif
/**
/**
...
@@ -167,8 +168,7 @@ public:
...
@@ -167,8 +168,7 @@ public:
/**
/**
* Reset the filter's state, e.g. drop/flush buffers.
* Reset the filter's state, e.g. drop/flush buffers.
*/
*/
void
Reset
()
noexcept
{
void
Reset
()
noexcept
;
}
/**
/**
* Calculate the size of one output frame.
* Calculate the size of one output frame.
...
...
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