2313
|
1 /* Audacious - Cross-platform multimedia platform.
|
|
2 * Copyright (C) 2005-2007 Audacious development team.
|
|
3 *
|
|
4 * Based on BMP:
|
|
5 * Copyright (C) 2003-2004 BMP development team.
|
|
6 *
|
|
7 * Based on XMMS:
|
|
8 * Copyright (C) 1998-2003 XMMS development team.
|
|
9 *
|
|
10 * This program is free software; you can redistribute it and/or modify
|
|
11 * it under the terms of the GNU General Public License as published by
|
|
12 * the Free Software Foundation; under version 2 of the License.
|
|
13 *
|
|
14 * This program is distributed in the hope that it will be useful,
|
|
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 * GNU General Public License for more details.
|
|
18 *
|
|
19 * You should have received a copy of the GNU General Public License
|
|
20 * along with this program; if not, write to the Free Software
|
|
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
22 */
|
|
23
|
|
24 #ifdef HAVE_CONFIG_H
|
|
25 # include "config.h"
|
|
26 #endif
|
|
27
|
|
28 #include "main.h"
|
|
29
|
|
30 #include <glib.h>
|
|
31 #include <glib/gi18n.h>
|
|
32 #include <glib/gprintf.h>
|
|
33 #include <gdk/gdk.h>
|
|
34 #include <stdlib.h>
|
|
35 #include <string.h>
|
|
36 #include <getopt.h>
|
|
37 #include <ctype.h>
|
|
38 #include <time.h>
|
|
39
|
|
40 #include <unistd.h>
|
|
41 #include <errno.h>
|
|
42 #include <sys/types.h>
|
|
43 #include <sys/stat.h>
|
|
44 #include <signal.h>
|
|
45
|
|
46 #include "libaudacious/configdb.h"
|
|
47 #include "libaudacious/beepctrl.h"
|
|
48
|
|
49 #include "controlsocket.h"
|
|
50 #include "dnd.h"
|
|
51 #include "effect.h"
|
|
52 #include "general.h"
|
|
53 #include "hints.h"
|
|
54 #include "input.h"
|
|
55 #include "logger.h"
|
|
56 #include "output.h"
|
|
57 #include "playback.h"
|
|
58 #include "playlist.h"
|
2420
|
59 #include "pluginenum.h"
|
|
60 #include "ui_main.h"
|
2313
|
61 #include "ui_playlist.h"
|
|
62 #include "util.h"
|
|
63 #include "visualization.h"
|
2420
|
64 #include "vfs.h"
|
2313
|
65
|
|
66 gboolean ev_waiting = FALSE;
|
|
67
|
|
68 static gboolean
|
|
69 idle_func_change_song(gboolean waiting)
|
|
70 {
|
|
71 static GTimer *pause_timer = NULL;
|
|
72
|
|
73 if (!pause_timer)
|
|
74 pause_timer = g_timer_new();
|
|
75
|
|
76 if (cfg.pause_between_songs) {
|
|
77 gint timeleft;
|
|
78
|
|
79 if (!waiting) {
|
|
80 g_timer_start(pause_timer);
|
|
81 waiting = TRUE;
|
|
82 }
|
|
83
|
|
84 timeleft = cfg.pause_between_songs_time -
|
|
85 (gint) g_timer_elapsed(pause_timer, NULL);
|
|
86
|
|
87 if (mainwin_10min_num != NULL) {
|
|
88 number_set_number(mainwin_10min_num, timeleft / 600);
|
|
89 number_set_number(mainwin_min_num, (timeleft / 60) % 10);
|
|
90 number_set_number(mainwin_10sec_num, (timeleft / 10) % 6);
|
|
91 number_set_number(mainwin_sec_num, timeleft % 10);
|
|
92 }
|
|
93
|
|
94 if (mainwin_sposition != NULL && !mainwin_sposition->hs_pressed) {
|
|
95 gchar time_str[5];
|
|
96
|
|
97 g_snprintf(time_str, sizeof(time_str), "%2.2d", timeleft / 60);
|
|
98 textbox_set_text(mainwin_stime_min, time_str);
|
|
99
|
|
100 g_snprintf(time_str, sizeof(time_str), "%2.2d", timeleft % 60);
|
|
101 textbox_set_text(mainwin_stime_sec, time_str);
|
|
102 }
|
|
103
|
|
104 playlistwin_set_time(timeleft * 1000, 0, TIMER_ELAPSED);
|
|
105 }
|
|
106
|
|
107 if (!cfg.pause_between_songs ||
|
|
108 g_timer_elapsed(pause_timer, NULL) >= cfg.pause_between_songs_time)
|
|
109 {
|
|
110 Playlist *playlist = playlist_get_active();
|
|
111
|
|
112 GDK_THREADS_ENTER();
|
|
113 playlist_eof_reached(playlist);
|
|
114 GDK_THREADS_LEAVE();
|
|
115
|
|
116 waiting = FALSE;
|
|
117 }
|
|
118
|
|
119 return waiting;
|
|
120 }
|
|
121
|
|
122 gint
|
|
123 audcore_generic_events(void)
|
|
124 {
|
|
125 gint time = 0;
|
|
126
|
|
127 ctrlsocket_check();
|
|
128
|
|
129 if (playback_get_playing()) {
|
|
130 time = playback_get_time();
|
|
131
|
|
132 switch (time) {
|
|
133 case -1:
|
|
134 /* no song playing */
|
|
135 ev_waiting = idle_func_change_song(ev_waiting);
|
|
136 break;
|
|
137
|
|
138 default:
|
|
139 ev_waiting = FALSE;
|
|
140 }
|
|
141 }
|
|
142
|
|
143 return time;
|
|
144 }
|
|
145
|