Mercurial > hg > xmms-sid
comparison xmms-songpos.patch-1.2.7 @ 1:183e7cbc1036
Initial revision
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 03 Jun 2003 10:23:04 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:5ce0a94edc2e | 1:183e7cbc1036 |
---|---|
1 diff -r -u xmms-1.2.7/General/ir/ir.c xmms-1.2.7-patched/General/ir/ir.c | |
2 --- xmms-1.2.7/General/ir/ir.c Mon Mar 5 15:15:13 2001 | |
3 +++ xmms-1.2.7-patched/General/ir/ir.c Sat Jun 1 17:27:31 2002 | |
4 @@ -292,12 +292,7 @@ | |
5 } | |
6 else if (!strcmp(text, ircfg.button_seekf) && g_timer_elapsed(timer1, NULL) > S_PAUSE / 2) | |
7 { | |
8 - output_time = xmms_remote_get_output_time(ir_gp.xmms_session); | |
9 - playlist_pos = xmms_remote_get_playlist_pos(ir_gp.xmms_session); | |
10 - playlist_time = xmms_remote_get_playlist_time(ir_gp.xmms_session, playlist_pos); | |
11 - if (playlist_time - output_time < 5000) | |
12 - output_time = playlist_time - 5000; | |
13 - xmms_remote_jump_to_time(ir_gp.xmms_session, output_time + 5000); | |
14 + xmms_remote_seek(ir_gp.xmms_session, + 5000); | |
15 g_timer_reset(timer1); | |
16 g_timer_reset(timer2); | |
17 g_timer_stop(timer2); | |
18 @@ -305,10 +300,7 @@ | |
19 } | |
20 else if (!strcmp(text, ircfg.button_seekb) && g_timer_elapsed(timer1, NULL) > S_PAUSE / 2) | |
21 { | |
22 - output_time = xmms_remote_get_output_time(ir_gp.xmms_session); | |
23 - if (output_time < 5000) | |
24 - output_time = 5000; | |
25 - xmms_remote_jump_to_time(ir_gp.xmms_session, output_time - 5000); | |
26 + xmms_remote_seek(ir_gp.xmms_session, - 5000); | |
27 g_timer_reset(timer1); | |
28 g_timer_reset(timer2); | |
29 g_timer_stop(timer2); | |
30 diff -r -u xmms-1.2.7/General/joystick/joy.c xmms-1.2.7-patched/General/joystick/joy.c | |
31 --- xmms-1.2.7/General/joystick/joy.c Mon Feb 5 15:27:10 2001 | |
32 +++ xmms-1.2.7-patched/General/joystick/joy.c Sat Jun 1 17:27:31 2002 | |
33 @@ -343,18 +343,10 @@ | |
34 xmms_remote_set_volume(joy_gp.xmms_session, vl - 5, vr - 5); | |
35 break; | |
36 case JC_FWD: | |
37 - output_time = xmms_remote_get_output_time(joy_gp.xmms_session); | |
38 - playlist_pos = xmms_remote_get_playlist_pos(joy_gp.xmms_session); | |
39 - playlist_time = xmms_remote_get_playlist_time(joy_gp.xmms_session, playlist_pos); | |
40 - if (playlist_time - output_time < 5000) | |
41 - output_time = playlist_time - 5000; | |
42 - xmms_remote_jump_to_time(joy_gp.xmms_session, output_time + 5000); | |
43 + xmms_remote_seek(joy_gp.xmms_session, + 5000); | |
44 break; | |
45 case JC_RWD: | |
46 - output_time = xmms_remote_get_output_time(joy_gp.xmms_session); | |
47 - if (output_time < 5000) | |
48 - output_time = 5000; | |
49 - xmms_remote_jump_to_time(joy_gp.xmms_session, output_time - 5000); | |
50 + xmms_remote_seek(joy_gp.xmms_session, - 5000); | |
51 break; | |
52 case JC_SHUFFLE: | |
53 xmms_remote_toggle_shuffle(joy_gp.xmms_session); | |
54 diff -r -u xmms-1.2.7/Input/mikmod/plugin.c xmms-1.2.7-patched/Input/mikmod/plugin.c | |
55 --- xmms-1.2.7/Input/mikmod/plugin.c Mon Jul 23 14:26:27 2001 | |
56 +++ xmms-1.2.7-patched/Input/mikmod/plugin.c Sat Jun 1 17:27:31 2002 | |
57 @@ -150,15 +150,8 @@ | |
58 | |
59 static void seek(int time) | |
60 { | |
61 - /* | |
62 - We need to seek in pattrens somehow | |
63 - can't seek by time only by X pattrens on way or the other | |
64 - | |
65 - Player_NextPosition (); | |
66 - Player_PrevPosition (); | |
67 - | |
68 - */ | |
69 - return; | |
70 + Player_SetPosition(time); | |
71 + mikmod_ip.output->flush(get_time()); | |
72 } | |
73 | |
74 static void mod_pause(short p) | |
75 @@ -174,6 +167,7 @@ | |
76 return -1; | |
77 if(!Player_Active() && !mikmod_ip.output->buffer_playing()) | |
78 return -1; | |
79 + set_song_position(mf->sngpos, 0, (mf->numpos - 1)); | |
80 return mikmod_ip.output->output_time(); | |
81 } | |
82 | |
83 Only in xmms-1.2.7-patched/Input/mikmod: plugin.c~ | |
84 diff -r -u xmms-1.2.7/Input/mpg123/common.c xmms-1.2.7-patched/Input/mpg123/common.c | |
85 --- xmms-1.2.7/Input/mpg123/common.c Wed Feb 20 15:17:30 2002 | |
86 +++ xmms-1.2.7-patched/Input/mpg123/common.c Sat Jun 1 17:27:31 2002 | |
87 @@ -56,6 +56,13 @@ | |
88 static FILE *filept; | |
89 static int filept_opened; | |
90 | |
91 +int streaming_http(void) | |
92 +{ | |
93 + if (!filept_opened) return FALSE; | |
94 + if (filept) return FALSE; | |
95 + return TRUE; | |
96 +} | |
97 + | |
98 static int get_fileinfo(void); | |
99 | |
100 static int fullread(FILE * fd, unsigned char *buf, int count) | |
101 diff -r -u xmms-1.2.7/Input/mpg123/http.c xmms-1.2.7-patched/Input/mpg123/http.c | |
102 --- xmms-1.2.7/Input/mpg123/http.c Mon Jan 7 15:08:04 2002 | |
103 +++ xmms-1.2.7-patched/Input/mpg123/http.c Sat Jun 1 17:27:31 2002 | |
104 @@ -194,6 +194,11 @@ | |
105 return (buffer_length - (wr_index - rd_index)) - 1; | |
106 } | |
107 | |
108 +void show_http_buffer_fullness(void) | |
109 +{ | |
110 + set_song_position(http_used(), 0, buffer_length); | |
111 +} | |
112 + | |
113 static void http_wait_for_data(gint bytes) | |
114 { | |
115 while ((prebuffering || http_used() < bytes) && !eof && going && mpg123_info->going) | |
116 Only in xmms-1.2.7-patched/Input/mpg123: http.c~ | |
117 diff -r -u xmms-1.2.7/Input/mpg123/mpg123.c xmms-1.2.7-patched/Input/mpg123/mpg123.c | |
118 --- xmms-1.2.7/Input/mpg123/mpg123.c Wed Feb 20 15:17:31 2002 | |
119 +++ xmms-1.2.7-patched/Input/mpg123/mpg123.c Sat Jun 1 17:27:31 2002 | |
120 @@ -1059,8 +1059,13 @@ | |
121 } | |
122 } | |
123 | |
124 +int streaming_http(void); | |
125 +void show_http_buffer_fullness(void); | |
126 + | |
127 static void seek(int time) | |
128 { | |
129 + if (streaming_http()) | |
130 + return; | |
131 mpg123_info->jump_to_time = time; | |
132 | |
133 while (mpg123_info->jump_to_time != -1) | |
134 @@ -1083,6 +1088,8 @@ | |
135 return -1; | |
136 if (!mpg123_info->going || (mpg123_info->eof && !mpg123_ip.output->buffer_playing())) | |
137 return -1; | |
138 + if (streaming_http()) | |
139 + show_http_buffer_fullness(); | |
140 return mpg123_ip.output->output_time(); | |
141 } | |
142 | |
143 Only in xmms-1.2.7-patched/Input/mpg123: mpg123.c~ | |
144 diff -r -u xmms-1.2.7/libxmms/xmmsctrl.c xmms-1.2.7-patched/libxmms/xmmsctrl.c | |
145 --- xmms-1.2.7/libxmms/xmmsctrl.c Sun Mar 3 21:24:27 2002 | |
146 +++ xmms-1.2.7-patched/libxmms/xmmsctrl.c Sat Jun 1 17:27:31 2002 | |
147 @@ -377,6 +377,11 @@ | |
148 remote_send_guint32(session, CMD_JUMP_TO_TIME, pos); | |
149 } | |
150 | |
151 +void xmms_remote_seek(gint session, gint off) | |
152 +{ | |
153 + remote_send_guint32(session, CMD_SEEK, off); | |
154 +} | |
155 + | |
156 void xmms_remote_get_volume(gint session, gint * vl, gint * vr) | |
157 { | |
158 ServerPktHeader pkt_hdr; | |
159 Only in xmms-1.2.7-patched/libxmms: xmmsctrl.c~ | |
160 diff -r -u xmms-1.2.7/libxmms/xmmsctrl.h xmms-1.2.7-patched/libxmms/xmmsctrl.h | |
161 --- xmms-1.2.7/libxmms/xmmsctrl.h Sun Mar 3 21:24:27 2002 | |
162 +++ xmms-1.2.7-patched/libxmms/xmmsctrl.h Sat Jun 1 17:27:31 2002 | |
163 @@ -42,6 +42,7 @@ | |
164 void xmms_remote_playlist_clear(gint session); | |
165 gint xmms_remote_get_output_time(gint session); | |
166 void xmms_remote_jump_to_time(gint session, gint pos); | |
167 +void xmms_remote_seek(gint session, gint off); | |
168 void xmms_remote_get_volume(gint session, gint * vl, gint * vr); | |
169 gint xmms_remote_get_main_volume(gint session); | |
170 gint xmms_remote_get_balance(gint session); | |
171 Only in xmms-1.2.7-patched/libxmms: xmmsctrl.h~ | |
172 diff -r -u xmms-1.2.7/xmms/controlsocket.c xmms-1.2.7-patched/xmms/controlsocket.c | |
173 --- xmms-1.2.7/xmms/controlsocket.c Sun Mar 3 21:24:33 2002 | |
174 +++ xmms-1.2.7-patched/xmms/controlsocket.c Sat Jun 1 17:28:51 2002 | |
175 @@ -451,6 +451,10 @@ | |
176 num < playlist_get_current_length()) | |
177 input_seek(num / 1000); | |
178 break; | |
179 + case CMD_SEEK: | |
180 + num = *((guint32 *) data); | |
181 + song_seek(num); | |
182 + break; | |
183 case CMD_SET_VOLUME: | |
184 v[0] = ((guint32 *) data)[0]; | |
185 v[1] = ((guint32 *) data)[1]; | |
186 diff -r -u xmms-1.2.7/xmms/controlsocket.h xmms-1.2.7-patched/xmms/controlsocket.h | |
187 --- xmms-1.2.7/xmms/controlsocket.h Sun Mar 3 21:24:33 2002 | |
188 +++ xmms-1.2.7-patched/xmms/controlsocket.h Sat Jun 1 17:27:31 2002 | |
189 @@ -33,7 +33,7 @@ | |
190 CMD_GET_VERSION, CMD_PLAYLIST_ADD, CMD_PLAY, CMD_PAUSE, CMD_STOP, | |
191 CMD_IS_PLAYING, CMD_IS_PAUSED, CMD_GET_PLAYLIST_POS, | |
192 CMD_SET_PLAYLIST_POS, CMD_GET_PLAYLIST_LENGTH, CMD_PLAYLIST_CLEAR, | |
193 - CMD_GET_OUTPUT_TIME, CMD_JUMP_TO_TIME, CMD_GET_VOLUME, | |
194 + CMD_GET_OUTPUT_TIME, CMD_JUMP_TO_TIME, CMD_SEEK, CMD_GET_VOLUME, | |
195 CMD_SET_VOLUME, CMD_GET_SKIN, CMD_SET_SKIN, CMD_GET_PLAYLIST_FILE, | |
196 CMD_GET_PLAYLIST_TITLE, CMD_GET_PLAYLIST_TIME, CMD_GET_INFO, | |
197 CMD_GET_EQ_DATA, CMD_SET_EQ_DATA, CMD_PL_WIN_TOGGLE, | |
198 diff -r -u xmms-1.2.7/xmms/input.c xmms-1.2.7-patched/xmms/input.c | |
199 --- xmms-1.2.7/xmms/input.c Wed Jul 11 14:19:23 2001 | |
200 +++ xmms-1.2.7-patched/xmms/input.c Sat Jun 1 17:27:31 2002 | |
201 @@ -295,6 +295,7 @@ | |
202 } | |
203 } | |
204 ip_data->playing = FALSE; | |
205 + set_song_position(0, 0, 0); | |
206 } | |
207 | |
208 void input_pause(void) | |
209 diff -r -u xmms-1.2.7/xmms/main.c xmms-1.2.7-patched/xmms/main.c | |
210 --- xmms-1.2.7/xmms/main.c Wed Feb 27 15:30:28 2002 | |
211 +++ xmms-1.2.7-patched/xmms/main.c Sat Jun 1 17:28:05 2002 | |
212 @@ -681,6 +681,55 @@ | |
213 g_free(filename); | |
214 } | |
215 | |
216 +/*\ | |
217 +|*| Separate song position stuff, for songs without a time length, | |
218 +|*| but that want to be able to seek anyway. | |
219 +|*| | |
220 +|*| Have the input plugin's get_time() function call | |
221 +|*| set_song_position(int pos, int first, int last) | |
222 +|*| to set the slider. If the slider is dragged, | |
223 +|*| the plugin's seek() is called with the position. | |
224 +|*| (If last <= first the feature is turned off) | |
225 +\*/ | |
226 + | |
227 +static int song_pos_cur, song_pos_first, song_pos_num = 0; | |
228 + | |
229 +void set_song_position(int pos, int first, int last) | |
230 +{ | |
231 + last -= first; | |
232 + song_pos_cur = pos; | |
233 + song_pos_first = first; | |
234 + song_pos_num = last; | |
235 + if (last <= 0) return; | |
236 + pos -= first; | |
237 + if (pos > last) pos = last; | |
238 + if (cfg.player_shaded) | |
239 + show_widget(mainwin_sposition); | |
240 + show_widget(mainwin_position); | |
241 + hslider_set_position(mainwin_position, (pos * 219) / last); | |
242 + hslider_set_position(mainwin_sposition, ((pos * 12) / last) + 1); | |
243 +} | |
244 + | |
245 +void song_seek(gint off) | |
246 +{ | |
247 + if (!get_input_playing()) return; | |
248 + if (song_pos_num > 0) { | |
249 + gint newpos = 0; | |
250 + if (off < 0) newpos = song_pos_cur - 1; | |
251 + else if (off > 0) newpos = song_pos_cur + 1; | |
252 + if (newpos < song_pos_first) newpos = song_pos_first; | |
253 + if (newpos > song_pos_first + song_pos_num) | |
254 + newpos = song_pos_first + song_pos_num; | |
255 + input_seek(newpos); | |
256 + } else { | |
257 + gint newpos = (input_get_time() / 1000) + (off / 1000); | |
258 + gint pcl = playlist_get_current_length() / 1000; | |
259 + if (newpos >= pcl) newpos = pcl - 1; | |
260 + if (newpos < 0) newpos = 0; | |
261 + input_seek(newpos); | |
262 + } | |
263 +} | |
264 + | |
265 gchar *xmms_get_gentitle_format(void) | |
266 { | |
267 return cfg.gentitle_format; | |
268 @@ -760,7 +809,9 @@ | |
269 show_widget(mainwin_stime_min); | |
270 show_widget(mainwin_stime_sec); | |
271 | |
272 - if (get_input_playing() && playlist_get_current_length() != -1) | |
273 + if (get_input_playing() && | |
274 + ((playlist_get_current_length() != -1) || | |
275 + (song_pos_num > 0))) | |
276 show_widget(mainwin_sposition); | |
277 | |
278 mainwin_shade->pb_ny = mainwin_shade->pb_py = 27; | |
279 @@ -1056,7 +1107,7 @@ | |
280 show_widget(mainwin_sec_num); | |
281 if (!get_input_paused()) | |
282 playstatus_set_status(mainwin_playstatus, STATUS_PLAY); | |
283 - if (playlist_get_current_length() != -1) | |
284 + if ((playlist_get_current_length() != -1) || (song_pos_num > 0)) | |
285 { | |
286 if (cfg.player_shaded) | |
287 show_widget(mainwin_sposition); | |
288 @@ -1352,13 +1403,19 @@ | |
289 break; | |
290 case GDK_Left: | |
291 case GDK_KP_Left: | |
292 +/* | |
293 if(playlist_get_current_length() != -1) | |
294 input_seek(CLAMP(input_get_time() - 5000, 0, playlist_get_current_length()) / 1000); | |
295 +*/ | |
296 + song_seek(-5000); | |
297 break; | |
298 case GDK_Right: | |
299 case GDK_KP_Right: | |
300 +/* | |
301 if(playlist_get_current_length() != -1) | |
302 input_seek(CLAMP(input_get_time() + 5000, 0, playlist_get_current_length()) / 1000); | |
303 +*/ | |
304 + song_seek(+5000); | |
305 break; | |
306 default: | |
307 break; | |
308 @@ -1988,6 +2045,16 @@ | |
309 | |
310 pos--; | |
311 | |
312 + if (song_pos_num > 0) { | |
313 + time = ((song_pos_num * pos + 6) / 12) + song_pos_first; | |
314 + tmp = g_strdup_printf("%d", time); | |
315 + textbox_set_text(mainwin_stime_min, tmp); | |
316 + g_free(tmp); | |
317 + tmp = g_strdup_printf("%d", song_pos_first + song_pos_num); | |
318 + textbox_set_text(mainwin_stime_sec, tmp); | |
319 + g_free(tmp); | |
320 + return; | |
321 + } | |
322 time = ((playlist_get_current_length() / 1000) * pos) / 12; | |
323 if (cfg.timer_mode == TIMER_REMAINING) | |
324 { | |
325 @@ -2009,6 +2076,10 @@ | |
326 | |
327 void mainwin_spos_release_cb(gint pos) | |
328 { | |
329 + if (song_pos_num > 0) { | |
330 + input_seek(((song_pos_num * (pos - 1) + 6) / 12) + song_pos_first); | |
331 + return; | |
332 + } | |
333 input_seek(((playlist_get_current_length() / 1000) * (pos - 1)) / 12); | |
334 } | |
335 | |
336 @@ -2017,6 +2088,14 @@ | |
337 gint length, time; | |
338 gchar *buf; | |
339 | |
340 + if (song_pos_num > 0) { | |
341 + time = ((song_pos_num * pos + 110) / 219) + song_pos_first; | |
342 + buf = g_strdup_printf("JUMP TO: %d/%d", time, | |
343 + song_pos_num + song_pos_first); | |
344 + mainwin_lock_info_text(buf); | |
345 + g_free(buf); | |
346 + return; | |
347 + } | |
348 length = playlist_get_current_length() / 1000; | |
349 time = (length * pos) / 219; | |
350 buf = g_strdup_printf(_("SEEK TO: %d:%-2.2d/%d:%-2.2d (%d%%)"), time / 60, time % 60, length / 60, length % 60, (length != 0) ? (time * 100) / length : 0); | |
351 @@ -2028,6 +2107,12 @@ | |
352 { | |
353 int length, time; | |
354 | |
355 + if (song_pos_num > 0) { | |
356 + time = ((song_pos_num * pos + 110) / 219) + song_pos_first; | |
357 + input_seek(time); | |
358 + mainwin_release_info_text(); | |
359 + return; | |
360 + } | |
361 length = playlist_get_current_length() / 1000; | |
362 time = (length * pos) / 219; | |
363 input_seek(time); | |
364 @@ -2423,12 +2508,10 @@ | |
365 case MAINWIN_GENERAL_STOPFADE: | |
366 break; | |
367 case MAINWIN_GENERAL_BACK5SEC: | |
368 - if (get_input_playing() && playlist_get_current_length() != -1) | |
369 - input_seek((((input_get_time() / 1000) - 5 >= 0) ? (input_get_time() / 1000) - 5 : 0)); | |
370 + song_seek(-5000); | |
371 break; | |
372 case MAINWIN_GENERAL_FWD5SEC: | |
373 - if (get_input_playing() && playlist_get_current_length() != -1) | |
374 - input_seek(((((input_get_time() / 1000) + 5) < (playlist_get_current_length() / 1000)) ? ((input_get_time() / 1000) + 5) : ((playlist_get_current_length() / 1000) - 1))); | |
375 + song_seek(+5000); | |
376 break; | |
377 case MAINWIN_GENERAL_START: | |
378 playlist_set_position(0); | |
379 @@ -3032,7 +3115,7 @@ | |
380 hslider_set_position(mainwin_sposition, ((time * 12) / length) + 1); | |
381 } | |
382 } | |
383 - else | |
384 + else if (song_pos_num <= 0) | |
385 { | |
386 hslider_set_position(mainwin_position, 0); | |
387 hslider_set_position(mainwin_sposition, 1); | |
388 diff -r -u xmms-1.2.7/xmms/main.h xmms-1.2.7-patched/xmms/main.h | |
389 --- xmms-1.2.7/xmms/main.h Mon Jan 21 15:22:38 2002 | |
390 +++ xmms-1.2.7-patched/xmms/main.h Sat Jun 1 17:27:31 2002 | |
391 @@ -87,6 +87,7 @@ | |
392 void mainwin_play_pushed(void); | |
393 void mainwin_stop_pushed(void); | |
394 void mainwin_eject_pushed(void); | |
395 +void song_seek(gint off); | |
396 | |
397 void mainwin_set_back_pixmap(void); | |
398 | |
399 diff -r -u xmms-1.2.7/xmms/plugin.h xmms-1.2.7-patched/xmms/plugin.h | |
400 --- xmms-1.2.7/xmms/plugin.h Fri Jul 6 21:15:34 2001 | |
401 +++ xmms-1.2.7-patched/xmms/plugin.h Sat Jun 1 17:27:31 2002 | |
402 @@ -154,4 +154,6 @@ | |
403 void (*render_freq)(gint16 freq_data[2][256]); /* Render the freq data, don't do anything time consuming in here */ | |
404 } VisPlugin; | |
405 | |
406 +void set_song_position(int pos, int first, int last); | |
407 + | |
408 #endif |