annotate audacious/playback.c @ 96:8dbd2d31c1f7 trunk

[svn] More work
author nenolod
date Tue, 01 Nov 2005 21:23:24 -0800
parents cb178e5ad177
children 32c320bba8a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 * Based on XMMS:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public Licensse as published by
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 * (at your option) any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 #ifdef HAVE_CONFIG_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23 # include "config.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 #include <glib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27 #include <glib/gi18n.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include <glib/gprintf.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 #include <stdlib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 #include <string.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 #include <time.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 #include <unistd.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 #include <sys/types.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35 #include <sys/stat.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 #include <dirent.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38 #include "libaudacious/util.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 #include "libaudacious/configdb.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41 #include "input.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 #include "main.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 #include "mainwin.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 #include "equalizer.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45 #include "output.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 #include "playlist.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 #include "playlistwin.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 #include "playlist_list.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 #include "skin.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 #include "skinwin.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 #include "urldecode.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 #include "util.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55 #include "playback.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 /* FIXME: yuck!! this shouldn't be here... */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 bmp_playback_set_random_skin(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 SkinNode *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 guint32 randval;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 /* Get a random value to select the skin to use */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 randval = g_random_int_range(0, g_list_length(skinlist));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 node = g_list_nth(skinlist, randval)->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 bmp_active_skin_load(node->path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 bmp_playback_get_time(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 if (!bmp_playback_get_playing())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 return -1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 if (!get_current_input_plugin())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 return -1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 return get_current_input_plugin()->get_time();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 bmp_playback_initiate(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 const gchar *filename = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 if (playlist_get_length() == 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 if (bmp_playback_get_playing())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 bmp_playback_stop();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 vis_clear_data(mainwin_vis);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 vis_clear_data(playlistwin_vis);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 svis_clear_data(mainwin_svis);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 mainwin_disable_seekbar();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 filename = playlist_get_filename_to_play();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 if (!filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 if (!bmp_playback_play_file(filename))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 if (bmp_playback_get_time() != -1) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 equalizerwin_load_auto_preset(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 input_set_eq(cfg.equalizer_active, cfg.equalizer_preamp,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 cfg.equalizer_bands);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 cfg.equalizer_bands);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 playlist_check_pos_current();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 mainwin_set_info_text();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 bmp_playback_pause(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 if (!bmp_playback_get_playing())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 if (!get_current_input_plugin())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 ip_data.paused = !ip_data.paused;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 if (ip_data.paused)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 playstatus_set_status(mainwin_playstatus, STATUS_PAUSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 playstatus_set_status(mainwin_playstatus, STATUS_PLAY);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 get_current_input_plugin()->pause(ip_data.paused);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 bmp_playback_stop(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 if (ip_data.playing && get_current_input_plugin()) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 ip_data.playing = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 if (bmp_playback_get_paused())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 bmp_playback_pause();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 if (get_current_input_plugin()->stop)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148 get_current_input_plugin()->stop();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 free_vis_data();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151 ip_data.paused = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153 if (input_info_text) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 g_free(input_info_text);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 input_info_text = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 mainwin_set_info_text();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160 ip_data.playing = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 run_no_output_plugin_dialog(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167 const gchar *markup =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168 N_("<b><big>No output plugin selected.</big></b>\n"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169 "You have not selected an output plugin.");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171 GtkWidget *dialog =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 GTK_DIALOG_DESTROY_WITH_PARENT,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 GTK_MESSAGE_ERROR,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 GTK_BUTTONS_OK,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 _(markup));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 gtk_dialog_run(GTK_DIALOG(dialog));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 gtk_widget_destroy(dialog);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 bmp_playback_play_file(const gchar * filename)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
184 GList *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
185 InputPlugin *ip;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
186 gchar *filename_proxy;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
188 g_return_val_if_fail(filename != NULL, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
189
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
190 if (!get_current_output_plugin()) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
191 run_no_output_plugin_dialog();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
192 mainwin_stop_pushed();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
193 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
194 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
195
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
196 if (cfg.random_skin_on_play)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
197 bmp_playback_set_random_skin();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
198
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
199 filename_proxy = g_strdup(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
200
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
201 node = get_input_list();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
202 node = g_list_first(node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
203
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
204 while (node) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
205
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
206 ip = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
207
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
208 if (!ip)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
209 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
210
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
211 if (ip && input_is_enabled(ip->filename) &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
212 ip->is_our_file(filename_proxy)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
213
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
214
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
215 set_current_input_plugin(ip);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
216 ip->output = get_current_output_plugin();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
217 ip->play_file(filename_proxy);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
218
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
219 /* FIXME: Why the hell (yes,hell!) doesn't the input
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
220 plugin set this itself???? -mderezynski */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
221 ip_data.playing = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
222
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
223 g_free(filename_proxy);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
224 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
225 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
226 node = g_list_next(node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
227 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
228
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
229 input_file_not_playable(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
230 set_current_input_plugin(NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
231 mainwin_set_info_text();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
232
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
233 g_free(filename_proxy);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
234
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
235 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
236 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
237
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
238 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
239 bmp_playback_get_playing(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
240 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
241 return ip_data.playing;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
242 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
243
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
244 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
245 bmp_playback_get_paused(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
246 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
247 return ip_data.paused;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
248 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
249
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
250 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
251 bmp_playback_seek(gint time)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
252 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
253 gboolean restore_pause = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
254 gint l=0, r=0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
255
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
256 if (!ip_data.playing)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
257 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
258
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
259 if (!get_current_input_plugin())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
260 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
261
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
262 /* FIXME WORKAROUND...that should work with all plugins
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
263 * mute the volume, start playback again, do the seek, then pause again
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
264 * -Patrick Sudowe */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
265 if(ip_data.paused)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
266 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
267 restore_pause = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
268 output_get_volume(&l, &r);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
269 output_set_volume(0,0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
270 bmp_playback_pause();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
271 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
272
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
273 free_vis_data();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
274 get_current_input_plugin()->seek(time);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
275
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
276 if(restore_pause)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
277 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
278 bmp_playback_pause();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
279 output_set_volume(l, r);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
280 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
281 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
282
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
283 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
284 bmp_playback_seek_relative(gint offset)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
285 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
286 gint time = CLAMP(bmp_playback_get_time() / 1000 + offset,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
287 0, playlist_get_current_length() / 1000 - 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
288 bmp_playback_seek(time);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
289 }