db_plugin: add method get_song()
New db_get_song() implementation.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user