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