Mercurial > hg > xmms-sid
comparison xmms-1.2.10-songpos.patch @ 155:52ad7e234a2c
Added songpos-patch
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 09 Mar 2004 21:11:05 +0000 |
parents | |
children | 773885f3b723 |
comparison
equal
deleted
inserted
replaced
154:995086002a8f | 155:52ad7e234a2c |
---|---|
1 diff -ur xmms-1.2.10/libxmms/xmmsctrl.c xmms-1.2.10-patched/libxmms/xmmsctrl.c | |
2 --- xmms-1.2.10/libxmms/xmmsctrl.c Mon Feb 23 22:31:42 2004 | |
3 +++ xmms-1.2.10-patched/libxmms/xmmsctrl.c Tue Mar 9 23:05:33 2004 | |
4 @@ -422,6 +422,11 @@ | |
5 remote_send_guint32(session, CMD_JUMP_TO_TIME, pos); | |
6 } | |
7 | |
8 +void xmms_remote_seek(gint session, gint off) | |
9 +{ | |
10 + remote_send_guint32(session, CMD_SEEK, off); | |
11 +} | |
12 + | |
13 void xmms_remote_get_volume(gint session, gint * vl, gint * vr) | |
14 { | |
15 ServerPktHeader pkt_hdr; | |
16 diff -ur xmms-1.2.10/libxmms/xmmsctrl.h xmms-1.2.10-patched/libxmms/xmmsctrl.h | |
17 --- xmms-1.2.10/libxmms/xmmsctrl.h Wed Jun 11 21:44:17 2003 | |
18 +++ xmms-1.2.10-patched/libxmms/xmmsctrl.h Tue Mar 9 23:05:33 2004 | |
19 @@ -42,6 +42,7 @@ | |
20 void xmms_remote_playlist_clear(gint session); | |
21 gint xmms_remote_get_output_time(gint session); | |
22 void xmms_remote_jump_to_time(gint session, gint pos); | |
23 +void xmms_remote_seek(gint session, gint off); | |
24 void xmms_remote_get_volume(gint session, gint * vl, gint * vr); | |
25 gint xmms_remote_get_main_volume(gint session); | |
26 gint xmms_remote_get_balance(gint session); | |
27 diff -ur xmms-1.2.10/xmms/controlsocket.c xmms-1.2.10-patched/xmms/controlsocket.c | |
28 --- xmms-1.2.10/xmms/controlsocket.c Mon Feb 23 22:31:43 2004 | |
29 +++ xmms-1.2.10-patched/xmms/controlsocket.c Tue Mar 9 23:05:33 2004 | |
30 @@ -502,6 +502,10 @@ | |
31 num < playlist_get_current_length()) | |
32 input_seek(num / 1000); | |
33 break; | |
34 + case CMD_SEEK: | |
35 + num = *((guint32 *) data); | |
36 + song_seek(num); | |
37 + break; | |
38 case CMD_SET_VOLUME: | |
39 v[0] = ((guint32 *) data)[0]; | |
40 v[1] = ((guint32 *) data)[1]; | |
41 Only in xmms-1.2.10-patched/xmms: controlsocket.c.orig | |
42 diff -ur xmms-1.2.10/xmms/controlsocket.h xmms-1.2.10-patched/xmms/controlsocket.h | |
43 --- xmms-1.2.10/xmms/controlsocket.h Wed Jun 11 21:44:17 2003 | |
44 +++ xmms-1.2.10-patched/xmms/controlsocket.h Tue Mar 9 23:05:33 2004 | |
45 @@ -33,7 +33,7 @@ | |
46 CMD_GET_VERSION, CMD_PLAYLIST_ADD, CMD_PLAY, CMD_PAUSE, CMD_STOP, | |
47 CMD_IS_PLAYING, CMD_IS_PAUSED, CMD_GET_PLAYLIST_POS, | |
48 CMD_SET_PLAYLIST_POS, CMD_GET_PLAYLIST_LENGTH, CMD_PLAYLIST_CLEAR, | |
49 - CMD_GET_OUTPUT_TIME, CMD_JUMP_TO_TIME, CMD_GET_VOLUME, | |
50 + CMD_GET_OUTPUT_TIME, CMD_JUMP_TO_TIME, CMD_SEEK, CMD_GET_VOLUME, | |
51 CMD_SET_VOLUME, CMD_GET_SKIN, CMD_SET_SKIN, CMD_GET_PLAYLIST_FILE, | |
52 CMD_GET_PLAYLIST_TITLE, CMD_GET_PLAYLIST_TIME, CMD_GET_INFO, | |
53 CMD_GET_EQ_DATA, CMD_SET_EQ_DATA, CMD_PL_WIN_TOGGLE, | |
54 diff -ur xmms-1.2.10/xmms/input.c xmms-1.2.10-patched/xmms/input.c | |
55 --- xmms-1.2.10/xmms/input.c Fri Aug 8 20:10:44 2003 | |
56 +++ xmms-1.2.10-patched/xmms/input.c Tue Mar 9 23:05:33 2004 | |
57 @@ -306,6 +306,7 @@ | |
58 } | |
59 } | |
60 ip_data->playing = FALSE; | |
61 + set_song_position(0, 0, 0); | |
62 } | |
63 | |
64 void input_pause(void) | |
65 diff -ur xmms-1.2.10/xmms/main.c xmms-1.2.10-patched/xmms/main.c | |
66 --- xmms-1.2.10/xmms/main.c Mon Feb 23 22:31:43 2004 | |
67 +++ xmms-1.2.10-patched/xmms/main.c Tue Mar 9 23:05:33 2004 | |
68 @@ -678,6 +678,55 @@ | |
69 g_free(filename); | |
70 } | |
71 | |
72 +/*\ | |
73 +|*| Separate song position stuff, for songs without a time length, | |
74 +|*| but that want to be able to seek anyway. | |
75 +|*| | |
76 +|*| Have the input plugin's get_time() function call | |
77 +|*| set_song_position(int pos, int first, int last) | |
78 +|*| to set the slider. If the slider is dragged, | |
79 +|*| the plugin's seek() is called with the position. | |
80 +|*| (If last <= first the feature is turned off) | |
81 +\*/ | |
82 + | |
83 +static int song_pos_cur, song_pos_first, song_pos_num = 0; | |
84 + | |
85 +void set_song_position(int pos, int first, int last) | |
86 +{ | |
87 + last -= first; | |
88 + song_pos_cur = pos; | |
89 + song_pos_first = first; | |
90 + song_pos_num = last; | |
91 + if (last <= 0) return; | |
92 + pos -= first; | |
93 + if (pos > last) pos = last; | |
94 + if (cfg.player_shaded) | |
95 + show_widget(mainwin_sposition); | |
96 + show_widget(mainwin_position); | |
97 + hslider_set_position(mainwin_position, (pos * 219) / last); | |
98 + hslider_set_position(mainwin_sposition, ((pos * 12) / last) + 1); | |
99 +} | |
100 + | |
101 +void song_seek(gint off) | |
102 +{ | |
103 + if (!get_input_playing()) return; | |
104 + if (song_pos_num > 0) { | |
105 + gint newpos = 0; | |
106 + if (off < 0) newpos = song_pos_cur - 1; | |
107 + else if (off > 0) newpos = song_pos_cur + 1; | |
108 + if (newpos < song_pos_first) newpos = song_pos_first; | |
109 + if (newpos > song_pos_first + song_pos_num) | |
110 + newpos = song_pos_first + song_pos_num; | |
111 + input_seek(newpos); | |
112 + } else { | |
113 + gint newpos = (input_get_time() / 1000) + (off / 1000); | |
114 + gint pcl = playlist_get_current_length() / 1000; | |
115 + if (newpos >= pcl) newpos = pcl - 1; | |
116 + if (newpos < 0) newpos = 0; | |
117 + input_seek(newpos); | |
118 + } | |
119 +} | |
120 + | |
121 gchar *xmms_get_gentitle_format(void) | |
122 { | |
123 return cfg.gentitle_format; | |
124 @@ -757,7 +806,9 @@ | |
125 show_widget(mainwin_stime_min); | |
126 show_widget(mainwin_stime_sec); | |
127 | |
128 - if (get_input_playing() && playlist_get_current_length() != -1) | |
129 + if (get_input_playing() && | |
130 + ((playlist_get_current_length() != -1) || | |
131 + (song_pos_num > 0))) | |
132 show_widget(mainwin_sposition); | |
133 | |
134 mainwin_shade->pb_ny = mainwin_shade->pb_py = 27; | |
135 @@ -1079,7 +1130,7 @@ | |
136 show_widget(mainwin_sec_num); | |
137 if (!get_input_paused()) | |
138 playstatus_set_status(mainwin_playstatus, STATUS_PLAY); | |
139 - if (playlist_get_current_length() != -1) | |
140 + if ((playlist_get_current_length() != -1) || (song_pos_num > 0)) | |
141 { | |
142 if (cfg.player_shaded) | |
143 show_widget(mainwin_sposition); | |
144 @@ -1398,13 +1449,19 @@ | |
145 break; | |
146 case GDK_Left: | |
147 case GDK_KP_Left: | |
148 +/* | |
149 if(playlist_get_current_length() != -1) | |
150 input_seek(CLAMP(input_get_time() - 5000, 0, playlist_get_current_length()) / 1000); | |
151 +*/ | |
152 + song_seek(-5000); | |
153 break; | |
154 case GDK_Right: | |
155 case GDK_KP_Right: | |
156 +/* | |
157 if(playlist_get_current_length() != -1) | |
158 input_seek(CLAMP(input_get_time() + 5000, 0, playlist_get_current_length()) / 1000); | |
159 +*/ | |
160 + song_seek(+5000); | |
161 break; | |
162 default: | |
163 break; | |
164 @@ -2084,6 +2141,16 @@ | |
165 | |
166 pos--; | |
167 | |
168 + if (song_pos_num > 0) { | |
169 + time = ((song_pos_num * pos + 6) / 12) + song_pos_first; | |
170 + tmp = g_strdup_printf("%d", time); | |
171 + textbox_set_text(mainwin_stime_min, tmp); | |
172 + g_free(tmp); | |
173 + tmp = g_strdup_printf("%d", song_pos_first + song_pos_num); | |
174 + textbox_set_text(mainwin_stime_sec, tmp); | |
175 + g_free(tmp); | |
176 + return; | |
177 + } | |
178 time = ((playlist_get_current_length() / 1000) * pos) / 12; | |
179 if (cfg.timer_mode == TIMER_REMAINING) | |
180 { | |
181 @@ -2105,6 +2172,10 @@ | |
182 | |
183 void mainwin_spos_release_cb(gint pos) | |
184 { | |
185 + if (song_pos_num > 0) { | |
186 + input_seek(((song_pos_num * (pos - 1) + 6) / 12) + song_pos_first); | |
187 + return; | |
188 + } | |
189 input_seek(((playlist_get_current_length() / 1000) * (pos - 1)) / 12); | |
190 } | |
191 | |
192 @@ -2113,6 +2184,14 @@ | |
193 gint length, time; | |
194 gchar *buf; | |
195 | |
196 + if (song_pos_num > 0) { | |
197 + time = ((song_pos_num * pos + 110) / 219) + song_pos_first; | |
198 + buf = g_strdup_printf("JUMP TO: %d/%d", time, | |
199 + song_pos_num + song_pos_first); | |
200 + mainwin_lock_info_text(buf); | |
201 + g_free(buf); | |
202 + return; | |
203 + } | |
204 length = playlist_get_current_length() / 1000; | |
205 time = (length * pos) / 219; | |
206 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); | |
207 @@ -2124,6 +2203,12 @@ | |
208 { | |
209 int length, time; | |
210 | |
211 + if (song_pos_num > 0) { | |
212 + time = ((song_pos_num * pos + 110) / 219) + song_pos_first; | |
213 + input_seek(time); | |
214 + mainwin_release_info_text(); | |
215 + return; | |
216 + } | |
217 length = playlist_get_current_length() / 1000; | |
218 time = (length * pos) / 219; | |
219 input_seek(time); | |
220 @@ -2530,12 +2615,10 @@ | |
221 case MAINWIN_GENERAL_STOPFADE: | |
222 break; | |
223 case MAINWIN_GENERAL_BACK5SEC: | |
224 - if (get_input_playing() && playlist_get_current_length() != -1) | |
225 - input_seek((((input_get_time() / 1000) - 5 >= 0) ? (input_get_time() / 1000) - 5 : 0)); | |
226 + song_seek(-5000); | |
227 break; | |
228 case MAINWIN_GENERAL_FWD5SEC: | |
229 - if (get_input_playing() && playlist_get_current_length() != -1) | |
230 - input_seek(((((input_get_time() / 1000) + 5) < (playlist_get_current_length() / 1000)) ? ((input_get_time() / 1000) + 5) : ((playlist_get_current_length() / 1000) - 1))); | |
231 + song_seek(+5000); | |
232 break; | |
233 case MAINWIN_GENERAL_START: | |
234 playlist_set_position(0); | |
235 @@ -3147,7 +3230,7 @@ | |
236 hslider_set_position(mainwin_sposition, ((time * 12) / length) + 1); | |
237 } | |
238 } | |
239 - else | |
240 + else if (song_pos_num <= 0) | |
241 { | |
242 hslider_set_position(mainwin_position, 0); | |
243 hslider_set_position(mainwin_sposition, 1); | |
244 Only in xmms-1.2.10-patched/xmms: main.c.orig | |
245 diff -ur xmms-1.2.10/xmms/main.h xmms-1.2.10-patched/xmms/main.h | |
246 --- xmms-1.2.10/xmms/main.h Sun Dec 7 04:06:43 2003 | |
247 +++ xmms-1.2.10-patched/xmms/main.h Tue Mar 9 23:05:33 2004 | |
248 @@ -85,6 +85,7 @@ | |
249 void mainwin_play_pushed(void); | |
250 void mainwin_stop_pushed(void); | |
251 void mainwin_eject_pushed(void); | |
252 +void song_seek(gint off); | |
253 | |
254 void mainwin_set_back_pixmap(void); | |
255 | |
256 diff -ur xmms-1.2.10/xmms/plugin.h xmms-1.2.10-patched/xmms/plugin.h | |
257 --- xmms-1.2.10/xmms/plugin.h Fri Jul 6 01:35:01 2001 | |
258 +++ xmms-1.2.10-patched/xmms/plugin.h Tue Mar 9 23:05:33 2004 | |
259 @@ -154,4 +154,6 @@ | |
260 void (*render_freq)(gint16 freq_data[2][256]); /* Render the freq data, don't do anything time consuming in here */ | |
261 } VisPlugin; | |
262 | |
263 +void set_song_position(int pos, int first, int last); | |
264 + | |
265 #endif |