Mercurial > audlegacy-plugins
diff src/streambrowser/streambrowser.c @ 2889:6c53f9fa9029
Backed out changeset 59ff744e1e23
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 12 Aug 2008 20:29:49 +0300 |
parents | 779125caa3ac |
children | c27da2c06805 |
line wrap: on
line diff
--- a/src/streambrowser/streambrowser.c Fri Aug 01 22:55:49 2008 +0300 +++ b/src/streambrowser/streambrowser.c Tue Aug 12 20:29:49 2008 +0300 @@ -34,6 +34,7 @@ streamdir_t *streamdir; category_t *category; streaminfo_t *streaminfo; + gboolean add_to_playlist; } update_thread_data_t; @@ -47,7 +48,7 @@ static void config_load(); static void config_save(); -static void streamdir_update(streamdir_t *streamdir, category_t *category, streaminfo_t *streaminfo); +static void streamdir_update(streamdir_t *streamdir, category_t *category, streaminfo_t *streaminfo, gboolean add_to_playlist); static gpointer update_thread_core(gpointer user_data); static void streaminfo_add_to_playlist(streaminfo_t *streaminfo); static void on_plugin_services_menu_item_click(); @@ -271,12 +272,13 @@ debug("configuration saved\n"); } -static void streamdir_update(streamdir_t *streamdir, category_t *category, streaminfo_t *streaminfo) +static void streamdir_update(streamdir_t *streamdir, category_t *category, streaminfo_t *streaminfo, gboolean add_to_playlist) { - debug("requested streamdir update (streamdir = '%s', category = '%s', streaminfo = '%s')\n", + debug("requested streamdir update (streamdir = '%s', category = '%s', streaminfo = '%s', add_to_playlist = %d)\n", streamdir == NULL ? "" : streamdir->name, category == NULL ? "" : category->name, - streaminfo == NULL ? "" : streaminfo->name); + streaminfo == NULL ? "" : streaminfo->name, + add_to_playlist); if (g_queue_get_length(update_thread_data_queue) >= MAX_UPDATE_THREADS) { debug("another %d streamdir updates are pending, this request will be dropped\n", g_queue_get_length(update_thread_data_queue)); @@ -295,7 +297,8 @@ update_thread_data = g_queue_peek_nth(update_thread_data_queue, i); if (update_thread_data->streamdir == streamdir && update_thread_data->category == category && - update_thread_data->streaminfo == streaminfo) { + update_thread_data->streaminfo == streaminfo && + update_thread_data->add_to_playlist == add_to_playlist) { exists = TRUE; break; } @@ -310,6 +313,7 @@ update_thread_data->streamdir = streamdir; update_thread_data->category = category; update_thread_data->streaminfo = streaminfo; + update_thread_data->add_to_playlist = add_to_playlist; g_queue_push_tail(update_thread_data_queue, update_thread_data); } @@ -326,6 +330,7 @@ data->streamdir = streamdir; data->category = category; data->streaminfo = streaminfo; + data->add_to_playlist = add_to_playlist; g_queue_push_tail(update_thread_data_queue, data); @@ -350,46 +355,50 @@ /* repetitively process the queue elements, until queue is empty */ while (data != NULL && g_queue_get_length(update_thread_data_queue) > 0) { - /* update a streaminfo - that is - add this streaminfo to playlist */ + /* update a streaminfo */ if (data->streaminfo != NULL) { gdk_threads_enter(); streambrowser_win_set_streaminfo_state(data->streamdir, data->category, data->streaminfo, TRUE); gdk_threads_leave(); - streaminfo_add_to_playlist(data->streaminfo); + if (data->add_to_playlist) + streaminfo_add_to_playlist(data->streaminfo); + else { + /* shoutcast */ + if (strncmp(data->streamdir->name, SHOUTCAST_NAME, strlen(SHOUTCAST_NAME)) == 0) { + shoutcast_streaminfo_fetch(data->category, data->streaminfo); + } + /* xiph */ + else if (strncmp(data->streamdir->name, XIPH_NAME, strlen(XIPH_NAME)) == 0) { + xiph_streaminfo_fetch(data->category, data->streaminfo); + } + } gdk_threads_enter(); + if (!data->add_to_playlist) + streambrowser_win_set_streaminfo(data->streamdir, data->category, data->streaminfo); streambrowser_win_set_streaminfo_state(data->streamdir, data->category, data->streaminfo, FALSE); gdk_threads_leave(); } /* update a category */ else if (data->category != NULL) { + gdk_threads_enter(); + streambrowser_win_set_category_state(data->streamdir, data->category, TRUE); + gdk_threads_leave(); + /* shoutcast */ if (strncmp(data->streamdir->name, SHOUTCAST_NAME, strlen(SHOUTCAST_NAME)) == 0) { - gdk_threads_enter(); - streambrowser_win_set_category_state(data->streamdir, data->category, TRUE); - gdk_threads_leave(); - shoutcast_category_fetch(data->category); - - gdk_threads_enter(); - streambrowser_win_set_category(data->streamdir, data->category); - streambrowser_win_set_category_state(data->streamdir, data->category, FALSE); - gdk_threads_leave(); } /* xiph */ else if (strncmp(data->streamdir->name, XIPH_NAME, strlen(XIPH_NAME)) == 0) { - gdk_threads_enter(); - streambrowser_win_set_category_state(data->streamdir, data->category, TRUE); - gdk_threads_leave(); - xiph_category_fetch(data->category); + } - gdk_threads_enter(); - streambrowser_win_set_category(data->streamdir, data->category); - streambrowser_win_set_category_state(data->streamdir, data->category, FALSE); - gdk_threads_leave(); - } + gdk_threads_enter(); + streambrowser_win_set_category(data->streamdir, data->category); + streambrowser_win_set_category_state(data->streamdir, data->category, FALSE); + gdk_threads_leave(); } /* update a streamdir */ else if (data->streamdir != NULL) { @@ -466,7 +475,7 @@ } if (strlen(streaminfo->url) > 0) { - aud_playlist_add(aud_playlist_get_active(), streaminfo->url); + aud_playlist_add(aud_playlist_get_active(), streaminfo->url); debug("stream '%s' added\n", streaminfo->url); } } @@ -476,6 +485,6 @@ debug("on_plugin_services_menu_item_click()\n"); streambrowser_win_show(); - streamdir_update(NULL, NULL, NULL); + streamdir_update(NULL, NULL, NULL, FALSE); }