Mercurial > audlegacy-plugins
diff src/streambrowser/streambrowser.c @ 2848:fbb32674bfd2
click on a stream updates; more comments; more proper stream icons
author | Calin Crisan ccrisan@gmail.com |
---|---|
date | Mon, 28 Jul 2008 23:43:31 +0300 |
parents | 779125caa3ac |
children | 587b3657990d |
line wrap: on
line diff
--- a/src/streambrowser/streambrowser.c Fri Jul 25 12:03:16 2008 +0300 +++ b/src/streambrowser/streambrowser.c Mon Jul 28 23:43:31 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,51 @@ /* 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) { + printf("DAAAA!\n"); + shoutcast_streaminfo_fetch(data->category, data->streaminfo); + } + /* xiph */ + else if (strncmp(data->streamdir->name, XIPH_NAME, strlen(XIPH_NAME)) == 0) { + //xiph_category_fetch(data->category); + } + } 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) { @@ -476,6 +486,6 @@ debug("on_plugin_services_menu_item_click()\n"); streambrowser_win_show(); - streamdir_update(NULL, NULL, NULL); + streamdir_update(NULL, NULL, NULL, FALSE); }