src/track.c in mockspotify-0.1.6 vs src/track.c in mockspotify-0.1.7
- old
+ new
@@ -19,15 +19,33 @@
t->duration = duration;
t->popularity = popularity;
t->album = album;
t->starred = 0;
+ t->artists = ALLOC_N(sp_artist*, num_artists);
+ MEMCPY_N(t->artists, artists, sp_artist*, num_artists);
+ t->num_artists = num_artists;
+
return t;
}
/*** Spotify API ***/
+sp_track *
+sp_localtrack_create(const char *artist, const char *title, const char *album, int length)
+{
+ sp_artist *partist = mocksp_artist_create(artist, 1);
+ sp_album *palbum = NULL;
+
+ if (strlen(album) > 0)
+ {
+ palbum = mocksp_album_create(album, partist, 2011, NULL, SP_ALBUMTYPE_UNKNOWN, 1, 1);
+ }
+
+ return mocksp_track_create(title, 1, &partist, palbum, length, 0, 0, 0, 0, 1);
+}
+
bool
sp_track_is_available(sp_session *session, sp_track *t)
{
return 1;
}
@@ -45,21 +63,19 @@
}
int
sp_track_num_artists(sp_track *t)
{
- return 3;
+ return t->num_artists;
}
sp_artist *
sp_track_artist(sp_track *t, int index)
{
- static sp_artist *a[3];
+ if (index >= sp_track_num_artists(t))
+ return NULL;
- a[0] = mocksp_artist_create("a1", 1);
- a[1] = mocksp_artist_create("a2", 1);
- a[2] = mocksp_artist_create("a3", 1);
- return a[index];
+ return t->artists[index];
}
int
sp_track_disc(sp_track *t)
{