Mercurial > audlegacy
comparison src/audacious/main.c @ 4385:88d8f699359a
moved some stuff around to increase headless support
author | mf0102 <0102@gmx.at> |
---|---|
date | Sat, 29 Mar 2008 13:35:02 +0100 |
parents | 335f4ac3993a |
children | 628926f505f8 |
comparison
equal
deleted
inserted
replaced
4384:db1c0a24e100 | 4385:88d8f699359a |
---|---|
656 title = playlist_get_current_name(playlist); | 656 title = playlist_get_current_name(playlist); |
657 | 657 |
658 return FALSE; /* keep loading other playlists */ | 658 return FALSE; /* keep loading other playlists */ |
659 } | 659 } |
660 | 660 |
661 static void | |
662 resume_playback_on_startup() | |
663 { | |
664 g_return_if_fail(cfg.resume_playback_on_startup); | |
665 g_return_if_fail(cfg.resume_playback_on_startup_time != -1); | |
666 g_return_if_fail(playlist_get_length(playlist_get_active()) > 0); | |
667 | |
668 int i; | |
669 gint l = 0, r = 0; | |
670 | |
671 while (gtk_events_pending()) gtk_main_iteration(); | |
672 | |
673 l = (cfg.saved_volume & 0xff00) >> 8; | |
674 r = cfg.saved_volume & 0x00ff; | |
675 output_set_volume(l, r); | |
676 | |
677 playback_initiate(); | |
678 | |
679 /* Busy wait; loop is fairly tight to minimize duration of | |
680 * "frozen" GUI. Feel free to tune. --chainsaw */ | |
681 for (i = 0; i < 20; i++) | |
682 { | |
683 g_usleep(1000); | |
684 if (!ip_data.playing) | |
685 break; | |
686 } | |
687 playback_seek(cfg.resume_playback_on_startup_time / 1000); | |
688 } | |
689 | |
661 gint | 690 gint |
662 main(gint argc, gchar ** argv) | 691 main(gint argc, gchar ** argv) |
663 { | 692 { |
664 Playlist *playlist; | 693 Playlist *playlist; |
665 | 694 |
744 | 773 |
745 #ifdef USE_DBUS | 774 #ifdef USE_DBUS |
746 init_dbus(); | 775 init_dbus(); |
747 #endif | 776 #endif |
748 | 777 |
778 playlist_start_get_info_thread(); | |
779 | |
749 if (options.headless == FALSE) | 780 if (options.headless == FALSE) |
750 { | 781 { |
751 bmp_set_default_icon(); | 782 bmp_set_default_icon(); |
752 #ifdef GDK_WINDOWING_QUARTZ | 783 #ifdef GDK_WINDOWING_QUARTZ |
753 set_dock_icon(); | 784 set_dock_icon(); |
791 if (cfg.playlist_visible) | 822 if (cfg.playlist_visible) |
792 playlistwin_show(); | 823 playlistwin_show(); |
793 | 824 |
794 hint_set_always(cfg.always_on_top); | 825 hint_set_always(cfg.always_on_top); |
795 | 826 |
796 playlist_start_get_info_thread(); | |
797 | |
798 has_x11_connection = TRUE; | 827 has_x11_connection = TRUE; |
799 | 828 |
800 if (cfg.resume_playback_on_startup) | 829 resume_playback_on_startup(); |
801 { | |
802 if (cfg.resume_playback_on_startup_time != -1 && | |
803 playlist_get_length(playlist) > 0) | |
804 { | |
805 int i; | |
806 gint l = 0, r = 0; | |
807 while (gtk_events_pending()) gtk_main_iteration(); | |
808 l = (cfg.saved_volume & 0xff00)>>8; | |
809 r = cfg.saved_volume & 0x00ff; | |
810 output_set_volume(0,0); | |
811 playback_initiate(); | |
812 | |
813 /* Busy wait; loop is fairly tight to minimize duration of | |
814 * "frozen" GUI. Feel free to tune. --chainsaw */ | |
815 for (i = 0; i < 20; i++) | |
816 { | |
817 g_usleep(1000); | |
818 if (!ip_data.playing) | |
819 break; | |
820 } | |
821 playback_seek(cfg.resume_playback_on_startup_time / 1000); | |
822 output_set_volume(l, r); | |
823 } | |
824 } | |
825 | 830 |
826 gtk_main(); | 831 gtk_main(); |
827 | 832 |
828 GDK_THREADS_LEAVE(); | 833 GDK_THREADS_LEAVE(); |
829 | |
830 g_cond_free(cond_scan); | |
831 g_mutex_free(mutex_scan); | |
832 | |
833 return EXIT_SUCCESS; | |
834 } | 834 } |
835 // if we are running headless | 835 // if we are running headless |
836 else | 836 else |
837 { | 837 { |
838 GMainLoop *loop; | 838 GMainLoop *loop; |
839 | 839 |
840 g_print(_("Headless operation enabled\n")); | 840 g_print(_("Headless operation enabled\n")); |
841 | 841 |
842 playlist_start_get_info_thread(); | 842 resume_playback_on_startup(); |
843 | 843 |
844 loop = g_main_loop_new(NULL, TRUE); | 844 loop = g_main_loop_new(NULL, TRUE); |
845 g_timeout_add(10, aud_headless_iteration, NULL); | 845 g_timeout_add(10, aud_headless_iteration, NULL); |
846 g_main_loop_run(loop); | 846 g_main_loop_run(loop); |
847 | 847 } |
848 return EXIT_SUCCESS; | 848 |
849 } | 849 g_cond_free(cond_scan); |
850 } | 850 g_mutex_free(mutex_scan); |
851 | |
852 return EXIT_SUCCESS; | |
853 } |