song: added song_in_database()
Some functions assume that a song is not in the database when it is a remote song. Based on that, they decide whether they are responsible for freeing the song struct. Add a special function which checks whether a song is in the database (currently equal to song_is_file()).
This commit is contained in:
parent
4a7ad5b618
commit
6d3488c8b3
@ -181,11 +181,9 @@ static int getNextId(void)
|
|||||||
void finishPlaylist(void)
|
void finishPlaylist(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < playlist.length; i++) {
|
for (i = 0; i < playlist.length; i++)
|
||||||
if (!song_is_file(playlist.songs[i])) {
|
if (!song_in_database(playlist.songs[i]))
|
||||||
song_free(playlist.songs[i]);
|
song_free(playlist.songs[i]);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
playlist.length = 0;
|
playlist.length = 0;
|
||||||
|
|
||||||
@ -208,9 +206,9 @@ void clearPlaylist(void)
|
|||||||
stopPlaylist();
|
stopPlaylist();
|
||||||
|
|
||||||
for (i = 0; i < playlist.length; i++) {
|
for (i = 0; i < playlist.length; i++) {
|
||||||
if (!song_is_file(playlist.songs[i])) {
|
if (!song_in_database(playlist.songs[i]))
|
||||||
song_free(playlist.songs[i]);
|
song_free(playlist.songs[i]);
|
||||||
}
|
|
||||||
playlist.idToPosition[playlist.positionToId[i]] = -1;
|
playlist.idToPosition[playlist.positionToId[i]] = -1;
|
||||||
playlist.songs[i] = NULL;
|
playlist.songs[i] = NULL;
|
||||||
}
|
}
|
||||||
@ -678,9 +676,8 @@ enum playlist_result deleteFromPlaylist(int song)
|
|||||||
|| playlist.order[playlist.current] == song))
|
|| playlist.order[playlist.current] == song))
|
||||||
clearPlayerQueue();
|
clearPlayerQueue();
|
||||||
|
|
||||||
if (!song_is_file(playlist.songs[song])) {
|
if (!song_in_database(playlist.songs[song]))
|
||||||
song_free(playlist.songs[song]);
|
song_free(playlist.songs[song]);
|
||||||
}
|
|
||||||
|
|
||||||
playlist.idToPosition[playlist.positionToId[song]] = -1;
|
playlist.idToPosition[playlist.positionToId[song]] = -1;
|
||||||
|
|
||||||
@ -858,6 +855,8 @@ static void syncCurrentPlayerDecodeMetadata(void)
|
|||||||
if (!song_is_file(song) &&
|
if (!song_is_file(song) &&
|
||||||
0 == strcmp(song_get_url(song, path_max_tmp), songPlayer->url) &&
|
0 == strcmp(song_get_url(song, path_max_tmp), songPlayer->url) &&
|
||||||
!tag_equal(song->tag, songPlayer->tag)) {
|
!tag_equal(song->tag, songPlayer->tag)) {
|
||||||
|
assert(!song_in_database(song));
|
||||||
|
|
||||||
if (song->tag)
|
if (song->tag)
|
||||||
tag_free(song->tag);
|
tag_free(song->tag);
|
||||||
song->tag = tag_dup(songPlayer->tag);
|
song->tag = tag_dup(songPlayer->tag);
|
||||||
|
@ -68,9 +68,15 @@ char *
|
|||||||
song_get_url(const struct song *song, char *path_max_tmp);
|
song_get_url(const struct song *song, char *path_max_tmp);
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
song_is_file(const struct song *song)
|
song_in_database(const struct song *song)
|
||||||
{
|
{
|
||||||
return song->parent != NULL;
|
return song->parent != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
song_is_file(const struct song *song)
|
||||||
|
{
|
||||||
|
return song_in_database(song);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user