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
96b76306
Commit
96b76306
authored
Jul 28, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ape: convert to C++
parent
dd5ba062
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
77 additions
and
102 deletions
+77
-102
Makefile.am
Makefile.am
+3
-6
ApeLoader.cxx
src/ApeLoader.cxx
+8
-8
ApeLoader.hxx
src/ApeLoader.hxx
+9
-8
ApeReplayGain.cxx
src/ApeReplayGain.cxx
+29
-29
ApeReplayGain.hxx
src/ApeReplayGain.hxx
+3
-5
ApeTag.cxx
src/ApeTag.cxx
+17
-30
ApeTag.hxx
src/ApeTag.hxx
+3
-3
DecoderThread.cxx
src/DecoderThread.cxx
+1
-4
SongUpdate.cxx
src/SongUpdate.cxx
+1
-1
WavpackDecoderPlugin.cxx
src/decoder/WavpackDecoderPlugin.cxx
+1
-1
EmbeddedCuePlaylistPlugin.cxx
src/playlist/EmbeddedCuePlaylistPlugin.cxx
+1
-4
read_tags.cxx
test/read_tags.cxx
+1
-3
No files found.
Makefile.am
View file @
96b76306
...
...
@@ -51,7 +51,6 @@ src_mpd_LDADD = \
mpd_headers
=
\
src/check.h
\
src/ack.h
\
src/ape.h
\
src/audio_format.h
\
src/audio_check.h
\
src/output_api.h
\
...
...
@@ -79,13 +78,11 @@ mpd_headers = \
src/aiff.h
\
src/replay_gain_config.h
\
src/replay_gain_info.h
\
src/replay_gain_ape.h
\
src/TimePrint.cxx src/TimePrint.hxx
\
src/stats.h
\
src/tag.h
\
src/tag_internal.h
\
src/tag_table.h
\
src/tag_ape.h
\
src/Timer.hxx
\
src/mpd_error.h
...
...
@@ -428,9 +425,9 @@ TAG_LIBS = \
$(ID3TAG_LIBS)
libtag_a_SOURCES
=
\
src/
ape.c
\
src/
replay_gain_ape.c
\
src/
tag_ape.c
src/
ApeLoader.cxx src/ApeLoader.hxx
\
src/
ApeReplayGain.cxx src/ApeReplayGain.hxx
\
src/
ApeTag.cxx src/ApeTag.hxx
if
HAVE_ID3TAG
libtag_a_SOURCES
+=
\
...
...
src/
ape.c
→
src/
ApeLoader.cxx
View file @
96b76306
/*
* 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,7 +18,7 @@
*/
#include "config.h"
#include "
ape.h
"
#include "
ApeLoader.hxx
"
#include <glib.h>
...
...
@@ -37,7 +37,7 @@ struct ape_footer {
};
static
bool
ape_scan_internal
(
FILE
*
fp
,
tag_ape_callback_t
callback
,
void
*
ctx
)
ape_scan_internal
(
FILE
*
fp
,
ApeTagCallback
callback
)
{
/* determine if file has an apeV2 tag */
struct
ape_footer
footer
;
...
...
@@ -59,7 +59,7 @@ ape_scan_internal(FILE *fp, tag_ape_callback_t callback, void *ctx)
remaining
-=
sizeof
(
footer
);
assert
(
remaining
>
10
);
char
*
buffer
=
g_malloc
(
remaining
);
char
*
buffer
=
(
char
*
)
g_malloc
(
remaining
);
if
(
fread
(
buffer
,
1
,
remaining
,
fp
)
!=
remaining
)
{
g_free
(
buffer
);
return
false
;
...
...
@@ -89,7 +89,7 @@ ape_scan_internal(FILE *fp, tag_ape_callback_t callback, void *ctx)
if
(
remaining
<
size
)
break
;
if
(
!
callback
(
flags
,
key
,
p
,
size
,
ctx
))
if
(
!
callback
(
flags
,
key
,
p
,
size
))
break
;
p
+=
size
;
...
...
@@ -101,15 +101,15 @@ ape_scan_internal(FILE *fp, tag_ape_callback_t callback, void *ctx)
}
bool
tag_ape_scan
(
const
char
*
path_fs
,
tag_ape_callback_t
callback
,
void
*
ctx
)
tag_ape_scan
(
const
char
*
path_fs
,
ApeTagCallback
callback
)
{
FILE
*
fp
;
fp
=
fopen
(
path_fs
,
"rb"
);
if
(
fp
==
NULL
)
if
(
fp
==
nullptr
)
return
false
;
bool
success
=
ape_scan_internal
(
fp
,
callback
,
ctx
);
bool
success
=
ape_scan_internal
(
fp
,
callback
);
fclose
(
fp
);
return
success
;
}
src/
ape.h
→
src/
ApeLoader.hxx
View file @
96b76306
/*
* 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
...
...
@@ -17,17 +17,18 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_APE_
H
#define MPD_APE_
H
#ifndef MPD_APE_
LOADER_HXX
#define MPD_APE_
LOADER_HXX
#include "check.h"
#include <stdbool.h>
#include <functional>
#include <stddef.h>
typedef
bool
(
*
tag_ape_callback_t
)
(
unsigned
long
flags
,
const
char
*
key
,
const
char
*
value
,
size_t
value_length
,
void
*
ctx
)
;
typedef
std
::
function
<
bool
(
unsigned
long
flags
,
const
char
*
key
,
const
char
*
value
,
size_t
value_length
)
>
ApeTagCallback
;
/**
* Scans the APE tag values from a file.
...
...
@@ -37,6 +38,6 @@ typedef bool (*tag_ape_callback_t)(unsigned long flags, const char *key,
* present
*/
bool
tag_ape_scan
(
const
char
*
path_fs
,
tag_ape_callback_t
callback
,
void
*
ctx
);
tag_ape_scan
(
const
char
*
path_fs
,
ApeTagCallback
callback
);
#endif
src/
replay_gain_ape.c
→
src/
ApeReplayGain.cxx
View file @
96b76306
/*
* 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,61 +18,61 @@
*/
#include "config.h"
#include "replay_gain_ape.h"
#include "ApeReplayGain.hxx"
#include "ApeLoader.hxx"
#include "replay_gain_info.h"
#include "ape.h"
#include <glib.h>
#include <string.h>
#include <stdlib.h>
struct
rg_ape_ctx
{
struct
replay_gain_info
*
info
;
bool
found
;
};
static
bool
replay_gain_ape_callback
(
unsigned
long
flags
,
const
char
*
key
,
const
char
*
_value
,
size_t
value_length
,
void
*
_ctx
)
const
char
*
_value
,
size_t
value_length
,
struct
replay_gain_info
*
info
)
{
struct
rg_ape_ctx
*
ctx
=
_ctx
;
/* we only care about utf-8 text tags */
if
((
flags
&
(
0x3
<<
1
))
!=
0
)
return
tru
e
;
return
fals
e
;
char
value
[
16
];
if
(
value_length
>=
sizeof
(
value
))
return
true
;
return
false
;
memcpy
(
value
,
_value
,
value_length
);
value
[
value_length
]
=
0
;
if
(
g_ascii_strcasecmp
(
key
,
"replaygain_track_gain"
)
==
0
)
{
ctx
->
info
->
tuples
[
REPLAY_GAIN_TRACK
].
gain
=
atof
(
value
);
ctx
->
found
=
true
;
info
->
tuples
[
REPLAY_GAIN_TRACK
].
gain
=
atof
(
value
);
return
true
;
}
else
if
(
g_ascii_strcasecmp
(
key
,
"replaygain_album_gain"
)
==
0
)
{
ctx
->
info
->
tuples
[
REPLAY_GAIN_ALBUM
].
gain
=
atof
(
value
);
ctx
->
found
=
true
;
info
->
tuples
[
REPLAY_GAIN_ALBUM
].
gain
=
atof
(
value
);
return
true
;
}
else
if
(
g_ascii_strcasecmp
(
key
,
"replaygain_track_peak"
)
==
0
)
{
ctx
->
info
->
tuples
[
REPLAY_GAIN_TRACK
].
peak
=
atof
(
value
);
ctx
->
found
=
true
;
info
->
tuples
[
REPLAY_GAIN_TRACK
].
peak
=
atof
(
value
);
return
true
;
}
else
if
(
g_ascii_strcasecmp
(
key
,
"replaygain_album_peak"
)
==
0
)
{
ctx
->
info
->
tuples
[
REPLAY_GAIN_ALBUM
].
peak
=
atof
(
value
);
ctx
->
found
=
true
;
}
return
true
;
info
->
tuples
[
REPLAY_GAIN_ALBUM
].
peak
=
atof
(
value
);
return
true
;
}
else
return
false
;
}
bool
replay_gain_ape_read
(
const
char
*
path_fs
,
struct
replay_gain_info
*
info
)
{
struct
rg_ape_ctx
ctx
=
{
.
info
=
info
,
.
found
=
false
,
bool
found
=
false
;
auto
callback
=
[
info
,
&
found
]
(
unsigned
long
flags
,
const
char
*
key
,
const
char
*
value
,
size_t
value_length
)
{
found
|=
replay_gain_ape_callback
(
flags
,
key
,
value
,
value_length
,
info
);
return
true
;
};
return
tag_ape_scan
(
path_fs
,
replay_gain_ape_callback
,
&
ctx
)
&&
ctx
.
found
;
return
tag_ape_scan
(
path_fs
,
callback
)
&&
found
;
}
src/
replay_gain_ape.h
→
src/
ApeReplayGain.hxx
View file @
96b76306
/*
* 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
...
...
@@ -17,13 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_
REPLAY_GAIN_APE_H
#define MPD_
REPLAY_GAIN_APE_H
#ifndef MPD_
APE_REPLAY_GAIN_HXX
#define MPD_
APE_REPLAY_GAIN_HXX
#include "check.h"
#include <stdbool.h>
struct
replay_gain_info
;
bool
...
...
src/
tag_ape.c
→
src/
ApeTag.cxx
View file @
96b76306
/*
* 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,16 +18,16 @@
*/
#include "config.h"
#include "tag_ape.h"
#include "ApeTag.hxx"
#include "ApeLoader.hxx"
#include "tag.h"
#include "tag_table.h"
#include "tag_handler.h"
#include "ape.h"
const
struct
tag_table
ape_tags
[]
=
{
{
"album artist"
,
TAG_ALBUM_ARTIST
},
{
"year"
,
TAG_DATE
},
{
NULL
,
TAG_NUM_OF_ITEM_TYPES
}
{
nullptr
,
TAG_NUM_OF_ITEM_TYPES
}
};
static
enum
tag_type
...
...
@@ -62,8 +62,8 @@ tag_ape_import_item(unsigned long flags,
const
char
*
end
=
value
+
value_length
;
while
(
true
)
{
/* multiple values are separated by null bytes */
const
char
*
n
=
memchr
(
value
,
0
,
end
-
value
);
if
(
n
!=
NULL
)
{
const
char
*
n
=
(
const
char
*
)
memchr
(
value
,
0
,
end
-
value
);
if
(
n
!=
nullptr
)
{
if
(
n
>
value
)
{
tag_handler_invoke_tag
(
handler
,
handler_ctx
,
type
,
value
);
...
...
@@ -84,34 +84,21 @@ tag_ape_import_item(unsigned long flags,
return
recognized
;
}
struct
tag_ape_ctx
{
const
struct
tag_handler
*
handler
;
void
*
handler_ctx
;
bool
recognized
;
};
static
bool
tag_ape_callback
(
unsigned
long
flags
,
const
char
*
key
,
const
char
*
value
,
size_t
value_length
,
void
*
_ctx
)
{
struct
tag_ape_ctx
*
ctx
=
_ctx
;
ctx
->
recognized
|=
tag_ape_import_item
(
flags
,
key
,
value
,
value_length
,
ctx
->
handler
,
ctx
->
handler_ctx
);
return
true
;
}
bool
tag_ape_scan2
(
const
char
*
path_fs
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
struct
tag_ape_ctx
ctx
=
{
.
handler
=
handler
,
.
handler_ctx
=
handler_ctx
,
.
recognized
=
false
,
bool
recognized
=
false
;
auto
callback
=
[
handler
,
handler_ctx
,
&
recognized
]
(
unsigned
long
flags
,
const
char
*
key
,
const
char
*
value
,
size_t
value_length
)
{
recognized
|=
tag_ape_import_item
(
flags
,
key
,
value
,
value_length
,
handler
,
handler_ctx
);
return
true
;
};
return
tag_ape_scan
(
path_fs
,
tag_ape_callback
,
&
ctx
)
&&
ctx
.
recognized
;
return
tag_ape_scan
(
path_fs
,
callback
)
&&
recognized
;
}
src/
tag_ape.h
→
src/
ApeTag.hxx
View file @
96b76306
/*
* 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
...
...
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_
TAG_APE_H
#define MPD_
TAG_APE_H
#ifndef MPD_
APE_TAG_HXX
#define MPD_
APE_TAG_HXX
#include "tag_table.h"
...
...
src/DecoderThread.cxx
View file @
96b76306
...
...
@@ -32,10 +32,7 @@
#include "InputStream.hxx"
#include "DecoderList.hxx"
#include "util/UriUtil.hxx"
extern
"C"
{
#include "replay_gain_ape.h"
}
#include "ApeReplayGain.hxx"
#include <glib.h>
...
...
src/SongUpdate.cxx
View file @
96b76306
...
...
@@ -29,9 +29,9 @@
#include "DecoderPlugin.hxx"
#include "DecoderList.hxx"
#include "TagId3.hxx"
#include "ApeTag.hxx"
extern
"C"
{
#include "tag_ape.h"
#include "tag_handler.h"
}
...
...
src/decoder/WavpackDecoderPlugin.cxx
View file @
96b76306
...
...
@@ -27,7 +27,7 @@ extern "C" {
}
#include "tag_handler.h"
#include "
tag_ape.h
"
#include "
ApeTag.hxx
"
#include <wavpack/wavpack.h>
#include <glib.h>
...
...
src/playlist/EmbeddedCuePlaylistPlugin.cxx
View file @
96b76306
...
...
@@ -29,14 +29,11 @@
#include "tag.h"
#include "tag_handler.h"
#include "TagId3.hxx"
#include "ApeTag.hxx"
#include "Song.hxx"
#include "TagFile.hxx"
#include "cue/CueParser.hxx"
extern
"C"
{
#include "tag_ape.h"
}
#include <glib.h>
#include <assert.h>
#include <string.h>
...
...
test/read_tags.cxx
View file @
96b76306
...
...
@@ -24,11 +24,9 @@
#include "InputInit.hxx"
#include "InputStream.hxx"
#include "audio_format.h"
extern
"C"
{
#include "tag_ape.h"
}
#include "tag_handler.h"
#include "TagId3.hxx"
#include "ApeTag.hxx"
#include <glib.h>
...
...
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