libsaria: Return default track values in error case
If we can't find the inode, I return some default values to the UI to keep it happy (and clear out the information from the previous song).
This commit is contained in:
parent
c894815dad
commit
049f91e514
|
@ -11,6 +11,7 @@ class Track
|
|||
TrackTag *tags;
|
||||
|
||||
public:
|
||||
Track();
|
||||
Track(ino_t, TrackTag *);
|
||||
~Track();
|
||||
|
||||
|
|
|
@ -18,9 +18,11 @@ namespace libsaria
|
|||
void current_track(void (*func)(Track &))
|
||||
{
|
||||
ino_t inode;
|
||||
/* TODO: Set to blank in error cases */
|
||||
if (current_inode(inode) < 0)
|
||||
if (current_inode(inode) < 0) {
|
||||
Track blank;
|
||||
func(blank);
|
||||
return;
|
||||
}
|
||||
library::get_info(inode, func);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,12 @@
|
|||
#include <libsaria/track.h>
|
||||
#include <libsaria/tags.h>
|
||||
|
||||
Track::Track()
|
||||
{
|
||||
inode = 0;
|
||||
tags = NULL;
|
||||
}
|
||||
|
||||
Track::Track(ino_t ino, TrackTag *tag)
|
||||
{
|
||||
inode = ino;
|
||||
|
@ -19,30 +25,42 @@ ino_t Track::get_inode()
|
|||
|
||||
unsigned int Track::get_track()
|
||||
{
|
||||
return tags->get_track();
|
||||
if (tags)
|
||||
return tags->get_track();
|
||||
return 0;
|
||||
}
|
||||
|
||||
string Track::get_title()
|
||||
{
|
||||
return tags->get_title();
|
||||
if (tags)
|
||||
return tags->get_title();
|
||||
return "";
|
||||
}
|
||||
|
||||
string Track::get_lenstr()
|
||||
{
|
||||
return tags->get_lenstr();
|
||||
if (tags)
|
||||
return tags->get_lenstr();
|
||||
return "";
|
||||
}
|
||||
|
||||
string Track::get_artist()
|
||||
{
|
||||
return tags->get_artist();
|
||||
if (tags)
|
||||
return tags->get_artist();
|
||||
return "";
|
||||
}
|
||||
|
||||
string Track::get_album()
|
||||
{
|
||||
return tags->get_album();
|
||||
if (tags)
|
||||
return tags->get_album();
|
||||
return "";
|
||||
}
|
||||
|
||||
unsigned int Track::get_year()
|
||||
{
|
||||
return tags->get_year();
|
||||
if (tags)
|
||||
return tags->get_year();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue