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
df4ecf63
Commit
df4ecf63
authored
Dec 09, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/wavpack: disable OPEN_TAGS
Use MPD's internal APE tag code, which works just as well. This removes some duplicate code for reading tags and ReplayGain.
parent
b4d19378
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
97 deletions
+3
-97
WavpackDecoderPlugin.cxx
src/decoder/plugins/WavpackDecoderPlugin.cxx
+3
-97
No files found.
src/decoder/plugins/WavpackDecoderPlugin.cxx
View file @
df4ecf63
...
...
@@ -23,7 +23,6 @@
#include "input/InputStream.hxx"
#include "CheckAudioFormat.hxx"
#include "tag/TagHandler.hxx"
#include "tag/ApeTag.hxx"
#include "fs/Path.hxx"
#include "util/Domain.hxx"
#include "util/Macros.hxx"
...
...
@@ -34,10 +33,9 @@
#include <wavpack/wavpack.h>
#include <stdexcept>
#include <memory>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#define ERRORLEN 80
...
...
@@ -197,66 +195,6 @@ wavpack_decode(DecoderClient &client, WavpackContext *wpc, bool can_seek)
}
}
/**
* Locate and parse a floating point tag. Returns true if it was
* found.
*/
static
bool
wavpack_tag_float
(
WavpackContext
*
wpc
,
const
char
*
key
,
float
*
value_r
)
{
char
buffer
[
64
];
if
(
WavpackGetTagItem
(
wpc
,
key
,
buffer
,
sizeof
(
buffer
))
<=
0
)
return
false
;
*
value_r
=
atof
(
buffer
);
return
true
;
}
static
bool
wavpack_replaygain
(
ReplayGainInfo
&
rgi
,
WavpackContext
*
wpc
)
{
rgi
.
Clear
();
bool
found
=
false
;
found
|=
wavpack_tag_float
(
wpc
,
"replaygain_track_gain"
,
&
rgi
.
track
.
gain
);
found
|=
wavpack_tag_float
(
wpc
,
"replaygain_track_peak"
,
&
rgi
.
track
.
peak
);
found
|=
wavpack_tag_float
(
wpc
,
"replaygain_album_gain"
,
&
rgi
.
album
.
gain
);
found
|=
wavpack_tag_float
(
wpc
,
"replaygain_album_peak"
,
&
rgi
.
album
.
peak
);
return
found
;
}
static
void
wavpack_scan_tag_item
(
WavpackContext
*
wpc
,
const
char
*
name
,
TagType
type
,
const
TagHandler
&
handler
,
void
*
handler_ctx
)
{
char
buffer
[
1024
];
int
len
=
WavpackGetTagItem
(
wpc
,
name
,
buffer
,
sizeof
(
buffer
));
if
(
len
<=
0
||
(
unsigned
)
len
>=
sizeof
(
buffer
))
return
;
tag_handler_invoke_tag
(
handler
,
handler_ctx
,
type
,
buffer
);
}
static
void
wavpack_scan_pair
(
WavpackContext
*
wpc
,
const
char
*
name
,
const
TagHandler
&
handler
,
void
*
handler_ctx
)
{
char
buffer
[
8192
];
int
len
=
WavpackGetTagItem
(
wpc
,
name
,
buffer
,
sizeof
(
buffer
));
if
(
len
<=
0
||
(
unsigned
)
len
>=
sizeof
(
buffer
))
return
;
tag_handler_invoke_pair
(
handler
,
handler_ctx
,
name
,
buffer
);
}
/*
* Reads metainfo from the specified file.
*/
...
...
@@ -266,7 +204,7 @@ wavpack_scan_file(Path path_fs,
{
char
error
[
ERRORLEN
];
WavpackContext
*
wpc
=
WavpackOpenFileInput
(
path_fs
.
c_str
(),
error
,
OPEN_TAGS
,
0
);
0
,
0
);
if
(
wpc
==
nullptr
)
{
FormatError
(
wavpack_domain
,
"failed to open WavPack file
\"
%s
\"
: %s"
,
...
...
@@ -283,34 +221,6 @@ wavpack_scan_file(Path path_fs,
WavpackGetSampleRate
(
wpc
));
tag_handler_invoke_duration
(
handler
,
handler_ctx
,
duration
);
/* the WavPack format implies APEv2 tags, which means we can
reuse the mapping from tag_ape.c */
for
(
unsigned
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
++
i
)
{
const
char
*
name
=
tag_item_names
[
i
];
if
(
name
!=
nullptr
)
wavpack_scan_tag_item
(
wpc
,
name
,
(
TagType
)
i
,
handler
,
handler_ctx
);
}
for
(
const
struct
tag_table
*
i
=
ape_tags
;
i
->
name
!=
nullptr
;
++
i
)
wavpack_scan_tag_item
(
wpc
,
i
->
name
,
i
->
type
,
handler
,
handler_ctx
);
if
(
handler
.
pair
!=
nullptr
)
{
char
name
[
64
];
for
(
int
i
=
0
,
n
=
WavpackGetNumTagItems
(
wpc
);
i
<
n
;
++
i
)
{
int
len
=
WavpackGetTagItemIndexed
(
wpc
,
i
,
name
,
sizeof
(
name
));
if
(
len
<=
0
||
(
unsigned
)
len
>=
sizeof
(
name
))
continue
;
wavpack_scan_pair
(
wpc
,
name
,
handler
,
handler_ctx
);
}
}
return
true
;
}
...
...
@@ -549,7 +459,7 @@ wavpack_filedecode(DecoderClient &client, Path path_fs)
{
char
error
[
ERRORLEN
];
WavpackContext
*
wpc
=
WavpackOpenFileInput
(
path_fs
.
c_str
(),
error
,
OPEN_
TAGS
|
OPEN_
WVC
|
OPEN_NORMALIZE
,
OPEN_WVC
|
OPEN_NORMALIZE
,
0
);
if
(
wpc
==
nullptr
)
{
FormatWarning
(
wavpack_domain
,
...
...
@@ -562,10 +472,6 @@ wavpack_filedecode(DecoderClient &client, Path path_fs)
WavpackCloseFile
(
wpc
);
};
ReplayGainInfo
rgi
;
if
(
wavpack_replaygain
(
rgi
,
wpc
))
client
.
SubmitReplayGain
(
&
rgi
);
wavpack_decode
(
client
,
wpc
,
true
);
}
...
...
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