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
9f878b77
Commit
9f878b77
authored
Dec 04, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/sidplay: use class SidDatabase
Remove our own songlength database parser.
parent
a547d2aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
53 deletions
+11
-53
configure.ac
configure.ac
+0
-2
SidplayDecoderPlugin.cxx
src/decoder/plugins/SidplayDecoderPlugin.cxx
+11
-51
No files found.
configure.ac
View file @
9f878b77
...
...
@@ -542,8 +542,6 @@ AC_ARG_ENABLE(sidplay,
AS_HELP_STRING([--enable-sidplay],
[enable C64 SID support via libsidplay2]),,
enable_sidplay=auto)
MPD_DEPENDS([enable_sidplay], [enable_glib],
[Cannot use --enable-sidplay with --disable-glib])
AC_ARG_ENABLE(shine-encoder,
AS_HELP_STRING([--enable-shine-encoder],
...
...
src/decoder/plugins/SidplayDecoderPlugin.cxx
View file @
9f878b77
...
...
@@ -33,57 +33,35 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <sidplay/sidplay2.h>
#include <sidplay/builders/resid.h>
#include <sidplay/utils/SidTuneMod.h>
#include <sidplay/utils/SidDatabase.h>
#define SUBTUNE_PREFIX "tune_"
static
constexpr
Domain
sidplay_domain
(
"sidplay"
);
static
GKeyFil
e
*
songlength_database
;
static
SidDatabas
e
*
songlength_database
;
static
bool
all_files_are_containers
;
static
unsigned
default_songlength
;
static
bool
filter_setting
;
static
GKeyFil
e
*
static
SidDatabas
e
*
sidplay_load_songlength_db
(
const
Path
path
)
{
GError
*
error
=
nullptr
;
gchar
*
data
;
gsize
size
;
if
(
!
g_file_get_contents
(
path
.
c_str
(),
&
data
,
&
size
,
&
error
))
{
SidDatabase
*
db
=
new
SidDatabase
();
if
(
db
->
open
(
path
.
c_str
())
<
0
)
{
FormatError
(
sidplay_domain
,
"unable to read songlengths file %s: %s"
,
path
.
c_str
(),
error
->
message
);
g_error_free
(
error
);
return
nullptr
;
}
/* replace any ; comment characters with # */
for
(
gsize
i
=
0
;
i
<
size
;
i
++
)
if
(
data
[
i
]
==
';'
)
data
[
i
]
=
'#'
;
GKeyFile
*
db
=
g_key_file_new
();
bool
success
=
g_key_file_load_from_data
(
db
,
data
,
size
,
G_KEY_FILE_NONE
,
&
error
);
g_free
(
data
);
if
(
!
success
)
{
FormatError
(
sidplay_domain
,
"unable to parse songlengths file %s: %s"
,
path
.
c_str
(),
error
->
message
);
g_error_free
(
error
);
g_key_file_free
(
db
);
path
.
c_str
(),
db
->
error
());
delete
db
;
return
nullptr
;
}
g_key_file_set_list_separator
(
db
,
' '
);
return
db
;
}
...
...
@@ -111,8 +89,7 @@ sidplay_init(const config_param ¶m)
static
void
sidplay_finish
()
{
if
(
songlength_database
)
g_key_file_free
(
songlength_database
);
delete
songlength_database
;
}
struct
SidplayContainerPath
{
...
...
@@ -171,28 +148,11 @@ get_song_length(const SidplayContainerPath &container)
const
unsigned
song_num
=
container
.
track
;
gsize
num_items
;
gchar
**
values
=
g_key_file_get_string_list
(
songlength_database
,
"Database"
,
md5sum
,
&
num_items
,
nullptr
);
if
(
!
values
||
song_num
>
num_items
)
{
g_strfreev
(
values
);
const
auto
length
=
songlength_database
->
length
(
md5sum
,
song_num
);
if
(
length
<
0
)
return
SignedSongTime
::
Negative
();
}
int
minutes
=
strtol
(
values
[
song_num
-
1
],
nullptr
,
10
);
if
(
errno
==
EINVAL
)
minutes
=
0
;
int
seconds
;
char
*
ptr
=
strchr
(
values
[
song_num
-
1
],
':'
);
if
(
ptr
)
{
seconds
=
strtol
(
ptr
+
1
,
nullptr
,
10
);
if
(
errno
==
EINVAL
)
seconds
=
0
;
}
else
seconds
=
0
;
g_strfreev
(
values
);
return
SignedSongTime
::
FromS
(
(
minutes
*
60
)
+
seconds
);
return
SignedSongTime
::
FromS
(
length
);
}
static
void
...
...
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