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
352d7f47
Commit
352d7f47
authored
Jul 28, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/{dsf,dsdiff}: convert to C++
parent
1fcf35ad
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
115 additions
and
120 deletions
+115
-120
Makefile.am
Makefile.am
+6
-6
DecoderList.cxx
src/DecoderList.cxx
+2
-2
DsdLib.cxx
src/decoder/DsdLib.cxx
+13
-12
DsdLib.hxx
src/decoder/DsdLib.hxx
+7
-3
DsdiffDecoderPlugin.cxx
src/decoder/DsdiffDecoderPlugin.cxx
+62
-68
DsdiffDecoderPlugin.hxx
src/decoder/DsdiffDecoderPlugin.hxx
+1
-1
DsfDecoderPlugin.cxx
src/decoder/DsfDecoderPlugin.cxx
+23
-27
DsfDecoderPlugin.hxx
src/decoder/DsfDecoderPlugin.hxx
+1
-1
No files found.
Makefile.am
View file @
352d7f47
...
...
@@ -448,12 +448,12 @@ endif
libdecoder_plugins_a_SOURCES
=
\
src/decoder/pcm_decoder_plugin.c
\
src/decoder/
dsdiff_decoder_plugin.c
\
src/decoder/
dsdiff_decoder_plugin.h
\
src/decoder/
dsf_decoder_plugin.c
\
src/decoder/
dsf_decoder_plugin.h
\
src/decoder/
dsdlib.c
\
src/decoder/
dsdlib.h
\
src/decoder/
DsdiffDecoderPlugin.cxx
\
src/decoder/
DsdiffDecoderPlugin.hxx
\
src/decoder/
DsfDecoderPlugin.cxx
\
src/decoder/
DsfDecoderPlugin.hxx
\
src/decoder/
DsdLib.cxx
\
src/decoder/
DsdLib.hxx
\
src/DecoderBuffer.cxx src/DecoderBuffer.hxx
\
src/DecoderPlugin.cxx
\
src/DecoderList.cxx src/DecoderList.hxx
...
...
src/DecoderList.cxx
View file @
352d7f47
...
...
@@ -23,8 +23,8 @@
#include "conf.h"
#include "mpd_error.h"
#include "decoder/pcm_decoder_plugin.h"
#include "decoder/
dsdiff_decoder_plugin.h
"
#include "decoder/
dsf_decoder_plugin.h
"
#include "decoder/
DsdiffDecoderPlugin.hxx
"
#include "decoder/
DsfDecoderPlugin.hxx
"
#include "decoder/FlacDecoderPlugin.h"
#include "decoder/OpusDecoderPlugin.h"
#include "decoder/VorbisDecoderPlugin.h"
...
...
src/decoder/
dsdlib.c
→
src/decoder/
DsdLib.cxx
View file @
352d7f47
/*
* Copyright (C) 20
12
The Music Player Daemon Project
* Copyright (C) 20
03-2013
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -24,13 +24,14 @@
*/
#include "config.h"
#include "
dsf_decoder_plugin.h
"
#include "
DsdLib.hxx
"
#include "decoder_api.h"
#include "util/bit_reverse.h"
#include "tag_handler.h"
extern
"C"
{
#include "tag_id3.h"
#include "dsdlib.h"
#include "dsdiff_decoder_plugin.h"
}
#include <unistd.h>
#include <stdio.h>
/* for SEEK_SET, SEEK_CUR */
...
...
@@ -42,8 +43,8 @@
bool
dsdlib_id_equals
(
const
struct
dsdlib_id
*
id
,
const
char
*
s
)
{
assert
(
id
!=
NULL
);
assert
(
s
!=
NULL
);
assert
(
id
!=
nullptr
);
assert
(
s
!=
nullptr
);
assert
(
strlen
(
s
)
==
sizeof
(
id
->
value
));
return
memcmp
(
id
->
value
,
s
,
sizeof
(
id
->
value
))
==
0
;
...
...
@@ -65,7 +66,7 @@ dsdlib_skip_to(struct decoder *decoder, struct input_stream *is,
goffset
offset
)
{
if
(
input_stream_is_seekable
(
is
))
return
input_stream_seek
(
is
,
offset
,
SEEK_SET
,
NULL
);
return
input_stream_seek
(
is
,
offset
,
SEEK_SET
,
nullptr
);
if
(
input_stream_get_offset
(
is
)
>
offset
)
return
false
;
...
...
@@ -98,7 +99,7 @@ dsdlib_skip(struct decoder *decoder, struct input_stream *is,
return
true
;
if
(
input_stream_is_seekable
(
is
))
return
input_stream_seek
(
is
,
delta
,
SEEK_CUR
,
NULL
);
return
input_stream_seek
(
is
,
delta
,
SEEK_CUR
,
nullptr
);
char
buffer
[
8192
];
while
(
delta
>
0
)
{
...
...
@@ -132,10 +133,10 @@ dsdlib_tag_id3(struct input_stream *is,
if
(
tagoffset
==
0
)
return
;
if
(
!
dsdlib_skip_to
(
NULL
,
is
,
tagoffset
))
if
(
!
dsdlib_skip_to
(
nullptr
,
is
,
tagoffset
))
return
;
struct
id3_tag
*
id3_tag
=
NULL
;
struct
id3_tag
*
id3_tag
=
nullptr
;
id3_length_t
count
;
/* Prevent broken files causing problems */
...
...
@@ -154,11 +155,11 @@ dsdlib_tag_id3(struct input_stream *is,
id3_byte_t
*
dsdid3data
;
dsdid3data
=
dsdid3
;
if
(
!
dsdlib_read
(
NULL
,
is
,
dsdid3data
,
count
))
if
(
!
dsdlib_read
(
nullptr
,
is
,
dsdid3data
,
count
))
return
;
id3_tag
=
id3_tag_parse
(
dsdid3data
,
count
);
if
(
id3_tag
==
NULL
)
if
(
id3_tag
==
nullptr
)
return
;
scan_id3_tag
(
id3_tag
,
handler
,
handler_ctx
);
...
...
src/decoder/
dsdlib.h
→
src/decoder/
DsdLib.hxx
View file @
352d7f47
/*
* Copyright (C) 20
12
The Music Player Daemon Project
* Copyright (C) 20
03-2013
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,8 +17,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_DECODER_DSDLIB_H
#define MPD_DECODER_DSDLIB_H
#ifndef MPD_DECODER_DSDLIB_HXX
#define MPD_DECODER_DSDLIB_HXX
#include <stdlib.h>
#include <glib.h>
struct
dsdlib_id
{
char
value
[
4
];
...
...
src/decoder/
dsdiff_decoder_plugin.c
→
src/decoder/
DsdiffDecoderPlugin.cxx
View file @
352d7f47
This diff is collapsed.
Click to expand it.
src/decoder/
dsdiff_decoder_plugin.h
→
src/decoder/
DsdiffDecoderPlugin.hxx
View file @
352d7f47
/*
* Copyright (C) 2003-201
2
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
src/decoder/
dsf_decoder_plugin.c
→
src/decoder/
DsfDecoderPlugin.cxx
View file @
352d7f47
/*
* Copyright (C) 20
12
The Music Player Daemon Project
* Copyright (C) 20
03-2013
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -28,11 +28,11 @@
*/
#include "config.h"
#include "
dsf_decoder_plugin.h
"
#include "
DsfDecoderPlugin.hxx
"
#include "decoder_api.h"
#include "audio_check.h"
#include "util/bit_reverse.h"
#include "
dsdlib.h
"
#include "
DsdLib.hxx
"
#include "tag_handler.h"
#include <unistd.h>
...
...
@@ -41,7 +41,7 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "dsf"
struct
dsf_metad
ata
{
struct
DsfMetaD
ata
{
unsigned
sample_rate
,
channels
;
bool
bitreverse
;
uint64_t
chunk_size
;
...
...
@@ -51,7 +51,7 @@ struct dsf_metadata {
#endif
};
struct
dsf_h
eader
{
struct
DsfH
eader
{
/** DSF header id: "DSD " */
struct
dsdlib_id
id
;
/** DSD chunk size, including id = 28 */
...
...
@@ -63,8 +63,7 @@ struct dsf_header {
};
/** DSF file fmt chunk */
struct
dsf_fmt_chunk
{
struct
DsfFmtChunk
{
/** id: "fmt " */
struct
dsdlib_id
id
;
/** fmt chunk size, including id, normally 52 */
...
...
@@ -89,7 +88,7 @@ struct dsf_fmt_chunk {
uint32_t
reserved
;
};
struct
dsf_data_c
hunk
{
struct
DsfDataC
hunk
{
struct
dsdlib_id
id
;
/** "data" chunk size, includes header (id+size) */
uint32_t
size_low
,
size_high
;
...
...
@@ -100,10 +99,10 @@ struct dsf_data_chunk {
*/
static
bool
dsf_read_metadata
(
struct
decoder
*
decoder
,
struct
input_stream
*
is
,
struct
dsf_metad
ata
*
metadata
)
DsfMetaD
ata
*
metadata
)
{
uint64_t
chunk_size
;
struct
dsf_h
eader
dsf_header
;
DsfH
eader
dsf_header
;
if
(
!
dsdlib_read
(
decoder
,
is
,
&
dsf_header
,
sizeof
(
dsf_header
))
||
!
dsdlib_id_equals
(
&
dsf_header
.
id
,
"DSD "
))
return
false
;
...
...
@@ -121,7 +120,7 @@ dsf_read_metadata(struct decoder *decoder, struct input_stream *is,
#endif
/* read the 'fmt ' chunk of the DSF file */
struct
dsf_fmt_c
hunk
dsf_fmt_chunk
;
DsfFmtC
hunk
dsf_fmt_chunk
;
if
(
!
dsdlib_read
(
decoder
,
is
,
&
dsf_fmt_chunk
,
sizeof
(
dsf_fmt_chunk
))
||
!
dsdlib_id_equals
(
&
dsf_fmt_chunk
.
id
,
"fmt "
))
return
false
;
...
...
@@ -150,7 +149,7 @@ dsf_read_metadata(struct decoder *decoder, struct input_stream *is,
return
false
;
/* read the 'data' chunk of the DSF file */
struct
dsf_data_c
hunk
data_chunk
;
DsfDataC
hunk
data_chunk
;
if
(
!
dsdlib_read
(
decoder
,
is
,
&
data_chunk
,
sizeof
(
data_chunk
))
||
!
dsdlib_id_equals
(
&
data_chunk
.
id
,
"data"
))
return
false
;
...
...
@@ -280,12 +279,8 @@ dsf_decode_chunk(struct decoder *decoder, struct input_stream *is,
static
void
dsf_stream_decode
(
struct
decoder
*
decoder
,
struct
input_stream
*
is
)
{
struct
dsf_metadata
metadata
=
{
.
sample_rate
=
0
,
.
channels
=
0
,
};
/* check if it is a proper DSF file */
DsfMetaData
metadata
;
if
(
!
dsf_read_metadata
(
decoder
,
is
,
&
metadata
))
return
;
...
...
@@ -317,12 +312,8 @@ dsf_scan_stream(struct input_stream *is,
G_GNUC_UNUSED
const
struct
tag_handler
*
handler
,
G_GNUC_UNUSED
void
*
handler_ctx
)
{
struct
dsf_metadata
metadata
=
{
.
sample_rate
=
0
,
.
channels
=
0
,
};
/* check DSF metadata */
DsfMetaData
metadata
;
if
(
!
dsf_read_metadata
(
NULL
,
is
,
&
metadata
))
return
false
;
...
...
@@ -356,9 +347,14 @@ static const char *const dsf_mime_types[] = {
};
const
struct
decoder_plugin
dsf_decoder_plugin
=
{
.
name
=
"dsf"
,
.
stream_decode
=
dsf_stream_decode
,
.
scan_stream
=
dsf_scan_stream
,
.
suffixes
=
dsf_suffixes
,
.
mime_types
=
dsf_mime_types
,
"dsf"
,
nullptr
,
nullptr
,
dsf_stream_decode
,
nullptr
,
nullptr
,
dsf_scan_stream
,
nullptr
,
dsf_suffixes
,
dsf_mime_types
,
};
src/decoder/
dsf_decoder_plugin.h
→
src/decoder/
DsfDecoderPlugin.hxx
View file @
352d7f47
/*
* Copyright (C) 20
12
The Music Player Daemon Project
* Copyright (C) 20
03-2013
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
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