annotate audacious/playback.c @ 659:bb0d818a6ed6 trunk

[svn] add HEADERS for audacious/
author nenolod
date Wed, 22 Feb 2006 17:10:11 -0800
parents 2b9dc862967b
children f52f596dc0d8
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
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public Licensse as published by
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
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
43 #include "mainwin.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
44 #include "equalizer.h"
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"
385
0a19db762240 [svn] WTF is this doing with UI code in it :S
nenolod
parents: 356
diff changeset
47 #include "ui_playlist.h"
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
48 #include "playlist_list.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
49 #include "skin.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
50 #include "skinwin.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
51 #include "urldecode.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
52 #include "util.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
53
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
54
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
55 #include "playback.h"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
56
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
57
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
58 /* FIXME: yuck!! this shouldn't be here... */
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
59 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
60 bmp_playback_set_random_skin(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
61 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
62 SkinNode *node;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
63 guint32 randval;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
64
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
65 /* Get a random value to select the skin to use */
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
66 randval = g_random_int_range(0, g_list_length(skinlist));
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
67 node = g_list_nth(skinlist, randval)->data;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
68 bmp_active_skin_load(node->path);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
69 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
70
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
71 gint
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
72 bmp_playback_get_time(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
73 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
74 if (!bmp_playback_get_playing())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
75 return -1;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
76
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
77 if (!get_current_input_plugin())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
78 return -1;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
79
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
80 return get_current_input_plugin()->get_time();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
81 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
82
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
83 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
84 bmp_playback_initiate(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
85 {
398
f908bcd87c3d [svn] Generate cache content on demand if it was not previously there.
nenolod
parents: 385
diff changeset
86 PlaylistEntry *entry;
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
87
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
88 if (playlist_get_length() == 0)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
89 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
90
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
91 if (bmp_playback_get_playing())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
92 bmp_playback_stop();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
93
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
94 vis_clear_data(mainwin_vis);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
95 svis_clear_data(mainwin_svis);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
96 mainwin_disable_seekbar();
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 entry = playlist_get_entry_to_play();
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
99
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
100 if (!entry)
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
101 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
102
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
103 if (!bmp_playback_play_file(entry))
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
104 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
105
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
106 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
107 equalizerwin_load_auto_preset(entry->filename);
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
108 input_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 output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
111 cfg.equalizer_bands);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
112 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
113
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
114 playlist_check_pos_current();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
115 mainwin_set_info_text();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
116 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
117
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
118 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
119 bmp_playback_pause(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
120 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
121 if (!bmp_playback_get_playing())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
122 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
123
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
124 if (!get_current_input_plugin())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
125 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
126
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
127 ip_data.paused = !ip_data.paused;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
128
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
129 if (ip_data.paused)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
130 playstatus_set_status(mainwin_playstatus, STATUS_PAUSE);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
131 else
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
132 playstatus_set_status(mainwin_playstatus, STATUS_PLAY);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
133
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
134 if (get_current_input_plugin()->pause)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
135 get_current_input_plugin()->pause(ip_data.paused);
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
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
160 ip_data.playing = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
161 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
162
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
163 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
164 bmp_playback_stop_reentrant(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
165 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
166 if (ip_data.playing && get_current_input_plugin()) {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
167 ip_data.playing = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
168
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
169 if (bmp_playback_get_paused())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
170 bmp_playback_pause();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
171
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
172 free_vis_data();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
173 ip_data.paused = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
174
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
175 if (input_info_text) {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
176 g_free(input_info_text);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
177 input_info_text = NULL;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
178 mainwin_set_info_text();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
179 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
180 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
181
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
182 ip_data.playing = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
183 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
184
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
185 static void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
186 run_no_output_plugin_dialog(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
187 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
188 const gchar *markup =
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
189 N_("<b><big>No output plugin selected.</big></b>\n"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
190 "You have not selected an output plugin.");
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
191
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
192 GtkWidget *dialog =
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
193 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin),
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
194 GTK_DIALOG_DESTROY_WITH_PARENT,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
195 GTK_MESSAGE_ERROR,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
196 GTK_BUTTONS_OK,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
197 _(markup));
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
198 gtk_dialog_run(GTK_DIALOG(dialog));
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
199 gtk_widget_destroy(dialog);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
200 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
201
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
202 gboolean
398
f908bcd87c3d [svn] Generate cache content on demand if it was not previously there.
nenolod
parents: 385
diff changeset
203 bmp_playback_play_file(PlaylistEntry *entry)
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
204 {
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
205 g_return_val_if_fail(entry != NULL, FALSE);
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
206
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
207 if (!get_current_output_plugin()) {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
208 run_no_output_plugin_dialog();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
209 mainwin_stop_pushed();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
210 return FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
211 }
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 (cfg.random_skin_on_play)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
214 bmp_playback_set_random_skin();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
215
398
f908bcd87c3d [svn] Generate cache content on demand if it was not previously there.
nenolod
parents: 385
diff changeset
216 if (!entry->decoder)
f908bcd87c3d [svn] Generate cache content on demand if it was not previously there.
nenolod
parents: 385
diff changeset
217 entry->decoder = input_check_file(entry->filename, FALSE);
f908bcd87c3d [svn] Generate cache content on demand if it was not previously there.
nenolod
parents: 385
diff changeset
218
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
219 if (!entry->decoder || !input_is_enabled(entry->decoder->filename))
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
220 {
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
221 input_file_not_playable(entry->filename);
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
222
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
223 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
224 mainwin_set_info_text();
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
225
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
226 return FALSE;
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
227 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
228
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
229 set_current_input_plugin(entry->decoder);
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
230 entry->decoder->output = get_current_output_plugin();
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
231 entry->decoder->play_file(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 ip_data.playing = TRUE;
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
234
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
235 return TRUE;
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
236 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
237
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
238 gboolean
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
239 bmp_playback_get_playing(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
240 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
241 return ip_data.playing;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
242 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
243
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
244 gboolean
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
245 bmp_playback_get_paused(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
246 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
247 return ip_data.paused;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
248 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
249
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
250 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
251 bmp_playback_seek(gint time)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
252 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
253 gboolean restore_pause = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
254 gint l=0, r=0;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
255
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
256 if (!ip_data.playing)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
257 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
258
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
259 if (!get_current_input_plugin())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
260 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
261
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
262 /* FIXME WORKAROUND...that should work with all plugins
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
263 * mute the volume, start playback again, do the seek, then pause again
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
264 * -Patrick Sudowe */
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
265 if(ip_data.paused)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
266 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
267 restore_pause = TRUE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
268 output_get_volume(&l, &r);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
269 output_set_volume(0,0);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
270 bmp_playback_pause();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
271 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
272
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
273 free_vis_data();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
274 get_current_input_plugin()->seek(time);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
275
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
276 if(restore_pause)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
277 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
278 bmp_playback_pause();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
279 output_set_volume(l, r);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
280 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
281 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
282
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
283 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
284 bmp_playback_seek_relative(gint offset)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
285 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
286 gint time = CLAMP(bmp_playback_get_time() / 1000 + offset,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
287 0, playlist_get_current_length() / 1000 - 1);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
288 bmp_playback_seek(time);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
289 }