Mercurial > hg > xmms-sid
comparison xmms-songpos.patch-1.2.5 @ 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.5/General/ir/ir.c xmms-1.2.5-patched/General/ir/ir.c | |
2 --- xmms-1.2.5/General/ir/ir.c Mon Mar 5 16:15:13 2001 | |
3 +++ xmms-1.2.5-patched/General/ir/ir.c Tue Jul 17 18:44:05 2001 | |
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.5/General/joystick/joy.c xmms-1.2.5-patched/General/joystick/joy.c | |
31 --- xmms-1.2.5/General/joystick/joy.c Mon Feb 5 16:27:10 2001 | |
32 +++ xmms-1.2.5-patched/General/joystick/joy.c Tue Jul 17 18:44:05 2001 | |
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.5/Input/mikmod/plugin.c xmms-1.2.5-patched/Input/mikmod/plugin.c | |
55 --- xmms-1.2.5/Input/mikmod/plugin.c Tue Aug 1 00:33:04 2000 | |
56 +++ xmms-1.2.5-patched/Input/mikmod/plugin.c Tue Jul 17 18:44:05 2001 | |
57 @@ -149,15 +149,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 @@ -173,6 +166,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 diff -r -u xmms-1.2.5/Input/mpg123/common.c xmms-1.2.5-patched/Input/mpg123/common.c | |
84 --- xmms-1.2.5/Input/mpg123/common.c Fri Jun 1 16:07:48 2001 | |
85 +++ xmms-1.2.5-patched/Input/mpg123/common.c Tue Jul 17 18:44:05 2001 | |
86 @@ -56,6 +56,13 @@ | |
87 static FILE *filept; | |
88 static int filept_opened; | |
89 | |
90 +int streaming_http(void) | |
91 +{ | |
92 + if (!filept_opened) return FALSE; | |
93 + if (filept) return FALSE; | |
94 + return TRUE; | |
95 +} | |
96 + | |
97 static int get_fileinfo(void); | |
98 | |
99 static int fullread(FILE * fd, unsigned char *buf, int count) | |
100 diff -r -u xmms-1.2.5/Input/mpg123/http.c xmms-1.2.5-patched/Input/mpg123/http.c | |
101 --- xmms-1.2.5/Input/mpg123/http.c Fri Jun 1 16:07:48 2001 | |
102 +++ xmms-1.2.5-patched/Input/mpg123/http.c Tue Jul 17 18:44:05 2001 | |
103 @@ -193,6 +193,11 @@ | |
104 return (buffer_length - (wr_index - rd_index)) - 1; | |
105 } | |
106 | |
107 +void show_http_buffer_fullness(void) | |
108 +{ | |
109 + set_song_position(http_used(), 0, buffer_length); | |
110 +} | |
111 + | |
112 static void http_wait_for_data(gint bytes) | |
113 { | |
114 while ((prebuffering || http_used() < bytes) && !eof && going && mpg123_info->going) | |
115 diff -r -u xmms-1.2.5/Input/mpg123/mpg123.c xmms-1.2.5-patched/Input/mpg123/mpg123.c | |
116 --- xmms-1.2.5/Input/mpg123/mpg123.c Thu May 10 22:43:37 2001 | |
117 +++ xmms-1.2.5-patched/Input/mpg123/mpg123.c Tue Jul 17 18:44:05 2001 | |
118 @@ -1029,8 +1029,13 @@ | |
119 } | |
120 } | |
121 | |
122 +int streaming_http(void); | |
123 +void show_http_buffer_fullness(void); | |
124 + | |
125 static void seek(int time) | |
126 { | |
127 + if (streaming_http()) | |
128 + return; | |
129 mpg123_info->jump_to_time = time; | |
130 | |
131 while (mpg123_info->jump_to_time != -1) | |
132 @@ -1050,6 +1055,8 @@ | |
133 return -1; | |
134 if (!mpg123_info->going || (mpg123_info->eof && !mpg123_ip.output->buffer_playing())) | |
135 return -1; | |
136 + if (streaming_http()) | |
137 + show_http_buffer_fullness(); | |
138 return mpg123_ip.output->output_time(); | |
139 } | |
140 | |
141 diff -r -u xmms-1.2.5/libxmms/xmmsctrl.c xmms-1.2.5-patched/libxmms/xmmsctrl.c | |
142 --- xmms-1.2.5/libxmms/xmmsctrl.c Fri Jun 1 16:07:49 2001 | |
143 +++ xmms-1.2.5-patched/libxmms/xmmsctrl.c Tue Jul 17 18:44:05 2001 | |
144 @@ -370,6 +370,11 @@ | |
145 remote_send_guint32(session, CMD_JUMP_TO_TIME, pos); | |
146 } | |
147 | |
148 +void xmms_remote_seek(gint session, gint off) | |
149 +{ | |
150 + remote_send_guint32(session, CMD_SEEK, off); | |
151 +} | |
152 + | |
153 void xmms_remote_get_volume(gint session, gint * vl, gint * vr) | |
154 { | |
155 ServerPktHeader pkt_hdr; | |
156 diff -r -u xmms-1.2.5/libxmms/xmmsctrl.h xmms-1.2.5-patched/libxmms/xmmsctrl.h | |
157 --- xmms-1.2.5/libxmms/xmmsctrl.h Fri Jun 16 18:00:28 2000 | |
158 +++ xmms-1.2.5-patched/libxmms/xmmsctrl.h Tue Jul 17 18:44:05 2001 | |
159 @@ -40,6 +40,7 @@ | |
160 void xmms_remote_playlist_clear(gint session); | |
161 gint xmms_remote_get_output_time(gint session); | |
162 void xmms_remote_jump_to_time(gint session, gint pos); | |
163 +void xmms_remote_seek(gint session, gint off); | |
164 void xmms_remote_get_volume(gint session, gint * vl, gint * vr); | |
165 gint xmms_remote_get_main_volume(gint session); | |
166 gint xmms_remote_get_balance(gint session); | |
167 diff -r -u xmms-1.2.5/xmms/controlsocket.c xmms-1.2.5-patched/xmms/controlsocket.c | |
168 --- xmms-1.2.5/xmms/controlsocket.c Sun Jun 17 02:05:47 2001 | |
169 +++ xmms-1.2.5-patched/xmms/controlsocket.c Tue Jul 17 18:44:05 2001 | |
170 @@ -434,6 +434,10 @@ | |
171 num < playlist_get_current_length()) | |
172 input_seek(num / 1000); | |
173 break; | |
174 + case CMD_SEEK: | |
175 + num = *((guint32 *) data); | |
176 + song_seek(num); | |
177 + break; | |
178 case CMD_SET_VOLUME: | |
179 v[0] = ((guint32 *) data)[0]; | |
180 v[1] = ((guint32 *) data)[1]; | |
181 diff -r -u xmms-1.2.5/xmms/controlsocket.h xmms-1.2.5-patched/xmms/controlsocket.h | |
182 --- xmms-1.2.5/xmms/controlsocket.h Fri Jun 16 18:00:28 2000 | |
183 +++ xmms-1.2.5-patched/xmms/controlsocket.h Tue Jul 17 18:44:05 2001 | |
184 @@ -31,7 +31,7 @@ | |
185 CMD_GET_VERSION, CMD_PLAYLIST_ADD, CMD_PLAY, CMD_PAUSE, CMD_STOP, | |
186 CMD_IS_PLAYING, CMD_IS_PAUSED, CMD_GET_PLAYLIST_POS, | |
187 CMD_SET_PLAYLIST_POS, CMD_GET_PLAYLIST_LENGTH, CMD_PLAYLIST_CLEAR, | |
188 - CMD_GET_OUTPUT_TIME, CMD_JUMP_TO_TIME, CMD_GET_VOLUME, | |
189 + CMD_GET_OUTPUT_TIME, CMD_JUMP_TO_TIME, CMD_SEEK, CMD_GET_VOLUME, | |
190 CMD_SET_VOLUME, CMD_GET_SKIN, CMD_SET_SKIN, CMD_GET_PLAYLIST_FILE, | |
191 CMD_GET_PLAYLIST_TITLE, CMD_GET_PLAYLIST_TIME, CMD_GET_INFO, | |
192 CMD_GET_EQ_DATA, CMD_SET_EQ_DATA, CMD_PL_WIN_TOGGLE, | |
193 diff -r -u xmms-1.2.5/xmms/input.c xmms-1.2.5-patched/xmms/input.c | |
194 --- xmms-1.2.5/xmms/input.c Thu Jun 14 15:30:33 2001 | |
195 +++ xmms-1.2.5-patched/xmms/input.c Tue Jul 17 18:44:05 2001 | |
196 @@ -294,6 +294,7 @@ | |
197 } | |
198 } | |
199 ip_data->playing = FALSE; | |
200 + set_song_position(0, 0, 0); | |
201 } | |
202 | |
203 void input_pause(void) | |
204 diff -r -u xmms-1.2.5/xmms/main.c xmms-1.2.5-patched/xmms/main.c | |
205 --- xmms-1.2.5/xmms/main.c Sun Jun 17 02:05:47 2001 | |
206 +++ xmms-1.2.5-patched/xmms/main.c Tue Jul 17 18:49:39 2001 | |
207 @@ -669,6 +669,55 @@ | |
208 g_free(filename); | |
209 } | |
210 | |
211 +/*\ | |
212 +|*| Separate song position stuff, for songs without a time length, | |
213 +|*| but that want to be able to seek anyway. | |
214 +|*| | |
215 +|*| Have the input plugin's get_time() function call | |
216 +|*| set_song_position(int pos, int first, int last) | |
217 +|*| to set the slider. If the slider is dragged, | |
218 +|*| the plugin's seek() is called with the position. | |
219 +|*| (If last <= first the feature is turned off) | |
220 +\*/ | |
221 + | |
222 +static int song_pos_cur, song_pos_first, song_pos_num = 0; | |
223 + | |
224 +void set_song_position(int pos, int first, int last) | |
225 +{ | |
226 + last -= first; | |
227 + song_pos_cur = pos; | |
228 + song_pos_first = first; | |
229 + song_pos_num = last; | |
230 + if (last <= 0) return; | |
231 + pos -= first; | |
232 + if (pos > last) pos = last; | |
233 + if (cfg.player_shaded) | |
234 + show_widget(mainwin_sposition); | |
235 + show_widget(mainwin_position); | |
236 + hslider_set_position(mainwin_position, (pos * 219) / last); | |
237 + hslider_set_position(mainwin_sposition, ((pos * 12) / last) + 1); | |
238 +} | |
239 + | |
240 +void song_seek(gint off) | |
241 +{ | |
242 + if (!get_input_playing()) return; | |
243 + if (song_pos_num > 0) { | |
244 + gint newpos = 0; | |
245 + if (off < 0) newpos = song_pos_cur - 1; | |
246 + else if (off > 0) newpos = song_pos_cur + 1; | |
247 + if (newpos < song_pos_first) newpos = song_pos_first; | |
248 + if (newpos > song_pos_first + song_pos_num) | |
249 + newpos = song_pos_first + song_pos_num; | |
250 + input_seek(newpos); | |
251 + } else { | |
252 + gint newpos = (input_get_time() / 1000) + (off / 1000); | |
253 + gint pcl = playlist_get_current_length() / 1000; | |
254 + if (newpos >= pcl) newpos = pcl - 1; | |
255 + if (newpos < 0) newpos = 0; | |
256 + input_seek(newpos); | |
257 + } | |
258 +} | |
259 + | |
260 gchar *xmms_get_gentitle_format(void) | |
261 { | |
262 return cfg.gentitle_format; | |
263 @@ -748,7 +797,9 @@ | |
264 show_widget(mainwin_stime_min); | |
265 show_widget(mainwin_stime_sec); | |
266 | |
267 - if (get_input_playing() && playlist_get_current_length() != -1) | |
268 + if (get_input_playing() && | |
269 + ((playlist_get_current_length() != -1) || | |
270 + (song_pos_num > 0))) | |
271 show_widget(mainwin_sposition); | |
272 | |
273 mainwin_shade->pb_ny = mainwin_shade->pb_py = 27; | |
274 @@ -1065,7 +1116,7 @@ | |
275 show_widget(mainwin_10sec_num); | |
276 show_widget(mainwin_sec_num); | |
277 playstatus_set_status(mainwin_playstatus, STATUS_PLAY); | |
278 - if (playlist_get_current_length() != -1) | |
279 + if ((playlist_get_current_length() != -1) || (song_pos_num > 0)) | |
280 { | |
281 if (cfg.player_shaded) | |
282 show_widget(mainwin_sposition); | |
283 @@ -1308,13 +1359,19 @@ | |
284 break; | |
285 case GDK_Left: | |
286 case GDK_KP_Left: | |
287 +/* | |
288 if(playlist_get_current_length() != -1) | |
289 input_seek(CLAMP(input_get_time() - 5000, 0, playlist_get_current_length()) / 1000); | |
290 +*/ | |
291 + song_seek(-5000); | |
292 break; | |
293 case GDK_Right: | |
294 case GDK_KP_Right: | |
295 +/* | |
296 if(playlist_get_current_length() != -1) | |
297 input_seek(CLAMP(input_get_time() + 5000, 0, playlist_get_current_length()) / 1000); | |
298 +*/ | |
299 + song_seek(+5000); | |
300 break; | |
301 default: | |
302 break; | |
303 @@ -1939,6 +1996,16 @@ | |
304 | |
305 pos--; | |
306 | |
307 + if (song_pos_num > 0) { | |
308 + time = ((song_pos_num * pos + 6) / 12) + song_pos_first; | |
309 + tmp = g_strdup_printf("%d", time); | |
310 + textbox_set_text(mainwin_stime_min, tmp); | |
311 + g_free(tmp); | |
312 + tmp = g_strdup_printf("%d", song_pos_first + song_pos_num); | |
313 + textbox_set_text(mainwin_stime_sec, tmp); | |
314 + g_free(tmp); | |
315 + return; | |
316 + } | |
317 time = ((playlist_get_current_length() / 1000) * pos) / 12; | |
318 if (cfg.timer_mode == TIMER_REMAINING) | |
319 { | |
320 @@ -1960,6 +2027,10 @@ | |
321 | |
322 void mainwin_spos_release_cb(gint pos) | |
323 { | |
324 + if (song_pos_num > 0) { | |
325 + input_seek(((song_pos_num * (pos - 1) + 6) / 12) + song_pos_first); | |
326 + return; | |
327 + } | |
328 input_seek(((playlist_get_current_length() / 1000) * (pos - 1)) / 12); | |
329 } | |
330 | |
331 @@ -1968,6 +2039,14 @@ | |
332 gint length, time; | |
333 gchar *buf; | |
334 | |
335 + if (song_pos_num > 0) { | |
336 + time = ((song_pos_num * pos + 110) / 219) + song_pos_first; | |
337 + buf = g_strdup_printf("JUMP TO: %d/%d", time, | |
338 + song_pos_num + song_pos_first); | |
339 + mainwin_lock_info_text(buf); | |
340 + g_free(buf); | |
341 + return; | |
342 + } | |
343 length = playlist_get_current_length() / 1000; | |
344 time = (length * pos) / 219; | |
345 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); | |
346 @@ -1979,6 +2058,12 @@ | |
347 { | |
348 int length, time; | |
349 | |
350 + if (song_pos_num > 0) { | |
351 + time = ((song_pos_num * pos + 110) / 219) + song_pos_first; | |
352 + input_seek(time); | |
353 + mainwin_release_info_text(); | |
354 + return; | |
355 + } | |
356 length = playlist_get_current_length() / 1000; | |
357 time = (length * pos) / 219; | |
358 input_seek(time); | |
359 @@ -2382,12 +2467,10 @@ | |
360 case MAINWIN_GENERAL_STOPFADE: | |
361 break; | |
362 case MAINWIN_GENERAL_BACK5SEC: | |
363 - if (get_input_playing() && playlist_get_current_length() != -1) | |
364 - input_seek((((input_get_time() / 1000) - 5 >= 0) ? (input_get_time() / 1000) - 5 : 0)); | |
365 + song_seek(-5000); | |
366 break; | |
367 case MAINWIN_GENERAL_FWD5SEC: | |
368 - if (get_input_playing() && playlist_get_current_length() != -1) | |
369 - input_seek(((((input_get_time() / 1000) + 5) < (playlist_get_current_length() / 1000)) ? ((input_get_time() / 1000) + 5) : ((playlist_get_current_length() / 1000) - 1))); | |
370 + song_seek(+5000); | |
371 break; | |
372 case MAINWIN_GENERAL_START: | |
373 playlist_set_position(0); | |
374 @@ -2981,7 +3064,7 @@ | |
375 hslider_set_position(mainwin_sposition, ((time * 12) / length) + 1); | |
376 } | |
377 } | |
378 - else | |
379 + else if (song_pos_num <= 0) | |
380 { | |
381 hslider_set_position(mainwin_position, 0); | |
382 hslider_set_position(mainwin_sposition, 1); | |
383 diff -r -u xmms-1.2.5/xmms/main.h xmms-1.2.5-patched/xmms/main.h | |
384 --- xmms-1.2.5/xmms/main.h Wed Mar 14 16:06:39 2001 | |
385 +++ xmms-1.2.5-patched/xmms/main.h Tue Jul 17 18:44:05 2001 | |
386 @@ -88,6 +88,7 @@ | |
387 void mainwin_play_pushed(void); | |
388 void mainwin_stop_pushed(void); | |
389 void mainwin_eject_pushed(void); | |
390 +void song_seek(gint off); | |
391 | |
392 void mainwin_set_back_pixmap(void); | |
393 | |
394 diff -r -u xmms-1.2.5/xmms/plugin.h xmms-1.2.5-patched/xmms/plugin.h | |
395 --- xmms-1.2.5/xmms/plugin.h Wed Mar 1 22:28:06 2000 | |
396 +++ xmms-1.2.5-patched/xmms/plugin.h Tue Jul 17 18:44:05 2001 | |
397 @@ -151,4 +151,6 @@ | |
398 void (*render_freq)(gint16 freq_data[2][256]); /* Render the freq data, don't do anything time consuming in here */ | |
399 } VisPlugin; | |
400 | |
401 +void set_song_position(int pos, int first, int last); | |
402 + | |
403 #endif |