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
5a22a0c2
Commit
5a22a0c2
authored
Jun 10, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/pcm: implement RFC 2586 (audio/L16)
https://bugs.musicpd.org/view.php?id=4525
parent
287ef181
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
2 deletions
+71
-2
NEWS
NEWS
+1
-0
user.xml
doc/user.xml
+3
-1
PcmDecoderPlugin.cxx
src/decoder/plugins/PcmDecoderPlugin.cxx
+67
-1
No files found.
NEWS
View file @
5a22a0c2
...
...
@@ -23,6 +23,7 @@ ver 0.20 (not yet released)
- gme: add option "accuracy"
- mad: reduce memory usage while scanning tags
- mpcdec: read the bit rate
- pcm: support audio/L16 (RFC 2586)
* playlist
- cue: don't skip pregap
- embcue: fix last track
...
...
doc/user.xml
View file @
5a22a0c2
...
...
@@ -1942,7 +1942,9 @@ buffer_size: 16384</programlisting>
<title><varname>
pcm
</varname></title>
<para>
Read raw PCM samples.
Read raw PCM samples. It understands the "audio/L16" MIME
type with parameters "rate" and "channels" according to RFC
2586.
</para>
</section>
...
...
src/decoder/plugins/PcmDecoderPlugin.cxx
View file @
5a22a0c2
...
...
@@ -20,9 +20,12 @@
#include "config.h"
#include "PcmDecoderPlugin.hxx"
#include "../DecoderAPI.hxx"
#include "CheckAudioFormat.hxx"
#include "input/InputStream.hxx"
#include "util/Error.hxx"
#include "util/ByteReverse.hxx"
#include "util/NumberParser.hxx"
#include "util/MimeType.hxx"
#include "Log.hxx"
#include <string.h>
...
...
@@ -30,7 +33,7 @@
static
void
pcm_stream_decode
(
Decoder
&
decoder
,
InputStream
&
is
)
{
static
constexpr
AudioFormat
audio_format
=
{
AudioFormat
audio_format
=
{
44100
,
SampleFormat
::
S16
,
2
,
...
...
@@ -40,6 +43,66 @@ pcm_stream_decode(Decoder &decoder, InputStream &is)
const
bool
reverse_endian
=
mime
!=
nullptr
&&
strcmp
(
mime
,
"audio/x-mpd-cdda-pcm-reverse"
)
==
0
;
const
bool
l16
=
mime
!=
nullptr
&&
GetMimeTypeBase
(
mime
)
==
"audio/L16"
;
if
(
l16
)
{
audio_format
.
sample_rate
=
0
;
audio_format
.
channels
=
1
;
}
{
const
auto
mime_parameters
=
ParseMimeTypeParameters
(
mime
);
Error
error
;
/* MIME type parameters according to RFC 2586 */
auto
i
=
mime_parameters
.
find
(
"rate"
);
if
(
i
!=
mime_parameters
.
end
())
{
const
char
*
s
=
i
->
second
.
c_str
();
char
*
endptr
;
unsigned
value
=
ParseUnsigned
(
s
,
&
endptr
);
if
(
endptr
==
s
||
*
endptr
!=
0
)
{
FormatWarning
(
audio_format_domain
,
"Failed to parse sample rate: %s"
,
s
);
return
;
}
if
(
!
audio_check_sample_rate
(
value
,
error
))
{
LogError
(
error
);
return
;
}
audio_format
.
sample_rate
=
value
;
}
i
=
mime_parameters
.
find
(
"channels"
);
if
(
i
!=
mime_parameters
.
end
())
{
const
char
*
s
=
i
->
second
.
c_str
();
char
*
endptr
;
unsigned
value
=
ParseUnsigned
(
s
,
&
endptr
);
if
(
endptr
==
s
||
*
endptr
!=
0
)
{
FormatWarning
(
audio_format_domain
,
"Failed to parse sample rate: %s"
,
s
);
return
;
}
if
(
!
audio_check_channel_count
(
value
,
error
))
{
LogError
(
error
);
return
;
}
audio_format
.
channels
=
value
;
}
}
if
(
audio_format
.
sample_rate
==
0
)
{
FormatWarning
(
audio_format_domain
,
"Missing 'rate' parameter: %s"
,
mime
);
return
;
}
const
auto
frame_size
=
audio_format
.
GetFrameSize
();
const
auto
total_time
=
is
.
KnownSize
()
...
...
@@ -88,6 +151,9 @@ pcm_stream_decode(Decoder &decoder, InputStream &is)
}
static
const
char
*
const
pcm_mime_types
[]
=
{
/* RFC 2586 */
"audio/L16"
,
/* for streams obtained by the cdio_paranoia input plugin */
"audio/x-mpd-cdda-pcm"
,
...
...
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