annotate libaudacious/beepctrl.c @ 525:6e332a32d2f5 trunk

[svn] amidi-plug: do not try to guess the correct alsa port from alsa-lib version if there's not a wavetable hw synth available
author giacomo
date Fri, 27 Jan 2006 12:00:13 -0800
parents cb178e5ad177
children 0a73d1faeb4e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* XMMS - Cross-platform multimedia player
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 * Copyright (C) 1998-2003 Peter Alm, Mikael Alm, Olle Hallnas,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 * Thomas Nilsson and 4Front Technologies
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 * Copyright (C) 1999-2003 Haavard Kvaalen
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 * (at your option) any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 * GNU General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21 #ifdef HAVE_CONFIG_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 # include "config.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25 #include <glib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 #include <sys/types.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27 #include <sys/stat.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include <sys/socket.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 #include <sys/un.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 #include <errno.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 #include <stdio.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 #include <stdlib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 #include <string.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 #include "beepctrl.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35 #include "audacious/controlsocket.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38 #ifdef HAVE_UNISTD_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 #include <unistd.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 static gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 read_all(gint fd, gpointer buf, size_t count)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45 size_t left = count;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 GTimer *timer;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 gulong usec;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 gint r;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 timer = g_timer_new();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 do {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 if ((r = read(fd, buf, left)) < 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 count = -1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 left -= r;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 buf = (gchar *) buf + r;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 g_timer_elapsed(timer, &usec);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 while (left > 0 && usec <= CTRLSOCKET_IO_TIMEOUT_USEC);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 g_timer_destroy(timer);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 return count - left;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 static gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 write_all(gint fd, gconstpointer buf, size_t count)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 size_t left = count;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 GTimer *timer;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 gulong usec;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 gint written;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 timer = g_timer_new();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 do {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 if ((written = write(fd, buf, left)) < 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 count = -1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 left -= written;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 buf = (gchar *) buf + written;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 g_timer_elapsed(timer, &usec);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 while (left > 0 && usec <= CTRLSOCKET_IO_TIMEOUT_USEC);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 g_timer_destroy(timer);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 return count - left;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 static gpointer
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 remote_read_packet(gint fd, ServerPktHeader * pkt_hdr)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 gpointer data = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 if (read_all(fd, pkt_hdr, sizeof(ServerPktHeader)) ==
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 sizeof(ServerPktHeader)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 if (pkt_hdr->data_length) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100 size_t data_length = pkt_hdr->data_length;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 data = g_malloc0(data_length);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 if (read_all(fd, data, data_length) < data_length) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 data = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 return data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 remote_read_ack(gint fd)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118 if (data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 remote_send_packet(gint fd, guint32 command, gpointer data,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 guint32 data_length)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 ClientPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 pkt_hdr.version = XMMS_PROTOCOL_VERSION;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 pkt_hdr.command = command;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 pkt_hdr.data_length = data_length;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 if (write_all(fd, &pkt_hdr, sizeof(ClientPktHeader)) < sizeof(pkt_hdr))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 if (data_length && data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 write_all(fd, data, data_length);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 remote_send_guint32(gint session, guint32 cmd, guint32 val)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 remote_send_packet(fd, cmd, &val, sizeof(guint32));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151 remote_send_boolean(gint session, guint32 cmd, gboolean val)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 remote_send_packet(fd, cmd, &val, sizeof(gboolean));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 remote_send_gfloat(gint session, guint32 cmd, gfloat value)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169 remote_send_packet(fd, cmd, &value, sizeof(gfloat));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 remote_send_string(gint session, guint32 cmd, gchar * string)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 remote_send_packet(fd, cmd, string, string ? strlen(string) + 1 : 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
184 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
185
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
186 static gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187 remote_cmd(gint session, guint32 cmd)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
188 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
189 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
190
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
191 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
192 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
193 remote_send_packet(fd, cmd, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
194 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
195 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
196
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
197 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
198 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
199
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
200 static gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
201 remote_get_gboolean(gint session, gint cmd)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
202 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
203 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
204 gboolean ret = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
205 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
206 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
207
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
208 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
209 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
210 remote_send_packet(fd, cmd, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
211 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
212 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
213 ret = *((gboolean *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
214 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
215 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
216 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
217 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
218
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
219 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
220 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
221
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
222 static guint32
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
223 remote_get_gint(gint session, gint cmd)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
224 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
225 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
226 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
227 gint fd, ret = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
228
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
229 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
230 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
231 remote_send_packet(fd, cmd, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
232 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
233 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
234 ret = *((gint *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
235 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
236 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
237 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
238 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
239 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
240 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
241
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
242 static gfloat
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
243 remote_get_gfloat(gint session, gint cmd)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
244 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
245 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
246 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
247 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
248 gfloat ret = 0.0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
249
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
250 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
251 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
252 remote_send_packet(fd, cmd, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
253 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
254 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
255 ret = *((gfloat *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
256 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
257 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
258 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
259 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
260 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
261 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
262
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
263 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
264 remote_get_string(gint session, gint cmd)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
265 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
266 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
267 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
268 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
269
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
270 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
271 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
272 remote_send_packet(fd, cmd, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
273 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
274 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
275 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
276 return data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
277 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
278
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
279 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
280 remote_get_string_pos(gint session, gint cmd, guint32 pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
281 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
282 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
283 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
284 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
285
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
286 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
287 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
288 remote_send_packet(fd, cmd, &pos, sizeof(guint32));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
289 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
290 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
291 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
292 return data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
293 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
294
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
295 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
296 xmms_connect_to_session(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
297 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
298 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
299 uid_t stored_uid, euid;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
300 struct sockaddr_un saddr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
301
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
302 if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
303 saddr.sun_family = AF_UNIX;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
304 stored_uid = getuid();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
305 euid = geteuid();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
306 setuid(euid);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
307 g_snprintf(saddr.sun_path, 108, "%s/%s_%s.%d", g_get_tmp_dir(),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
308 CTRLSOCKET_NAME, g_get_user_name(), session);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
309 setreuid(stored_uid, euid);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
310 if (connect(fd, (struct sockaddr *) &saddr, sizeof(saddr)) != -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
311 return fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
312 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
313 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
314 return -1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
315 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
316
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
317 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
318 xmms_remote_playlist(gint session, gchar ** list, gint num, gboolean enqueue)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
319 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
320 gint fd, i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
321 gchar *data, *ptr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
322 gint data_length;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
323 guint32 len;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
324
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
325 g_return_if_fail(list != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
326 g_return_if_fail(num > 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
327
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
328 if (!enqueue)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
329 xmms_remote_playlist_clear(session);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
330
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
331 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
332 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
333
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
334 for (i = 0, data_length = 0; i < num; i++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
335 data_length += (((strlen(list[i]) + 1) + 3) / 4) * 4 + 4;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
336 if (data_length) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
337 data_length += 4;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
338 data = g_malloc(data_length);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
339 for (i = 0, ptr = data; i < num; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
340 len = strlen(list[i]) + 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
341 *((guint32 *) ptr) = len;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
342 ptr += 4;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
343 memcpy(ptr, list[i], len);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
344 ptr += ((len + 3) / 4) * 4;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
345 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
346 *((guint32 *) ptr) = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
347 remote_send_packet(fd, CMD_PLAYLIST_ADD, data, data_length);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
348 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
349 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
350 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
351 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
352
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
353 if (!enqueue)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
354 xmms_remote_play(session);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
355 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
356
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
357 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
358 xmms_remote_get_version(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
359 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
360 return remote_get_gint(session, CMD_GET_VERSION);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
361 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
362
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
363 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
364 xmms_remote_play_files(gint session, GList * list)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
365 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
366 g_return_if_fail(list != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
367
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
368 xmms_remote_playlist_clear(session);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
369 xmms_remote_add_files(session, list);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
370 xmms_remote_play(session);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
371 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
372
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
373 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
374 xmms_remote_playlist_add(gint session, GList * list)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
375 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
376 gchar **str_list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
377 GList *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
378 gint i, num;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
379
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
380 g_return_if_fail(list != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
381
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
382 num = g_list_length(list);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
383 str_list = g_malloc0(num * sizeof(gchar *));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
384 for (i = 0, node = list; i < num && node; i++, node = g_list_next(node))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
385 str_list[i] = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
386
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
387 xmms_remote_playlist(session, str_list, num, TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
388 g_free(str_list);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
389 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
390
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
391 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
392 xmms_remote_playlist_delete(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
393 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
394 remote_send_guint32(session, CMD_PLAYLIST_DELETE, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
395 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
396
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
397 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
398 xmms_remote_play(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
399 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
400 remote_cmd(session, CMD_PLAY);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
401 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
402
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
403 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
404 xmms_remote_pause(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
405 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
406 remote_cmd(session, CMD_PAUSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
407 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
408
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
409 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
410 xmms_remote_stop(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
411 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
412 remote_cmd(session, CMD_STOP);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
413 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
414
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
415 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
416 xmms_remote_play_pause(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
417 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
418 remote_cmd(session, CMD_PLAY_PAUSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
419 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
420
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
421 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
422 xmms_remote_is_playing(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
423 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
424 return remote_get_gboolean(session, CMD_IS_PLAYING);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
425 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
426
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
427 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
428 xmms_remote_is_paused(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
429 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
430 return remote_get_gboolean(session, CMD_IS_PAUSED);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
431 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
432
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
433 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
434 xmms_remote_get_playlist_pos(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
435 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
436 return remote_get_gint(session, CMD_GET_PLAYLIST_POS);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
437 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
438
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
439 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
440 xmms_remote_set_playlist_pos(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
441 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
442 remote_send_guint32(session, CMD_SET_PLAYLIST_POS, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
443 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
444
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
445 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
446 xmms_remote_get_playlist_length(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
447 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
448 return remote_get_gint(session, CMD_GET_PLAYLIST_LENGTH);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
449 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
450
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
451 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
452 xmms_remote_playlist_clear(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
453 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
454 remote_cmd(session, CMD_PLAYLIST_CLEAR);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
455 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
456
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
457 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
458 xmms_remote_get_output_time(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
459 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
460 return remote_get_gint(session, CMD_GET_OUTPUT_TIME);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
461 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
462
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
463 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
464 xmms_remote_jump_to_time(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
465 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
466 remote_send_guint32(session, CMD_JUMP_TO_TIME, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
467 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
468
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
469 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
470 xmms_remote_get_volume(gint session, gint * vl, gint * vr)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
471 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
472 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
473 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
474 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
475
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
476 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
477 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
478
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
479 remote_send_packet(fd, CMD_GET_VOLUME, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
480 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
481 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
482 *vl = ((guint32 *) data)[0];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
483 *vr = ((guint32 *) data)[1];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
484 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
485 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
486 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
487 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
488 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
489
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
490 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
491 xmms_remote_get_main_volume(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
492 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
493 gint vl, vr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
494
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
495 xmms_remote_get_volume(session, &vl, &vr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
496
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
497 return (vl > vr) ? vl : vr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
498 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
499
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
500 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
501 xmms_remote_get_balance(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
502 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
503 return remote_get_gint(session, CMD_GET_BALANCE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
504 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
505
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
506 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
507 xmms_remote_set_volume(gint session, gint vl, gint vr)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
508 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
509 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
510 guint32 v[2];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
511
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
512 if (vl < 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
513 vl = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
514 if (vl > 100)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
515 vl = 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
516 if (vr < 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
517 vr = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
518 if (vr > 100)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
519 vr = 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
520
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
521 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
522 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
523 v[0] = vl;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
524 v[1] = vr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
525 remote_send_packet(fd, CMD_SET_VOLUME, v, 2 * sizeof(guint32));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
526 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
527 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
528 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
529
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
530 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
531 xmms_remote_set_main_volume(gint session, gint v)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
532 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
533 gint b, vl, vr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
534
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
535 b = xmms_remote_get_balance(session);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
536
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
537 if (b < 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
538 vl = v;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
539 vr = (v * (100 - abs(b))) / 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
540 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
541 else if (b > 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
542 vl = (v * (100 - b)) / 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
543 vr = v;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
544 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
545 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
546 vl = vr = v;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
547 xmms_remote_set_volume(session, vl, vr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
548 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
549
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
550 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
551 xmms_remote_set_balance(gint session, gint b)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
552 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
553 gint v, vl, vr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
554
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
555 if (b < -100)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
556 b = -100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
557 if (b > 100)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
558 b = 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
559
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
560 v = xmms_remote_get_main_volume(session);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
561
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
562 if (b < 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
563 vl = v;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
564 vr = (v * (100 - abs(b))) / 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
565 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
566 else if (b > 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
567 vl = (v * (100 - b)) / 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
568 vr = v;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
569 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
570 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
571 vl = vr = v;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
572 xmms_remote_set_volume(session, vl, vr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
573 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
574
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
575 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
576 xmms_remote_get_skin(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
577 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
578 return remote_get_string(session, CMD_GET_SKIN);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
579 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
580
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
581 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
582 xmms_remote_set_skin(gint session, gchar * skinfile)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
583 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
584 remote_send_string(session, CMD_SET_SKIN, skinfile);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
585 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
586
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
587 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
588 xmms_remote_get_playlist_file(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
589 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
590 return remote_get_string_pos(session, CMD_GET_PLAYLIST_FILE, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
591 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
592
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
593 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
594 xmms_remote_get_playlist_title(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
595 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
596 return remote_get_string_pos(session, CMD_GET_PLAYLIST_TITLE, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
597 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
598
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
599 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
600 xmms_remote_get_playlist_time(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
601 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
602 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
603 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
604 gint fd, ret = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
605 guint32 p = pos;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
606
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
607 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
608 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
609 remote_send_packet(fd, CMD_GET_PLAYLIST_TIME, &p, sizeof(guint32));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
610 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
611 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
612 ret = *((gint *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
613 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
614 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
615 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
616 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
617 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
618 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
619
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
620 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
621 xmms_remote_get_info(gint session, gint * rate, gint * freq, gint * nch)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
622 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
623 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
624 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
625 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
626
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
627 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
628 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
629 remote_send_packet(fd, CMD_GET_INFO, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
630 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
631 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
632 *rate = ((guint32 *) data)[0];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
633 *freq = ((guint32 *) data)[1];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
634 *nch = ((guint32 *) data)[2];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
635 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
636 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
637 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
638 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
639 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
640
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
641 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
642 xmms_remote_get_eq_data(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
643 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
644 /* Obsolete */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
645 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
646
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
647 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
648 xmms_remote_set_eq_data(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
649 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
650 /* Obsolete */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
651 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
652
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
653 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
654 xmms_remote_pl_win_toggle(gint session, gboolean show)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
655 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
656 remote_send_boolean(session, CMD_PL_WIN_TOGGLE, show);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
657 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
658
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
659 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
660 xmms_remote_eq_win_toggle(gint session, gboolean show)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
661 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
662 remote_send_boolean(session, CMD_EQ_WIN_TOGGLE, show);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
663 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
664
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
665 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
666 xmms_remote_main_win_toggle(gint session, gboolean show)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
667 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
668 remote_send_boolean(session, CMD_MAIN_WIN_TOGGLE, show);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
669 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
670
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
671 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
672 xmms_remote_is_main_win(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
673 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
674 return remote_get_gboolean(session, CMD_IS_MAIN_WIN);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
675 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
676
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
677 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
678 xmms_remote_is_pl_win(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
679 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
680 return remote_get_gboolean(session, CMD_IS_PL_WIN);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
681 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
682
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
683 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
684 xmms_remote_is_eq_win(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
685 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
686 return remote_get_gboolean(session, CMD_IS_EQ_WIN);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
687 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
688
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
689 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
690 xmms_remote_show_prefs_box(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
691 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
692 remote_cmd(session, CMD_SHOW_PREFS_BOX);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
693 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
694
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
695 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
696 xmms_remote_toggle_aot(gint session, gboolean ontop)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
697 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
698 remote_send_boolean(session, CMD_TOGGLE_AOT, ontop);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
699 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
700
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
701 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
702 xmms_remote_show_about_box(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
703 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
704 remote_cmd(session, CMD_SHOW_ABOUT_BOX);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
705 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
706
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
707 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
708 xmms_remote_eject(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
709 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
710 remote_cmd(session, CMD_EJECT);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
711 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
712
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
713 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
714 xmms_remote_playlist_prev(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
715 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
716 remote_cmd(session, CMD_PLAYLIST_PREV);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
717 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
718
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
719 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
720 xmms_remote_playlist_next(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
721 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
722 remote_cmd(session, CMD_PLAYLIST_NEXT);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
723 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
724
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
725 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
726 xmms_remote_playlist_add_url_string(gint session, gchar * string)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
727 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
728 g_return_if_fail(string != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
729 remote_send_string(session, CMD_PLAYLIST_ADD_URL_STRING, string);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
730 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
731
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
732 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
733 xmms_remote_playlist_ins_url_string(gint session, gchar * string, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
734 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
735 gint fd, size;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
736 gchar *packet;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
737
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
738 g_return_if_fail(string != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
739
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
740 size = strlen(string) + 1 + sizeof(gint);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
741
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
742 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
743 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
744
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
745 packet = g_malloc0(size);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
746 *((gint *) packet) = pos;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
747 strcpy(packet + sizeof(gint), string);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
748 remote_send_packet(fd, CMD_PLAYLIST_INS_URL_STRING, packet, size);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
749 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
750 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
751 g_free(packet);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
752 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
753
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
754 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
755 xmms_remote_is_running(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
756 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
757 return remote_cmd(session, CMD_PING);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
758 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
759
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
760 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
761 xmms_remote_toggle_repeat(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
762 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
763 remote_cmd(session, CMD_TOGGLE_REPEAT);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
764 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
765
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
766 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
767 xmms_remote_toggle_shuffle(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
768 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
769 remote_cmd(session, CMD_TOGGLE_SHUFFLE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
770 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
771
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
772 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
773 xmms_remote_toggle_advance(int session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
774 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
775 remote_cmd(session, CMD_TOGGLE_ADVANCE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
776 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
777
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
778 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
779 xmms_remote_is_repeat(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
780 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
781 return remote_get_gboolean(session, CMD_IS_REPEAT);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
782 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
783
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
784 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
785 xmms_remote_is_shuffle(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
786 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
787 return remote_get_gboolean(session, CMD_IS_SHUFFLE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
788 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
789
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
790 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
791 xmms_remote_is_advance(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
792 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
793 return remote_get_gboolean(session, CMD_IS_ADVANCE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
794 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
795
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
796 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
797 xmms_remote_playqueue_add(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
798 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
799 remote_send_guint32(session, CMD_PLAYQUEUE_ADD, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
800 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
801
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
802 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
803 xmms_remote_playqueue_remove(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
804 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
805 remote_send_guint32(session, CMD_PLAYQUEUE_REMOVE, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
806 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
807
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
808 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
809 xmms_remote_get_playqueue_length(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
810 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
811 return remote_get_gint(session, CMD_GET_PLAYQUEUE_LENGTH);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
812 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
813
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
814 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
815 xmms_remote_get_eq(gint session, gfloat * preamp, gfloat ** bands)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
816 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
817 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
818 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
819 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
820
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
821 if (preamp)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
822 *preamp = 0.0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
823
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
824 if (bands)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
825 *bands = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
826
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
827 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
828 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
829 remote_send_packet(fd, CMD_GET_EQ, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
830 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
831 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
832 if (pkt_hdr.data_length >= 11 * sizeof(gfloat)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
833 if (preamp)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
834 *preamp = *((gfloat *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
835 if (bands)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
836 *bands =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
837 (gfloat *) g_memdup((gfloat *) data + 1,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
838 10 * sizeof(gfloat));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
839 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
840 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
841 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
842 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
843 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
844 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
845
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
846 gfloat
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
847 xmms_remote_get_eq_preamp(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
848 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
849 return remote_get_gfloat(session, CMD_GET_EQ_PREAMP);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
850 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
851
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
852 gfloat
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
853 xmms_remote_get_eq_band(gint session, gint band)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
854 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
855 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
856 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
857 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
858 gfloat val = 0.0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
859
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
860 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
861 return val;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
862 remote_send_packet(fd, CMD_GET_EQ_BAND, &band, sizeof(band));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
863 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
864 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
865 val = *((gfloat *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
866 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
867 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
868 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
869 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
870 return val;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
871 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
872
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
873 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
874 xmms_remote_set_eq(gint session, gfloat preamp, gfloat * bands)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
875 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
876 gint fd, i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
877 gfloat data[11];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
878
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
879 g_return_if_fail(bands != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
880
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
881 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
882 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
883 data[0] = preamp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
884 for (i = 0; i < 10; i++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
885 data[i + 1] = bands[i];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
886 remote_send_packet(fd, CMD_SET_EQ, data, sizeof(data));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
887 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
888 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
889 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
890
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
891 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
892 xmms_remote_set_eq_preamp(gint session, gfloat preamp)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
893 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
894 remote_send_gfloat(session, CMD_SET_EQ_PREAMP, preamp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
895 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
896
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
897 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
898 xmms_remote_set_eq_band(gint session, gint band, gfloat value)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
899 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
900 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
901 gchar data[sizeof(gint) + sizeof(gfloat)];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
902
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
903 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
904 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
905 *((gint *) data) = band;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
906 *((gfloat *) (data + sizeof(gint))) = value;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
907 remote_send_packet(fd, CMD_SET_EQ_BAND, data, sizeof(data));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
908 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
909 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
910 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
911
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
912 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
913 xmms_remote_quit(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
914 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
915 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
916
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
917 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
918 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
919 remote_send_packet(fd, CMD_QUIT, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
920 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
921 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
922 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
923
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
924 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
925 xmms_remote_activate(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
926 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
927 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
928
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
929 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
930 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
931 remote_send_packet(fd, CMD_ACTIVATE, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
932 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
933 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
934 }