Mercurial > hg > xmms-sid
comparison xmms-songpos.patch-1.2.2 @ 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.2/General/ir/ir.c xmms-1.2.2-songpos/General/ir/ir.c | |
2 --- xmms-1.2.2/General/ir/ir.c Wed Mar 1 15:13:49 2000 | |
3 +++ xmms-1.2.2-songpos/General/ir/ir.c Sat Nov 11 18:23:55 2000 | |
4 @@ -288,12 +288,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 @@ -301,10 +296,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.2/General/joystick/joy.c xmms-1.2.2-songpos/General/joystick/joy.c | |
31 --- xmms-1.2.2/General/joystick/joy.c Wed Mar 1 15:13:49 2000 | |
32 +++ xmms-1.2.2-songpos/General/joystick/joy.c Sat Nov 11 18:23:55 2000 | |
33 @@ -316,18 +316,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.2/Input/mikmod/plugin.c xmms-1.2.2-songpos/Input/mikmod/plugin.c | |
55 --- xmms-1.2.2/Input/mikmod/plugin.c Sun Feb 6 14:52:58 2000 | |
56 +++ xmms-1.2.2-songpos/Input/mikmod/plugin.c Sat Nov 11 18:23:55 2000 | |
57 @@ -189,15 +189,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 @@ -213,6 +206,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.2/libxmms/xmmsctrl.c xmms-1.2.2-songpos/libxmms/xmmsctrl.c | |
84 --- xmms-1.2.2/libxmms/xmmsctrl.c Wed Jun 21 15:29:29 2000 | |
85 +++ xmms-1.2.2-songpos/libxmms/xmmsctrl.c Sat Nov 11 18:23:55 2000 | |
86 @@ -365,6 +365,11 @@ | |
87 remote_send_guint32(session, CMD_JUMP_TO_TIME, pos); | |
88 } | |
89 | |
90 +void xmms_remote_seek(gint session, gint off) | |
91 +{ | |
92 + remote_send_guint32(session, CMD_SEEK, off); | |
93 +} | |
94 + | |
95 void xmms_remote_get_volume(gint session, gint * vl, gint * vr) | |
96 { | |
97 ServerPktHeader pkt_hdr; | |
98 diff -r -u xmms-1.2.2/libxmms/xmmsctrl.h xmms-1.2.2-songpos/libxmms/xmmsctrl.h | |
99 --- xmms-1.2.2/libxmms/xmmsctrl.h Mon Jun 19 15:25:09 2000 | |
100 +++ xmms-1.2.2-songpos/libxmms/xmmsctrl.h Sat Nov 11 18:23:55 2000 | |
101 @@ -40,6 +40,7 @@ | |
102 void xmms_remote_playlist_clear(gint session); | |
103 gint xmms_remote_get_output_time(gint session); | |
104 void xmms_remote_jump_to_time(gint session, gint pos); | |
105 +void xmms_remote_seek(gint session, gint off); | |
106 void xmms_remote_get_volume(gint session, gint * vl, gint * vr); | |
107 gint xmms_remote_get_main_volume(gint session); | |
108 gint xmms_remote_get_balance(gint session); | |
109 diff -r -u xmms-1.2.2/xmms/controlsocket.c xmms-1.2.2-songpos/xmms/controlsocket.c | |
110 --- xmms-1.2.2/xmms/controlsocket.c Sat Jul 8 17:35:12 2000 | |
111 +++ xmms-1.2.2-songpos/xmms/controlsocket.c Sat Nov 11 18:27:16 2000 | |
112 @@ -445,6 +445,10 @@ | |
113 if (num <= playlist_get_current_length()) | |
114 input_seek(num / 1000); | |
115 break; | |
116 + case CMD_SEEK: | |
117 + num = *((guint32 *) data); | |
118 + song_seek(num); | |
119 + break; | |
120 case CMD_SET_VOLUME: | |
121 v[0] = ((guint32 *) data)[0]; | |
122 v[1] = ((guint32 *) data)[1]; | |
123 diff -r -u xmms-1.2.2/xmms/controlsocket.h xmms-1.2.2-songpos/xmms/controlsocket.h | |
124 --- xmms-1.2.2/xmms/controlsocket.h Mon Jun 19 15:25:14 2000 | |
125 +++ xmms-1.2.2-songpos/xmms/controlsocket.h Sat Nov 11 18:23:55 2000 | |
126 @@ -31,7 +31,7 @@ | |
127 CMD_GET_VERSION, CMD_PLAYLIST_ADD, CMD_PLAY, CMD_PAUSE, CMD_STOP, | |
128 CMD_IS_PLAYING, CMD_IS_PAUSED, CMD_GET_PLAYLIST_POS, | |
129 CMD_SET_PLAYLIST_POS, CMD_GET_PLAYLIST_LENGTH, CMD_PLAYLIST_CLEAR, | |
130 - CMD_GET_OUTPUT_TIME, CMD_JUMP_TO_TIME, CMD_GET_VOLUME, | |
131 + CMD_GET_OUTPUT_TIME, CMD_JUMP_TO_TIME, CMD_SEEK, CMD_GET_VOLUME, | |
132 CMD_SET_VOLUME, CMD_GET_SKIN, CMD_SET_SKIN, CMD_GET_PLAYLIST_FILE, | |
133 CMD_GET_PLAYLIST_TITLE, CMD_GET_PLAYLIST_TIME, CMD_GET_INFO, | |
134 CMD_GET_EQ_DATA, CMD_SET_EQ_DATA, CMD_PL_WIN_TOGGLE, | |
135 diff -r -u xmms-1.2.2/xmms/input.c xmms-1.2.2-songpos/xmms/input.c | |
136 --- xmms-1.2.2/xmms/input.c Wed Feb 16 23:05:57 2000 | |
137 +++ xmms-1.2.2-songpos/xmms/input.c Sat Nov 11 18:28:47 2000 | |
138 @@ -281,6 +281,7 @@ | |
139 } | |
140 } | |
141 ip_data->playing = FALSE; | |
142 + set_song_position(0, 0, 0); | |
143 } | |
144 | |
145 void input_pause(void) | |
146 diff -r -u xmms-1.2.2/xmms/main.c xmms-1.2.2-songpos/xmms/main.c | |
147 --- xmms-1.2.2/xmms/main.c Tue Jul 11 19:11:14 2000 | |
148 +++ xmms-1.2.2-songpos/xmms/main.c Sat Nov 11 18:32:36 2000 | |
149 @@ -614,6 +614,55 @@ | |
150 g_free(filename); | |
151 } | |
152 | |
153 +/*\ | |
154 +|*| Separate song position stuff, for songs without a time length, | |
155 +|*| but that want to be able to seek anyway. | |
156 +|*| | |
157 +|*| Have the input plugin's get_time() function call | |
158 +|*| set_song_position(int pos, int first, int last) | |
159 +|*| to set the slider. If the slider is dragged, | |
160 +|*| the plugin's seek() is called with the position. | |
161 +|*| (If last <= first the feature is turned off) | |
162 +\*/ | |
163 + | |
164 +static int song_pos_cur, song_pos_first, song_pos_num = 0; | |
165 + | |
166 +void set_song_position(int pos, int first, int last) | |
167 +{ | |
168 + last -= first; | |
169 + song_pos_cur = pos; | |
170 + song_pos_first = first; | |
171 + song_pos_num = last; | |
172 + if (last <= 0) return; | |
173 + pos -= first; | |
174 + if (pos > last) pos = last; | |
175 + if (cfg.player_shaded) | |
176 + show_widget(mainwin_sposition); | |
177 + show_widget(mainwin_position); | |
178 + hslider_set_position(mainwin_position, (pos * 219) / last); | |
179 + hslider_set_position(mainwin_sposition, ((pos * 12) / last) + 1); | |
180 +} | |
181 + | |
182 +void song_seek(gint off) | |
183 +{ | |
184 + if (!get_input_playing()) return; | |
185 + if (song_pos_num > 0) { | |
186 + gint newpos; | |
187 + if (off < 0) newpos = song_pos_cur - 1; | |
188 + else if (off > 0) newpos = song_pos_cur + 1; | |
189 + if (newpos < song_pos_first) newpos = song_pos_first; | |
190 + if (newpos > song_pos_first + song_pos_num) | |
191 + newpos = song_pos_first + song_pos_num; | |
192 + input_seek(newpos); | |
193 + } else { | |
194 + gint newpos = (input_get_time() / 1000) + (off / 1000); | |
195 + gint pcl = playlist_get_current_length() / 1000; | |
196 + if (newpos >= pcl) newpos = pcl - 1; | |
197 + if (newpos < 0) newpos = 0; | |
198 + input_seek(newpos); | |
199 + } | |
200 +} | |
201 + | |
202 void mainwin_set_always_on_top(gboolean always) | |
203 { | |
204 cfg.always_on_top = always; | |
205 @@ -680,7 +729,9 @@ | |
206 show_widget(mainwin_stime_min); | |
207 show_widget(mainwin_stime_sec); | |
208 | |
209 - if (get_input_playing() && playlist_get_current_length() != -1) | |
210 + if (get_input_playing() && | |
211 + ((playlist_get_current_length() != -1) || | |
212 + (song_pos_num > 0))) | |
213 show_widget(mainwin_sposition); | |
214 | |
215 mainwin_shade->pb_ny = mainwin_shade->pb_py = 27; | |
216 @@ -987,7 +1038,7 @@ | |
217 show_widget(mainwin_10sec_num); | |
218 show_widget(mainwin_sec_num); | |
219 playstatus_set_status(mainwin_playstatus, STATUS_PLAY); | |
220 - if (playlist_get_current_length() != -1) | |
221 + if ((playlist_get_current_length() != -1) || (song_pos_num > 0)) | |
222 { | |
223 if (cfg.player_shaded) | |
224 show_widget(mainwin_sposition); | |
225 @@ -1217,13 +1268,19 @@ | |
226 break; | |
227 case GDK_Left: | |
228 case GDK_KP_Left: | |
229 +/* | |
230 if(playlist_get_current_length() != -1) | |
231 input_seek(CLAMP(input_get_time() - 5000, 0, playlist_get_current_length()) / 1000); | |
232 +*/ | |
233 + song_seek(-5000); | |
234 break; | |
235 case GDK_Right: | |
236 case GDK_KP_Right: | |
237 +/* | |
238 if(playlist_get_current_length() != -1) | |
239 input_seek(CLAMP(input_get_time() + 5000, 0, playlist_get_current_length()) / 1000); | |
240 +*/ | |
241 + song_seek(+5000); | |
242 break; | |
243 default: | |
244 break; | |
245 @@ -1805,6 +1862,16 @@ | |
246 | |
247 pos--; | |
248 | |
249 + if (song_pos_num > 0) { | |
250 + time = ((song_pos_num * pos + 6) / 12) + song_pos_first; | |
251 + tmp = g_strdup_printf("%d", time); | |
252 + textbox_set_text(mainwin_stime_min, tmp); | |
253 + g_free(tmp); | |
254 + tmp = g_strdup_printf("%d", song_pos_first + song_pos_num); | |
255 + textbox_set_text(mainwin_stime_sec, tmp); | |
256 + g_free(tmp); | |
257 + return; | |
258 + } | |
259 time = ((playlist_get_current_length() / 1000) * pos) / 12; | |
260 if (cfg.timer_mode == TIMER_REMAINING) | |
261 { | |
262 @@ -1826,6 +1893,10 @@ | |
263 | |
264 void mainwin_spos_release_cb(gint pos) | |
265 { | |
266 + if (song_pos_num > 0) { | |
267 + input_seek(((song_pos_num * (pos - 1) + 6) / 12) + song_pos_first); | |
268 + return; | |
269 + } | |
270 input_seek(((playlist_get_current_length() / 1000) * (pos - 1)) / 12); | |
271 } | |
272 | |
273 @@ -1834,6 +1905,14 @@ | |
274 gint length, time; | |
275 gchar *buf; | |
276 | |
277 + if (song_pos_num > 0) { | |
278 + time = ((song_pos_num * pos + 110) / 219) + song_pos_first; | |
279 + buf = g_strdup_printf("JUMP TO: %d/%d", time, | |
280 + song_pos_num + song_pos_first); | |
281 + mainwin_lock_info_text(buf); | |
282 + g_free(buf); | |
283 + return; | |
284 + } | |
285 length = playlist_get_current_length() / 1000; | |
286 time = (length * pos) / 219; | |
287 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); | |
288 @@ -1845,6 +1924,12 @@ | |
289 { | |
290 int length, time; | |
291 | |
292 + if (song_pos_num > 0) { | |
293 + time = ((song_pos_num * pos + 110) / 219) + song_pos_first; | |
294 + input_seek(time); | |
295 + mainwin_release_info_text(); | |
296 + return; | |
297 + } | |
298 length = playlist_get_current_length() / 1000; | |
299 time = (length * pos) / 219; | |
300 input_seek(time); | |
301 @@ -2236,12 +2321,18 @@ | |
302 case MAINWIN_GENERAL_STOPFADE: | |
303 break; | |
304 case MAINWIN_GENERAL_BACK5SEC: | |
305 +/* | |
306 if (get_input_playing() && playlist_get_current_length() != -1) | |
307 input_seek((((input_get_time() / 1000) - 5 >= 0) ? (input_get_time() / 1000) - 5 : 0)); | |
308 +*/ | |
309 + song_seek(-5000); | |
310 break; | |
311 case MAINWIN_GENERAL_FWD5SEC: | |
312 +/* | |
313 if (get_input_playing() && playlist_get_current_length() != -1) | |
314 input_seek(((((input_get_time() / 1000) + 5) < (playlist_get_current_length() / 1000)) ? ((input_get_time() / 1000) + 5) : ((playlist_get_current_length() / 1000) - 1))); | |
315 +*/ | |
316 + song_seek(+5000); | |
317 break; | |
318 case MAINWIN_GENERAL_START: | |
319 playlist_set_position(0); | |
320 @@ -2801,7 +2892,7 @@ | |
321 hslider_set_position(mainwin_sposition, ((time * 12) / length) + 1); | |
322 } | |
323 } | |
324 - else | |
325 + else if (song_pos_num <= 0) | |
326 { | |
327 hslider_set_position(mainwin_position, 0); | |
328 hslider_set_position(mainwin_sposition, 1); | |
329 diff -r -u xmms-1.2.2/xmms/main.h xmms-1.2.2-songpos/xmms/main.h | |
330 --- xmms-1.2.2/xmms/main.h Fri Jul 7 19:18:26 2000 | |
331 +++ xmms-1.2.2-songpos/xmms/main.h Sat Nov 11 18:23:55 2000 | |
332 @@ -82,6 +82,7 @@ | |
333 void mainwin_play_pushed(void); | |
334 void mainwin_stop_pushed(void); | |
335 void mainwin_eject_pushed(void); | |
336 +void song_seek(gint off); | |
337 | |
338 void mainwin_set_back_pixmap(void); | |
339 | |
340 diff -r -u xmms-1.2.2/xmms/plugin.h xmms-1.2.2-songpos/xmms/plugin.h | |
341 --- xmms-1.2.2/xmms/plugin.h Wed Mar 1 22:28:06 2000 | |
342 +++ xmms-1.2.2-songpos/xmms/plugin.h Sat Nov 11 18:23:55 2000 | |
343 @@ -151,4 +151,6 @@ | |
344 void (*render_freq)(gint16 freq_data[2][256]); /* Render the freq data, don't do anything time consuming in here */ | |
345 } VisPlugin; | |
346 | |
347 +void set_song_position(int pos, int first, int last); | |
348 + | |
349 #endif |