annotate audacious/playback.c @ 1828:b469c6c567a4 trunk

[svn] - use gtk_window_present() to make X render the right sized skin
author nenolod
date Thu, 05 Oct 2006 07:09:01 -0700
parents 600efc52c645
children 30d40252862d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
3 *
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
4 * Based on XMMS:
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
6 *
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
1460
411b4aaf928b [svn] fine
nemo
parents: 1459
diff changeset
8 * it under the terms of the GNU General Public License as published by
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
10 * (at your option) any later version.
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
11 *
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
16 *
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
1459
705d4c089fce [svn] Fix postal code.
chainsaw
parents: 1458
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
20 */
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
21
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
22 #ifdef HAVE_CONFIG_H
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
23 # include "config.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
24 #endif
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
25
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
26 #include <glib.h>
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
27 #include <glib/gi18n.h>
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
28 #include <glib/gprintf.h>
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
29 #include <stdlib.h>
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
30 #include <string.h>
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
31 #include <time.h>
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
32
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
33 #include <unistd.h>
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
34 #include <sys/types.h>
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
35 #include <sys/stat.h>
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
36 #include <dirent.h>
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
37
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
38 #include "libaudacious/util.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
39 #include "libaudacious/configdb.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
40
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
41 #include "input.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
42 #include "main.h"
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
43 #include "mainwin.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
44 #include "equalizer.h"
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
45 #include "output.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
46 #include "playlist.h"
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
47 #include "ui_playlist.h"
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
48 #include "skinwin.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
49 #include "urldecode.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
50 #include "util.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
51
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
52
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
53 #include "playback.h"
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
54
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
55
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
56 /* FIXME: yuck!! this shouldn't be here... */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
57 void
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
58 bmp_playback_set_random_skin(void)
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
59 {
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
60 SkinNode *node;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
61 guint32 randval;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
62
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
63 /* Get a random value to select the skin to use */
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
64 randval = g_random_int_range(0, g_list_length(skinlist));
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
65 node = g_list_nth(skinlist, randval)->data;
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
66 bmp_active_skin_load(node->path);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
67 }
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
68
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
69 gint
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
70 bmp_playback_get_time(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
71 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
72 if (!bmp_playback_get_playing())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
73 return -1;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
74
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
75 if (!get_current_input_plugin())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
76 return -1;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
77
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
78 return get_current_input_plugin()->get_time();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
79 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
80
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
81 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
82 bmp_playback_initiate(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
83 {
398
f908bcd87c3d [svn] Generate cache content on demand if it was not previously there.
nenolod
parents: 385
diff changeset
84 PlaylistEntry *entry;
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
85
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
86 if (playlist_get_length() == 0)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
87 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
88
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
89 if (bmp_playback_get_playing())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
90 bmp_playback_stop();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
91
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
92 vis_clear_data(mainwin_vis);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
93 svis_clear_data(mainwin_svis);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
94 mainwin_disable_seekbar();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
95
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
96 entry = playlist_get_entry_to_play();
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
97
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
98 if (!entry)
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
99 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
100
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
101 if (!bmp_playback_play_file(entry))
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
102 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
103
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
104 if (bmp_playback_get_time() != -1) {
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
105 equalizerwin_load_auto_preset(entry->filename);
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
106 input_set_eq(cfg.equalizer_active, cfg.equalizer_preamp,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
107 cfg.equalizer_bands);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
108 output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
109 cfg.equalizer_bands);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
110 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
111
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
112 playlist_check_pos_current();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
113 mainwin_set_info_text();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
114 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
115
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
116 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
117 bmp_playback_pause(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
118 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
119 if (!bmp_playback_get_playing())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
120 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
121
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
122 if (!get_current_input_plugin())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
123 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
124
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
125 ip_data.paused = !ip_data.paused;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
126
1672
600efc52c645 [svn] - be careful about referencing a NULL widget (e.g. headless/serveronly mode crashes on streams, bug #562)
nenolod
parents: 1653
diff changeset
127 if (get_current_input_plugin()->pause)
600efc52c645 [svn] - be careful about referencing a NULL widget (e.g. headless/serveronly mode crashes on streams, bug #562)
nenolod
parents: 1653
diff changeset
128 get_current_input_plugin()->pause(ip_data.paused);
600efc52c645 [svn] - be careful about referencing a NULL widget (e.g. headless/serveronly mode crashes on streams, bug #562)
nenolod
parents: 1653
diff changeset
129
600efc52c645 [svn] - be careful about referencing a NULL widget (e.g. headless/serveronly mode crashes on streams, bug #562)
nenolod
parents: 1653
diff changeset
130 g_return_if_fail(mainwin_playstatus != NULL);
600efc52c645 [svn] - be careful about referencing a NULL widget (e.g. headless/serveronly mode crashes on streams, bug #562)
nenolod
parents: 1653
diff changeset
131
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
132 if (ip_data.paused)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
133 playstatus_set_status(mainwin_playstatus, STATUS_PAUSE);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
134 else
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
135 playstatus_set_status(mainwin_playstatus, STATUS_PLAY);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
136 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
137
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
138 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
139 bmp_playback_stop(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
140 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
141 if (ip_data.playing && get_current_input_plugin()) {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
142 ip_data.playing = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
143
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
144 if (bmp_playback_get_paused())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
145 bmp_playback_pause();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
146
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
147 if (get_current_input_plugin()->stop)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
148 get_current_input_plugin()->stop();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
149
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
150 free_vis_data();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
151 ip_data.paused = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
152
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
153 if (input_info_text) {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
154 g_free(input_info_text);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
155 input_info_text = NULL;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
156 mainwin_set_info_text();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
157 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
158 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
159
1273
3b990c26fc46 [svn] - Support for the buffer indicator in playpaus.png that was apparently
nhjm449
parents: 890
diff changeset
160 ip_data.buffering = FALSE;
1672
600efc52c645 [svn] - be careful about referencing a NULL widget (e.g. headless/serveronly mode crashes on streams, bug #562)
nenolod
parents: 1653
diff changeset
161 ip_data.playing = FALSE;
600efc52c645 [svn] - be careful about referencing a NULL widget (e.g. headless/serveronly mode crashes on streams, bug #562)
nenolod
parents: 1653
diff changeset
162
600efc52c645 [svn] - be careful about referencing a NULL widget (e.g. headless/serveronly mode crashes on streams, bug #562)
nenolod
parents: 1653
diff changeset
163 g_return_if_fail(mainwin_playstatus != NULL);
600efc52c645 [svn] - be careful about referencing a NULL widget (e.g. headless/serveronly mode crashes on streams, bug #562)
nenolod
parents: 1653
diff changeset
164
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
165 playstatus_set_status_buffering(mainwin_playstatus, FALSE);
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
166 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
167
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
168 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
169 bmp_playback_stop_reentrant(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
170 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
171 if (ip_data.playing && get_current_input_plugin()) {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
172 ip_data.playing = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
173
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
174 if (bmp_playback_get_paused())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
175 bmp_playback_pause();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
176
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
177 free_vis_data();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
178 ip_data.paused = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
179
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
180 if (input_info_text) {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
181 g_free(input_info_text);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
182 input_info_text = NULL;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
183 mainwin_set_info_text();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
184 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
185 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
186
1273
3b990c26fc46 [svn] - Support for the buffer indicator in playpaus.png that was apparently
nhjm449
parents: 890
diff changeset
187 ip_data.buffering = FALSE;
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
188 ip_data.playing = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
189 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
190
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
191 static void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
192 run_no_output_plugin_dialog(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
193 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
194 const gchar *markup =
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
195 N_("<b><big>No output plugin selected.</big></b>\n"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
196 "You have not selected an output plugin.");
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
197
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
198 GtkWidget *dialog =
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
199 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin),
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
200 GTK_DIALOG_DESTROY_WITH_PARENT,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
201 GTK_MESSAGE_ERROR,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
202 GTK_BUTTONS_OK,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
203 _(markup));
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
204 gtk_dialog_run(GTK_DIALOG(dialog));
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
205 gtk_widget_destroy(dialog);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
206 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
207
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
208 gboolean
398
f908bcd87c3d [svn] Generate cache content on demand if it was not previously there.
nenolod
parents: 385
diff changeset
209 bmp_playback_play_file(PlaylistEntry *entry)
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
210 {
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
211 g_return_val_if_fail(entry != NULL, FALSE);
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
212
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
213 if (!get_current_output_plugin()) {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
214 run_no_output_plugin_dialog();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
215 mainwin_stop_pushed();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
216 return FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
217 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
218
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
219 if (cfg.random_skin_on_play)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
220 bmp_playback_set_random_skin();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
221
677
f52f596dc0d8 [svn] - Working exception handling at no extra charge. Closes bugs #408, #409.
nenolod
parents: 561
diff changeset
222 /*
f52f596dc0d8 [svn] - Working exception handling at no extra charge. Closes bugs #408, #409.
nenolod
parents: 561
diff changeset
223 * This is slightly uglier than the original version, but should
f52f596dc0d8 [svn] - Working exception handling at no extra charge. Closes bugs #408, #409.
nenolod
parents: 561
diff changeset
224 * fix the "crash" issues as seen in 0.2 when dealing with this situation.
f52f596dc0d8 [svn] - Working exception handling at no extra charge. Closes bugs #408, #409.
nenolod
parents: 561
diff changeset
225 * - nenolod
f52f596dc0d8 [svn] - Working exception handling at no extra charge. Closes bugs #408, #409.
nenolod
parents: 561
diff changeset
226 */
f52f596dc0d8 [svn] - Working exception handling at no extra charge. Closes bugs #408, #409.
nenolod
parents: 561
diff changeset
227 if (!entry->decoder &&
678
41ae3a48e202 [svn] Squelch a stupid warning here.
nenolod
parents: 677
diff changeset
228 (((entry->decoder = input_check_file(entry->filename, FALSE)) == NULL) ||
41ae3a48e202 [svn] Squelch a stupid warning here.
nenolod
parents: 677
diff changeset
229 !input_is_enabled(entry->decoder->filename)))
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
230 {
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
231 input_file_not_playable(entry->filename);
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
232
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
233 set_current_input_plugin(NULL);
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
234 mainwin_set_info_text();
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
235
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
236 return FALSE;
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
237 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
238
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
239 set_current_input_plugin(entry->decoder);
890
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 678
diff changeset
240 entry->decoder->output = &psuedo_output_plugin;
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
241 entry->decoder->play_file(entry->filename);
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
242
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
243 ip_data.playing = TRUE;
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
244
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
245 return TRUE;
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
246 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
247
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
248 gboolean
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
249 bmp_playback_get_playing(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
250 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
251 return ip_data.playing;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
252 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
253
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
254 gboolean
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
255 bmp_playback_get_paused(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
256 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
257 return ip_data.paused;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
258 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
259
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
260 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
261 bmp_playback_seek(gint time)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
262 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
263 gboolean restore_pause = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
264 gint l=0, r=0;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
265
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
266 if (!ip_data.playing)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
267 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
268
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
269 if (!get_current_input_plugin())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
270 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
271
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
272 /* FIXME WORKAROUND...that should work with all plugins
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
273 * mute the volume, start playback again, do the seek, then pause again
677
f52f596dc0d8 [svn] - Working exception handling at no extra charge. Closes bugs #408, #409.
nenolod
parents: 561
diff changeset
274 * -Patrick Sudowe
f52f596dc0d8 [svn] - Working exception handling at no extra charge. Closes bugs #408, #409.
nenolod
parents: 561
diff changeset
275 */
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
276 if(ip_data.paused)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
277 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
278 restore_pause = TRUE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
279 output_get_volume(&l, &r);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
280 output_set_volume(0,0);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
281 bmp_playback_pause();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
282 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
284 free_vis_data();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
285 get_current_input_plugin()->seek(time);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
286
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
287 if(restore_pause)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
288 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
289 bmp_playback_pause();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
290 output_set_volume(l, r);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
291 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
292 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
293
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
294 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
295 bmp_playback_seek_relative(gint offset)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
296 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
297 gint time = CLAMP(bmp_playback_get_time() / 1000 + offset,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
298 0, playlist_get_current_length() / 1000 - 1);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
299 bmp_playback_seek(time);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
300 }