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
ff871455
Commit
ff871455
authored
Jan 29, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sticker: don't use classes Directory and Song
Don't depend on the "simple" database plugin. This fixes an assertion failure / crash and allows using stickers with other plugins.
parent
667481c3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
22 deletions
+21
-22
StickerCommands.cxx
src/command/StickerCommands.cxx
+4
-11
SongSticker.cxx
src/sticker/SongSticker.cxx
+15
-9
SongSticker.hxx
src/sticker/SongSticker.hxx
+2
-2
No files found.
src/command/StickerCommands.cxx
View file @
ff871455
...
...
@@ -124,24 +124,17 @@ handle_sticker_song(Client &client, int argc, char *argv[])
/* find song dir key */
}
else
if
(
argc
==
5
&&
strcmp
(
argv
[
1
],
"find"
)
==
0
)
{
/* "sticker find song a/directory name" */
const
char
*
const
base_uri
=
argv
[
3
];
bool
success
;
struct
sticker_song_find_data
data
=
{
client
,
argv
[
4
],
};
db_lock
();
Directory
*
directory
=
db_get_directory
(
argv
[
3
]);
if
(
directory
==
nullptr
)
{
db_unlock
();
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"no such directory"
);
return
CommandResult
::
ERROR
;
}
success
=
sticker_song_find
(
*
directory
,
data
.
name
,
success
=
sticker_song_find
(
base_uri
,
data
.
name
,
sticker_song_find_print_cb
,
&
data
);
db_unlock
();
if
(
!
success
)
{
command_error
(
client
,
ACK_ERROR_SYSTEM
,
"failed to set search sticker database"
);
...
...
src/sticker/SongSticker.cxx
View file @
ff871455
...
...
@@ -21,8 +21,9 @@
#include "SongSticker.hxx"
#include "StickerDatabase.hxx"
#include "db/LightSong.hxx"
#include "db/Song.hxx"
#include "db/Directory.hxx"
#include "db/DatabaseGlue.hxx"
#include "db/DatabasePlugin.hxx"
#include "util/Error.hxx"
#include <glib.h>
...
...
@@ -66,7 +67,7 @@ sticker_song_get(const LightSong &song)
}
struct
sticker_song_find_data
{
Directory
*
directory
;
const
Database
*
db
;
const
char
*
base_uri
;
size_t
base_uri_length
;
...
...
@@ -85,24 +86,29 @@ sticker_song_find_cb(const char *uri, const char *value, void *user_data)
/* should not happen, ignore silently */
return
;
Song
*
song
=
data
->
directory
->
LookupSong
(
uri
+
data
->
base_uri_length
);
if
(
song
!=
nullptr
)
data
->
func
(
song
->
Export
(),
value
,
data
->
user_data
);
const
Database
*
db
=
data
->
db
;
const
LightSong
*
song
=
db
->
GetSong
(
uri
,
IgnoreError
());
if
(
song
!=
nullptr
)
{
data
->
func
(
*
song
,
value
,
data
->
user_data
);
db
->
ReturnSong
(
song
);
}
}
bool
sticker_song_find
(
Directory
&
directory
,
const
char
*
name
,
sticker_song_find
(
const
char
*
base_uri
,
const
char
*
name
,
void
(
*
func
)(
const
LightSong
&
song
,
const
char
*
value
,
void
*
user_data
),
void
*
user_data
)
{
struct
sticker_song_find_data
data
;
data
.
directory
=
&
directory
;
data
.
db
=
GetDatabase
();
assert
(
data
.
db
!=
nullptr
);
data
.
func
=
func
;
data
.
user_data
=
user_data
;
char
*
allocated
;
data
.
base_uri
=
directory
.
GetPath
()
;
data
.
base_uri
=
base_uri
;
if
(
*
data
.
base_uri
!=
0
)
/* append slash to base_uri */
data
.
base_uri
=
allocated
=
...
...
src/sticker/SongSticker.hxx
View file @
ff871455
...
...
@@ -72,13 +72,13 @@ sticker_song_get(const LightSong &song);
*
* Caller must lock the #db_mutex.
*
* @param
directory
the base directory to search in
* @param
base_uri
the base directory to search in
* @param name the name of the sticker
* @return true on success (even if no sticker was found), false on
* failure
*/
bool
sticker_song_find
(
Directory
&
directory
,
const
char
*
name
,
sticker_song_find
(
const
char
*
base_uri
,
const
char
*
name
,
void
(
*
func
)(
const
LightSong
&
song
,
const
char
*
value
,
void
*
user_data
),
void
*
user_data
);
...
...
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