Mercurial > audlegacy
annotate src/audacious/auddrct.c @ 3718:a98b1189777b
add new hook, playback seek, and subscribe mainwin_update_song_info() to it.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Thu, 11 Oct 2007 19:38:55 -0500 |
parents | f02623377013 |
children | 22d71f986b86 |
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" |
3251 | 34 #include "skin.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
|
35 |
2742 | 36 /* player */ |
37 | |
38 void | |
39 audacious_drct_quit ( void ) | |
40 { | |
41 mainwin_quit_cb(); | |
42 return; | |
43 } | |
44 | |
45 void | |
46 audacious_drct_eject ( void ) | |
47 { | |
48 if (has_x11_connection) | |
49 mainwin_eject_pushed(); | |
50 return; | |
51 } | |
52 | |
2745 | 53 void |
54 audacious_drct_jtf_show ( void ) | |
55 { | |
56 if (has_x11_connection) | |
57 ui_jump_to_track(); | |
58 return; | |
59 } | |
60 | |
2742 | 61 gboolean |
62 audacious_drct_main_win_is_visible ( void ) | |
63 { | |
64 return cfg.player_visible; | |
65 } | |
66 | |
67 void | |
2744 | 68 audacious_drct_main_win_toggle ( gboolean show ) |
2742 | 69 { |
70 if (has_x11_connection) | |
71 mainwin_show(show); | |
72 return; | |
73 } | |
74 | |
75 gboolean | |
2744 | 76 audacious_drct_eq_win_is_visible ( void ) |
2742 | 77 { |
78 return cfg.equalizer_visible; | |
79 } | |
80 | |
81 void | |
2744 | 82 audacious_drct_eq_win_toggle ( gboolean show ) |
2742 | 83 { |
84 if (has_x11_connection) | |
85 equalizerwin_show(show); | |
86 return; | |
87 } | |
88 | |
89 gboolean | |
2744 | 90 audacious_drct_pl_win_is_visible ( void ) |
2742 | 91 { |
92 return cfg.playlist_visible; | |
93 } | |
94 | |
95 void | |
2744 | 96 audacious_drct_pl_win_toggle ( gboolean show ) |
2742 | 97 { |
98 if (has_x11_connection) { | |
99 if (show) | |
100 playlistwin_show(); | |
101 else | |
102 playlistwin_hide(); | |
103 } | |
104 return; | |
105 } | |
106 | |
2785 | 107 void audacious_drct_set_skin(gchar *skinfile) |
108 { | |
109 if (has_x11_connection) | |
110 bmp_active_skin_load(skinfile); | |
111 } | |
112 | |
113 void audacious_drct_activate(void) | |
114 { | |
115 gtk_window_present(GTK_WINDOW(mainwin)); | |
116 } | |
2742 | 117 |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
118 /* playback */ |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
119 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
120 void |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
121 audacious_drct_play ( void ) |
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 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
|
124 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
|
125 else if (playlist_get_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
|
126 playback_initiate(); |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
127 else |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
128 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
|
129 return; |
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 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
132 void |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
133 audacious_drct_pause ( void ) |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
134 { |
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_pause(); |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
136 return; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
137 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
138 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
139 void |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
140 audacious_drct_stop ( void ) |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
141 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
142 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
|
143 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
|
144 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
|
145 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
|
146 return; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
147 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
148 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
149 gboolean |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
150 audacious_drct_get_playing ( void ) |
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 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
|
153 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
154 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
155 gboolean |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
156 audacious_drct_get_paused ( void ) |
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 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
|
159 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
160 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
161 gboolean |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
162 audacious_drct_get_stopped ( void ) |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
163 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
164 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
|
165 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
166 |
2748 | 167 void |
168 audacious_drct_get_info( gint *rate, gint *freq, gint *nch) | |
169 { | |
170 playback_get_sample_params(rate, freq, nch); | |
171 } | |
172 | |
2739
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
173 gint |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
174 audacious_drct_get_time ( void ) |
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 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
|
177 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
|
178 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
|
179 else |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
180 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
|
181 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
|
182 } |
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 void |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
185 audacious_drct_seek ( guint pos ) |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
186 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
187 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
|
188 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
|
189 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
|
190 return; |
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 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
193 void |
2760 | 194 audacious_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
|
195 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
196 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
|
197 return; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
198 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
199 |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
200 void |
2760 | 201 audacious_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
|
202 { |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 return; |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
209 } |
953001c668ae
[svn] - added auddrct.c/h, a migration api for plugins that once used xmms_remote; to be completed
giacomo
parents:
diff
changeset
|
210 |
2760 | 211 void |
212 audacious_drct_get_volume_main( gint *v ) | |
213 { | |
214 gint vl, vr; | |
215 audacious_drct_get_volume(&vl, &vr); | |
216 *v = (vl > vr) ? vl : vr; | |
217 return; | |
218 } | |
219 | |
220 void | |
221 audacious_drct_set_volume_main ( gint v ) | |
222 { | |
223 gint b, vl, vr; | |
224 audacious_drct_get_volume_balance(&b); | |
225 if (b < 0) { | |
226 vl = v; | |
227 vr = (v * (100 - abs(b))) / 100; | |
228 } | |
229 else if (b > 0) { | |
230 vl = (v * (100 - b)) / 100; | |
231 vr = v; | |
232 } | |
233 else | |
234 vl = vr = v; | |
235 audacious_drct_set_volume(vl, vr); | |
236 } | |
237 | |
238 void | |
239 audacious_drct_get_volume_balance ( gint *b ) | |
240 { | |
241 gint vl, vr; | |
242 input_get_volume(&vl, &vr); | |
243 if (vl < 0 || vr < 0) | |
244 *b = 0; | |
245 else if (vl > vr) | |
246 *b = -100 + ((vr * 100) / vl); | |
247 else if (vr > vl) | |
248 *b = 100 - ((vl * 100) / vr); | |
249 else | |
250 *b = 0; | |
251 return; | |
252 } | |
253 | |
254 void | |
255 audacious_drct_set_volume_balance ( gint b ) | |
256 { | |
257 gint v, vl, vr; | |
258 if (b < -100) | |
259 b = -100; | |
260 if (b > 100) | |
261 b = 100; | |
262 audacious_drct_get_volume_main(&v); | |
263 if (b < 0) { | |
264 vl = v; | |
265 vr = (v * (100 - abs(b))) / 100; | |
266 } | |
267 else if (b > 0) { | |
268 vl = (v * (100 - b)) / 100; | |
269 vr = v; | |
270 } | |
271 else | |
272 { | |
273 vl = v; | |
274 vr = v; | |
275 } | |
276 audacious_drct_set_volume(vl, vr); | |
277 return; | |
278 } | |
279 | |
2742 | 280 |
281 /* playlist */ | |
282 | |
283 void | |
284 audacious_drct_pl_next ( void ) | |
285 { | |
286 playlist_next(playlist_get_active()); | |
287 return; | |
288 } | |
289 | |
290 void | |
291 audacious_drct_pl_prev ( void ) | |
292 { | |
293 playlist_prev(playlist_get_active()); | |
294 return; | |
295 } | |
2745 | 296 |
297 gboolean | |
298 audacious_drct_pl_repeat_is_enabled( void ) | |
299 { | |
300 return cfg.repeat; | |
301 } | |
302 | |
303 void | |
304 audacious_drct_pl_repeat_toggle( void ) | |
305 { | |
306 mainwin_repeat_pushed(!cfg.repeat); | |
307 return; | |
308 } | |
309 | |
310 gboolean | |
311 audacious_drct_pl_repeat_is_shuffled( void ) | |
312 { | |
313 return cfg.shuffle; | |
314 } | |
315 | |
316 void | |
317 audacious_drct_pl_shuffle_toggle( void ) | |
318 { | |
319 mainwin_shuffle_pushed(!cfg.shuffle); | |
320 return; | |
321 } | |
2748 | 322 |
323 gchar * | |
324 audacious_drct_pl_get_title( gint pos ) | |
325 { | |
326 return playlist_get_songtitle(playlist_get_active(), pos); | |
327 } | |
328 | |
329 gint | |
330 audacious_drct_pl_get_time( gint pos ) | |
331 { | |
332 return playlist_get_songtime(playlist_get_active(), pos); | |
333 } | |
334 | |
335 gint | |
336 audacious_drct_pl_get_pos( void ) | |
337 { | |
338 return playlist_get_position_nolock(playlist_get_active()); | |
339 } | |
340 | |
341 gchar * | |
342 audacious_drct_pl_get_file( gint pos ) | |
343 { | |
344 return playlist_get_filename(playlist_get_active(), pos); | |
345 } | |
2760 | 346 |
347 void | |
348 audacious_drct_pl_add ( GList * list ) | |
349 { | |
350 GList *node = list; | |
351 while ( node != NULL ) | |
352 { | |
353 playlist_add_url(playlist_get_active(), (gchar*)node->data); | |
354 node = g_list_next(node); | |
355 } | |
356 return; | |
357 } | |
358 | |
359 void | |
360 audacious_drct_pl_clear ( void ) | |
361 { | |
362 playlist_clear(playlist_get_active()); | |
363 mainwin_clear_song_info(); | |
364 return; | |
365 } | |
2775 | 366 |
367 | |
368 /* following functions are not tested yet. be careful. --yaz */ | |
369 void | |
370 audacious_drct_pl_delete ( gint pos ) | |
371 { | |
372 GDK_THREADS_ENTER(); | |
373 playlist_delete_index(playlist_get_active(), pos); | |
374 GDK_THREADS_LEAVE(); | |
375 } | |
376 | |
377 void | |
378 audacious_drct_pl_set_pos( gint pos ) | |
379 { | |
380 Playlist *playlist = playlist_get_active(); | |
381 if (pos < (guint)playlist_get_length(playlist)) | |
382 playlist_set_position(playlist, pos); | |
383 } | |
384 | |
385 gint | |
386 audacious_drct_pl_get_length( void ) | |
387 { | |
388 return playlist_get_length(playlist_get_active()); | |
389 } | |
390 | |
391 void | |
392 audacious_drct_pl_ins_url_string( gchar * string, gint pos ) | |
393 { | |
394 playlist_ins_url(playlist_get_active(), string, pos); | |
395 } | |
396 | |
397 void | |
398 audacious_drct_pl_add_url_string( gchar * string ) | |
399 { | |
400 GDK_THREADS_ENTER(); | |
401 playlist_add_url(playlist_get_active(), string); | |
402 GDK_THREADS_LEAVE(); | |
403 } | |
404 | |
405 void | |
406 audacious_drct_pl_enqueue_to_temp( gchar * string ) | |
407 { | |
408 Playlist *new_pl = playlist_new(); | |
409 | |
410 GDK_THREADS_ENTER(); | |
411 playlist_select_playlist(new_pl); | |
412 playlist_add_url(new_pl, string); | |
413 GDK_THREADS_LEAVE(); | |
414 } | |
415 | |
416 | |
417 /* playqueue */ | |
418 gint | |
419 audacious_drct_pq_get_length( void ) | |
420 { | |
421 return playlist_queue_get_length(playlist_get_active()); | |
422 } | |
423 | |
424 void | |
425 audacious_drct_pq_add( gint pos ) | |
426 { | |
427 Playlist *playlist = playlist_get_active(); | |
428 if (pos < (guint)playlist_get_length(playlist)) | |
429 playlist_queue_position(playlist, pos); | |
430 } | |
431 | |
432 void | |
433 audacious_drct_pq_remove( gint pos ) | |
434 { | |
435 Playlist *playlist = playlist_get_active(); | |
436 if (pos < (guint)playlist_get_length(playlist)) | |
437 playlist_queue_remove(playlist_get_active(), pos); | |
438 } | |
439 | |
440 void | |
441 audacious_drct_pq_clear( void ) | |
442 { | |
443 playlist_clear_queue(playlist_get_active()); | |
444 } | |
445 | |
446 gboolean | |
447 audacious_drct_pq_is_queued( gint pos ) | |
448 { | |
449 return playlist_is_position_queued(playlist_get_active(), pos); | |
450 } | |
451 | |
452 gint | |
453 audacious_drct_pq_get_position( gint pos ) | |
454 { | |
455 return playlist_get_queue_position_number(playlist_get_active(), pos); | |
456 } | |
457 | |
458 gint | |
459 audaciuos_drct_pq_get_queue_position( gint pos ) | |
460 { | |
461 return playlist_get_queue_position_number(playlist_get_active(), pos); | |
462 } | |
2785 | 463 |