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
bed8a0e0
Commit
bed8a0e0
authored
Aug 10, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/sidplay: move global variables to struct SidplayGlobal
parent
b8a64771
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
23 deletions
+43
-23
SidplayDecoderPlugin.cxx
src/decoder/plugins/SidplayDecoderPlugin.cxx
+43
-23
No files found.
src/decoder/plugins/SidplayDecoderPlugin.cxx
View file @
bed8a0e0
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include "util/AllocatedString.hxx"
#include "util/AllocatedString.hxx"
#include "util/CharUtil.hxx"
#include "util/CharUtil.hxx"
#include "util/ByteOrder.hxx"
#include "util/ByteOrder.hxx"
#include "util/Manual.hxx"
#include "Log.hxx"
#include "Log.hxx"
#ifdef HAVE_SIDPLAYFP
#ifdef HAVE_SIDPLAYFP
...
@@ -67,17 +68,35 @@
...
@@ -67,17 +68,35 @@
static
constexpr
Domain
sidplay_domain
(
"sidplay"
);
static
constexpr
Domain
sidplay_domain
(
"sidplay"
);
static
SidDatabase
*
songlength_database
;
struct
SidplayGlobal
{
SidDatabase
*
songlength_database
;
static
bool
all_files_are_containers
;
bool
all_files_are_containers
;
static
unsigned
default_songlength
;
unsigned
default_songlength
;
static
std
::
string
default_genre
;
std
::
string
default_genre
;
static
bool
filter_setting
;
bool
filter_setting
;
#ifdef HAVE_SIDPLAYFP
uint8_t
*
kernal
=
nullptr
,
*
basic
=
nullptr
;
#endif
explicit
SidplayGlobal
(
const
ConfigBlock
&
block
);
~
SidplayGlobal
()
noexcept
{
delete
songlength_database
;
#ifdef HAVE_SIDPLAYFP
delete
[]
basic
;
delete
[]
kernal
;
#endif
}
};
static
SidplayGlobal
*
sidplay_global
;
#ifdef HAVE_SIDPLAYFP
#ifdef HAVE_SIDPLAYFP
static
constexpr
unsigned
rom_size
=
8192
;
static
constexpr
unsigned
rom_size
=
8192
;
static
uint8_t
*
kernal
,
*
basic
=
nullptr
;
static
void
loadRom
(
const
Path
rom_path
,
uint8_t
*
dump
)
static
void
loadRom
(
const
Path
rom_path
,
uint8_t
*
dump
)
{
{
...
@@ -110,8 +129,8 @@ sidplay_load_songlength_db(const Path path) noexcept
...
@@ -110,8 +129,8 @@ sidplay_load_songlength_db(const Path path) noexcept
return
db
;
return
db
;
}
}
static
bool
inline
sidplay_init
(
const
ConfigBlock
&
block
)
SidplayGlobal
::
SidplayGlobal
(
const
ConfigBlock
&
block
)
{
{
/* read the songlengths database file */
/* read the songlengths database file */
const
auto
database_path
=
block
.
GetPath
(
"songlength_database"
);
const
auto
database_path
=
block
.
GetPath
(
"songlength_database"
);
...
@@ -144,19 +163,19 @@ sidplay_init(const ConfigBlock &block)
...
@@ -144,19 +163,19 @@ sidplay_init(const ConfigBlock &block)
loadRom
(
basic_path
,
basic
);
loadRom
(
basic_path
,
basic
);
}
}
#endif
#endif
}
static
bool
sidplay_init
(
const
ConfigBlock
&
block
)
{
sidplay_global
=
new
SidplayGlobal
(
block
);
return
true
;
return
true
;
}
}
static
void
static
void
sidplay_finish
()
noexcept
sidplay_finish
()
noexcept
{
{
delete
songlength_database
;
delete
sidplay_global
;
#ifdef HAVE_SIDPLAYFP
delete
[]
basic
;
delete
[]
kernal
;
#endif
}
}
struct
SidplayContainerPath
{
struct
SidplayContainerPath
{
...
@@ -207,10 +226,10 @@ get_song_length(T &tune) noexcept
...
@@ -207,10 +226,10 @@ get_song_length(T &tune) noexcept
{
{
assert
(
tune
.
getStatus
());
assert
(
tune
.
getStatus
());
if
(
songlength_database
==
nullptr
)
if
(
s
idplay_global
->
s
onglength_database
==
nullptr
)
return
SignedSongTime
::
Negative
();
return
SignedSongTime
::
Negative
();
const
auto
length
=
songlength_database
->
length
(
tune
);
const
auto
length
=
s
idplay_global
->
s
onglength_database
->
length
(
tune
);
if
(
length
<
0
)
if
(
length
<
0
)
return
SignedSongTime
::
Negative
();
return
SignedSongTime
::
Negative
();
...
@@ -245,15 +264,15 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
...
@@ -245,15 +264,15 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
tune
.
selectSong
(
song_num
);
tune
.
selectSong
(
song_num
);
auto
duration
=
get_song_length
(
tune
);
auto
duration
=
get_song_length
(
tune
);
if
(
duration
.
IsNegative
()
&&
default_songlength
>
0
)
if
(
duration
.
IsNegative
()
&&
sidplay_global
->
default_songlength
>
0
)
duration
=
SongTime
::
FromS
(
default_songlength
);
duration
=
SongTime
::
FromS
(
sidplay_global
->
default_songlength
);
/* initialize the player */
/* initialize the player */
#ifdef HAVE_SIDPLAYFP
#ifdef HAVE_SIDPLAYFP
sidplayfp
player
;
sidplayfp
player
;
player
.
setRoms
(
kernal
,
basic
,
nullptr
);
player
.
setRoms
(
sidplay_global
->
kernal
,
sidplay_global
->
basic
,
nullptr
);
#else
#else
sidplay2
player
;
sidplay2
player
;
#endif
#endif
...
@@ -296,7 +315,7 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
...
@@ -296,7 +315,7 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
}
}
#endif
#endif
builder
.
filter
(
filter_setting
);
builder
.
filter
(
sidplay_global
->
filter_setting
);
#ifdef HAVE_SIDPLAYFP
#ifdef HAVE_SIDPLAYFP
if
(
!
builder
.
getStatus
())
{
if
(
!
builder
.
getStatus
())
{
FormatWarning
(
sidplay_domain
,
FormatWarning
(
sidplay_domain
,
...
@@ -529,8 +548,9 @@ ScanSidTuneInfo(const SidTuneInfo &info, unsigned track, unsigned n_tracks,
...
@@ -529,8 +548,9 @@ ScanSidTuneInfo(const SidTuneInfo &info, unsigned track, unsigned n_tracks,
handler
.
OnTag
(
TAG_ARTIST
,
artist
.
c_str
());
handler
.
OnTag
(
TAG_ARTIST
,
artist
.
c_str
());
/* genre */
/* genre */
if
(
!
default_genre
.
empty
())
if
(
!
sidplay_global
->
default_genre
.
empty
())
handler
.
OnTag
(
TAG_GENRE
,
default_genre
.
c_str
());
handler
.
OnTag
(
TAG_GENRE
,
sidplay_global
->
default_genre
.
c_str
());
/* date */
/* date */
const
auto
date
=
GetDateString
(
info
);
const
auto
date
=
GetDateString
(
info
);
...
@@ -598,7 +618,7 @@ sidplay_container_scan(Path path_fs)
...
@@ -598,7 +618,7 @@ sidplay_container_scan(Path path_fs)
/* Don't treat sids containing a single tune
/* Don't treat sids containing a single tune
as containers */
as containers */
if
(
!
all_files_are_containers
&&
n_tracks
<
2
)
if
(
!
sidplay_global
->
all_files_are_containers
&&
n_tracks
<
2
)
return
list
;
return
list
;
TagBuilder
tag_builder
;
TagBuilder
tag_builder
;
...
...
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