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
3dd38e7b
Commit
3dd38e7b
authored
Jan 10, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/wavpack: convert to C++
parent
3711a976
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
37 deletions
+61
-37
Makefile.am
Makefile.am
+3
-1
WavpackDecoderPlugin.cxx
src/decoder/WavpackDecoderPlugin.cxx
+32
-24
WavpackDecoderPlugin.hxx
src/decoder/WavpackDecoderPlugin.hxx
+25
-0
decoder_list.c
src/decoder_list.c
+1
-1
utils.h
src/utils.h
+0
-11
No files found.
Makefile.am
View file @
3dd38e7b
...
...
@@ -544,7 +544,9 @@ libdecoder_plugins_a_SOURCES += \
endif
if
HAVE_WAVPACK
libdecoder_plugins_a_SOURCES
+=
src/decoder/wavpack_decoder_plugin.c
libdecoder_plugins_a_SOURCES
+=
\
src/decoder/WavpackDecoderPlugin.cxx
\
src/decoder/WavpackDecoderPlugin.hxx
endif
if
HAVE_ADPLUG
...
...
src/decoder/
wavpack_decoder_plugin.c
→
src/decoder/
WavpackDecoderPlugin.cxx
View file @
3dd38e7b
/*
* Copyright (C) 2003-201
1
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
...
...
@@ -18,9 +18,13 @@
*/
#include "config.h"
#include "WavpackDecoderPlugin.hxx"
#include "decoder_api.h"
extern
"C"
{
#include "audio_check.h"
#include "utils.h"
}
#include "tag_handler.h"
#include "tag_ape.h"
...
...
@@ -50,18 +54,18 @@ typedef void (*format_samples_t)(
static
void
format_samples_int
(
int
bytes_per_sample
,
void
*
buffer
,
uint32_t
count
)
{
int32_t
*
src
=
buffer
;
int32_t
*
src
=
(
int32_t
*
)
buffer
;
switch
(
bytes_per_sample
)
{
case
1
:
{
int8_t
*
dst
=
buffer
;
int8_t
*
dst
=
(
int8_t
*
)
buffer
;
/*
* The asserts like the following one are because we do the
* formatting of samples within a single buffer. The size
* of the output samples never can be greater than the size
* of the input ones. Otherwise we would have an overflow.
*/
assert_static
(
sizeof
(
*
dst
)
<=
sizeof
(
*
src
)
);
static_assert
(
sizeof
(
*
dst
)
<=
sizeof
(
*
src
),
"Wrong size"
);
/* pass through and align 8-bit samples */
while
(
count
--
)
{
...
...
@@ -70,8 +74,8 @@ format_samples_int(int bytes_per_sample, void *buffer, uint32_t count)
break
;
}
case
2
:
{
uint16_t
*
dst
=
buffer
;
assert_static
(
sizeof
(
*
dst
)
<=
sizeof
(
*
src
)
);
uint16_t
*
dst
=
(
uint16_t
*
)
buffer
;
static_assert
(
sizeof
(
*
dst
)
<=
sizeof
(
*
src
),
"Wrong size"
);
/* pass through and align 16-bit samples */
while
(
count
--
)
{
...
...
@@ -94,7 +98,7 @@ static void
format_samples_float
(
G_GNUC_UNUSED
int
bytes_per_sample
,
void
*
buffer
,
uint32_t
count
)
{
float
*
p
=
buffer
;
float
*
p
=
(
float
*
)
buffer
;
while
(
count
--
)
{
*
p
/=
(
1
<<
23
);
...
...
@@ -356,7 +360,7 @@ static struct wavpack_input *
wpin
(
void
*
id
)
{
assert
(
id
);
return
id
;
return
(
struct
wavpack_input
*
)
id
;
}
static
int32_t
...
...
@@ -438,14 +442,14 @@ wavpack_input_can_seek(void *id)
}
static
WavpackStreamReader
mpd_is_reader
=
{
.
read_bytes
=
wavpack_input_read_bytes
,
.
get_pos
=
wavpack_input_get_pos
,
.
set_pos_abs
=
wavpack_input_set_pos_abs
,
.
set_pos_rel
=
wavpack_input_set_pos_rel
,
.
push_back_byte
=
wavpack_input_push_back_byte
,
.
get_length
=
wavpack_input_get_length
,
.
can_seek
=
wavpack_input_can_seek
,
.
write_bytes
=
NULL
/* no need to write edited tags */
wavpack_input_read_bytes
,
wavpack_input_get_pos
,
wavpack_input_set_pos_abs
,
wavpack_input_set_pos_rel
,
wavpack_input_push_back_byte
,
wavpack_input_get_length
,
wavpack_input_can_seek
,
nullptr
/* no need to write edited tags */
};
static
void
...
...
@@ -472,7 +476,7 @@ wavpack_open_wvc(struct decoder *decoder, const char *uri,
* single files. utf8url is not absolute file path :/
*/
if
(
uri
==
NULL
)
return
false
;
return
nullptr
;
wvc_url
=
g_strconcat
(
uri
,
"c"
,
NULL
);
is_wvc
=
input_stream_open
(
wvc_url
,
mutex
,
cond
,
NULL
);
...
...
@@ -584,10 +588,14 @@ static char const *const wavpack_mime_types[] = {
};
const
struct
decoder_plugin
wavpack_decoder_plugin
=
{
.
name
=
"wavpack"
,
.
stream_decode
=
wavpack_streamdecode
,
.
file_decode
=
wavpack_filedecode
,
.
scan_file
=
wavpack_scan_file
,
.
suffixes
=
wavpack_suffixes
,
.
mime_types
=
wavpack_mime_types
"wavpack"
,
nullptr
,
nullptr
,
wavpack_streamdecode
,
wavpack_filedecode
,
wavpack_scan_file
,
nullptr
,
nullptr
,
wavpack_suffixes
,
wavpack_mime_types
};
src/decoder/WavpackDecoderPlugin.hxx
0 → 100644
View file @
3dd38e7b
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_DECODER_WAVPACK_HXX
#define MPD_DECODER_WAVPACK_HXX
extern
const
struct
decoder_plugin
wavpack_decoder_plugin
;
#endif
src/decoder_list.c
View file @
3dd38e7b
...
...
@@ -30,6 +30,7 @@
#include "decoder/OpusDecoderPlugin.h"
#include "decoder/VorbisDecoderPlugin.h"
#include "decoder/AdPlugDecoderPlugin.h"
#include "decoder/WavpackDecoderPlugin.hxx"
#include <glib.h>
...
...
@@ -42,7 +43,6 @@ extern const struct decoder_plugin audiofile_decoder_plugin;
extern
const
struct
decoder_plugin
mp4ff_decoder_plugin
;
extern
const
struct
decoder_plugin
faad_decoder_plugin
;
extern
const
struct
decoder_plugin
mpcdec_decoder_plugin
;
extern
const
struct
decoder_plugin
wavpack_decoder_plugin
;
extern
const
struct
decoder_plugin
modplug_decoder_plugin
;
extern
const
struct
decoder_plugin
mikmod_decoder_plugin
;
extern
const
struct
decoder_plugin
sidplay_decoder_plugin
;
...
...
src/utils.h
View file @
3dd38e7b
...
...
@@ -22,17 +22,6 @@
#include "gerror.h"
#include <stdbool.h>
#ifndef assert_static
/* Compile time assertion developed by Ralf Holly */
/* http://pera-software.com/articles/compile-time-assertions.pdf */
#define assert_static(e) \
do { \
enum { assert_static__ = 1/(e) }; \
} while (0)
#endif
/* !assert_static */
char
*
parsePath
(
const
char
*
path
,
GError
**
error_r
);
...
...
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