Mercurial > audlegacy-plugins
comparison src/streambrowser/streambrowser.c @ 2757:4ec0e13208de
added shoutcast icon; fixed some small bugs
| author | Calin Crisan ccrisan@gmail.com |
|---|---|
| date | Tue, 01 Jul 2008 21:13:22 +0300 |
| parents | 6d6a3eb67510 |
| children | c5005707a575 |
comparison
equal
deleted
inserted
replaced
| 2736:4d9540bcd7e2 | 2757:4ec0e13208de |
|---|---|
| 35 static void streaminfo_add_to_playlist(streaminfo_t *streaminfo); | 35 static void streaminfo_add_to_playlist(streaminfo_t *streaminfo); |
| 36 static void on_plugin_services_menu_item_click(); | 36 static void on_plugin_services_menu_item_click(); |
| 37 | 37 |
| 38 static GtkWidget* playlist_menu_item; | 38 static GtkWidget* playlist_menu_item; |
| 39 static GtkWidget* main_menu_item; | 39 static GtkWidget* main_menu_item; |
| 40 static update_thread_data_t update_thread_data_queue[MAX_UPDATE_THREADS]; | 40 static GQueue* update_thread_data_queue; |
| 41 static gint update_thread_count = 0; | 41 static gint update_thread_count = 0; |
| 42 static GMutex* update_thread_mutex; | 42 static GMutex* update_thread_mutex; |
| 43 | 43 |
| 44 | 44 |
| 45 streambrowser_cfg_t streambrowser_cfg; | 45 streambrowser_cfg_t streambrowser_cfg; |
| 170 audacious_menu_plugin_item_add(AUDACIOUS_MENU_MAIN, main_menu_item); | 170 audacious_menu_plugin_item_add(AUDACIOUS_MENU_MAIN, main_menu_item); |
| 171 | 171 |
| 172 /* main streambrowser window */ | 172 /* main streambrowser window */ |
| 173 streambrowser_win_init(); | 173 streambrowser_win_init(); |
| 174 streambrowser_win_set_update_function(streamdir_update); | 174 streambrowser_win_set_update_function(streamdir_update); |
| 175 | |
| 176 /* others */ | |
| 175 update_thread_mutex = g_mutex_new(); | 177 update_thread_mutex = g_mutex_new(); |
| 178 update_thread_data_queue = g_queue_new(); | |
| 176 | 179 |
| 177 debug("gui initialized\n"); | 180 debug("gui initialized\n"); |
| 178 } | 181 } |
| 179 | 182 |
| 180 static void gui_done() | 183 static void gui_done() |
| 184 audacious_menu_plugin_item_remove(AUDACIOUS_MENU_MAIN, main_menu_item); | 187 audacious_menu_plugin_item_remove(AUDACIOUS_MENU_MAIN, main_menu_item); |
| 185 | 188 |
| 186 /* main streambrowser window */ | 189 /* main streambrowser window */ |
| 187 streambrowser_win_hide(); | 190 streambrowser_win_hide(); |
| 188 streambrowser_win_done(); | 191 streambrowser_win_done(); |
| 192 | |
| 193 /* others */ | |
| 194 g_mutex_free(update_thread_mutex); | |
| 195 g_queue_free(update_thread_data_queue); | |
| 189 | 196 |
| 190 debug("gui destroied\n"); | 197 debug("gui destroied\n"); |
| 191 } | 198 } |
| 192 | 199 |
| 193 static void config_load() | 200 static void config_load() |
| 236 else | 243 else |
| 237 if (update_thread_count > 0) { | 244 if (update_thread_count > 0) { |
| 238 debug("another %d streamdir updates are pending, this request will be queued\n", update_thread_count); | 245 debug("another %d streamdir updates are pending, this request will be queued\n", update_thread_count); |
| 239 | 246 |
| 240 g_mutex_lock(update_thread_mutex); | 247 g_mutex_lock(update_thread_mutex); |
| 241 update_thread_data_queue[update_thread_count].streamdir = streamdir; | 248 |
| 242 update_thread_data_queue[update_thread_count].category = category; | 249 update_thread_data_t *update_thread_data = g_malloc(sizeof(update_thread_data_t)); |
| 243 update_thread_data_queue[update_thread_count].streaminfo = streaminfo; | 250 |
| 251 update_thread_data->streamdir = streamdir; | |
| 252 update_thread_data->category = category; | |
| 253 update_thread_data->streaminfo = streaminfo; | |
| 254 g_queue_push_tail(update_thread_data_queue, update_thread_data); | |
| 244 | 255 |
| 245 update_thread_count++; | 256 update_thread_count++; |
| 257 | |
| 246 g_mutex_unlock(update_thread_mutex); | 258 g_mutex_unlock(update_thread_mutex); |
| 247 } | 259 } |
| 248 else { | 260 else { |
| 249 update_thread_data_t *data = g_malloc(sizeof(update_thread_data_t)); | 261 update_thread_data_t *data = g_malloc(sizeof(update_thread_data_t)); |
| 250 | 262 |
| 256 } | 268 } |
| 257 } | 269 } |
| 258 | 270 |
| 259 static gpointer update_thread_core(update_thread_data_t *data) | 271 static gpointer update_thread_core(update_thread_data_t *data) |
| 260 { | 272 { |
| 273 g_mutex_lock(update_thread_mutex); | |
| 274 update_thread_count++; | |
| 275 g_mutex_unlock(update_thread_mutex); | |
| 276 | |
| 261 /* update a streaminfo - that is - add this streaminfo to playlist */ | 277 /* update a streaminfo - that is - add this streaminfo to playlist */ |
| 262 if (data->streaminfo != NULL) { | 278 if (data->streaminfo != NULL) { |
| 263 streaminfo_add_to_playlist(data->streaminfo); | 279 streaminfo_add_to_playlist(data->streaminfo); |
| 264 } | 280 } |
| 265 /* update a category */ | 281 /* update a category */ |
| 300 | 316 |
| 301 /* check to see if there are pending update requests */ | 317 /* check to see if there are pending update requests */ |
| 302 | 318 |
| 303 data = NULL; | 319 data = NULL; |
| 304 g_mutex_lock(update_thread_mutex); | 320 g_mutex_lock(update_thread_mutex); |
| 321 update_thread_count--; | |
| 322 | |
| 305 if (update_thread_count > 0) { | 323 if (update_thread_count > 0) { |
| 306 data = g_malloc(sizeof(update_thread_data_t)); | 324 data = g_queue_pop_head(update_thread_data_queue); |
| 307 data->streamdir = update_thread_data_queue[0].streamdir; | |
| 308 data->category = update_thread_data_queue[0].category; | |
| 309 data->streaminfo = update_thread_data_queue[0].streaminfo; | |
| 310 | |
| 311 int i; | |
| 312 for (i = 0; i < update_thread_count; i++) { | |
| 313 update_thread_data_queue[i].streamdir = update_thread_data_queue[i + 1].streamdir; | |
| 314 update_thread_data_queue[i].category = update_thread_data_queue[i + 1].category; | |
| 315 update_thread_data_queue[i].streaminfo = update_thread_data_queue[i + 1].streaminfo; | |
| 316 } | |
| 317 | 325 |
| 318 update_thread_count--; | 326 update_thread_count--; |
| 319 } | 327 } |
| 320 g_mutex_unlock(update_thread_mutex); | 328 g_mutex_unlock(update_thread_mutex); |
| 321 | 329 |
