annotate libaudcore/playback.c @ 474:f3b46533da81 trunk

[svn] Experimental about box stuff... doesnt work right yet. Work in progress!
author nenolod
date Wed, 18 Jan 2006 21:21:50 -0800
parents f908bcd87c3d
children
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 vis_clear_data(playlistwin_vis);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
96 svis_clear_data(mainwin_svis);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
97 mainwin_disable_seekbar();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
98
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
99 entry = playlist_get_entry_to_play();
283
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 (!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
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
104 if (!bmp_playback_play_file(entry))
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
105 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
106
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
107 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
108 equalizerwin_load_auto_preset(entry->filename);
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
109 input_set_eq(cfg.equalizer_active, cfg.equalizer_preamp,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
110 cfg.equalizer_bands);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
111 output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
112 cfg.equalizer_bands);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
113 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
114
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
115 playlist_check_pos_current();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
116 mainwin_set_info_text();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
117 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
118
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
119 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
120 bmp_playback_pause(void)
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 (!bmp_playback_get_playing())
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 if (!get_current_input_plugin())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
126 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
127
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
128 ip_data.paused = !ip_data.paused;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
129
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
130 if (ip_data.paused)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
131 playstatus_set_status(mainwin_playstatus, STATUS_PAUSE);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
132 else
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
133 playstatus_set_status(mainwin_playstatus, STATUS_PLAY);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
134
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
135 if (get_current_input_plugin()->pause)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
136 get_current_input_plugin()->pause(ip_data.paused);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
137 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
138
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
139 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
140 bmp_playback_stop(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
141 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
142 if (ip_data.playing && get_current_input_plugin()) {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
143 ip_data.playing = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
144
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
145 if (bmp_playback_get_paused())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
146 bmp_playback_pause();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
147
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
148 if (get_current_input_plugin()->stop)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
149 get_current_input_plugin()->stop();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
150
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
151 free_vis_data();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
152 ip_data.paused = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
153
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
154 if (input_info_text) {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
155 g_free(input_info_text);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
156 input_info_text = NULL;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
157 mainwin_set_info_text();
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
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
161 ip_data.playing = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
162 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
163
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
164 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
165 bmp_playback_stop_reentrant(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
166 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
167 if (ip_data.playing && get_current_input_plugin()) {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
168 ip_data.playing = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
169
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
170 if (bmp_playback_get_paused())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
171 bmp_playback_pause();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
172
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
173 free_vis_data();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
174 ip_data.paused = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
175
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
176 if (input_info_text) {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
177 g_free(input_info_text);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
178 input_info_text = NULL;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
179 mainwin_set_info_text();
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
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
183 ip_data.playing = FALSE;
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 static void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
187 run_no_output_plugin_dialog(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
188 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
189 const gchar *markup =
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
190 N_("<b><big>No output plugin selected.</big></b>\n"
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
191 "You have not selected an output plugin.");
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
192
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
193 GtkWidget *dialog =
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
194 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin),
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
195 GTK_DIALOG_DESTROY_WITH_PARENT,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
196 GTK_MESSAGE_ERROR,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
197 GTK_BUTTONS_OK,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
198 _(markup));
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
199 gtk_dialog_run(GTK_DIALOG(dialog));
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
200 gtk_widget_destroy(dialog);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
201 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
202
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
203 gboolean
398
f908bcd87c3d [svn] Generate cache content on demand if it was not previously there.
nenolod
parents: 385
diff changeset
204 bmp_playback_play_file(PlaylistEntry *entry)
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
205 {
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
206 g_return_val_if_fail(entry != NULL, FALSE);
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
207
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
208 if (!get_current_output_plugin()) {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
209 run_no_output_plugin_dialog();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
210 mainwin_stop_pushed();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
211 return FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
212 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
213
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
214 if (cfg.random_skin_on_play)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
215 bmp_playback_set_random_skin();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
216
398
f908bcd87c3d [svn] Generate cache content on demand if it was not previously there.
nenolod
parents: 385
diff changeset
217 if (!entry->decoder)
f908bcd87c3d [svn] Generate cache content on demand if it was not previously there.
nenolod
parents: 385
diff changeset
218 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
219
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
220 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
221 {
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
222 input_file_not_playable(entry->filename);
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
223
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
224 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
225 mainwin_set_info_text();
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
226
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
227 return FALSE;
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
228 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
229
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
230 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
231 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
232 entry->decoder->play_file(entry->filename);
283
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
233
356
99928e1275a1 [svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents: 283
diff changeset
234 ip_data.playing = TRUE;
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 TRUE;
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
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
239 gboolean
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
240 bmp_playback_get_playing(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
241 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
242 return ip_data.playing;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
243 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
244
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
245 gboolean
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
246 bmp_playback_get_paused(void)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
247 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
248 return ip_data.paused;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
249 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
250
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
251 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
252 bmp_playback_seek(gint time)
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 restore_pause = FALSE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
255 gint l=0, r=0;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
256
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
257 if (!ip_data.playing)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
258 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
259
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
260 if (!get_current_input_plugin())
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
261 return;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
262
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
263 /* FIXME WORKAROUND...that should work with all plugins
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
264 * mute the volume, start playback again, do the seek, then pause again
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
265 * -Patrick Sudowe */
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
266 if(ip_data.paused)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
267 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
268 restore_pause = TRUE;
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
269 output_get_volume(&l, &r);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
270 output_set_volume(0,0);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
271 bmp_playback_pause();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
272 }
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
273
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
274 free_vis_data();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
275 get_current_input_plugin()->seek(time);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
276
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
277 if(restore_pause)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
278 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
279 bmp_playback_pause();
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
280 output_set_volume(l, r);
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
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
284 void
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
285 bmp_playback_seek_relative(gint offset)
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
286 {
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
287 gint time = CLAMP(bmp_playback_get_time() / 1000 + offset,
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
288 0, playlist_get_current_length() / 1000 - 1);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
289 bmp_playback_seek(time);
72dcd30156ca [svn] Very initial start on libaudcore.
nenolod
parents:
diff changeset
290 }