Mercurial > audlegacy
annotate src/audacious/auddrct.c @ 4539:8c2a166168dd
Fix a theoretical infinite loop: if plugin matches a mime-type, but probe
function does not recognize contents, input probing gets into a infinite loop.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 11 May 2008 01:40:50 +0300 |
parents | de1f750f6152 |
children | 26209b646930 |
rev | line source |
---|---|
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
1 /* |
2892
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
2 * Audacious: A cross-platform multimedia player |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
3 * Copyright (c) 2007 Giacomo Lozito |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
4 * |
2892
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2892
diff
changeset
|
7 * the Free Software Foundation; under version 3 of the License. |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
8 * |
2892
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, |
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
12 * GNU General Public License for more details. |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
13 * |
2892
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2892
diff
changeset
|
15 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
16 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
17 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
18 * Audacious or using our public API to be a derived work. |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
19 */ |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
20 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
21 /* audacious_drct_* provides a handy interface for player |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
22 plugins, originally intended for migration from xmms_remote_* calls */ |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
23 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
24 |
2743 | 25 #include "main.h" |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
26 #include "input.h" |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
27 #include "playback.h" |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
28 #include "ui_main.h" |
2743 | 29 #include "ui_playlist.h" |
30 #include "ui_equalizer.h" | |
2745 | 31 #include "ui_jumptotrack.h" |
2760 | 32 #include "auddrct.h" |
2775 | 33 #include "playlist.h" |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
34 |
2742 | 35 /* player */ |
36 | |
37 void | |
3753 | 38 drct_quit ( void ) |
2742 | 39 { |
4449
19e3f3c5fe7f
introduce function aud_quit(), which is basically mainwin_quit_cb(), but
mf0102 <0102@gmx.at>
parents:
4413
diff
changeset
|
40 aud_quit(); |
2742 | 41 } |
42 | |
43 void | |
3753 | 44 drct_eject ( void ) |
2742 | 45 { |
46 if (has_x11_connection) | |
47 mainwin_eject_pushed(); | |
48 return; | |
49 } | |
50 | |
2745 | 51 void |
3753 | 52 drct_jtf_show ( void ) |
2745 | 53 { |
54 if (has_x11_connection) | |
55 ui_jump_to_track(); | |
56 return; | |
57 } | |
58 | |
2742 | 59 gboolean |
3753 | 60 drct_main_win_is_visible ( void ) |
2742 | 61 { |
62 return cfg.player_visible; | |
63 } | |
64 | |
65 void | |
3753 | 66 drct_main_win_toggle ( gboolean show ) |
2742 | 67 { |
68 if (has_x11_connection) | |
69 mainwin_show(show); | |
70 return; | |
71 } | |
72 | |
73 gboolean | |
3753 | 74 drct_eq_win_is_visible ( void ) |
2742 | 75 { |
76 return cfg.equalizer_visible; | |
77 } | |
78 | |
79 void | |
3753 | 80 drct_eq_win_toggle ( gboolean show ) |
2742 | 81 { |
82 if (has_x11_connection) | |
83 equalizerwin_show(show); | |
84 return; | |
85 } | |
86 | |
87 gboolean | |
3753 | 88 drct_pl_win_is_visible ( void ) |
2742 | 89 { |
90 return cfg.playlist_visible; | |
91 } | |
92 | |
93 void | |
3753 | 94 drct_pl_win_toggle ( gboolean show ) |
2742 | 95 { |
96 if (has_x11_connection) { | |
97 if (show) | |
98 playlistwin_show(); | |
99 else | |
100 playlistwin_hide(); | |
101 } | |
102 return; | |
103 } | |
104 | |
3753 | 105 void drct_activate(void) |
2785 | 106 { |
107 gtk_window_present(GTK_WINDOW(mainwin)); | |
108 } | |
2742 | 109 |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
110 /* playback */ |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
111 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
112 void |
3753 | 113 drct_play ( void ) |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
114 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
115 if (playback_get_paused()) |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
116 playback_pause(); |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
117 else if (playlist_get_length(playlist_get_active())) |
4026
17bf734f8187
avoid crash when audacious is launched with -p option.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3753
diff
changeset
|
118 event_queue("playback initiate", (gpointer)0xdeadbeef); // to avoid crash at startup. --yaz |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
119 else |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
120 mainwin_eject_pushed(); |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
121 return; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
122 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
123 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
124 void |
3753 | 125 drct_pause ( void ) |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
126 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
127 playback_pause(); |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
128 return; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
129 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
130 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
131 void |
3753 | 132 drct_stop ( void ) |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
133 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
134 ip_data.stop = TRUE; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
135 playback_stop(); |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
136 ip_data.stop = FALSE; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
137 mainwin_clear_song_info(); |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
138 return; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
139 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
140 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
141 gboolean |
3753 | 142 drct_get_playing ( void ) |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
143 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
144 return playback_get_playing(); |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
145 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
146 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
147 gboolean |
3753 | 148 drct_get_paused ( void ) |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
149 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
150 return playback_get_paused(); |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
151 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
152 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
153 gboolean |
3753 | 154 drct_get_stopped ( void ) |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
155 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
156 return !playback_get_playing(); |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
157 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
158 |
2748 | 159 void |
3753 | 160 drct_get_info( gint *rate, gint *freq, gint *nch) |
2748 | 161 { |
162 playback_get_sample_params(rate, freq, nch); | |
163 } | |
164 | |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
165 gint |
3753 | 166 drct_get_time ( void ) |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
167 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
168 gint time; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
169 if (playback_get_playing()) |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
170 time = playback_get_time(); |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
171 else |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
172 time = 0; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
173 return time; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
174 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
175 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
176 void |
3753 | 177 drct_seek ( guint pos ) |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
178 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
179 if (playlist_get_current_length(playlist_get_active()) > 0 && |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
180 pos < (guint)playlist_get_current_length(playlist_get_active())) |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
181 playback_seek(pos / 1000); |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
182 return; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
183 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
184 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
185 void |
3753 | 186 drct_get_volume ( gint *vl, gint *vr ) |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
187 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
188 input_get_volume(vl, vr); |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
189 return; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
190 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
191 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
192 void |
3753 | 193 drct_set_volume ( gint vl, gint vr ) |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
194 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
195 if (vl > 100) |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
196 vl = 100; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
197 if (vr > 100) |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
198 vr = 100; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
199 input_set_volume(vl, vr); |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
200 return; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
201 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
202 |
2760 | 203 void |
3753 | 204 drct_get_volume_main( gint *v ) |
2760 | 205 { |
206 gint vl, vr; | |
3753 | 207 drct_get_volume(&vl, &vr); |
2760 | 208 *v = (vl > vr) ? vl : vr; |
209 return; | |
210 } | |
211 | |
212 void | |
3753 | 213 drct_set_volume_main ( gint v ) |
2760 | 214 { |
215 gint b, vl, vr; | |
3753 | 216 drct_get_volume_balance(&b); |
2760 | 217 if (b < 0) { |
218 vl = v; | |
219 vr = (v * (100 - abs(b))) / 100; | |
220 } | |
221 else if (b > 0) { | |
222 vl = (v * (100 - b)) / 100; | |
223 vr = v; | |
224 } | |
225 else | |
226 vl = vr = v; | |
3753 | 227 drct_set_volume(vl, vr); |
2760 | 228 } |
229 | |
230 void | |
3753 | 231 drct_get_volume_balance ( gint *b ) |
2760 | 232 { |
233 gint vl, vr; | |
234 input_get_volume(&vl, &vr); | |
235 if (vl < 0 || vr < 0) | |
236 *b = 0; | |
237 else if (vl > vr) | |
238 *b = -100 + ((vr * 100) / vl); | |
239 else if (vr > vl) | |
240 *b = 100 - ((vl * 100) / vr); | |
241 else | |
242 *b = 0; | |
243 return; | |
244 } | |
245 | |
246 void | |
3753 | 247 drct_set_volume_balance ( gint b ) |
2760 | 248 { |
249 gint v, vl, vr; | |
250 if (b < -100) | |
251 b = -100; | |
252 if (b > 100) | |
253 b = 100; | |
3753 | 254 drct_get_volume_main(&v); |
2760 | 255 if (b < 0) { |
256 vl = v; | |
257 vr = (v * (100 - abs(b))) / 100; | |
258 } | |
259 else if (b > 0) { | |
260 vl = (v * (100 - b)) / 100; | |
261 vr = v; | |
262 } | |
263 else | |
264 { | |
265 vl = v; | |
266 vr = v; | |
267 } | |
3753 | 268 drct_set_volume(vl, vr); |
2760 | 269 return; |
270 } | |
271 | |
2742 | 272 |
273 /* playlist */ | |
274 | |
275 void | |
3753 | 276 drct_pl_next ( void ) |
2742 | 277 { |
278 playlist_next(playlist_get_active()); | |
279 return; | |
280 } | |
281 | |
282 void | |
3753 | 283 drct_pl_prev ( void ) |
2742 | 284 { |
285 playlist_prev(playlist_get_active()); | |
286 return; | |
287 } | |
2745 | 288 |
289 gboolean | |
3753 | 290 drct_pl_repeat_is_enabled( void ) |
2745 | 291 { |
292 return cfg.repeat; | |
293 } | |
294 | |
295 void | |
3753 | 296 drct_pl_repeat_toggle( void ) |
2745 | 297 { |
298 mainwin_repeat_pushed(!cfg.repeat); | |
299 return; | |
300 } | |
301 | |
302 gboolean | |
3753 | 303 drct_pl_repeat_is_shuffled( void ) |
2745 | 304 { |
305 return cfg.shuffle; | |
306 } | |
307 | |
308 void | |
3753 | 309 drct_pl_shuffle_toggle( void ) |
2745 | 310 { |
311 mainwin_shuffle_pushed(!cfg.shuffle); | |
312 return; | |
313 } | |
2748 | 314 |
315 gchar * | |
3753 | 316 drct_pl_get_title( gint pos ) |
2748 | 317 { |
318 return playlist_get_songtitle(playlist_get_active(), pos); | |
319 } | |
320 | |
321 gint | |
3753 | 322 drct_pl_get_time( gint pos ) |
2748 | 323 { |
324 return playlist_get_songtime(playlist_get_active(), pos); | |
325 } | |
326 | |
327 gint | |
3753 | 328 drct_pl_get_pos( void ) |
2748 | 329 { |
330 return playlist_get_position_nolock(playlist_get_active()); | |
331 } | |
332 | |
333 gchar * | |
3753 | 334 drct_pl_get_file( gint pos ) |
2748 | 335 { |
336 return playlist_get_filename(playlist_get_active(), pos); | |
337 } | |
2760 | 338 |
339 void | |
3753 | 340 drct_pl_add ( GList * list ) |
2760 | 341 { |
342 GList *node = list; | |
343 while ( node != NULL ) | |
344 { | |
345 playlist_add_url(playlist_get_active(), (gchar*)node->data); | |
346 node = g_list_next(node); | |
347 } | |
348 return; | |
349 } | |
350 | |
351 void | |
3753 | 352 drct_pl_clear ( void ) |
2760 | 353 { |
354 playlist_clear(playlist_get_active()); | |
355 mainwin_clear_song_info(); | |
356 return; | |
357 } | |
2775 | 358 |
359 | |
360 /* following functions are not tested yet. be careful. --yaz */ | |
361 void | |
3753 | 362 drct_pl_delete ( gint pos ) |
2775 | 363 { |
364 GDK_THREADS_ENTER(); | |
365 playlist_delete_index(playlist_get_active(), pos); | |
366 GDK_THREADS_LEAVE(); | |
367 } | |
368 | |
369 void | |
3753 | 370 drct_pl_set_pos( gint pos ) |
2775 | 371 { |
372 Playlist *playlist = playlist_get_active(); | |
373 if (pos < (guint)playlist_get_length(playlist)) | |
374 playlist_set_position(playlist, pos); | |
375 } | |
376 | |
377 gint | |
3753 | 378 drct_pl_get_length( void ) |
2775 | 379 { |
380 return playlist_get_length(playlist_get_active()); | |
381 } | |
382 | |
383 void | |
3753 | 384 drct_pl_ins_url_string( gchar * string, gint pos ) |
2775 | 385 { |
386 playlist_ins_url(playlist_get_active(), string, pos); | |
387 } | |
388 | |
389 void | |
3753 | 390 drct_pl_add_url_string( gchar * string ) |
2775 | 391 { |
392 GDK_THREADS_ENTER(); | |
393 playlist_add_url(playlist_get_active(), string); | |
394 GDK_THREADS_LEAVE(); | |
395 } | |
396 | |
397 void | |
3753 | 398 drct_pl_enqueue_to_temp( gchar * string ) |
2775 | 399 { |
400 Playlist *new_pl = playlist_new(); | |
401 | |
402 GDK_THREADS_ENTER(); | |
403 playlist_select_playlist(new_pl); | |
404 playlist_add_url(new_pl, string); | |
405 GDK_THREADS_LEAVE(); | |
406 } | |
407 | |
408 | |
409 /* playqueue */ | |
410 gint | |
3753 | 411 drct_pq_get_length( void ) |
2775 | 412 { |
413 return playlist_queue_get_length(playlist_get_active()); | |
414 } | |
415 | |
416 void | |
3753 | 417 drct_pq_add( gint pos ) |
2775 | 418 { |
419 Playlist *playlist = playlist_get_active(); | |
420 if (pos < (guint)playlist_get_length(playlist)) | |
421 playlist_queue_position(playlist, pos); | |
422 } | |
423 | |
424 void | |
3753 | 425 drct_pq_remove( gint pos ) |
2775 | 426 { |
427 Playlist *playlist = playlist_get_active(); | |
428 if (pos < (guint)playlist_get_length(playlist)) | |
429 playlist_queue_remove(playlist_get_active(), pos); | |
430 } | |
431 | |
432 void | |
3753 | 433 drct_pq_clear( void ) |
2775 | 434 { |
435 playlist_clear_queue(playlist_get_active()); | |
436 } | |
437 | |
438 gboolean | |
3753 | 439 drct_pq_is_queued( gint pos ) |
2775 | 440 { |
441 return playlist_is_position_queued(playlist_get_active(), pos); | |
442 } | |
443 | |
444 gint | |
3753 | 445 drct_pq_get_position( gint pos ) |
2775 | 446 { |
447 return playlist_get_queue_position_number(playlist_get_active(), pos); | |
448 } | |
449 | |
450 gint | |
3753 | 451 drct_pq_get_queue_position( gint pos ) |
2775 | 452 { |
453 return playlist_get_queue_position_number(playlist_get_active(), pos); | |
454 } | |
2785 | 455 |