Mercurial > audlegacy
annotate src/audacious/playback.c @ 3123:f1c756f39e6c trunk audacious-1.4.0-DR1
Invoke "Plugins are not derived work" clause provided by GPL3.
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Fri, 20 Jul 2007 09:09:58 -0500 |
parents | 3b6d316f8b09 |
children | c92070f10148 |
rev | line source |
---|---|
2313 | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2007 Audacious development team | |
3 * | |
4 * Based on BMP: | |
5 * Copyright (C) 2003-2004 BMP development team. | |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3093
diff
changeset
|
12 * the Free Software Foundation; under version 3 of the License. |
2313 | 13 * |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3093
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
21 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
22 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
23 * Audacious or using our public API to be a derived work. |
2313 | 24 */ |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 # include "config.h" | |
28 #endif | |
29 | |
30 #include <glib.h> | |
31 #include <glib/gi18n.h> | |
32 #include <glib/gprintf.h> | |
33 #include <stdlib.h> | |
34 #include <string.h> | |
35 #include <time.h> | |
36 | |
37 #include <unistd.h> | |
38 #include <sys/types.h> | |
39 #include <sys/stat.h> | |
40 #include <dirent.h> | |
41 | |
2717 | 42 #include "configdb.h" |
2313 | 43 |
2420 | 44 #include "hook.h" |
2313 | 45 #include "input.h" |
46 #include "main.h" | |
47 #include "ui_equalizer.h" | |
48 #include "output.h" | |
49 #include "playlist.h" | |
2420 | 50 #include "ui_main.h" |
2313 | 51 #include "ui_playlist.h" |
52 #include "ui_skinselector.h" | |
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3054
diff
changeset
|
53 #include "ui_skinned_playstatus.h" |
2313 | 54 #include "util.h" |
3082
91df04ec5ef7
From: Daniel Drake <dsd@gentoo.org>
William Pitcock <nenolod@atheme-project.org>
parents:
3042
diff
changeset
|
55 #include "visualization.h" |
2313 | 56 |
57 #include "playback.h" | |
58 | |
3018
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
59 static int song_info_timeout_source = 0; |
2313 | 60 |
61 gint | |
62 playback_get_time(void) | |
63 { | |
2438
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
64 InputPlayback *playback; |
2420 | 65 g_return_val_if_fail(playback_get_playing(), -1); |
2438
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
66 playback = get_current_input_playback(); |
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
67 g_return_val_if_fail(playback, -1); |
2313 | 68 |
2438
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
69 if (playback->plugin->get_time) |
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
70 return playback->plugin->get_time(playback); |
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
71 if (playback->error) |
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
72 return -2; |
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
73 if (!playback->playing || |
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
74 (playback->eof && !playback->output->buffer_playing())) |
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
75 return -1; |
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
76 return playback->output->output_time(); |
2313 | 77 } |
78 | |
79 void | |
80 playback_initiate(void) | |
81 { | |
82 PlaylistEntry *entry = NULL; | |
83 Playlist *playlist = playlist_get_active(); | |
84 | |
2420 | 85 g_return_if_fail(playlist_get_length(playlist) != 0); |
2313 | 86 |
87 if (playback_get_playing()) | |
88 playback_stop(); | |
89 | |
3020 | 90 ui_vis_clear_data(mainwin_vis); |
3054 | 91 ui_svis_clear_data(mainwin_svis); |
2313 | 92 mainwin_disable_seekbar(); |
93 | |
94 entry = playlist_get_entry_to_play(playlist); | |
2420 | 95 g_return_if_fail(entry != NULL); |
2592
6f7be3702c5f
[svn] - revert the penalty-based "find something to play" logic of 1.2. it's
nenolod
parents:
2454
diff
changeset
|
96 playback_play_file(entry); |
2313 | 97 |
98 if (playback_get_time() != -1) { | |
99 equalizerwin_load_auto_preset(entry->filename); | |
100 input_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, | |
101 cfg.equalizer_bands); | |
102 output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, | |
103 cfg.equalizer_bands); | |
104 } | |
105 | |
106 playlist_check_pos_current(playlist); | |
107 mainwin_set_info_text(); | |
3018
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
108 mainwin_update_song_info(); |
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
109 |
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
110 /* FIXME: use g_timeout_add_seconds when glib-2.14 is required */ |
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
111 song_info_timeout_source = g_timeout_add(1000, |
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
112 (GSourceFunc) mainwin_update_song_info, NULL); |
2407
1dc1d36d0347
[svn] - add hooks: playback begin, playback end, playlist reached end
nenolod
parents:
2366
diff
changeset
|
113 |
3000
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2976
diff
changeset
|
114 if (cfg.player_shaded) { |
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2976
diff
changeset
|
115 gtk_widget_show(mainwin_stime_min); |
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2976
diff
changeset
|
116 gtk_widget_show(mainwin_stime_sec); |
3042
01ae56759d15
mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
3041
diff
changeset
|
117 gtk_widget_show(mainwin_sposition); |
3001
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
118 } else { |
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
119 gtk_widget_show(mainwin_minus_num); |
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
120 gtk_widget_show(mainwin_10min_num); |
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
121 gtk_widget_show(mainwin_min_num); |
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
122 gtk_widget_show(mainwin_10sec_num); |
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
123 gtk_widget_show(mainwin_sec_num); |
3040
067e0186623a
import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
3021
diff
changeset
|
124 gtk_widget_show(mainwin_position); |
3000
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2976
diff
changeset
|
125 } |
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2976
diff
changeset
|
126 |
3082
91df04ec5ef7
From: Daniel Drake <dsd@gentoo.org>
William Pitcock <nenolod@atheme-project.org>
parents:
3042
diff
changeset
|
127 vis_playback_start(); |
3092
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
128 |
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
129 hook_call("playback begin", entry); |
2313 | 130 } |
131 | |
132 void | |
133 playback_pause(void) | |
134 { | |
135 if (!playback_get_playing()) | |
136 return; | |
137 | |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2420
diff
changeset
|
138 if (!get_current_input_playback()) |
2313 | 139 return; |
140 | |
141 ip_data.paused = !ip_data.paused; | |
142 | |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2420
diff
changeset
|
143 if (get_current_input_playback()->plugin->pause) |
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2420
diff
changeset
|
144 get_current_input_playback()->plugin->pause(get_current_input_playback(), |
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2420
diff
changeset
|
145 ip_data.paused); |
2313 | 146 |
3039
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
147 if (ip_data.paused) |
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
148 hook_call("playback pause", NULL); |
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
149 else |
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
150 hook_call("playback unpause", NULL); |
c981df78db8c
added hooks: playback pause and playback unpause
Giacomo Lozito <james@develia.org>
parents:
3021
diff
changeset
|
151 |
2313 | 152 g_return_if_fail(mainwin_playstatus != NULL); |
153 | |
154 if (ip_data.paused) | |
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3054
diff
changeset
|
155 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PAUSE); |
2313 | 156 else |
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3054
diff
changeset
|
157 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY); |
2313 | 158 } |
159 | |
160 void | |
161 playback_stop(void) | |
162 { | |
3092
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
163 if (ip_data.playing && get_current_input_playback()) { |
2313 | 164 |
3092
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
165 if (playback_get_paused()) { |
2313 | 166 output_flush(get_written_time()); /* to avoid noise */ |
167 playback_pause(); | |
168 } | |
169 | |
170 ip_data.playing = FALSE; | |
171 | |
3092
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
172 if (get_current_input_playback()->plugin->stop) |
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
173 get_current_input_playback()->plugin->stop(get_current_input_playback()); |
2313 | 174 |
175 free_vis_data(); | |
176 ip_data.paused = FALSE; | |
177 | |
3092
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
178 if (input_info_text) { |
2313 | 179 g_free(input_info_text); |
180 input_info_text = NULL; | |
181 mainwin_set_info_text(); | |
182 } | |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2420
diff
changeset
|
183 |
3092
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
184 g_free(get_current_input_playback()->filename); |
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
185 g_free(get_current_input_playback()); |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2420
diff
changeset
|
186 set_current_input_playback(NULL); |
2313 | 187 } |
188 | |
189 ip_data.buffering = FALSE; | |
190 ip_data.playing = FALSE; | |
3018
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
191 |
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
192 if (song_info_timeout_source) |
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
193 g_source_remove(song_info_timeout_source); |
6a9fdd5aee3a
Move timer updates out of the 100hz giant loop.
Daniel Drake <dsd@gentoo.org>
parents:
3001
diff
changeset
|
194 |
3082
91df04ec5ef7
From: Daniel Drake <dsd@gentoo.org>
William Pitcock <nenolod@atheme-project.org>
parents:
3042
diff
changeset
|
195 vis_playback_stop(); |
91df04ec5ef7
From: Daniel Drake <dsd@gentoo.org>
William Pitcock <nenolod@atheme-project.org>
parents:
3042
diff
changeset
|
196 |
2313 | 197 g_return_if_fail(mainwin_playstatus != NULL); |
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3054
diff
changeset
|
198 ui_skinned_playstatus_set_buffering(mainwin_playstatus, FALSE); |
2313 | 199 } |
200 | |
201 static void | |
202 run_no_output_plugin_dialog(void) | |
203 { | |
204 const gchar *markup = | |
205 N_("<b><big>No output plugin selected.</big></b>\n" | |
206 "You have not selected an output plugin."); | |
207 | |
208 GtkWidget *dialog = | |
209 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
210 GTK_DIALOG_DESTROY_WITH_PARENT, | |
211 GTK_MESSAGE_ERROR, | |
212 GTK_BUTTONS_OK, | |
213 _(markup)); | |
214 gtk_dialog_run(GTK_DIALOG(dialog)); | |
215 gtk_widget_destroy(dialog); | |
216 } | |
217 | |
218 gboolean | |
219 playback_play_file(PlaylistEntry *entry) | |
220 { | |
3092
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
221 InputPlayback * playback; |
2313 | 222 g_return_val_if_fail(entry != NULL, FALSE); |
223 | |
224 if (!get_current_output_plugin()) { | |
225 run_no_output_plugin_dialog(); | |
226 mainwin_stop_pushed(); | |
227 return FALSE; | |
228 } | |
229 | |
230 if (cfg.random_skin_on_play) | |
2443
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2438
diff
changeset
|
231 skin_set_random_skin(); |
2313 | 232 |
233 /* | |
234 * This is slightly uglier than the original version, but should | |
235 * fix the "crash" issues as seen in 0.2 when dealing with this situation. | |
236 * - nenolod | |
237 */ | |
238 if (!entry->decoder && | |
2420 | 239 (((entry->decoder = input_check_file(entry->filename, FALSE)) == NULL) || |
2313 | 240 !input_is_enabled(entry->decoder->filename))) |
241 { | |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2420
diff
changeset
|
242 set_current_input_playback(NULL); |
2313 | 243 mainwin_set_info_text(); |
244 | |
245 return FALSE; | |
246 } | |
247 | |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2420
diff
changeset
|
248 playback = g_new0(InputPlayback, 1); |
3092
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
249 |
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
250 entry->decoder->output = &psuedo_output_plugin; |
3089
f40b8491a812
Remove genevent, seperate playback logic into seperate control thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3084
diff
changeset
|
251 |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2420
diff
changeset
|
252 playback->plugin = entry->decoder; |
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2420
diff
changeset
|
253 playback->output = &psuedo_output_plugin; |
2438
8750a62abed8
[svn] Provide flags in InputPlayback for common plugin flag needs, and provide a
iabervon
parents:
2436
diff
changeset
|
254 playback->filename = g_strdup(entry->filename); |
3092
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
255 |
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
256 set_current_input_playback(playback); |
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
257 |
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
258 entry->decoder->play_file(playback); |
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
259 |
1ddeb9f068ab
Backed out changeset b87335249c69d45d253b1b960a9ec7f60b68e5a5
William Pitcock <nenolod@atheme-project.org>
parents:
3089
diff
changeset
|
260 ip_data.playing = TRUE; |
2313 | 261 |
262 return TRUE; | |
263 } | |
264 | |
265 gboolean | |
266 playback_get_playing(void) | |
267 { | |
268 return ip_data.playing; | |
269 } | |
270 | |
271 gboolean | |
272 playback_get_paused(void) | |
273 { | |
274 return ip_data.paused; | |
275 } | |
276 | |
277 void | |
278 playback_seek(gint time) | |
279 { | |
280 gboolean restore_pause = FALSE; | |
281 gint l=0, r=0; | |
282 | |
2420 | 283 g_return_if_fail(ip_data.playing); |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2420
diff
changeset
|
284 g_return_if_fail(get_current_input_playback()); |
2313 | 285 |
286 /* FIXME WORKAROUND...that should work with all plugins | |
287 * mute the volume, start playback again, do the seek, then pause again | |
288 * -Patrick Sudowe | |
289 */ | |
2420 | 290 if (ip_data.paused) |
2313 | 291 { |
2420 | 292 restore_pause = TRUE; |
293 output_get_volume(&l, &r); | |
294 output_set_volume(0,0); | |
295 playback_pause(); | |
2313 | 296 } |
297 | |
298 free_vis_data(); | |
2454 | 299 get_current_input_playback()->plugin->seek(get_current_input_playback(), time); |
2313 | 300 |
2420 | 301 if (restore_pause) |
2313 | 302 { |
2420 | 303 playback_pause(); |
304 output_set_volume(l, r); | |
2313 | 305 } |
306 } | |
307 | |
308 void | |
309 playback_seek_relative(gint offset) | |
310 { | |
311 gint time = CLAMP(playback_get_time() / 1000 + offset, | |
312 0, playlist_get_current_length(playlist_get_active()) / 1000 - 1); | |
313 playback_seek(time); | |
314 } |