Mercurial > audlegacy
changeset 3642:e9852ec75c5c
Automated merge with ssh://sidhe.atheme.org//hg/audacious
author | Jonathan Schleifer <js@h3c.de> |
---|---|
date | Wed, 26 Sep 2007 03:02:44 +0200 |
parents | 12500701b6dd (current diff) d5309028af21 (diff) |
children | aeaee911a68d |
files | |
diffstat | 6 files changed, 112 insertions(+), 147 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/playlist.c Wed Sep 26 03:02:23 2007 +0200 +++ b/src/audacious/playlist.c Wed Sep 26 03:02:44 2007 +0200 @@ -205,16 +205,15 @@ g_thread_self() != playlist_get_info_thread) return FALSE; - if (entry->decoder == NULL) - { + if (entry->decoder == NULL) { pr = input_check_file(entry->filename, FALSE); if (pr) - entry->decoder = pr->ip; + entry->decoder = pr->ip; } /* renew tuple if file mtime is newer than tuple mtime. */ - if(entry->tuple){ - if(tuple_get_int(entry->tuple, FIELD_MTIME, NULL) == modtime) + if (entry->tuple){ + if (tuple_get_int(entry->tuple, FIELD_MTIME, NULL) == modtime) return TRUE; else { mowgli_object_unref(entry->tuple); @@ -371,18 +370,17 @@ gboolean playlist_set_current_name(Playlist *playlist, const gchar * title) { - gchar *oldtitle; - oldtitle = playlist->title; + gchar *oldtitle = playlist->title; if (!title) { playlist->title = NULL; - if(oldtitle) g_free(oldtitle); + g_free(oldtitle); playlist_manager_update(); return FALSE; } playlist->title = str_to_utf8(title); - if(oldtitle) g_free(oldtitle); + g_free(oldtitle); playlist_manager_update(); return TRUE; } @@ -394,21 +392,21 @@ gchar *old; old = playlist->filename; - if(!filename) { + if (!filename) { playlist->filename = NULL; - if(old) g_free(old); + g_free(old); return FALSE; } playlist->filename = filename_to_utf8(filename); - if(old) g_free(old); + g_free(old); return TRUE; } gchar * playlist_filename_get(Playlist *playlist) { - if(!playlist->filename) return NULL; + if (!playlist->filename) return NULL; return g_filename_from_utf8(playlist->filename, -1, NULL, NULL, NULL); } @@ -435,7 +433,7 @@ { GList *tmp = playlist->queue; - REQUIRE_LOCK( playlist->mutex ); + REQUIRE_LOCK(playlist->mutex); playlist->position = playlist->queue->data; playlist->queue = g_list_remove_link(playlist->queue, playlist->queue); @@ -556,9 +554,8 @@ if (restart_playing) { if (playlist->position) playback_initiate(); - else { + else mainwin_clear_song_info(); - } } playlist_manager_update(); @@ -594,9 +591,8 @@ if (restart_playing) { if (playlist->position) playback_initiate(); - else { + else mainwin_clear_song_info(); - } } playlist_manager_update(); @@ -634,9 +630,8 @@ if (restart_playing) { if (playlist->position) playback_initiate(); - else { + else mainwin_clear_song_info(); - } } playlistwin_update_list(playlist); @@ -673,33 +668,34 @@ InputPlugin * dec) { PlaylistEntry *entry; - gint subtunes_num = 0, i = 0; + Tuple *main_tuple = NULL; + gint nsubtunes = 0, i = 0; + gboolean add_flag = TRUE; g_return_if_fail(playlist != NULL); g_return_if_fail(filename != NULL); - if (tuple != NULL) - { - subtunes_num = tuple_get_int(tuple, FIELD_SUBSONG_NUM, NULL); - if (subtunes_num > 0) - { + if (tuple != NULL) { + nsubtunes = tuple->nsubtunes; + if (nsubtunes > 0) { + main_tuple = tuple; i = 1; - tuple_free(tuple); /* will be replaced by subtune tuples */ } } - for (; i <= subtunes_num; i++) - { + for (; add_flag && i <= nsubtunes; i++) { gchar *filename_entry; - if (subtunes_num > 0) - { - filename_entry = g_strdup_printf("%s?%d", filename, i); - /* we're dealing with subtune, let's ask again tuple information - to plugin, by passing the ?subsong suffix; this way we may get - specific subtune information in the tuple, if available */ + + if (nsubtunes > 0) { + filename_entry = g_strdup_printf("%s?%d", filename, + main_tuple->subtunes ? main_tuple->subtunes[i] : i); + + /* We're dealing with subtune, let's ask again tuple information + * to plugin, by passing the ?subtune suffix; this way we get + * specific subtune information in the tuple, if available. + */ tuple = dec->get_song_tuple(filename_entry); - } - else + } else filename_entry = g_strdup(filename); @@ -708,7 +704,7 @@ tuple ? tuple_get_int(tuple, FIELD_LENGTH, NULL) : -1, dec); g_free(filename_entry); - if(!playlist->tail) + if (!playlist->tail) playlist->tail = g_list_last(playlist->entries); PLAYLIST_LOCK(playlist); @@ -723,14 +719,14 @@ if(!playlist->entries) { // this is the first element playlist->entries = element; playlist->tail = element; + } else { // the rests + if (playlist->tail != NULL) { + playlist->tail->next = element; + playlist->tail = element; + } else + add_flag = FALSE; } - else { // the rests - g_return_if_fail(playlist->tail != NULL); - playlist->tail->next = element; - playlist->tail = element; - } - } - else { + } else { playlist->entries = g_list_insert(playlist->entries, entry, pos); } @@ -738,14 +734,18 @@ if (tuple != NULL) { const gchar *formatter = tuple_get_string(tuple, FIELD_FORMATTER, NULL); - entry->title = tuple_formatter_make_title_string(tuple, formatter ? - formatter : get_gentitle_format()); + entry->title = tuple_formatter_make_title_string(tuple, + formatter ? formatter : get_gentitle_format()); entry->length = tuple_get_int(tuple, FIELD_LENGTH, NULL); entry->tuple = tuple; } } - - if(tuple != NULL && tuple_get_int(tuple, FIELD_MTIME, NULL) == -1) { // kick the scanner thread only if mtime = -1 (uninitialized). + + if (main_tuple) + tuple_free(main_tuple); + + if (tuple != NULL && tuple_get_int(tuple, FIELD_MTIME, NULL) == -1) { + // kick the scanner thread only if mtime = -1 (uninitialized) g_mutex_lock(mutex_scan); playlist_get_info_scan_active = TRUE; g_mutex_unlock(mutex_scan); @@ -776,21 +776,20 @@ if (playlist->loading_playlist == TRUE || cfg.playlist_detect == TRUE) dec = NULL; else if (!str_has_prefix_nocase(filename, "http://") && - !str_has_prefix_nocase(filename, "https://")) - { + !str_has_prefix_nocase(filename, "https://")) { pr = input_check_file(filename, TRUE); - if (pr) - { + if (pr) { dec = pr->ip; tuple = pr->tuple; } - g_free(pr); } - if (cfg.playlist_detect == TRUE || playlist->loading_playlist == TRUE || (playlist->loading_playlist == FALSE && dec != NULL) || (playlist->loading_playlist == FALSE && !is_playlist_name(filename) && str_has_prefix_nocase(filename, "http"))) - { + if (cfg.playlist_detect == TRUE || playlist->loading_playlist == TRUE || + (playlist->loading_playlist == FALSE && dec != NULL) || + (playlist->loading_playlist == FALSE && !is_playlist_name(filename) && + str_has_prefix_nocase(filename, "http"))) { __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, dec); playlist_generate_shuffle_list(playlist); playlistwin_update_list(playlist); @@ -812,7 +811,7 @@ if (!vfs_file_test(filename, G_FILE_TEST_IS_REGULAR)) return FALSE; - if (!(file = vfs_fopen(filename, "rb"))) + if ((file = vfs_fopen(filename, "rb")) == NULL) return FALSE; r = vfs_fread(buf, 1, sizeof(buf), file); @@ -848,8 +847,7 @@ { DeviceInode *devino = g_new0(DeviceInode, 1); - if (devino) - { + if (devino) { devino->dev = device; devino->ino = inode; } @@ -1112,7 +1110,7 @@ playlist->position->length = length; // overwrite tuple::title, mainly for streaming. it may incur side effects. --yaz - if(playlist->position->tuple && tuple_get_int(playlist->position->tuple, FIELD_LENGTH, NULL) == -1){ + if (playlist->position->tuple && tuple_get_int(playlist->position->tuple, FIELD_LENGTH, NULL) == -1){ tuple_disassociate(playlist->position->tuple, FIELD_TITLE, NULL); tuple_associate_string(playlist->position->tuple, FIELD_TITLE, NULL, title); } @@ -1151,7 +1149,7 @@ mainwin_set_song_info(rate, freq, nch); - if ( playlist->position ) + if (playlist->position) hook_call( "playlist set info" , playlist->position ); } @@ -1189,13 +1187,13 @@ { GList *plist_pos_list; gboolean restart_playing = FALSE; + if (!playlist_get_length(playlist)) return; PLAYLIST_LOCK(playlist); - if ((playlist_position_before_jump != NULL) && playlist->queue == NULL) - { + if ((playlist_position_before_jump != NULL) && playlist->queue == NULL) { playlist->position = playlist_position_before_jump; playlist_position_before_jump = NULL; } @@ -1230,7 +1228,9 @@ else playlist->position = playlist->entries->data; } + PLAYLIST_UNLOCK(playlist); + playlist_check_pos_current(playlist); if (restart_playing) @@ -1251,8 +1251,7 @@ PLAYLIST_LOCK(playlist); - if ((playlist_position_before_jump != NULL) && playlist->queue == NULL) - { + if ((playlist_position_before_jump != NULL) && playlist->queue == NULL) { playlist->position = playlist_position_before_jump; playlist_position_before_jump = NULL; } @@ -1310,8 +1309,7 @@ PLAYLIST_LOCK(playlist); - if ((cfg.shuffle) && (playlist_position_before_jump == NULL)) - { + if ((cfg.shuffle) && (playlist_position_before_jump == NULL)) { /* Shuffling and this is our first manual jump. */ playlist_position_before_jump = playlist->position; } @@ -1586,13 +1584,11 @@ title = str_to_utf8(playlist->position->title); } else { - gchar *realfn = NULL; - gchar *basename = NULL; - realfn = g_filename_from_uri(playlist->position->filename, NULL, NULL); - basename = g_path_get_basename(realfn ? realfn : playlist->position->filename); + gchar *realfn = g_filename_from_uri(playlist->position->filename, NULL, NULL); + gchar *basename = g_path_get_basename(realfn ? realfn : playlist->position->filename); title = filename_to_utf8(basename); - g_free(realfn); realfn = NULL; - g_free(basename); basename = NULL; + g_free(realfn); + g_free(basename); } /* @@ -1702,7 +1698,7 @@ filename = g_strchug(g_strdup(filename_p)); - if(cfg.convert_slash) + if (cfg.convert_slash) while ((tmp = strchr(filename, '\\')) != NULL) *tmp = '/'; @@ -1770,7 +1766,7 @@ filename = g_strchug(g_strdup(filename_p)); - if(cfg.convert_slash) + if (cfg.convert_slash) while ((tmp = strchr(filename, '\\')) != NULL) *tmp = '/'; @@ -2005,9 +2001,8 @@ if (!playlist) return -1; - if (!(node = g_list_nth(playlist->entries, pos))) { + if (!(node = g_list_nth(playlist->entries, pos))) return -1; - } entry = node->data; @@ -2021,10 +2016,8 @@ if (playlist_entry_get_info(entry)) song_time = entry->length; - } - else { + } else song_time = entry->length; - } return song_time; } @@ -2056,6 +2049,19 @@ tracknumber_a - tracknumber_b : 0); } +static void +playlist_get_entry_title(PlaylistEntry * e, const gchar ** title) +{ + if (e->title) + *title = e->title; + else { + if (strrchr(e->filename, '/')) + *title = strrchr(e->filename, '/') + 1; + else + *title = e->filename; + } +} + static gint playlist_compare_playlist(PlaylistEntry * a, PlaylistEntry * b) @@ -2064,24 +2070,9 @@ g_return_val_if_fail(a != NULL, 0); g_return_val_if_fail(b != NULL, 0); - - if (a->title != NULL) - a_title = a->title; - else { - if (strrchr(a->filename, '/')) - a_title = strrchr(a->filename, '/') + 1; - else - a_title = a->filename; - } - - if (b->title != NULL) - b_title = b->title; - else { - if (strrchr(a->filename, '/')) - b_title = strrchr(b->filename, '/') + 1; - else - b_title = b->filename; - } + + playlist_get_entry_title(a, &a_title); + playlist_get_entry_title(b, &b_title); return strcasecmp(a_title, b_title); } @@ -2095,9 +2086,9 @@ g_return_val_if_fail(a != NULL, 0); g_return_val_if_fail(b != NULL, 0); - if(!a->tuple) + if (a->tuple == NULL) playlist_entry_get_info(a); - if(!b->tuple) + if (b->tuple == NULL) playlist_entry_get_info(b); if (a->tuple != NULL) @@ -2108,23 +2099,8 @@ if (a_title != NULL && b_title != NULL) return strcasecmp(a_title, b_title); - if (a->title != NULL) - a_title = a->title; - else { - if (strrchr(a->filename, '/')) - a_title = strrchr(a->filename, '/') + 1; - else - a_title = a->filename; - } - - if (b->title != NULL) - b_title = b->title; - else { - if (strrchr(a->filename, '/')) - b_title = strrchr(b->filename, '/') + 1; - else - b_title = b->filename; - } + playlist_get_entry_title(a, &a_title); + playlist_get_entry_title(b, &b_title); return strcasecmp(a_title, b_title); } @@ -2827,23 +2803,8 @@ g_return_val_if_fail(a != NULL, 0); g_return_val_if_fail(b != NULL, 0); - if (a->title) - a_title = a->title; - else { - if (strrchr(a->filename, '/')) - a_title = strrchr(a->filename, '/') + 1; - else - a_title = a->filename; - } - - if (b->title) - b_title = b->title; - else { - if (strrchr(a->filename, '/')) - b_title = strrchr(b->filename, '/') + 1; - else - b_title = b->filename; - } + playlist_get_entry_title(a, &a_title); + playlist_get_entry_title(b, &b_title); return strcmp(a_title, b_title); }
--- a/src/audacious/playlist_container.c Wed Sep 26 03:02:23 2007 +0200 +++ b/src/audacious/playlist_container.c Wed Sep 26 03:02:44 2007 +0200 @@ -40,7 +40,7 @@ registered_plcs = g_list_remove(registered_plcs, plc); } -PlaylistContainer *playlist_container_find(char *ext) +PlaylistContainer *playlist_container_find(gchar *ext) { GList *node; PlaylistContainer *plc; @@ -58,9 +58,9 @@ return NULL; } -void playlist_container_read(char *filename, gint pos) +void playlist_container_read(gchar *filename, gint pos) { - char *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ + gchar *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ PlaylistContainer *plc = playlist_container_find(ext); if (plc->plc_read == NULL) @@ -69,9 +69,9 @@ plc->plc_read(filename, pos); } -void playlist_container_write(char *filename, gint pos) +void playlist_container_write(gchar *filename, gint pos) { - char *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ + gchar *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ PlaylistContainer *plc = playlist_container_find(ext); if (plc->plc_write == NULL) @@ -80,9 +80,9 @@ plc->plc_write(filename, pos); } -gboolean is_playlist_name(char *filename) +gboolean is_playlist_name(gchar *filename) { - char *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ + gchar *ext = strrchr(filename, '.') + 1; /* optimization: skip past the dot -nenolod */ PlaylistContainer *plc = playlist_container_find(ext); if (plc != NULL)
--- a/src/audacious/playlist_container.h Wed Sep 26 03:02:23 2007 +0200 +++ b/src/audacious/playlist_container.h Wed Sep 26 03:02:44 2007 +0200 @@ -25,8 +25,8 @@ G_BEGIN_DECLS struct _PlaylistContainer { - char *name; /* human-readable name */ - char *ext; /* extension */ + gchar *name; /* human-readable name */ + gchar *ext; /* extension */ void (*plc_read)(const gchar *filename, gint pos); /* plc_load */ void (*plc_write)(const gchar *filename, gint pos); /* plc_write */ }; @@ -37,9 +37,9 @@ extern void playlist_container_register(PlaylistContainer *plc); extern void playlist_container_unregister(PlaylistContainer *plc); -extern void playlist_container_read(char *filename, gint pos); -extern void playlist_container_write(char *filename, gint pos); -extern PlaylistContainer *playlist_container_find(char *ext); +extern void playlist_container_read(gchar *filename, gint pos); +extern void playlist_container_write(gchar *filename, gint pos); +extern PlaylistContainer *playlist_container_find(gchar *ext); G_END_DECLS
--- a/src/audacious/tuple.c Wed Sep 26 03:02:23 2007 +0200 +++ b/src/audacious/tuple.c Wed Sep 26 03:02:44 2007 +0200 @@ -112,6 +112,8 @@ mowgli_heap_free(tuple_value_heap, value); } + g_free(tuple->subtunes); + mowgli_heap_free(tuple_heap, tuple); TUPLE_UNLOCK_WRITE(); }
--- a/src/audacious/tuple.h Wed Sep 26 03:02:23 2007 +0200 +++ b/src/audacious/tuple.h Wed Sep 26 03:02:44 2007 +0200 @@ -82,6 +82,8 @@ mowgli_object_t parent; mowgli_dictionary_t *dict; TupleValue *values[FIELD_LAST]; + gint nsubtunes; + gint *subtunes; } Tuple;
--- a/src/audacious/util.c Wed Sep 26 03:02:23 2007 +0200 +++ b/src/audacious/util.c Wed Sep 26 03:02:44 2007 +0200 @@ -308,7 +308,7 @@ return NULL; } #else - tmpdir = g_strdup_printf("%s/audacious.%ld", g_get_tmp_dir(), rand()); + tmpdir = g_strdup_printf("%s/audacious.%ld", g_get_tmp_dir(), (long) rand()); make_directory(tmpdir, mode755); #endif