core/tags/track: Convert Track class into a struct

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-10-24 19:34:45 -04:00
parent 446f1228cf
commit 765079df94
20 changed files with 170 additions and 168 deletions

View File

@ -10,7 +10,7 @@
static bool _pause_enabled = false;
static unsigned int _pause_count = 0;
static Track *cur_track = NULL;
static struct track *cur_track = NULL;
static struct file f_cur_track;
static AudioDriver *cur_driver = NULL;
@ -22,7 +22,7 @@ static void save_state()
file_close(&f_cur_track);
}
static void _load_track(Track *track, bool start_playback)
static void _load_track(struct track *track, bool start_playback)
{
cur_track = track;
if (!track)
@ -136,7 +136,7 @@ void audio :: prev()
_load_track(deck :: prev(), cur_driver->is_playing());
}
void audio :: load_track(Track *track)
void audio :: load_track(struct track *track)
{
if (!track || track == cur_track)
return;
@ -145,7 +145,7 @@ void audio :: load_track(Track *track)
deck :: get_queue()->add(cur_track);
}
Track *audio :: current_track()
struct track *audio :: current_track()
{
return cur_track;
}

View File

@ -11,7 +11,7 @@ class RecentQueue : public Queue
public:
RecentQueue() : Queue(Q_ENABLED | Q_REPEAT | Q_NO_SORT) {}
unsigned int add(Track *track)
unsigned int add(struct track *track)
{
del(track);
_cur = 0;
@ -41,14 +41,14 @@ void TempQueue :: unset_flag(queue_flags flag)
deck :: write();
}
unsigned int TempQueue :: add(Track *track)
unsigned int TempQueue :: add(struct track *track)
{
unsigned int res = Queue :: add(track);
deck :: write();
return res;
}
void TempQueue :: del(Track *track)
void TempQueue :: del(struct track *track)
{
Queue :: del(track);
deck :: write();
@ -198,9 +198,9 @@ Queue *deck :: get(unsigned int index)
return NULL;
}
Track *deck :: next()
struct track *deck :: next()
{
Track *track = NULL;
struct track *track = NULL;
std::list<TempQueue>::iterator it;
for (it = queue_deck.begin(); it != queue_deck.end(); it++) {
@ -220,7 +220,7 @@ Track *deck :: next()
return track;
}
Track *deck :: prev()
struct track *deck :: prev()
{
return recent_queue.next();
}

View File

@ -82,7 +82,7 @@ static void scan_path(struct scan_info &);
*/
static void tag_track(struct library *library, const std::string &filepath)
{
Track *track;
struct track *track;
TagLib :: Tag *tag;
TagLib :: AudioProperties *audio;
TagLib :: FileRef ref(filepath.c_str(), true, TagLib::AudioProperties::Fast);
@ -142,7 +142,7 @@ static void scan_path(struct scan_info &scan)
static void validate_library(struct library *&library)
{
Track *track;
struct track *track;
for (unsigned int i = 0; i < tags :: track_size(); i++) {
track = tags :: get_track(i);
@ -164,7 +164,7 @@ static void validate_library(struct library *&library)
void collection :: init()
{
Track *track;
struct track *track;
library_q.load();
@ -220,7 +220,7 @@ void collection :: update_all()
void collection :: set_enabled(struct library *library, bool enabled)
{
Track *track;
struct track *track;
if (!library || (library->li_enabled == enabled))
return;

View File

@ -33,7 +33,7 @@ public:
unsigned int find_average_count()
{
Track *track;
struct track *track;
unsigned int total = 0, count = 0;
for (unsigned int i = 0; i < tags :: track_size(); i++) {
@ -49,7 +49,7 @@ public:
return 0;
}
void dynamic_add(const std::string &name, Track *track, unsigned int avg)
void dynamic_add(const std::string &name, struct track *track, unsigned int avg)
{
if ((name == "Unplayed") && (track->count() == 0))
add(track);
@ -61,7 +61,7 @@ public:
void dynamic_fill(const std::string &name)
{
Track *track;
struct track *track;
unsigned int avg = 0;
if ((name == "Most Played") || (name == "Least Played"))
@ -98,12 +98,12 @@ void playlist :: init()
collection :: get_queue()->del(tags :: get_track(it.it_val));
}
bool playlist :: has(Track *track, const std::string &name)
bool playlist :: has(struct track *track, const std::string &name)
{
return index_has(&playlist_db, name.c_str(), track->index());
}
void playlist :: add(Track *track, const std::string &name)
void playlist :: add(struct track *track, const std::string &name)
{
if (!( (name == "Banned") || (name == "Favorites") ))
return;
@ -117,7 +117,7 @@ void playlist :: add(Track *track, const std::string &name)
}
}
void playlist :: del(Track *track, const std::string &name)
void playlist :: del(struct track *track, const std::string &name)
{
index_remove(&playlist_db, name.c_str(), track->index());
if (cur_plist == name)

View File

@ -76,7 +76,7 @@ void Queue :: set_notifier(QNotifier *notify)
* < 0: lhs < rhs, or rhs is empty
* > 0: lhs > rhs, or lhs is empty
*/
static inline int track_compare(Track *lhs, Track *rhs, sort_t field)
static inline int track_compare(struct track *lhs, struct track *rhs, sort_t field)
{
switch (field) {
case SORT_ARTIST:
@ -92,7 +92,7 @@ static inline int track_compare(Track *lhs, Track *rhs, sort_t field)
case SORT_TITLE:
return lhs->compare(rhs);
case SORT_TRACK:
return lhs->track() - rhs->track();
return lhs->track_nr() - rhs->track_nr();
case SORT_YEAR:
if (lhs->album()->al_year - rhs->album()->al_year != 0)
return lhs->album()->al_year - rhs->album()->al_year;
@ -102,7 +102,7 @@ static inline int track_compare(Track *lhs, Track *rhs, sort_t field)
return 0;
}
static bool track_less_than(Track *lhs, Track *rhs,
static bool track_less_than(struct track *lhs, struct track *rhs,
std::vector<struct sort_info> &order)
{
int res;
@ -119,9 +119,9 @@ static bool track_less_than(Track *lhs, Track *rhs,
return res < 0;
}
unsigned int Queue :: find_sorted_id(Track *rhs)
unsigned int Queue :: find_sorted_id(struct track *rhs)
{
Track *lhs;
struct track *lhs;
unsigned int begin = 0, end = (_tracks.size() - 1), mid;
if (_tracks.size() == 0)
@ -146,7 +146,7 @@ unsigned int Queue :: find_sorted_id(Track *rhs)
return begin;
}
unsigned int Queue :: _add_at(Track *track, unsigned int pos)
unsigned int Queue :: _add_at(struct track *track, unsigned int pos)
{
_tracks.insert(_tracks.begin() + pos, track);
_length += track->length();
@ -154,7 +154,7 @@ unsigned int Queue :: _add_at(Track *track, unsigned int pos)
return pos;
}
unsigned int Queue :: add(Track *track)
unsigned int Queue :: add(struct track *track)
{
unsigned int id = _tracks.size();
if (_sort_order.size() > 0)
@ -169,7 +169,7 @@ void Queue :: del(unsigned int index)
_notify->on_track_removed(index);
}
void Queue :: del(Track *track)
void Queue :: del(struct track *track)
{
for (unsigned int i = 0; i < _tracks.size(); i++) {
while ((i < _tracks.size()) && (_tracks[i] == track))
@ -177,7 +177,7 @@ void Queue :: del(Track *track)
}
}
void Queue :: updated(Track *track)
void Queue :: updated(struct track *track)
{
for (unsigned int i = 0; i < _tracks.size(); i++) {
if (_tracks[i] == track)
@ -185,9 +185,9 @@ void Queue :: updated(Track *track)
}
}
Track *Queue :: next()
struct track *Queue :: next()
{
Track *res;
struct track *res;
if (_tracks.size() == 0)
return NULL;
@ -221,7 +221,7 @@ class SortTracks {
public:
std::vector<struct sort_info> fields;
SortTracks(std::vector<sort_info> f) : fields(f) {}
bool operator()(Track *lhs, Track *rhs)
bool operator()(struct track *lhs, struct track *rhs)
{
return track_less_than(lhs, rhs, fields);
}
@ -254,7 +254,7 @@ void Queue :: sort(sort_t field, bool reset)
_notify->on_track_updated(i);
}
Track *Queue :: operator[](unsigned int index)
struct track *Queue :: operator[](unsigned int index)
{
return _tracks[index];
}

View File

@ -8,7 +8,7 @@
#include <glib.h>
static database<Track> track_db;
static database<struct track> track_db;
static const std::string make_key(struct library *library, const std::string &path)
{
@ -24,121 +24,125 @@ static const std::string make_key(struct library *library, const std::string &pa
return res;
}
Track :: Track()
track :: track()
: GenericTag(),
_album(NULL), _artist(NULL), _genre(NULL), _library(NULL),
_count(0), _length(0), _track(0)
tr_album(NULL), tr_artist(NULL), tr_genre(NULL), tr_library(NULL),
tr_count(0), tr_length(0), tr_track(0)
{}
Track :: Track(struct album *album, struct artist *artist, struct genre *genre,
track :: track(struct album *album, struct artist *artist, struct genre *genre,
struct library *library, const std::string &filepath,
const std::string &name, unsigned int length, unsigned int track)
: GenericTag(name),
_album(album), _artist(artist), _genre(genre), _library(library),
_count(0), _length(length), _track(track), _path(filepath)
tr_album(album), tr_artist(artist), tr_genre(genre),
tr_library(library), tr_count(0), tr_length(length), tr_track(track),
tr_path(filepath)
{
date_set(&_date, 0, 0, 0);
date_set(&tr_date, 0, 0, 0);
filter :: add(this->name(), index());
filter :: add(_artist->ar_name, index());
filter :: add(_album->al_name, index());
_library->li_size++;
filter :: add(tr_artist->ar_name, index());
filter :: add(tr_album->al_name, index());
tr_library->li_size++;
}
Track :: Track(const Track &track)
track :: track(const struct track &track)
: GenericTag(track),
_album(track._album), _artist(track._artist), _genre(track._genre),
_library(track._library), _count(track._count), _length(track._length),
_track(track._track), _date(track._date), _path(track._path)
tr_album(track.tr_album), tr_artist(track.tr_artist),
tr_genre(track.tr_genre), tr_library(track.tr_library),
tr_count(track.tr_count), tr_length(track.tr_length),
tr_track(track.tr_track), tr_date(track.tr_date),
tr_path(track.tr_path)
{
_library->li_size++;
tr_library->li_size++;
}
Track :: ~Track()
track :: ~track()
{
if (_library)
_library->li_size--;
if (tr_library)
tr_library->li_size--;
}
struct album *Track :: album() { return _album; }
struct artist *Track :: artist() { return _artist; }
struct genre *Track :: genre() { return _genre; }
struct library *Track :: library() { return _library; }
struct album *track :: album() { return tr_album; }
struct artist *track :: artist() { return tr_artist; }
struct genre *track :: genre() { return tr_genre; }
struct library *track :: library() { return tr_library; }
unsigned int Track :: count() { return _count; }
unsigned int Track :: length() { return _length; }
unsigned int Track :: track() { return _track; }
unsigned int track :: count() { return tr_count; }
unsigned int track :: length() { return tr_length; }
unsigned int track :: track_nr() { return tr_track; }
const std::string Track :: date() const
const std::string track :: date() const
{
char *buf;
std::string res = "Never";
if (_count > 0) {
buf = date_string(&_date);
if (tr_count > 0) {
buf = date_string(&tr_date);
res = buf;
g_free(buf);
}
return res;
}
const std::string Track :: path() const
const std::string track :: path() const
{
if (_library)
return library_file(_library, _path);
if (tr_library)
return library_file(tr_library, tr_path);
return "";
}
const std::string Track :: primary_key() const
const std::string track :: primary_key() const
{
return make_key(_library, _path);
return make_key(tr_library, tr_path);
}
void Track :: played()
void track :: played()
{
_count++;
date_today(&_date);
tr_count++;
date_today(&tr_date);
tags :: commit_track_db();
}
int Track :: compare_date(const Track *rhs)
int track :: compare_date(const struct track *rhs)
{
return date_compare(&_date, &rhs->_date);
return date_compare(&tr_date, &rhs->tr_date);
}
void Track :: read(file &file)
void track :: read(file &file)
{
unsigned int library_id, artist_id, album_id, genre_id;
gchar *path;
file_readf(&file, "%u %u %u %u %u", &library_id, &artist_id,
&album_id, &genre_id, &_track);
date_read(&file, &_date);
file_readf(&file, "%u %u", &_count, &_length);
&album_id, &genre_id, &tr_track);
date_read(&file, &tr_date);
file_readf(&file, "%u %u", &tr_count, &tr_length);
GenericTag :: read(file);
path = file_readl(&file);
_path = path;
tr_path = path;
g_free(path);
_library = library_get(library_id);
_artist = artist_get(artist_id);
_album = album_get(album_id);
_genre = genre_get(genre_id);
tr_library = library_get(library_id);
tr_artist = artist_get(artist_id);
tr_album = album_get(album_id);
tr_genre = genre_get(genre_id);
filter :: add(name(), index());
filter :: add(_artist->ar_name, index());
filter :: add(_album->al_name, index());
_library->li_size++;
filter :: add(tr_artist->ar_name, index());
filter :: add(tr_album->al_name, index());
tr_library->li_size++;
}
void Track :: write(file &file)
void track :: write(file &file)
{
file_writef(&file, "%u %u %u %u %u ", _library->index(), _artist->index(),
_album->index(), _genre->index(), _track);
date_write(&file, &_date);
file_writef(&file, " %u %u ", _count, _length);
file_writef(&file, "%u %u %u %u %u ", tr_library->index(),
tr_artist->index(), tr_album->index(),
tr_genre->index(), tr_track);
date_write(&file, &tr_date);
file_writef(&file, " %u %u ", tr_count, tr_length);
GenericTag :: write(file);
file_writef(&file, "\n%s\n", _path.c_str());
file_writef(&file, "\n%s\n", tr_path.c_str());
}
@ -148,7 +152,7 @@ void tags :: init_track_db()
db_load(&track_db);
}
Track *tags :: add_track(struct album *album, struct artist *artist,
struct track *tags :: add_track(struct album *album, struct artist *artist,
struct genre *genre, struct library *library,
const std::string &filepath, const std::string &name,
unsigned int length, unsigned int track)
@ -156,23 +160,23 @@ Track *tags :: add_track(struct album *album, struct artist *artist,
std::string path = filepath.substr(library->primary_key().size() + 1);
if (db_get(&track_db, make_key(library, path).c_str()))
return NULL;
return db_insert(&track_db, new Track(album, artist, genre, library,
return db_insert(&track_db, new struct track(album, artist, genre, library,
path, name, length, track));
}
Track *tags :: get_track(const unsigned int index)
struct track *tags :: get_track(const unsigned int index)
{
return db_at(&track_db, index);
}
void tags :: remove_track(Track *track)
void tags :: remove_track(struct track *track)
{
db_remove(&track_db, track);
}
void tags :: remove_library_tracks(struct library *library)
{
Track *it, *next;
struct track *it, *next;
db_for_each(it, next, &track_db) {
if (it->library() == library)

View File

@ -57,7 +57,7 @@ static void set_markup(Gtk::Label *label, const std::string &size,
class GSTDriver : public AudioDriver
{
public:
void load(Track *track)
void load(struct track *track)
{
gchar *uri = gst_filename_to_uri(track->path().c_str(), NULL);
gchar *len = string_sec2str(track->length());
@ -136,7 +136,7 @@ static GSTDriver *gst_driver;
static void parse_gst_error(GstMessage *error)
{
GError *err;
Track *track = audio :: current_track();
struct track *track = audio :: current_track();
gst_message_parse_error(error, &err, NULL);

View File

@ -124,7 +124,7 @@ public:
static void on_ban()
{
Track *track = audio :: current_track();
struct track *track = audio :: current_track();
if (o_ban->get_active()) {
if (!playlist :: has(track, "Banned")) {
playlist :: add(track, "Banned");
@ -136,7 +136,7 @@ static void on_ban()
static void on_favorite()
{
Track *track = audio :: current_track();
struct track *track = audio :: current_track();
if (o_fav->get_active())
playlist :: add(track, "Favorites");
else
@ -145,7 +145,7 @@ static void on_favorite()
void plist :: track_loaded(Track *track)
void plist :: track_loaded(struct track *track)
{
o_ban->set_active(playlist :: has(track, "Banned"));
o_fav->set_active(playlist :: has(track, "Favorites"));

View File

@ -97,7 +97,7 @@ static void set_val(const T &t, Glib::ValueBase &value)
void QueueModel::get_value_vfunc(const Gtk::TreeIter &iter, int column,
Glib::ValueBase &value) const
{
Track *track;
struct track *track;
gchar *str;
if (!check_iter_validity(iter) ||
@ -108,7 +108,7 @@ void QueueModel::get_value_vfunc(const Gtk::TreeIter &iter, int column,
switch (column) {
case 0:
return set_val(track->track(), value);
return set_val(track->track_nr(), value);
case 1:
return set_val(track->name(), value);
case 2:

View File

@ -27,7 +27,7 @@ public:
*
* @param track The Track to load.
*/
virtual void load(Track *track) = 0;
virtual void load(struct track *track) = 0;
/**
* Called to begin playback on the currently loaded track.
@ -115,12 +115,12 @@ namespace audio
*
* @param track The track that should be loaded.
*/
void load_track(Track *track);
void load_track(struct track *track);
/**
* @return A pointer to the currently playing track object.
*/
Track *current_track();
struct track *current_track();
/**
* Configure the automatic pausing feature.

View File

@ -21,8 +21,8 @@ public:
void set_flag(queue_flags);
void unset_flag(queue_flags);
unsigned int add(Track *);
void del(Track *);
unsigned int add(struct track *);
void del(struct track *);
void del(unsigned int);
void sort(sort_t, bool);
@ -97,12 +97,12 @@ namespace deck
* @return A track from the first enabled queue. If no queues are
* enabled, return a track from the Library.
*/
Track *next();
struct track *next();
/**
* @return A track from the recent tracks queue.
*/
Track *prev();
struct track *prev();
/**
* @return The deck of queues.

View File

@ -37,7 +37,7 @@ namespace playlist
* @param name The name of the playlist to check.
* @return True if the track is in the playlist, false otherwise.
*/
bool has(Track *, const std::string &);
bool has(struct track *, const std::string &);
/**
* Add a track to a playlist.
@ -48,7 +48,7 @@ namespace playlist
* @param track The track to add.
* @param name The name of the playlist to add to.
*/
void add(Track *, const std::string &);
void add(struct track *, const std::string &);
/**
* Remove a track from a playlist.
@ -59,7 +59,7 @@ namespace playlist
* @param track The track to remove.
* @param name The name of the playlist to remove from.
*/
void del(Track *, const std::string &);
void del(struct track *, const std::string &);
/**
* Use to change the currently displayed playlist.

View File

@ -91,15 +91,15 @@ struct sort_info {
*/
class Queue {
protected:
std :: vector <Track *> _tracks; /**< List of tracks in this queue. */
std :: vector <struct track *> _tracks; /**< List of tracks in this queue. */
std :: vector <struct sort_info> _sort_order; /**< Current sort settings. */
unsigned int _cur; /**< The index of the last track played. */
unsigned int _flags; /**< Mask of queue_flags. */
unsigned int _length; /**< Total runtime of the queue. */
QNotifier *_notify; /**< Notification object associated with this queue. */
unsigned int find_sorted_id(Track *);
unsigned int _add_at(Track *, unsigned int);
unsigned int find_sorted_id(struct track *);
unsigned int _add_at(struct track *, unsigned int);
public:
/**
@ -165,7 +165,7 @@ public:
* @param track Track to add to the queue.
* @return The index of the track in the queue.
*/
virtual unsigned int add(Track *);
virtual unsigned int add(struct track *);
/**
* Remove a track based on its queue index.
@ -179,14 +179,14 @@ public:
*
* @param track Track to remove from the queue.
*/
virtual void del(Track *);
virtual void del(struct track *);
/**
* Signal to the queue that a track has been updated.
*
* @param track The track that has been modified.
*/
void updated(Track *);
void updated(struct track *);
/**
* Pick the next track from the queue. If Q_RANDOM is set then a
@ -196,7 +196,7 @@ public:
*
* @return The next Track on the queue, or NULL if the Queue is empty.
*/
Track *next();
struct track *next();
/**
@ -232,7 +232,7 @@ public:
* @param index The index to look up.
* @return The track found at the requested index.
*/
Track *operator[](unsigned int);
struct track *operator[](unsigned int);
/**
* Tell the queue that a track has been selected for playback without

View File

@ -18,21 +18,19 @@ extern "C" {
* The Track tag is used to store information about tracks that
* have been added to the tag database.
*/
class Track : public GenericTag {
private:
struct album *_album; /**< Pointer to the Album containing this track. */
struct artist *_artist; /**< Pointer to the Artist performing this track. */
struct genre *_genre; /**< Pointer to the Genre describing this track. */
struct library *_library; /**< Pointer to the Library containing this track. */
struct track : public GenericTag {
struct album *tr_album; /* This track's associated album. */
struct artist *tr_artist; /* This track's associated artist. */
struct genre *tr_genre; /* This track's associated genre. */
struct library *tr_library; /* This track's associated library. */
unsigned int _count; /**< Number of times this track has been played.*/
unsigned int _length; /**< Length of this track (in seconds). */
unsigned int _track; /**< Track number of this track. */
unsigned int tr_count; /* This track's play count. */
unsigned int tr_length; /* This track's length, in seconds. */
unsigned int tr_track; /* This track's track number. */
struct date _date; /**< Date that we last played this track. */
std::string _path; /**< Path of this track, relative to the Library. */
struct date tr_date; /* This track's last-played date. */
std::string tr_path; /* This track's path, relative to the library. */
public:
/**
* Track constructor
*
@ -45,7 +43,7 @@ public:
* @param length The length of this track (in seconds).
* @param track The track number of this track.
*/
Track(struct album *, struct artist *, struct genre *, struct library *,
track(struct album *, struct artist *, struct genre *, struct library *,
const std::string &, const std::string &, unsigned int,
unsigned int);
@ -54,10 +52,10 @@ public:
*
* @param track The Track tag that should be copied.
*/
Track(const Track &);
track(const struct track &);
Track(); /**< Track constructor. */
~Track(); /**< Track destructor. */
track(); /**< Track constructor. */
~track(); /**< Track destructor. */
struct album *album(); /**< @return Track::_album. */
@ -67,7 +65,7 @@ public:
unsigned int count(); /**< @return Track::_count. */
unsigned int length(); /**< @return Track::_length. */
unsigned int track(); /**< @return Track::_track. */
unsigned int track_nr(); /**< @return Track::_track. */
/**
@ -99,7 +97,7 @@ public:
* @return 0: lhs == rhs.
* @return > 0: lhs > rhs;
*/
int compare_date(const Track *);
int compare_date(const struct track *);
/**
@ -136,7 +134,7 @@ namespace tags
* @return A new Track tag, or NULL if this Track is already in
* the track_db.
*/
Track *add_track(struct album *, struct artist *, struct genre *,
struct track *add_track(struct album *, struct artist *, struct genre *,
struct library *, const std::string &,
const std::string &, unsigned int, unsigned int);
@ -146,14 +144,14 @@ namespace tags
* @param index The index of the Track tag.
* @return A matching Track tag, or NULL.
*/
Track *get_track(const unsigned int);
struct track *get_track(const unsigned int);
/**
* Called to remove a Track tag from the database.
*
* @param track The Track tag to be removed.
*/
void remove_track(Track *);
void remove_track(struct track *);
/**
* Called to remove all tracks associated with a specific Library.

View File

@ -55,7 +55,7 @@ namespace manager
/* playlist.cpp */
namespace plist
{
void track_loaded(Track *track);
void track_loaded(struct track *track);
void init();
}

View File

@ -7,7 +7,7 @@
#include <core/tags/tags.h>
#include "test.h"
Track *TRACK_NULL = NULL;
struct track *TRACK_NULL = NULL;
class TestDriver : public AudioDriver
@ -21,7 +21,7 @@ public:
TestDriver() : playing(false), cur_pos(0), cur_duration(0) {}
~TestDriver() {};
void load(Track *track)
void load(struct track *track)
{
cur_file = track->path();
playing = false;
@ -75,7 +75,7 @@ void test_pre_init()
void test_init()
{
Track *track;
struct track *track;
test_cp_data_dir();
audio :: init();
@ -119,7 +119,7 @@ void test_playback_controls()
void test_track_controls()
{
Track *track = NULL;
struct track *track = NULL;
TestDriver *driver = (TestDriver *)audio :: get_driver();
collection :: get_queue()->unset_flag(Q_RANDOM);

View File

@ -8,7 +8,7 @@
#include "test.h"
static Queue *Q_NULL = NULL;
static Track *TRACK_NULL = NULL;
static struct track *TRACK_NULL = NULL;
static void test_init()
{

View File

@ -106,7 +106,7 @@ static void test_delete()
static void test_has()
{
Track *track;
struct track *track;
for (unsigned int i = 0; i < 24; i++) {
track = tags :: get_track(i);

View File

@ -15,7 +15,7 @@ unsigned int count_del = 0;
unsigned int count_updated = 0;
unsigned int last_update = 0;
unsigned int expected = 0;
Track *TRACK_NULL = NULL;
struct track *TRACK_NULL = NULL;
static class TestNotifier : public QNotifier {
@ -47,7 +47,7 @@ void test_default()
test_equal(q.get_flags(), (unsigned)0);
test_equal(q.length(), (unsigned)0);
test_equal(q.get_sorder().size(), (size_t)0);
test_equal(q.next(), (Track *)NULL);
test_equal(q.next(), (struct track *)NULL);
test_equal(q.get_notify(), &test_notifier);
}
@ -60,7 +60,7 @@ void test_constructor()
test_equal(q.get_flags(), flags);
test_equal(q.length(), (unsigned)0);
test_equal(q.get_sorder().size(), (size_t)0);
test_equal(q.next(), (Track *)NULL);
test_equal(q.next(), (struct track *)NULL);
test_equal(q.get_notify(), &test_notifier);
}
@ -88,7 +88,7 @@ void test_flags()
void test_add_remove()
{
TestQueue q(0);
Track *track;
struct track *track;
test_cp_data_dir();
filter_init();
@ -161,7 +161,7 @@ static void test_fill_q(TestQueue *q)
void test_updated()
{
Track *track;
struct track *track;
TestQueue q(0);
test_fill_q(&q);
@ -185,7 +185,7 @@ unsigned int expected_rand[] = { 1, 4, 8, 13, 19, 3, 14, 16, 20, 2, 11, 17,
void test_next()
{
Track *track;
struct track *track;
TestQueue q(0);
test_fill_q(&q);

View File

@ -22,7 +22,7 @@ const std::string MUSIC_DIR = "/home/Zelda/Music";
static void test_track_tag_default()
{
Track track;
struct track track;
test_equal(track.album(), (struct album *)NULL);
test_equal(track.artist(), (struct artist *)NULL);
@ -35,12 +35,12 @@ static void test_track_tag_default()
test_equal(track.date(), (std::string)"Never");
test_equal(track.path(), (std::string)"");
test_equal(track.track(), (unsigned)0);
test_equal(track.track_nr(), (unsigned)0);
test_equal(track.length(), (unsigned)0);
test_equal(track.count(), (unsigned)0);
}
static void verify_track_tag(Track *track, unsigned int size)
static void verify_track_tag(struct track *track, unsigned int size)
{
test_equal(track->album(), album);
test_equal(track->artist(), artist);
@ -53,7 +53,7 @@ static void verify_track_tag(Track *track, unsigned int size)
test_equal(track->path(), (std::string)MUSIC_DIR + "/Hyrule Symphony/13 - Legend of Zelda Medley.mp3");
test_equal(track->primary_key(), (std::string)"0/Hyrule Symphony/13 - Legend of Zelda Medley.mp3");
test_equal(track->track(), (unsigned)13);
test_equal(track->track_nr(), (unsigned)13);
test_equal(track->length(), (unsigned)288);
test_equal(track->count(), (unsigned)0);
test_equal(library->li_size, size);
@ -70,11 +70,11 @@ static void test_track_tag_constructor()
genre = genre_find("Video Game Music");
library = library_find(MUSIC_DIR);
Track a(album, artist, genre, library,
struct track a(album, artist, genre, library,
"Hyrule Symphony/13 - Legend of Zelda Medley.mp3",
"Legend of Zelda Medley", 288, 13);
struct set search = SET_INIT();
Track b;
struct track b;
verify_track_tag(&a, 1);
@ -110,7 +110,7 @@ static void test_track_tag_destructor()
static void test_track_tag_load_db(unsigned int size)
{
database<Track> track_db;
database<struct track> track_db;
db_init(&track_db, "track.db", false);
db_load(&track_db);
test_equal(track_db.db_size, size);
@ -120,18 +120,18 @@ static void test_track_tag_load_db(unsigned int size)
static void test_track_tag_lookup()
{
unsigned int index;
Track *a, *b;
struct track *a, *b;
a = tags :: add_track(album, artist, genre, library,
MUSIC_DIR + "/Hyrule Symphony/13 - Legend of Zelda Medley.mp3",
"Legend of Zelda Medley", 288, 13);
test_not_equal(a, (Track *)NULL);
test_not_equal(a, (struct track *)NULL);
verify_track_tag(a, 1);
b = tags :: add_track(album, artist, genre, library,
MUSIC_DIR + "/Hyrule Symphony/13 - Legend of Zelda Medley.mp3",
"Legend of Zelda Medley", 288, 13);
test_equal(b, (Track *)NULL);
test_equal(b, (struct track *)NULL);
b = tags :: add_track(album, artist, genre, library,
MUSIC_DIR + "/Hyrule Symphony/12 - Ocarina Medley.mp3",
@ -143,7 +143,7 @@ static void test_track_tag_lookup()
test_equal(tags :: get_track(a->index()), a);
test_equal(tags :: get_track(a->index() + 1), b);
test_equal(tags :: get_track(a->index() + 2), (Track *)NULL);
test_equal(tags :: get_track(a->index() + 2), (struct track *)NULL);
test_track_tag_load_db(0);
tags :: commit_track_db();
@ -152,7 +152,7 @@ static void test_track_tag_lookup()
index = a->index();
tags :: remove_track(a);
test_equal(tags :: get_track(index), (Track *)NULL);
test_equal(tags :: get_track(index), (struct track *)NULL);
test_track_tag_load_db(2);
tags :: commit_track_db();
test_track_tag_load_db(1);
@ -163,7 +163,7 @@ static void test_track_tag_lookup()
a = tags :: add_track(album, artist, genre, library,
MUSIC_DIR + "/Hyrule Symphony/13 - Legend of Zelda Medley.mp3",
"Legend of Zelda Medley", 288, 13);
test_not_equal(a, (Track *)NULL);
test_not_equal(a, (struct track *)NULL);
verify_track_tag(a, 2);
test_equal(tags :: track_size(), a->index() + 1);
@ -176,7 +176,7 @@ static void test_track_tag_locale()
{
time_t rawtime = time(NULL);
struct tm *now = localtime(&rawtime);
Track *track = tags :: add_track(album, artist, genre, library,
struct track *track = tags :: add_track(album, artist, genre, library,
MUSIC_DIR + "/Hyrule Symphony/6 - Kakariko Village.mp3",
"Kakariko Village", 186, 6);
gchar *date;