song: renamed attribute "url" to "uri"
This commit is contained in:
parent
28442cce9f
commit
f7ce4f6239
@ -1559,7 +1559,7 @@ sticker_song_find_print_cb(struct song *song, const char *value,
|
|||||||
{
|
{
|
||||||
struct sticker_song_find_data *data = user_data;
|
struct sticker_song_find_data *data = user_data;
|
||||||
|
|
||||||
song_print_url(data->client, song);
|
song_print_uri(data->client, song);
|
||||||
sticker_print_value(data->client, data->name, value);
|
sticker_print_value(data->client, data->name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ static int
|
|||||||
printSongInDirectory(struct song *song, G_GNUC_UNUSED void *data)
|
printSongInDirectory(struct song *song, G_GNUC_UNUSED void *data)
|
||||||
{
|
{
|
||||||
struct client *client = data;
|
struct client *client = data;
|
||||||
song_print_url(client, song);
|
song_print_uri(client, song);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ visitTag(struct client *client, struct strset *set,
|
|||||||
struct tag *tag = song->tag;
|
struct tag *tag = song->tag;
|
||||||
|
|
||||||
if (tagType == LOCATE_TAG_FILE_TYPE) {
|
if (tagType == LOCATE_TAG_FILE_TYPE) {
|
||||||
song_print_url(client, song);
|
song_print_uri(client, song);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,9 +159,9 @@ map_song_fs(const struct song *song)
|
|||||||
assert(song_is_file(song));
|
assert(song_is_file(song));
|
||||||
|
|
||||||
if (song_in_database(song))
|
if (song_in_database(song))
|
||||||
return map_directory_child_fs(song->parent, song->url);
|
return map_directory_child_fs(song->parent, song->uri);
|
||||||
else
|
else
|
||||||
return utf8_to_fs_charset(song->url);
|
return utf8_to_fs_charset(song->uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
@ -136,7 +136,7 @@ player_wait_for_decoder(struct player *player)
|
|||||||
dc_command_wait(&pc.notify);
|
dc_command_wait(&pc.notify);
|
||||||
|
|
||||||
if (decoder_lock_has_failed()) {
|
if (decoder_lock_has_failed()) {
|
||||||
assert(dc.next_song == NULL || dc.next_song->url != NULL);
|
assert(dc.next_song == NULL || dc.next_song->uri != NULL);
|
||||||
pc.errored_song = dc.next_song;
|
pc.errored_song = dc.next_song;
|
||||||
pc.error = PLAYER_ERROR_FILE;
|
pc.error = PLAYER_ERROR_FILE;
|
||||||
pc.next_song = NULL;
|
pc.next_song = NULL;
|
||||||
@ -177,7 +177,7 @@ player_check_decoder_startup(struct player *player)
|
|||||||
|
|
||||||
if (decoder_has_failed()) {
|
if (decoder_has_failed()) {
|
||||||
/* the decoder failed */
|
/* the decoder failed */
|
||||||
assert(dc.next_song == NULL || dc.next_song->url != NULL);
|
assert(dc.next_song == NULL || dc.next_song->uri != NULL);
|
||||||
|
|
||||||
decoder_unlock();
|
decoder_unlock();
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ player_check_decoder_startup(struct player *player)
|
|||||||
"while playing \"%s\"", uri);
|
"while playing \"%s\"", uri);
|
||||||
g_free(uri);
|
g_free(uri);
|
||||||
|
|
||||||
assert(dc.next_song == NULL || dc.next_song->url != NULL);
|
assert(dc.next_song == NULL || dc.next_song->uri != NULL);
|
||||||
pc.errored_song = dc.next_song;
|
pc.errored_song = dc.next_song;
|
||||||
pc.error = PLAYER_ERROR_AUDIO;
|
pc.error = PLAYER_ERROR_AUDIO;
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ static void player_process_command(struct player *player)
|
|||||||
} else {
|
} else {
|
||||||
/* the audio device has failed - rollback to
|
/* the audio device has failed - rollback to
|
||||||
pause mode */
|
pause mode */
|
||||||
assert(dc.next_song == NULL || dc.next_song->url != NULL);
|
assert(dc.next_song == NULL || dc.next_song->uri != NULL);
|
||||||
pc.errored_song = dc.next_song;
|
pc.errored_song = dc.next_song;
|
||||||
pc.error = PLAYER_ERROR_AUDIO;
|
pc.error = PLAYER_ERROR_AUDIO;
|
||||||
|
|
||||||
|
24
src/song.c
24
src/song.c
@ -27,18 +27,18 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
static struct song *
|
static struct song *
|
||||||
song_alloc(const char *url, struct directory *parent)
|
song_alloc(const char *uri, struct directory *parent)
|
||||||
{
|
{
|
||||||
size_t urllen;
|
size_t uri_length;
|
||||||
struct song *song;
|
struct song *song;
|
||||||
|
|
||||||
assert(url);
|
assert(uri);
|
||||||
urllen = strlen(url);
|
uri_length = strlen(uri);
|
||||||
assert(urllen);
|
assert(uri_length);
|
||||||
song = g_malloc(sizeof(*song) - sizeof(song->url) + urllen + 1);
|
song = g_malloc(sizeof(*song) - sizeof(song->uri) + uri_length + 1);
|
||||||
|
|
||||||
song->tag = NULL;
|
song->tag = NULL;
|
||||||
memcpy(song->url, url, urllen + 1);
|
memcpy(song->uri, uri, uri_length + 1);
|
||||||
song->parent = parent;
|
song->parent = parent;
|
||||||
song->mtime = 0;
|
song->mtime = 0;
|
||||||
|
|
||||||
@ -46,9 +46,9 @@ song_alloc(const char *url, struct directory *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct song *
|
struct song *
|
||||||
song_remote_new(const char *url)
|
song_remote_new(const char *uri)
|
||||||
{
|
{
|
||||||
return song_alloc(url, NULL);
|
return song_alloc(uri, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct song *
|
struct song *
|
||||||
@ -71,11 +71,11 @@ char *
|
|||||||
song_get_uri(const struct song *song)
|
song_get_uri(const struct song *song)
|
||||||
{
|
{
|
||||||
assert(song != NULL);
|
assert(song != NULL);
|
||||||
assert(*song->url);
|
assert(*song->uri);
|
||||||
|
|
||||||
if (!song_in_database(song) || directory_is_root(song->parent))
|
if (!song_in_database(song) || directory_is_root(song->parent))
|
||||||
return g_strdup(song->url);
|
return g_strdup(song->uri);
|
||||||
else
|
else
|
||||||
return g_strconcat(directory_get_path(song->parent),
|
return g_strconcat(directory_get_path(song->parent),
|
||||||
"/", song->url, NULL);
|
"/", song->uri, NULL);
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,12 @@ struct song {
|
|||||||
struct tag *tag;
|
struct tag *tag;
|
||||||
struct directory *parent;
|
struct directory *parent;
|
||||||
time_t mtime;
|
time_t mtime;
|
||||||
char url[sizeof(int)];
|
char uri[sizeof(int)];
|
||||||
};
|
};
|
||||||
|
|
||||||
/** allocate a new song with a remote URL */
|
/** allocate a new song with a remote URL */
|
||||||
struct song *
|
struct song *
|
||||||
song_remote_new(const char *url);
|
song_remote_new(const char *uri);
|
||||||
|
|
||||||
/** allocate a new song with a local file name */
|
/** allocate a new song with a local file name */
|
||||||
struct song *
|
struct song *
|
||||||
@ -81,7 +81,7 @@ song_in_database(const struct song *song)
|
|||||||
static inline bool
|
static inline bool
|
||||||
song_is_file(const struct song *song)
|
song_is_file(const struct song *song)
|
||||||
{
|
{
|
||||||
return song_in_database(song) || song->url[0] == '/';
|
return song_in_database(song) || song->uri[0] == '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,18 +26,18 @@
|
|||||||
#include "uri.h"
|
#include "uri.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
song_print_url(struct client *client, struct song *song)
|
song_print_uri(struct client *client, struct song *song)
|
||||||
{
|
{
|
||||||
if (song_in_database(song) && !directory_is_root(song->parent)) {
|
if (song_in_database(song) && !directory_is_root(song->parent)) {
|
||||||
client_printf(client, "%s%s/%s\n", SONG_FILE,
|
client_printf(client, "%s%s/%s\n", SONG_FILE,
|
||||||
directory_get_path(song->parent), song->url);
|
directory_get_path(song->parent), song->uri);
|
||||||
} else {
|
} else {
|
||||||
char *allocated;
|
char *allocated;
|
||||||
const char *uri;
|
const char *uri;
|
||||||
|
|
||||||
uri = allocated = uri_remove_auth(song->url);
|
uri = allocated = uri_remove_auth(song->uri);
|
||||||
if (uri == NULL)
|
if (uri == NULL)
|
||||||
uri = song->url;
|
uri = song->uri;
|
||||||
|
|
||||||
client_printf(client, "%s%s\n", SONG_FILE, uri);
|
client_printf(client, "%s%s\n", SONG_FILE, uri);
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ song_print_url(struct client *client, struct song *song)
|
|||||||
int
|
int
|
||||||
song_print_info(struct client *client, struct song *song)
|
song_print_info(struct client *client, struct song *song)
|
||||||
{
|
{
|
||||||
song_print_url(client, song);
|
song_print_uri(client, song);
|
||||||
|
|
||||||
if (song->mtime > 0) {
|
if (song->mtime > 0) {
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
|
@ -30,6 +30,6 @@ song_print_info(struct client *client, struct song *song);
|
|||||||
int songvec_print(struct client *client, const struct songvec *sv);
|
int songvec_print(struct client *client, const struct songvec *sv);
|
||||||
|
|
||||||
void
|
void
|
||||||
song_print_url(struct client *client, struct song *song);
|
song_print_uri(struct client *client, struct song *song);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,14 +41,13 @@ song_save_quark(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
song_save_url(FILE *fp, struct song *song)
|
song_save_uri(FILE *fp, struct song *song)
|
||||||
{
|
{
|
||||||
if (song->parent != NULL && song->parent->path != NULL)
|
if (song->parent != NULL && song->parent->path != NULL)
|
||||||
fprintf(fp, SONG_FILE "%s/%s\n",
|
fprintf(fp, SONG_FILE "%s/%s\n",
|
||||||
directory_get_path(song->parent), song->url);
|
directory_get_path(song->parent), song->uri);
|
||||||
else
|
else
|
||||||
fprintf(fp, SONG_FILE "%s\n",
|
fprintf(fp, SONG_FILE "%s\n", song->uri);
|
||||||
song->url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -56,9 +55,9 @@ song_save(struct song *song, void *data)
|
|||||||
{
|
{
|
||||||
FILE *fp = data;
|
FILE *fp = data;
|
||||||
|
|
||||||
fprintf(fp, SONG_KEY "%s\n", song->url);
|
fprintf(fp, SONG_KEY "%s\n", song->uri);
|
||||||
|
|
||||||
song_save_url(fp, song);
|
song_save_uri(fp, song);
|
||||||
|
|
||||||
if (song->tag != NULL)
|
if (song->tag != NULL)
|
||||||
tag_save(fp, song->tag);
|
tag_save(fp, song->tag);
|
||||||
@ -78,7 +77,7 @@ void songvec_save(FILE *fp, struct songvec *sv)
|
|||||||
static void
|
static void
|
||||||
commit_song(struct songvec *sv, struct song *newsong)
|
commit_song(struct songvec *sv, struct song *newsong)
|
||||||
{
|
{
|
||||||
struct song *existing = songvec_find(sv, newsong->url);
|
struct song *existing = songvec_find(sv, newsong->uri);
|
||||||
|
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
songvec_add(sv, newsong);
|
songvec_add(sv, newsong);
|
||||||
|
@ -103,7 +103,7 @@ song_file_update(struct song *song)
|
|||||||
|
|
||||||
/* check if there's a suffix and a plugin */
|
/* check if there's a suffix and a plugin */
|
||||||
|
|
||||||
suffix = uri_get_suffix(song->url);
|
suffix = uri_get_suffix(song->uri);
|
||||||
if (suffix == NULL)
|
if (suffix == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ song_file_update_inarchive(struct song *song)
|
|||||||
|
|
||||||
/* check if there's a suffix and a plugin */
|
/* check if there's a suffix and a plugin */
|
||||||
|
|
||||||
suffix = uri_get_suffix(song->url);
|
suffix = uri_get_suffix(song->uri);
|
||||||
if (suffix == NULL)
|
if (suffix == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ static int songvec_cmp(const void *s1, const void *s2)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* still no difference? compare file name */
|
/* still no difference? compare file name */
|
||||||
return g_utf8_collate(a->url, b->url);
|
return g_utf8_collate(a->uri, b->uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t sv_size(const struct songvec *sv)
|
static size_t sv_size(const struct songvec *sv)
|
||||||
@ -108,14 +108,14 @@ void songvec_sort(struct songvec *sv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct song *
|
struct song *
|
||||||
songvec_find(const struct songvec *sv, const char *url)
|
songvec_find(const struct songvec *sv, const char *uri)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct song *ret = NULL;
|
struct song *ret = NULL;
|
||||||
|
|
||||||
g_mutex_lock(nr_lock);
|
g_mutex_lock(nr_lock);
|
||||||
for (i = sv->nr; --i >= 0; ) {
|
for (i = sv->nr; --i >= 0; ) {
|
||||||
if (strcmp(sv->base[i]->url, url))
|
if (strcmp(sv->base[i]->uri, uri))
|
||||||
continue;
|
continue;
|
||||||
ret = sv->base[i];
|
ret = sv->base[i];
|
||||||
break;
|
break;
|
||||||
@ -182,7 +182,7 @@ songvec_for_each(const struct songvec *sv,
|
|||||||
struct song *song = sv->base[i];
|
struct song *song = sv->base[i];
|
||||||
|
|
||||||
assert(song);
|
assert(song);
|
||||||
assert(*song->url);
|
assert(*song->uri);
|
||||||
|
|
||||||
prev_nr = sv->nr;
|
prev_nr = sv->nr;
|
||||||
g_mutex_unlock(nr_lock); /* fn() may block */
|
g_mutex_unlock(nr_lock); /* fn() may block */
|
||||||
|
@ -34,7 +34,7 @@ void songvec_deinit(void);
|
|||||||
void songvec_sort(struct songvec *sv);
|
void songvec_sort(struct songvec *sv);
|
||||||
|
|
||||||
struct song *
|
struct song *
|
||||||
songvec_find(const struct songvec *sv, const char *url);
|
songvec_find(const struct songvec *sv, const char *uri);
|
||||||
|
|
||||||
int
|
int
|
||||||
songvec_delete(struct songvec *sv, const struct song *del);
|
songvec_delete(struct songvec *sv, const struct song *del);
|
||||||
|
@ -113,7 +113,7 @@ int main(int argc, char **argv)
|
|||||||
/* dump the playlist */
|
/* dump the playlist */
|
||||||
|
|
||||||
while ((song = playlist_plugin_read(playlist)) != NULL) {
|
while ((song = playlist_plugin_read(playlist)) != NULL) {
|
||||||
g_print("%s\n", song->url);
|
g_print("%s\n", song->uri);
|
||||||
if (song->tag != NULL)
|
if (song->tag != NULL)
|
||||||
tag_save(stdout, song->tag);
|
tag_save(stdout, song->tag);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user