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
2fe1b503
Commit
2fe1b503
authored
Sep 13, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db_plugin: add method get_song()
New db_get_song() implementation.
parent
b4430839
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
2 deletions
+39
-2
database.c
src/database.c
+1
-2
simple_db_plugin.c
src/db/simple_db_plugin.c
+17
-0
db_plugin.h
src/db_plugin.h
+21
-0
No files found.
src/database.c
View file @
2fe1b503
...
...
@@ -104,8 +104,7 @@ db_get_song(const char *file)
if
(
db
==
NULL
)
return
NULL
;
struct
directory
*
music_root
=
db_get_root
();
return
directory_lookup_song
(
music_root
,
file
);
return
db_plugin_get_song
(
db
,
file
,
NULL
);
}
bool
...
...
src/db/simple_db_plugin.c
View file @
2fe1b503
...
...
@@ -20,6 +20,7 @@
#include "config.h"
#include "simple_db_plugin.h"
#include "db_internal.h"
#include "db_error.h"
#include "db_save.h"
#include "conf.h"
#include "glib_compat.h"
...
...
@@ -214,12 +215,28 @@ simple_db_close(struct db *_db)
directory_free
(
db
->
root
);
}
static
struct
song
*
simple_db_get_song
(
struct
db
*
_db
,
const
char
*
uri
,
GError
**
error_r
)
{
struct
simple_db
*
db
=
(
struct
simple_db
*
)
_db
;
assert
(
db
->
root
!=
NULL
);
struct
song
*
song
=
directory_lookup_song
(
db
->
root
,
uri
);
if
(
song
==
NULL
)
g_set_error
(
error_r
,
db_quark
(),
DB_NOT_FOUND
,
"No such song: %s"
,
uri
);
return
song
;
}
const
struct
db_plugin
simple_db_plugin
=
{
.
name
=
"simple"
,
.
init
=
simple_db_init
,
.
finish
=
simple_db_finish
,
.
open
=
simple_db_open
,
.
close
=
simple_db_close
,
.
get_song
=
simple_db_get_song
,
};
struct
directory
*
...
...
src/db_plugin.h
View file @
2fe1b503
...
...
@@ -58,6 +58,15 @@ struct db_plugin {
* Close the database, free allocated memory.
*/
void
(
*
close
)(
struct
db
*
db
);
/**
* Look up a song (including tag data) in the database.
*
* @param the URI of the song within the music directory
* (UTF-8)
*/
struct
song
*
(
*
get_song
)(
struct
db
*
db
,
const
char
*
uri
,
GError
**
error_r
);
};
G_GNUC_MALLOC
...
...
@@ -68,6 +77,7 @@ db_plugin_new(const struct db_plugin *plugin, const struct config_param *param,
assert
(
plugin
!=
NULL
);
assert
(
plugin
->
init
!=
NULL
);
assert
(
plugin
->
finish
!=
NULL
);
assert
(
plugin
->
get_song
!=
NULL
);
assert
(
error_r
==
NULL
||
*
error_r
==
NULL
);
struct
db
*
db
=
plugin
->
init
(
param
,
error_r
);
...
...
@@ -108,4 +118,15 @@ db_plugin_close(struct db *db)
db
->
plugin
->
close
(
db
);
}
static
inline
struct
song
*
db_plugin_get_song
(
struct
db
*
db
,
const
char
*
uri
,
GError
**
error_r
)
{
assert
(
db
!=
NULL
);
assert
(
db
->
plugin
!=
NULL
);
assert
(
db
->
plugin
->
get_song
!=
NULL
);
assert
(
uri
!=
NULL
);
return
db
->
plugin
->
get_song
(
db
,
uri
,
error_r
);
}
#endif
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