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
aa55d759
Commit
aa55d759
authored
Aug 08, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DatabaseGlue: add function db_is_simple()
Preparing for non-"simple" database plugins.
parent
2043579f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
5 deletions
+38
-5
DatabaseGlue.cxx
src/DatabaseGlue.cxx
+11
-0
Stats.cxx
src/Stats.cxx
+8
-4
database.h
src/database.h
+18
-0
update.c
src/update.c
+1
-1
No files found.
src/DatabaseGlue.cxx
View file @
aa55d759
...
...
@@ -87,10 +87,19 @@ GetDatabase()
return
db
;
}
bool
db_is_simple
(
void
)
{
assert
(
db
==
NULL
||
db_is_open
);
return
dynamic_cast
<
SimpleDatabase
*>
(
db
)
!=
nullptr
;
}
struct
directory
*
db_get_root
(
void
)
{
assert
(
db
!=
NULL
);
assert
(
db_is_simple
());
return
((
SimpleDatabase
*
)
db
)
->
GetRoot
();
}
...
...
@@ -128,6 +137,7 @@ db_save(GError **error_r)
{
assert
(
db
!=
NULL
);
assert
(
db_is_open
);
assert
(
db_is_simple
());
return
((
SimpleDatabase
*
)
db
)
->
Save
(
error_r
);
}
...
...
@@ -153,6 +163,7 @@ db_get_mtime(void)
{
assert
(
db
!=
NULL
);
assert
(
db_is_open
);
assert
(
db_is_simple
());
return
((
SimpleDatabase
*
)
db
)
->
GetLastModified
();
}
src/Stats.cxx
View file @
aa55d759
...
...
@@ -119,14 +119,18 @@ int stats_print(struct client *client)
"songs: %i
\n
"
"uptime: %li
\n
"
"playtime: %li
\n
"
"db_playtime: %li
\n
"
"db_update: %li
\n
"
,
"db_playtime: %li
\n
"
,
stats
.
artist_count
,
stats
.
album_count
,
stats
.
song_count
,
(
long
)
g_timer_elapsed
(
stats
.
timer
,
NULL
),
(
long
)(
pc_get_total_play_time
(
client
->
player_control
)
+
0.5
),
stats
.
song_duration
,
(
long
)
db_get_mtime
());
stats
.
song_duration
);
if
(
db_is_simple
())
client_printf
(
client
,
"db_update: %li
\n
"
,
(
long
)
db_get_mtime
());
return
0
;
}
src/database.h
View file @
aa55d759
...
...
@@ -44,8 +44,18 @@ void
db_finish
(
void
);
/**
* Check whether the default #SimpleDatabasePlugin is used. This
* allows using db_get_root(), db_save(), db_get_mtime() and
* db_exists().
*/
bool
db_is_simple
(
void
);
/**
* Returns the root directory object. Returns NULL if there is no
* configured music directory.
*
* May only be used if db_is_simple() returns true.
*/
gcc_pure
struct
directory
*
...
...
@@ -64,18 +74,26 @@ gcc_pure
struct
song
*
db_get_song
(
const
char
*
file
);
/**
* May only be used if db_is_simple() returns true.
*/
bool
db_save
(
GError
**
error_r
);
bool
db_load
(
GError
**
error
);
/**
* May only be used if db_is_simple() returns true.
*/
gcc_pure
time_t
db_get_mtime
(
void
);
/**
* Returns true if there is a valid database file on the disk.
*
* May only be used if db_is_simple() returns true.
*/
gcc_pure
static
inline
bool
...
...
src/update.c
View file @
aa55d759
...
...
@@ -118,7 +118,7 @@ update_enqueue(const char *path, bool _discard)
{
assert
(
g_thread_self
()
==
main_task
);
if
(
!
mapper_has_music_directory
())
if
(
!
db_is_simple
()
||
!
mapper_has_music_directory
())
return
0
;
if
(
progress
!=
UPDATE_PROGRESS_IDLE
)
{
...
...
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