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
d3641766
Commit
d3641766
authored
Jul 28, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/sndfile: convert to C++
parent
b25d5c5d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
28 deletions
+61
-28
Makefile.am
Makefile.am
+3
-1
DecoderList.cxx
src/DecoderList.cxx
+1
-1
SndfileDecoderPlugin.cxx
src/decoder/SndfileDecoderPlugin.cxx
+32
-26
SndfileDecoderPlugin.hxx
src/decoder/SndfileDecoderPlugin.hxx
+25
-0
No files found.
Makefile.am
View file @
d3641766
...
...
@@ -604,7 +604,9 @@ libdecoder_plugins_a_SOURCES += \
endif
if
ENABLE_SNDFILE
libdecoder_plugins_a_SOURCES
+=
src/decoder/sndfile_decoder_plugin.c
libdecoder_plugins_a_SOURCES
+=
\
src/decoder/SndfileDecoderPlugin.cxx
\
src/decoder/SndfileDecoderPlugin.hxx
endif
if
HAVE_GME
...
...
src/DecoderList.cxx
View file @
d3641766
...
...
@@ -35,13 +35,13 @@
#include "decoder/GmeDecoderPlugin.hxx"
#include "decoder/FaadDecoderPlugin.hxx"
#include "decoder/MadDecoderPlugin.hxx"
#include "decoder/SndfileDecoderPlugin.hxx"
#include <glib.h>
#include <string.h>
extern
const
struct
decoder_plugin
mpg123_decoder_plugin
;
extern
const
struct
decoder_plugin
sndfile_decoder_plugin
;
extern
const
struct
decoder_plugin
mpcdec_decoder_plugin
;
extern
const
struct
decoder_plugin
modplug_decoder_plugin
;
extern
const
struct
decoder_plugin
mikmod_decoder_plugin
;
...
...
src/decoder/
sndfile_decoder_plugin.c
→
src/decoder/
SndfileDecoderPlugin.cxx
View file @
d3641766
/*
* 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,6 +18,7 @@
*/
#include "config.h"
#include "SndfileDecoderPlugin.hxx"
#include "decoder_api.h"
#include "audio_check.h"
#include "tag_handler.h"
...
...
@@ -30,7 +31,7 @@
static
sf_count_t
sndfile_vio_get_filelen
(
void
*
user_data
)
{
const
struct
input_stream
*
is
=
user_data
;
const
struct
input_stream
*
is
=
(
const
struct
input_stream
*
)
user_data
;
return
input_stream_get_size
(
is
);
}
...
...
@@ -38,10 +39,10 @@ sndfile_vio_get_filelen(void *user_data)
static
sf_count_t
sndfile_vio_seek
(
sf_count_t
offset
,
int
whence
,
void
*
user_data
)
{
struct
input_stream
*
is
=
user_data
;
struct
input_stream
*
is
=
(
struct
input_stream
*
)
user_data
;
bool
success
;
success
=
input_stream_lock_seek
(
is
,
offset
,
whence
,
NULL
);
success
=
input_stream_lock_seek
(
is
,
offset
,
whence
,
nullptr
);
if
(
!
success
)
return
-
1
;
...
...
@@ -51,12 +52,12 @@ sndfile_vio_seek(sf_count_t offset, int whence, void *user_data)
static
sf_count_t
sndfile_vio_read
(
void
*
ptr
,
sf_count_t
count
,
void
*
user_data
)
{
struct
input_stream
*
is
=
user_data
;
GError
*
error
=
NULL
;
struct
input_stream
*
is
=
(
struct
input_stream
*
)
user_data
;
GError
*
error
=
nullptr
;
size_t
nbytes
;
nbytes
=
input_stream_lock_read
(
is
,
ptr
,
count
,
&
error
);
if
(
nbytes
==
0
&&
error
!=
NULL
)
{
if
(
nbytes
==
0
&&
error
!=
nullptr
)
{
g_warning
(
"%s"
,
error
->
message
);
g_error_free
(
error
);
return
-
1
;
...
...
@@ -77,7 +78,7 @@ sndfile_vio_write(G_GNUC_UNUSED const void *ptr,
static
sf_count_t
sndfile_vio_tell
(
void
*
user_data
)
{
const
struct
input_stream
*
is
=
user_data
;
const
struct
input_stream
*
is
=
(
const
struct
input_stream
*
)
user_data
;
return
input_stream_get_offset
(
is
);
}
...
...
@@ -87,11 +88,11 @@ sndfile_vio_tell(void *user_data)
* libsndfile stream.
*/
static
SF_VIRTUAL_IO
vio
=
{
.
get_filelen
=
sndfile_vio_get_filelen
,
.
seek
=
sndfile_vio_seek
,
.
read
=
sndfile_vio_read
,
.
write
=
sndfile_vio_write
,
.
tell
=
sndfile_vio_tell
,
sndfile_vio_get_filelen
,
sndfile_vio_seek
,
sndfile_vio_read
,
sndfile_vio_write
,
sndfile_vio_tell
,
};
/**
...
...
@@ -115,7 +116,7 @@ time_to_frame(float t, const struct audio_format *audio_format)
static
void
sndfile_stream_decode
(
struct
decoder
*
decoder
,
struct
input_stream
*
is
)
{
GError
*
error
=
NULL
;
GError
*
error
=
nullptr
;
SNDFILE
*
sf
;
SF_INFO
info
;
struct
audio_format
audio_format
;
...
...
@@ -127,7 +128,7 @@ sndfile_stream_decode(struct decoder *decoder, struct input_stream *is)
info
.
format
=
0
;
sf
=
sf_open_virtual
(
&
vio
,
SFM_READ
,
&
info
,
is
);
if
(
sf
==
NULL
)
{
if
(
sf
==
nullptr
)
{
g_warning
(
"sf_open_virtual() failed"
);
return
;
}
...
...
@@ -184,7 +185,7 @@ sndfile_scan_file(const char *path_fs,
info
.
format
=
0
;
sf
=
sf_open
(
path_fs
,
SFM_READ
,
&
info
);
if
(
sf
==
NULL
)
if
(
sf
==
nullptr
)
return
false
;
if
(
!
audio_valid_sample_rate
(
info
.
samplerate
))
{
...
...
@@ -197,17 +198,17 @@ sndfile_scan_file(const char *path_fs,
info
.
frames
/
info
.
samplerate
);
p
=
sf_get_string
(
sf
,
SF_STR_TITLE
);
if
(
p
!=
NULL
)
if
(
p
!=
nullptr
)
tag_handler_invoke_tag
(
handler
,
handler_ctx
,
TAG_TITLE
,
p
);
p
=
sf_get_string
(
sf
,
SF_STR_ARTIST
);
if
(
p
!=
NULL
)
if
(
p
!=
nullptr
)
tag_handler_invoke_tag
(
handler
,
handler_ctx
,
TAG_ARTIST
,
p
);
p
=
sf_get_string
(
sf
,
SF_STR_DATE
);
if
(
p
!=
NULL
)
if
(
p
!=
nullptr
)
tag_handler_invoke_tag
(
handler
,
handler_ctx
,
TAG_DATE
,
p
);
...
...
@@ -234,7 +235,7 @@ static const char *const sndfile_suffixes[] = {
linking with libFLAC and libvorbis - we can do better, we
have native plugins for these libraries */
NULL
nullptr
};
static
const
char
*
const
sndfile_mime_types
[]
=
{
...
...
@@ -243,13 +244,18 @@ static const char *const sndfile_mime_types[] = {
/* what are the MIME types of the other supported formats? */
NULL
nullptr
};
const
struct
decoder_plugin
sndfile_decoder_plugin
=
{
.
name
=
"sndfile"
,
.
stream_decode
=
sndfile_stream_decode
,
.
scan_file
=
sndfile_scan_file
,
.
suffixes
=
sndfile_suffixes
,
.
mime_types
=
sndfile_mime_types
,
"sndfile"
,
nullptr
,
nullptr
,
sndfile_stream_decode
,
nullptr
,
sndfile_scan_file
,
nullptr
,
nullptr
,
sndfile_suffixes
,
sndfile_mime_types
,
};
src/decoder/SndfileDecoderPlugin.hxx
0 → 100644
View file @
d3641766
/*
* 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_SNDFILE_HXX
#define MPD_DECODER_SNDFILE_HXX
extern
const
struct
decoder_plugin
sndfile_decoder_plugin
;
#endif
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