Mercurial > audlegacy
comparison src/audlegacy/main.c @ 4843:ca837b93ad0f
Fix "audacious -p" crash and failing to play on startup
author | John Lindgren <john.lindgren@tds.net> |
---|---|
date | Fri, 10 Apr 2009 20:02:45 -0400 |
parents | a2ae808cabb4 |
children | b2ee645f3e59 |
comparison
equal
deleted
inserted
replaced
4842:62cb85252393 | 4843:ca837b93ad0f |
---|---|
338 g_list_foreach(fns, (GFunc) g_free, NULL); | 338 g_list_foreach(fns, (GFunc) g_free, NULL); |
339 g_list_free(fns); | 339 g_list_free(fns); |
340 } | 340 } |
341 | 341 |
342 static void | 342 static void |
343 handle_cmd_line_options(gboolean skip) | 343 handle_cmd_line_options_first (void) |
344 { | 344 { |
345 gboolean is_running = FALSE; | 345 #ifdef USE_DBUS |
346 | 346 DBusGProxy * session; |
347 #ifdef USE_DBUS | 347 #endif |
348 DBusGProxy *session = audacious_get_dbus_proxy(); | 348 if (options.version) { |
349 | 349 print_version (); |
350 if (skip) | 350 exit (EXIT_SUCCESS); |
351 is_running = audacious_remote_is_running(session); | 351 } |
352 #endif | 352 #ifdef USE_DBUS |
353 | 353 session = audacious_get_dbus_proxy (); |
354 if (options.version) | 354 if (audacious_remote_is_running (session)) { |
355 { | 355 handle_cmd_line_filenames (TRUE); |
356 print_version(); | 356 if (options.rew) |
357 exit(EXIT_SUCCESS); | 357 audacious_remote_playlist_prev (session); |
358 } | 358 if (options.play) |
359 | 359 audacious_remote_play (session); |
360 if (options.interface == NULL) | 360 if (options.pause) |
361 { | 361 audacious_remote_pause (session); |
362 mcs_handle_t *db = cfg_db_open(); | 362 if (options.stop) |
363 cfg_db_get_string(db, NULL, "interface", &options.interface); | 363 audacious_remote_stop (session); |
364 | 364 if (options.fwd) |
365 if (options.interface == NULL) | 365 audacious_remote_playlist_next (session); |
366 options.interface = g_strdup("legacy"); | 366 if (options.play_pause) |
367 } | 367 audacious_remote_play_pause (session); |
368 | 368 if (options.show_jump_box) |
369 handle_cmd_line_filenames(is_running); | 369 audacious_remote_show_jtf_box (session); |
370 | 370 if (options.mainwin) |
371 #ifdef USE_DBUS | 371 audacious_remote_main_win_toggle (session, 1); |
372 if (is_running) | 372 if (options.activate) |
373 { | 373 audacious_remote_activate (session); |
374 if (options.rew) | 374 exit (EXIT_SUCCESS); |
375 audacious_remote_playlist_prev(session); | 375 } |
376 | 376 #endif |
377 if (options.play) | 377 if (options.interface == NULL) { |
378 audacious_remote_play(session); | 378 mcs_handle_t * db = cfg_db_open (); |
379 | 379 cfg_db_get_string (db, NULL, "interface", & options.interface); |
380 if (options.pause) | 380 if (options.interface == NULL) |
381 audacious_remote_pause(session); | 381 options.interface = g_strdup ("legacy"); |
382 | 382 } |
383 if (options.stop) | 383 } |
384 audacious_remote_stop(session); | 384 |
385 | 385 static void |
386 if (options.fwd) | 386 handle_cmd_line_options (void) |
387 audacious_remote_playlist_next(session); | 387 { |
388 | 388 handle_cmd_line_filenames (FALSE); |
389 if (options.play_pause) | 389 if (options.rew) |
390 audacious_remote_play_pause(session); | 390 drct_pl_prev (); |
391 | 391 if (options.play || options.play_pause) |
392 if (options.show_jump_box) | 392 g_idle_add (aud_start_playback, NULL); |
393 audacious_remote_show_jtf_box(session); | 393 if (options.fwd) |
394 | 394 drct_pl_next (); |
395 if (options.mainwin) | 395 if (options.show_jump_box) |
396 audacious_remote_main_win_toggle(session, TRUE); | 396 drct_jtf_show (); |
397 | 397 if (options.mainwin) |
398 if (options.activate) | 398 drct_main_win_toggle (TRUE); |
399 audacious_remote_activate(session); | 399 if (options.activate) |
400 | 400 drct_activate (); |
401 exit(EXIT_SUCCESS); | |
402 } /* is_running */ | |
403 else | |
404 #endif | |
405 { | |
406 if (options.rew) | |
407 drct_pl_prev(); | |
408 | |
409 if (options.play) | |
410 drct_play(); | |
411 | |
412 if (options.pause) | |
413 drct_pause(); | |
414 | |
415 if (options.stop) | |
416 drct_stop(); | |
417 | |
418 if (options.fwd) | |
419 drct_pl_next(); | |
420 | |
421 if (options.play_pause) | |
422 { | |
423 if (drct_get_paused()) | |
424 drct_play(); | |
425 else | |
426 drct_pause(); | |
427 } | |
428 | |
429 if (options.show_jump_box) | |
430 drct_jtf_show(); | |
431 | |
432 if (options.mainwin) | |
433 drct_main_win_toggle(TRUE); | |
434 | |
435 if (options.activate) | |
436 drct_activate(); | |
437 } /* !is_running */ | |
438 } | 401 } |
439 | 402 |
440 static void | 403 static void |
441 aud_setup_logger(void) | 404 aud_setup_logger(void) |
442 { | 405 { |
567 | 530 |
568 g_message("Initializing signal handlers"); | 531 g_message("Initializing signal handlers"); |
569 signal_handlers_init(); | 532 signal_handlers_init(); |
570 | 533 |
571 g_message("Handling commandline options, part #1"); | 534 g_message("Handling commandline options, part #1"); |
572 handle_cmd_line_options(TRUE); | 535 handle_cmd_line_options_first (); |
573 | 536 |
574 if (g_ascii_strcasecmp(options.interface, "headless")) /* XXX */ | 537 if (g_ascii_strcasecmp(options.interface, "headless")) /* XXX */ |
575 { | 538 { |
576 g_message("Non-headless operation setup"); | 539 g_message("Non-headless operation setup"); |
577 ui_main_check_theme_engine(); | 540 ui_main_check_theme_engine(); |
597 | 560 |
598 g_message("Setting up playlists"); | 561 g_message("Setting up playlists"); |
599 playlist_system_init(); | 562 playlist_system_init(); |
600 | 563 |
601 g_message("Handling commandline options, part #2"); | 564 g_message("Handling commandline options, part #2"); |
602 handle_cmd_line_options(FALSE); | 565 handle_cmd_line_options (); |
603 | 566 |
604 g_message("Playlist scanner thread startup"); | 567 g_message("Playlist scanner thread startup"); |
605 playlist_start_get_info_thread(); | 568 playlist_start_get_info_thread(); |
606 | 569 |
607 output_set_volume((cfg.saved_volume & 0xff00) >> 8, | 570 output_set_volume((cfg.saved_volume & 0xff00) >> 8, |