Mercurial > audlegacy
changeset 356:99928e1275a1 trunk
[svn] This commit reduces the amount of times we probe a source down to ONE
SINGLE TIME, using the cache I created earlier to provide all the
information we need!
author | nenolod |
---|---|
date | Thu, 29 Dec 2005 22:44:13 -0800 |
parents | 1c701dfe5098 |
children | 115d00db8fb3 |
files | audacious/playlist.c audacious/playlist.h libaudcore/playback.c libaudcore/playback.h |
diffstat | 4 files changed, 46 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/audacious/playlist.c Thu Dec 29 22:10:26 2005 -0800 +++ b/audacious/playlist.c Thu Dec 29 22:44:13 2005 -0800 @@ -2392,3 +2392,22 @@ return filename; } + +const PlaylistEntry * +playlist_get_entry_to_play(void) +{ + PLAYLIST_LOCK(); + + if (playlist) { + if (!playlist_position) { + if (cfg.shuffle) + playlist_position = shuffle_list->data; + else + playlist_position = playlist->data; + } + } + + PLAYLIST_UNLOCK(); + + return playlist_position; +}
--- a/audacious/playlist.h Thu Dec 29 22:10:26 2005 -0800 +++ b/audacious/playlist.h Thu Dec 29 22:44:13 2005 -0800 @@ -37,7 +37,6 @@ PLAYLIST_FORMAT_COUNT } PlaylistFormat; - #define PLAYLIST_ENTRY(x) ((PlaylistEntry*)(x)) struct _PlaylistEntry { gchar *filename; @@ -109,7 +108,11 @@ void playlist_delete_index(guint pos); void playlist_delete_filenames(GList * filenames); +const PlaylistEntry *playlist_get_entry_to_play(); + +/* XXX this is for reverse compatibility --nenolod */ const gchar *playlist_get_filename_to_play(); + gchar *playlist_get_filename(guint pos); gchar *playlist_get_songtitle(guint pos); gint playlist_get_songtime(guint pos); @@ -147,4 +150,6 @@ G_LOCK_EXTERN(playlist); +extern PlaylistEntry *playlist_position; + #endif
--- a/libaudcore/playback.c Thu Dec 29 22:10:26 2005 -0800 +++ b/libaudcore/playback.c Thu Dec 29 22:44:13 2005 -0800 @@ -83,7 +83,7 @@ void bmp_playback_initiate(void) { - const gchar *filename = NULL; + const PlaylistEntry *entry; if (playlist_get_length() == 0) return; @@ -96,16 +96,16 @@ svis_clear_data(mainwin_svis); mainwin_disable_seekbar(); - filename = playlist_get_filename_to_play(); + entry = playlist_get_entry_to_play(); - if (!filename) + if (!entry) return; - if (!bmp_playback_play_file(filename)) + if (!bmp_playback_play_file(entry)) return; if (bmp_playback_get_time() != -1) { - equalizerwin_load_auto_preset(filename); + equalizerwin_load_auto_preset(entry->filename); input_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, cfg.equalizer_bands); output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, @@ -201,13 +201,9 @@ } gboolean -bmp_playback_play_file(const gchar * filename) +bmp_playback_play_file(const PlaylistEntry *entry) { - GList *node; - InputPlugin *ip; - gchar *filename_proxy; - - g_return_val_if_fail(filename != NULL, FALSE); + g_return_val_if_fail(entry != NULL, FALSE); if (!get_current_output_plugin()) { run_no_output_plugin_dialog(); @@ -218,43 +214,23 @@ if (cfg.random_skin_on_play) bmp_playback_set_random_skin(); - filename_proxy = g_strdup(filename); - - node = get_input_list(); - node = g_list_first(node); - - while (node) { - - ip = node->data; - - if (!ip) - break; + if (!entry->decoder || !input_is_enabled(entry->decoder->filename)) + { + input_file_not_playable(entry->filename); - if (ip && input_is_enabled(ip->filename) && - ip->is_our_file(filename_proxy)) { - - - set_current_input_plugin(ip); - ip->output = get_current_output_plugin(); - ip->play_file(filename_proxy); + set_current_input_plugin(NULL); + mainwin_set_info_text(); - /* FIXME: Why the hell (yes,hell!) doesn't the input - plugin set this itself???? -mderezynski */ - ip_data.playing = TRUE; - - g_free(filename_proxy); - return TRUE; - } - node = g_list_next(node); + return FALSE; } - input_file_not_playable(filename); - set_current_input_plugin(NULL); - mainwin_set_info_text(); + set_current_input_plugin(entry->decoder); + entry->decoder->output = get_current_output_plugin(); + entry->decoder->play_file(entry->filename); - g_free(filename_proxy); + ip_data.playing = TRUE; - return FALSE; + return TRUE; } gboolean
--- a/libaudcore/playback.h Thu Dec 29 22:10:26 2005 -0800 +++ b/libaudcore/playback.h Thu Dec 29 22:44:13 2005 -0800 @@ -21,13 +21,15 @@ #include <glib.h> +#include "audacious/playlist.h" + void bmp_playback_set_random_skin(void); gint bmp_playback_get_time(void); void bmp_playback_initiate(void); void bmp_playback_pause(void); void bmp_playback_stop(void); void bmp_playback_stop_reentrant(void); -gboolean bmp_playback_play_file(const gchar * filename); +gboolean bmp_playback_play_file(const PlaylistEntry *entry); gboolean bmp_playback_get_playing(void); gboolean bmp_playback_get_paused(void); void bmp_playback_seek(gint time);