comparison src/audacious/playlist.c @ 4516:9fbb55542e73

hookified many function calls
author mf0102 <0102@gmx.at>
date Wed, 23 Apr 2008 20:11:10 +0200
parents 212790dd92ba
children 16466c2624b2
comparison
equal deleted inserted replaced
4515:212790dd92ba 4516:9fbb55542e73
60 #include "playlist_container.h" 60 #include "playlist_container.h"
61 #include "playlist_evmessages.h" 61 #include "playlist_evmessages.h"
62 #include "pluginenum.h" 62 #include "pluginenum.h"
63 #include "strings.h" 63 #include "strings.h"
64 #include "ui_main.h" 64 #include "ui_main.h"
65 #include "ui_playlist_manager.h"
66 #include "ui_playlist.h" 65 #include "ui_playlist.h"
67 #include "util.h" 66 #include "util.h"
68 #include "vfs.h" 67 #include "vfs.h"
69 68
70 #include "debug.h" 69 #include "debug.h"
290 playlists = g_list_append(playlists, playlist); 289 playlists = g_list_append(playlists, playlist);
291 290
292 if (playlists_iter == NULL) 291 if (playlists_iter == NULL)
293 playlists_iter = playlists; 292 playlists_iter = playlists;
294 293
295 playlist_manager_update(); 294 hook_call("playlist update", NULL);
296 } 295 }
297 296
298 void 297 void
299 playlist_remove_playlist(Playlist *playlist) 298 playlist_remove_playlist(Playlist *playlist)
300 { 299 {
324 playlist_free(playlist); 323 playlist_free(playlist);
325 324
326 if (playlists_iter == NULL) 325 if (playlists_iter == NULL)
327 playlists_iter = playlists; 326 playlists_iter = playlists;
328 327
329 playlist_manager_update(); 328 hook_call("playlist update", NULL);
330 } 329 }
331 330
332 GList * 331 GList *
333 playlist_get_playlists(void) 332 playlist_get_playlists(void)
334 { 333 {
344 playlists_iter = g_list_next(playlists_iter); 343 playlists_iter = g_list_next(playlists_iter);
345 344
346 if (playlists_iter == NULL) 345 if (playlists_iter == NULL)
347 playlists_iter = playlists; 346 playlists_iter = playlists;
348 347
349 playlistwin_update_list(playlist_get_active()); 348 hook_call("playlist update", playlist_get_active());
350 playlist_manager_update();
351 } 349 }
352 350
353 void 351 void
354 playlist_select_prev(void) 352 playlist_select_prev(void)
355 { 353 {
359 playlists_iter = g_list_previous(playlists_iter); 357 playlists_iter = g_list_previous(playlists_iter);
360 358
361 if (playlists_iter == NULL) 359 if (playlists_iter == NULL)
362 playlists_iter = playlists; 360 playlists_iter = playlists;
363 361
364 playlistwin_update_list(playlist_get_active()); 362 hook_call("playlist update", playlist_get_active());
365 playlist_manager_update();
366 } 363 }
367 364
368 void 365 void
369 playlist_select_playlist(Playlist *playlist) 366 playlist_select_playlist(Playlist *playlist)
370 { 367 {
371 playlists_iter = g_list_find(playlists, playlist); 368 playlists_iter = g_list_find(playlists, playlist);
372 369
373 if (playlists_iter == NULL) 370 if (playlists_iter == NULL)
374 playlists_iter = playlists; 371 playlists_iter = playlists;
375 372
376 playlistwin_update_list(playlist); 373 hook_call("playlist update", playlist);
377 playlist_manager_update();
378 } 374 }
379 375
380 /* *********************** playlist code ********************** */ 376 /* *********************** playlist code ********************** */
381 377
382 const gchar * 378 const gchar *
393 gchar *oldtitle = playlist->title; 389 gchar *oldtitle = playlist->title;
394 390
395 if (!title) { 391 if (!title) {
396 playlist->title = NULL; 392 playlist->title = NULL;
397 g_free(oldtitle); 393 g_free(oldtitle);
398 playlist_manager_update(); 394 hook_call("playlist update", NULL);
399 return FALSE; 395 return FALSE;
400 } 396 }
401 397
402 playlist->title = str_to_utf8(title); 398 playlist->title = str_to_utf8(title);
403 g_free(oldtitle); 399 g_free(oldtitle);
404 playlist_manager_update(); 400 hook_call("playlist update", NULL);
405 return TRUE; 401 return TRUE;
406 } 402 }
407 403
408 /* Setting the filename allows the original playlist to be modified later */ 404 /* Setting the filename allows the original playlist to be modified later */
409 gboolean 405 gboolean
482 if (!playlist) 478 if (!playlist)
483 return; 479 return;
484 480
485 playlist_clear_only(playlist); 481 playlist_clear_only(playlist);
486 playlist_generate_shuffle_list(playlist); 482 playlist_generate_shuffle_list(playlist);
487 playlistwin_update_list(playlist); 483 hook_call("playlist update", playlist);
488 playlist_recalc_total_time(playlist); 484 playlist_recalc_total_time(playlist);
489 PLAYLIST_INCR_SERIAL(playlist); 485 PLAYLIST_INCR_SERIAL(playlist);
490 playlist_manager_update();
491 } 486 }
492 487
493 static void 488 static void
494 playlist_delete_node(Playlist * playlist, GList * node, gboolean * set_info_text, 489 playlist_delete_node(Playlist * playlist, GList * node, gboolean * set_info_text,
495 gboolean * restart_playing) 490 gboolean * restart_playing)
572 PLAYLIST_UNLOCK(playlist); 567 PLAYLIST_UNLOCK(playlist);
573 568
574 playlist_recalc_total_time(playlist); 569 playlist_recalc_total_time(playlist);
575 PLAYLIST_INCR_SERIAL(playlist); 570 PLAYLIST_INCR_SERIAL(playlist);
576 571
577 playlistwin_update_list(playlist); 572 hook_call("playlist update", playlist);
578 if (restart_playing) { 573 if (restart_playing) {
579 if (playlist->position) 574 if (playlist->position)
580 playback_initiate(); 575 playback_initiate();
581 else 576 else
582 hook_call("playlist end reached", NULL); 577 hook_call("playlist end reached", NULL);
583 } 578 }
584
585 playlist_manager_update();
586 } 579 }
587 580
588 void 581 void
589 playlist_delete(Playlist * playlist, gboolean crop) 582 playlist_delete(Playlist * playlist, gboolean crop)
590 { 583 {
620 playback_initiate(); 613 playback_initiate();
621 else 614 else
622 hook_call("playlist end reached", NULL); 615 hook_call("playlist end reached", NULL);
623 } 616 }
624 617
625 playlistwin_update_list(playlist); 618 hook_call("playlist update", playlist);
626 playlist_manager_update();
627 } 619 }
628 620
629 static void 621 static void
630 __playlist_ins_file(Playlist * playlist, 622 __playlist_ins_file(Playlist * playlist,
631 const gchar * filename, 623 const gchar * filename,
768 { 760 {
769 __playlist_ins_file(playlist, filename, pos, tuple, NULL, -1, dec); 761 __playlist_ins_file(playlist, filename, pos, tuple, NULL, -1, dec);
770 762
771 g_free(pr); 763 g_free(pr);
772 playlist_generate_shuffle_list(playlist); 764 playlist_generate_shuffle_list(playlist);
773 playlistwin_update_list(playlist); 765 hook_call("playlist update", playlist);
774 playlist_manager_update();
775 return TRUE; 766 return TRUE;
776 } 767 }
777 } 768 }
778 769
779 /* Some files (typically produced by some cgi-scripts) don't have 770 /* Some files (typically produced by some cgi-scripts) don't have
1012 g_list_free(list); 1003 g_list_free(list);
1013 g_free(path2); 1004 g_free(path2);
1014 1005
1015 playlist_recalc_total_time(playlist); 1006 playlist_recalc_total_time(playlist);
1016 playlist_generate_shuffle_list(playlist); 1007 playlist_generate_shuffle_list(playlist);
1017 playlistwin_update_list(playlist); 1008 hook_call("playlist update", playlist);
1018 playlist_manager_update();
1019 return entries; 1009 return entries;
1020 } 1010 }
1021 1011
1022 guint 1012 guint
1023 playlist_ins_url(Playlist * playlist, const gchar * string, 1013 playlist_ins_url(Playlist * playlist, const gchar * string,
1066 } 1056 }
1067 1057
1068 playlist_recalc_total_time(playlist); 1058 playlist_recalc_total_time(playlist);
1069 PLAYLIST_INCR_SERIAL(playlist); 1059 PLAYLIST_INCR_SERIAL(playlist);
1070 playlist_generate_shuffle_list(playlist); 1060 playlist_generate_shuffle_list(playlist);
1071 playlistwin_update_list(playlist); 1061 hook_call("playlist update", playlist);
1072
1073 playlist_manager_update();
1074 1062
1075 return entries; 1063 return entries;
1076 } 1064 }
1077 1065
1078 /* set info for current song. */ 1066 /* set info for current song. */
1209 playlist_check_pos_current(playlist); 1197 playlist_check_pos_current(playlist);
1210 1198
1211 if (restart_playing) 1199 if (restart_playing)
1212 playback_initiate(); 1200 playback_initiate();
1213 1201
1214 playlistwin_update_list(playlist); 1202 hook_call("playlist update", playlist);
1215 playlist_manager_update();
1216 } 1203 }
1217 1204
1218 void 1205 void
1219 playlist_prev(Playlist *playlist) 1206 playlist_prev(Playlist *playlist)
1220 { 1207 {
1269 playlist_check_pos_current(playlist); 1256 playlist_check_pos_current(playlist);
1270 1257
1271 if (restart_playing) 1258 if (restart_playing)
1272 playback_initiate(); 1259 playback_initiate();
1273 else 1260 else
1274 playlistwin_update_list(playlist); 1261 hook_call("playlist update", playlist);
1275
1276 playlist_manager_update();
1277 } 1262 }
1278 1263
1279 void 1264 void
1280 playlist_queue(Playlist *playlist) 1265 playlist_queue(Playlist *playlist)
1281 { 1266 {
1308 playlist->queue = g_list_concat(playlist->queue, list); 1293 playlist->queue = g_list_concat(playlist->queue, list);
1309 1294
1310 PLAYLIST_UNLOCK(playlist); 1295 PLAYLIST_UNLOCK(playlist);
1311 1296
1312 playlist_recalc_total_time(playlist); 1297 playlist_recalc_total_time(playlist);
1313 playlistwin_update_list(playlist); 1298 hook_call("playlist update", playlist);
1314 } 1299 }
1315 1300
1316 void 1301 void
1317 playlist_queue_position(Playlist *playlist, guint pos) 1302 playlist_queue_position(Playlist *playlist, guint pos)
1318 { 1303 {
1335 else 1320 else
1336 playlist->queue = g_list_append(playlist->queue, entry); 1321 playlist->queue = g_list_append(playlist->queue, entry);
1337 PLAYLIST_UNLOCK(playlist); 1322 PLAYLIST_UNLOCK(playlist);
1338 1323
1339 playlist_recalc_total_time(playlist); 1324 playlist_recalc_total_time(playlist);
1340 playlistwin_update_list(playlist); 1325 hook_call("playlist update", playlist);
1341 } 1326 }
1342 1327
1343 gboolean 1328 gboolean
1344 playlist_is_position_queued(Playlist *playlist, guint pos) 1329 playlist_is_position_queued(Playlist *playlist, guint pos)
1345 { 1330 {
1389 g_list_free(playlist->queue); 1374 g_list_free(playlist->queue);
1390 playlist->queue = NULL; 1375 playlist->queue = NULL;
1391 PLAYLIST_UNLOCK(playlist); 1376 PLAYLIST_UNLOCK(playlist);
1392 1377
1393 playlist_recalc_total_time(playlist); 1378 playlist_recalc_total_time(playlist);
1394 playlistwin_update_list(playlist); 1379 hook_call("playlist update", playlist);
1395 } 1380 }
1396 1381
1397 void 1382 void
1398 playlist_queue_remove(Playlist *playlist, guint pos) 1383 playlist_queue_remove(Playlist *playlist, guint pos)
1399 { 1384 {
1402 PLAYLIST_LOCK(playlist); 1387 PLAYLIST_LOCK(playlist);
1403 entry = g_list_nth_data(playlist->entries, pos); 1388 entry = g_list_nth_data(playlist->entries, pos);
1404 playlist->queue = g_list_remove(playlist->queue, entry); 1389 playlist->queue = g_list_remove(playlist->queue, entry);
1405 PLAYLIST_UNLOCK(playlist); 1390 PLAYLIST_UNLOCK(playlist);
1406 1391
1407 playlistwin_update_list(playlist); 1392 hook_call("playlist update", playlist);
1408 } 1393 }
1409 1394
1410 gint 1395 gint
1411 playlist_get_queue_position(Playlist *playlist, PlaylistEntry * entry) 1396 playlist_get_queue_position(Playlist *playlist, PlaylistEntry * entry)
1412 { 1397 {
1451 playlist_check_pos_current(playlist); 1436 playlist_check_pos_current(playlist);
1452 1437
1453 if (restart_playing) 1438 if (restart_playing)
1454 playback_initiate(); 1439 playback_initiate();
1455 else 1440 else
1456 playlistwin_update_list(playlist); 1441 hook_call("playlist update", playlist);
1457 } 1442 }
1458 1443
1459 void 1444 void
1460 playlist_eof_reached(Playlist *playlist) 1445 playlist_eof_reached(Playlist *playlist)
1461 { 1446 {
1517 1502
1518 PLAYLIST_UNLOCK(playlist); 1503 PLAYLIST_UNLOCK(playlist);
1519 1504
1520 playlist_check_pos_current(playlist); 1505 playlist_check_pos_current(playlist);
1521 playback_initiate(); 1506 playback_initiate();
1522 playlistwin_update_list(playlist); 1507 hook_call("playlist update", playlist);
1523 } 1508 }
1524 1509
1525 gint 1510 gint
1526 playlist_queue_get_length(Playlist *playlist) 1511 playlist_queue_get_length(Playlist *playlist)
1527 { 1512 {
1759 plc->plc_read(filename, pos); 1744 plc->plc_read(filename, pos);
1760 } 1745 }
1761 new_len = playlist_get_length(playlist); 1746 new_len = playlist_get_length(playlist);
1762 1747
1763 playlist_generate_shuffle_list(playlist); 1748 playlist_generate_shuffle_list(playlist);
1764 playlistwin_update_list(playlist); 1749 hook_call("playlist update", playlist);
1765 playlist_manager_update();
1766 1750
1767 playlist_recalc_total_time(playlist); //tentative --yaz 1751 playlist_recalc_total_time(playlist); //tentative --yaz
1768 PLAYLIST_INCR_SERIAL(playlist); 1752 PLAYLIST_INCR_SERIAL(playlist);
1769 1753
1770 return new_len - old_len; 1754 return new_len - old_len;
2333 PLAYLIST_ENTRY(node->data)->selected = FALSE; 2317 PLAYLIST_ENTRY(node->data)->selected = FALSE;
2334 } 2318 }
2335 PLAYLIST_INCR_SERIAL(playlist); 2319 PLAYLIST_INCR_SERIAL(playlist);
2336 PLAYLIST_UNLOCK(playlist); 2320 PLAYLIST_UNLOCK(playlist);
2337 playlist_recalc_total_time(playlist); 2321 playlist_recalc_total_time(playlist);
2338 playlist_manager_update(); 2322 hook_call("playlist update", playlist);
2339 } 2323 }
2340 2324
2341 gint 2325 gint
2342 playlist_get_num_selected(Playlist *playlist) 2326 playlist_get_num_selected(Playlist *playlist)
2343 { 2327 {
2468 node = g_list_next(node)) { 2452 node = g_list_next(node)) {
2469 2453
2470 entry = node->data; 2454 entry = node->data;
2471 2455
2472 if (playlist->attribute & PLAYLIST_STATIC || 2456 if (playlist->attribute & PLAYLIST_STATIC ||
2473 (entry->tuple && 2457 (entry->tuple &&
2474 tuple_get_int(entry->tuple, FIELD_LENGTH, NULL) > -1 && 2458 tuple_get_int(entry->tuple, FIELD_LENGTH, NULL) > -1 &&
2475 tuple_get_int(entry->tuple, FIELD_MTIME, NULL) != -1 && 2459 tuple_get_int(entry->tuple, FIELD_MTIME, NULL) != -1 &&
2476 entry->title_is_valid)) 2460 entry->title_is_valid))
2477 continue; 2461 continue;
2478 2462
2479 AUDDBG("len=%d mtime=%d\n", 2463 AUDDBG("len=%d mtime=%d\n",
2480 tuple_get_int(entry->tuple, FIELD_LENGTH, NULL), 2464 tuple_get_int(entry->tuple, FIELD_LENGTH, NULL),
2481 tuple_get_int(entry->tuple, FIELD_MTIME, NULL)); 2465 tuple_get_int(entry->tuple, FIELD_MTIME, NULL));
2511 g_mutex_unlock(mutex_scan); 2495 g_mutex_unlock(mutex_scan);
2512 } 2496 }
2513 2497
2514 if (update_playlistwin) { 2498 if (update_playlistwin) {
2515 Playlist *playlist = playlist_get_active(); 2499 Playlist *playlist = playlist_get_active();
2516 event_queue("playlistwin update list", playlist); 2500 event_queue("playlist update", playlist);
2517 PLAYLIST_INCR_SERIAL(playlist); 2501 PLAYLIST_INCR_SERIAL(playlist);
2518 update_playlistwin = FALSE; 2502 update_playlistwin = FALSE;
2519 } 2503 }
2520 2504
2521 if (playlist_get_info_scan_active) 2505 if (playlist_get_info_scan_active)
2622 } 2606 }
2623 2607
2624 PLAYLIST_UNLOCK(playlist); 2608 PLAYLIST_UNLOCK(playlist);
2625 2609
2626 playlist_generate_shuffle_list(playlist); 2610 playlist_generate_shuffle_list(playlist);
2627 playlistwin_update_list(playlist); 2611 hook_call("playlist update", playlist);
2628 playlist_recalc_total_time(playlist); 2612 playlist_recalc_total_time(playlist);
2629 PLAYLIST_INCR_SERIAL(playlist); 2613 PLAYLIST_INCR_SERIAL(playlist);
2630 playlist_manager_update();
2631 } 2614 }
2632 2615
2633 2616
2634 static gint 2617 static gint
2635 playlist_dupscmp_title(PlaylistEntry * a, 2618 playlist_dupscmp_title(PlaylistEntry * a,
2742 } 2725 }
2743 } 2726 }
2744 2727
2745 PLAYLIST_UNLOCK(playlist); 2728 PLAYLIST_UNLOCK(playlist);
2746 2729
2747 playlistwin_update_list(playlist); 2730 hook_call("playlist update", playlist);
2748 playlist_recalc_total_time(playlist); 2731 playlist_recalc_total_time(playlist);
2749 PLAYLIST_INCR_SERIAL(playlist); 2732 PLAYLIST_INCR_SERIAL(playlist);
2750
2751 playlist_manager_update();
2752 } 2733 }
2753 2734
2754 void 2735 void
2755 playlist_get_total_time(Playlist * playlist, 2736 playlist_get_total_time(Playlist * playlist,
2756 gulong * total_time, 2737 gulong * total_time,
3084 } 3065 }
3085 } 3066 }
3086 3067
3087 PLAYLIST_UNLOCK(playlist); 3068 PLAYLIST_UNLOCK(playlist);
3088 3069
3089 playlistwin_update_list(playlist); 3070 hook_call("playlist update", playlist);
3090 playlist_recalc_total_time(playlist); 3071 playlist_recalc_total_time(playlist);
3091 PLAYLIST_INCR_SERIAL(playlist); //tentative --yaz 3072 PLAYLIST_INCR_SERIAL(playlist); //tentative --yaz
3092 3073
3093 return retval; 3074 return retval;
3094 } 3075 }
3107 playlist_entry_get_info(entry); 3088 playlist_entry_get_info(entry);
3108 } 3089 }
3109 3090
3110 PLAYLIST_UNLOCK(playlist); 3091 PLAYLIST_UNLOCK(playlist);
3111 3092
3112 playlistwin_update_list(playlist); 3093 hook_call("playlist update", playlist);
3113 playlist_recalc_total_time(playlist); 3094 playlist_recalc_total_time(playlist);
3114 PLAYLIST_INCR_SERIAL(playlist); //tentative --yaz 3095 PLAYLIST_INCR_SERIAL(playlist); //tentative --yaz
3115 } 3096 }
3116 3097
3117 Playlist * 3098 Playlist *
3192 } 3173 }
3193 3174
3194 PLAYLIST_UNLOCK(playlist); 3175 PLAYLIST_UNLOCK(playlist);
3195 3176
3196 playlist_recalc_total_time(newpl); 3177 playlist_recalc_total_time(newpl);
3197 playlistwin_update_list(playlist); 3178 hook_call("playlist update", playlist);
3198 playlist_manager_update();
3199 3179
3200 return newpl; 3180 return newpl;
3201 } 3181 }
3202 3182
3203 const gchar * 3183 const gchar *