Mercurial > audlegacy-plugins
comparison src/streambrowser/streambrowser.c @ 2817:779125caa3ac
added xiph icon; smaller icons for streamdirs; fetch queue fix; up/down keys in tree view no longer focus the search entry
author | Calin Crisan ccrisan@gmail.com |
---|---|
date | Sun, 13 Jul 2008 14:42:27 +0300 |
parents | cc6f02424609 |
children | fbb32674bfd2 6c53f9fa9029 |
comparison
equal
deleted
inserted
replaced
2815:cc6f02424609 | 2817:779125caa3ac |
---|---|
54 | 54 |
55 static GtkWidget *playlist_menu_item; | 55 static GtkWidget *playlist_menu_item; |
56 static GtkWidget *main_menu_item; | 56 static GtkWidget *main_menu_item; |
57 static GQueue *update_thread_data_queue = NULL; | 57 static GQueue *update_thread_data_queue = NULL; |
58 static GMutex *update_thread_mutex = NULL; | 58 static GMutex *update_thread_mutex = NULL; |
59 static gint update_thread_count = 0; | |
60 | 59 |
61 streambrowser_cfg_t streambrowser_cfg; | 60 streambrowser_cfg_t streambrowser_cfg; |
62 | 61 |
63 static GeneralPlugin sb_plugin = | 62 static GeneralPlugin sb_plugin = |
64 { | 63 { |
277 debug("requested streamdir update (streamdir = '%s', category = '%s', streaminfo = '%s')\n", | 276 debug("requested streamdir update (streamdir = '%s', category = '%s', streaminfo = '%s')\n", |
278 streamdir == NULL ? "" : streamdir->name, | 277 streamdir == NULL ? "" : streamdir->name, |
279 category == NULL ? "" : category->name, | 278 category == NULL ? "" : category->name, |
280 streaminfo == NULL ? "" : streaminfo->name); | 279 streaminfo == NULL ? "" : streaminfo->name); |
281 | 280 |
282 if (update_thread_count >= MAX_UPDATE_THREADS) { | 281 if (g_queue_get_length(update_thread_data_queue) >= MAX_UPDATE_THREADS) { |
283 debug("another %d streamdir updates are pending, this request will be dropped\n", update_thread_count); | 282 debug("another %d streamdir updates are pending, this request will be dropped\n", g_queue_get_length(update_thread_data_queue)); |
284 } | 283 } |
285 else { | 284 else { |
286 g_mutex_lock(update_thread_mutex); | 285 g_mutex_lock(update_thread_mutex); |
287 | 286 |
288 /* do we have a running thread? */ | 287 /* do we have a running thread? */ |
289 if (update_thread_count > 0) { | 288 if (g_queue_get_length(update_thread_data_queue) > 0) { |
290 int i; | 289 int i; |
291 gboolean exists = FALSE; | 290 gboolean exists = FALSE; |
292 update_thread_data_t *update_thread_data; | 291 update_thread_data_t *update_thread_data; |
293 | 292 |
294 /* search for another identic update request */ | 293 /* search for another identic update request */ |
302 } | 301 } |
303 } | 302 } |
304 | 303 |
305 /* if no other similar request exists, we enqueue it */ | 304 /* if no other similar request exists, we enqueue it */ |
306 if (!exists) { | 305 if (!exists) { |
307 debug("another %d streamdir updates are pending, this request will be queued\n", update_thread_count); | 306 debug("another %d streamdir updates are pending, this request will be queued\n", g_queue_get_length(update_thread_data_queue)); |
308 | 307 |
309 update_thread_data = g_malloc(sizeof(update_thread_data_t)); | 308 update_thread_data = g_malloc(sizeof(update_thread_data_t)); |
310 | 309 |
311 update_thread_data->streamdir = streamdir; | 310 update_thread_data->streamdir = streamdir; |
312 update_thread_data->category = category; | 311 update_thread_data->category = category; |
313 update_thread_data->streaminfo = streaminfo; | 312 update_thread_data->streaminfo = streaminfo; |
314 | 313 |
315 g_queue_push_tail(update_thread_data_queue, update_thread_data); | 314 g_queue_push_tail(update_thread_data_queue, update_thread_data); |
316 update_thread_count++; | |
317 } | 315 } |
318 else { | 316 else { |
319 debug("this request is already present in the queue, dropping\n"); | 317 debug("this request is already present in the queue, dropping\n"); |
320 } | 318 } |
321 } | 319 } |
328 data->streamdir = streamdir; | 326 data->streamdir = streamdir; |
329 data->category = category; | 327 data->category = category; |
330 data->streaminfo = streaminfo; | 328 data->streaminfo = streaminfo; |
331 | 329 |
332 g_queue_push_tail(update_thread_data_queue, data); | 330 g_queue_push_tail(update_thread_data_queue, data); |
333 update_thread_count++; | |
334 | 331 |
335 g_thread_create((GThreadFunc) update_thread_core, NULL, FALSE, NULL); | 332 g_thread_create((GThreadFunc) update_thread_core, NULL, FALSE, NULL); |
336 } | 333 } |
337 | 334 |
338 g_mutex_unlock(update_thread_mutex); | 335 g_mutex_unlock(update_thread_mutex); |
344 debug("entering update thread core\n"); | 341 debug("entering update thread core\n"); |
345 | 342 |
346 /* try to get the last item in the queue, but don't remove it */ | 343 /* try to get the last item in the queue, but don't remove it */ |
347 g_mutex_lock(update_thread_mutex); | 344 g_mutex_lock(update_thread_mutex); |
348 update_thread_data_t *data = NULL; | 345 update_thread_data_t *data = NULL; |
349 if (update_thread_count > 0) { | 346 if (g_queue_get_length(update_thread_data_queue) > 0) { |
350 data = g_queue_peek_head(update_thread_data_queue); | 347 data = g_queue_peek_head(update_thread_data_queue); |
351 } | 348 } |
352 g_mutex_unlock(update_thread_mutex); | 349 g_mutex_unlock(update_thread_mutex); |
353 | 350 |
354 /* repetitively process the queue elements, until queue is empty */ | 351 /* repetitively process the queue elements, until queue is empty */ |
355 while (data != NULL && update_thread_count > 0) { | 352 while (data != NULL && g_queue_get_length(update_thread_data_queue) > 0) { |
356 /* update a streaminfo - that is - add this streaminfo to playlist */ | 353 /* update a streaminfo - that is - add this streaminfo to playlist */ |
357 if (data->streaminfo != NULL) { | 354 if (data->streaminfo != NULL) { |
358 gdk_threads_enter(); | 355 gdk_threads_enter(); |
359 streambrowser_win_set_streaminfo_state(data->streamdir, data->category, data->streaminfo, TRUE); | 356 streambrowser_win_set_streaminfo_state(data->streamdir, data->category, data->streaminfo, TRUE); |
360 gdk_threads_leave(); | 357 gdk_threads_leave(); |
437 | 434 |
438 g_mutex_lock(update_thread_mutex); | 435 g_mutex_lock(update_thread_mutex); |
439 | 436 |
440 /* remove the just processed data from the queue */ | 437 /* remove the just processed data from the queue */ |
441 g_queue_pop_head(update_thread_data_queue); | 438 g_queue_pop_head(update_thread_data_queue); |
442 update_thread_count--; | |
443 | 439 |
444 /* try to get the last item in the queue */ | 440 /* try to get the last item in the queue */ |
445 if (update_thread_count > 0) | 441 if (g_queue_get_length(update_thread_data_queue) > 0) |
446 data = g_queue_pop_head(update_thread_data_queue); | 442 data = g_queue_peek_head(update_thread_data_queue); |
447 else | 443 else |
448 data = NULL; | 444 data = NULL; |
445 | |
449 g_mutex_unlock(update_thread_mutex); | 446 g_mutex_unlock(update_thread_mutex); |
450 } | 447 } |
451 | 448 |
452 debug("leaving update thread core\n"); | 449 debug("leaving update thread core\n"); |
453 | 450 |