annotate audacious/controlsocket.c @ 1828:b469c6c567a4 trunk

[svn] - use gtk_window_present() to make X render the right sized skin
author nenolod
date Thu, 05 Oct 2006 07:09:01 -0700
parents 6cbb9360e8e2
children 0985452d1962
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 * Based on XMMS:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 * (at your option) any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
1459
705d4c089fce [svn] Fix postal code.
chainsaw
parents: 1458
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 #include "controlsocket.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 #include <glib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25 #include <stdlib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 #include <string.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include <unistd.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 #include <errno.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 #include <sys/time.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 #include <sys/types.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 #include <sys/socket.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 #include <sys/un.h>
1444
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
34 #include <arpa/inet.h>
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
35 #include <netdb.h>
1583
58f3eb64f390 [svn] - freebsd compatibility
nenolod
parents: 1582
diff changeset
36 #include <netinet/in.h>
58f3eb64f390 [svn] - freebsd compatibility
nenolod
parents: 1582
diff changeset
37 #include <unistd.h>
58f3eb64f390 [svn] - freebsd compatibility
nenolod
parents: 1582
diff changeset
38 #include <grp.h>
58f3eb64f390 [svn] - freebsd compatibility
nenolod
parents: 1582
diff changeset
39 #include <sys/time.h>
58f3eb64f390 [svn] - freebsd compatibility
nenolod
parents: 1582
diff changeset
40 #include <sys/wait.h>
58f3eb64f390 [svn] - freebsd compatibility
nenolod
parents: 1582
diff changeset
41 #include <sys/resource.h>
58f3eb64f390 [svn] - freebsd compatibility
nenolod
parents: 1582
diff changeset
42 #include <sys/socket.h>
58f3eb64f390 [svn] - freebsd compatibility
nenolod
parents: 1582
diff changeset
43 #include <fcntl.h>
58f3eb64f390 [svn] - freebsd compatibility
nenolod
parents: 1582
diff changeset
44 #include <arpa/inet.h>
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 #include "main.h"
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
47 #include "equalizer.h"
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
48 #include "mainwin.h"
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 #include "input.h"
538
e4e897d20791 [svn] remove libaudcore, we never did anything with it
nenolod
parents: 383
diff changeset
50 #include "playback.h"
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 #include "playlist.h"
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
52 #include "ui_playlist.h"
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 #include "prefswin.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 #include "libaudacious/beepctrl.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 #define CTRLSOCKET_BACKLOG 100
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 #define CTRLSOCKET_TIMEOUT 100000
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 static gint session_id = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 static gint ctrl_fd = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 static gchar *socket_name = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 static gpointer ctrlsocket_func(gpointer);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 static GThread *ctrlsocket_thread;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 static GList *packet_list = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 static GMutex *packet_list_mutex = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 static gboolean started = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 static gboolean going = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 static GCond *start_cond = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 static GMutex *status_mutex = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 ctrlsocket_start_thread(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 start_cond = g_cond_new();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 status_mutex = g_mutex_new();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 packet_list_mutex = g_mutex_new();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 ctrlsocket_thread = g_thread_create(ctrlsocket_func, NULL, TRUE, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 ctrlsocket_setup(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 {
1761
70caa62ead63 [svn] - fix for "bmp_rcfile_write_string: assertion `value != NULL' failed"
yaz
parents: 1653
diff changeset
90 if (strcmp(cfg.session_uri_base, ""))
70caa62ead63 [svn] - fix for "bmp_rcfile_write_string: assertion `value != NULL' failed"
yaz
parents: 1653
diff changeset
91 audacious_set_session_uri(cfg.session_uri_base);
70caa62ead63 [svn] - fix for "bmp_rcfile_write_string: assertion `value != NULL' failed"
yaz
parents: 1653
diff changeset
92 else
70caa62ead63 [svn] - fix for "bmp_rcfile_write_string: assertion `value != NULL' failed"
yaz
parents: 1653
diff changeset
93 return ctrlsocket_setup_unix();
1453
1c0cd95ef1ed [svn] - fix nemo's bug
nenolod
parents: 1445
diff changeset
94
1c0cd95ef1ed [svn] - fix nemo's bug
nenolod
parents: 1445
diff changeset
95 if (!g_strncasecmp(cfg.session_uri_base, "tcp://", 6))
1444
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
96 return ctrlsocket_setup_tcp();
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
97
1443
2f714bee0645 [svn] - prepare for tcp listener code
nenolod
parents: 984
diff changeset
98 return ctrlsocket_setup_unix();
2f714bee0645 [svn] - prepare for tcp listener code
nenolod
parents: 984
diff changeset
99 }
2f714bee0645 [svn] - prepare for tcp listener code
nenolod
parents: 984
diff changeset
100
2f714bee0645 [svn] - prepare for tcp listener code
nenolod
parents: 984
diff changeset
101 gboolean
2f714bee0645 [svn] - prepare for tcp listener code
nenolod
parents: 984
diff changeset
102 ctrlsocket_setup_unix(void)
2f714bee0645 [svn] - prepare for tcp listener code
nenolod
parents: 984
diff changeset
103 {
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 struct sockaddr_un saddr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107
1456
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1454
diff changeset
108 audacious_set_session_type((gint *) AUDACIOUS_TYPE_UNIX);
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1454
diff changeset
109
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 g_critical("ctrlsocket_setup(): Failed to open socket: %s",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 strerror(errno));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 for (i = 0;; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 saddr.sun_family = AF_UNIX;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118 g_snprintf(saddr.sun_path, sizeof(saddr.sun_path),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 "%s/%s_%s.%d", g_get_tmp_dir(),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 CTRLSOCKET_NAME, g_get_user_name(), i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 if (xmms_remote_is_running(i)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 if (cfg.allow_multiple_instances)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 continue;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 if ((unlink(saddr.sun_path) == -1) && errno != ENOENT) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 g_critical
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 ("ctrlsocket_setup(): Failed to unlink %s (Error: %s)",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 saddr.sun_path, strerror(errno));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 if (bind(fd, (struct sockaddr *) &saddr, sizeof(saddr)) == -1) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 g_critical
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 ("ctrlsocket_setup(): Failed to assign %s to a socket (Error: %s)",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 saddr.sun_path, strerror(errno));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 listen(fd, CTRLSOCKET_BACKLOG);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 socket_name = g_strdup(saddr.sun_path);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 ctrl_fd = fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 session_id = i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 going = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 ctrlsocket_start_thread();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158
1444
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
159 gboolean
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
160 ctrlsocket_setup_tcp(void)
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
161 {
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
162 struct sockaddr_in saddr;
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
163 gint i;
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
164 gint fd;
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
165
1456
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1454
diff changeset
166 audacious_set_session_type((gint *) AUDACIOUS_TYPE_TCP);
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1454
diff changeset
167
1444
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
168 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
169 g_critical("ctrlsocket_setup(): Failed to open socket: %s",
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
170 strerror(errno));
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
171 return FALSE;
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
172 }
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
173
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
174 for (i = 0;; i++) {
1454
de0146be48ee [svn] - fix the other bug exposed by strace
nenolod
parents: 1453
diff changeset
175 memset(&saddr, '\0', sizeof(saddr));
1444
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
176 saddr.sin_family = AF_INET;
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
177 saddr.sin_port = htons(37370 + i);
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
178
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
179 if (xmms_remote_is_running(i)) {
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
180 if (cfg.allow_multiple_instances)
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
181 continue;
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
182 break;
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
183 }
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
184
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
185 if (bind(fd, (struct sockaddr *) &saddr, sizeof(saddr)) == -1) {
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
186 g_critical
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
187 ("ctrlsocket_setup(): Failed to bind the socket (Error: %s)",
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
188 strerror(errno));
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
189 break;
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
190 }
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
191
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
192 listen(fd, CTRLSOCKET_BACKLOG);
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
193
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
194 ctrl_fd = fd;
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
195 session_id = i;
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
196 going = TRUE;
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
197
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
198 ctrlsocket_start_thread();
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
199
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
200 return TRUE;
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
201 }
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
202
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
203 close(fd);
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
204
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
205 return FALSE;
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
206 }
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
207
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
208 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
209 ctrlsocket_get_session_id(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
210 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
211 return session_id;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
212 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
213
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
214 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
215 ctrlsocket_cleanup(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
216 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
217 if (ctrl_fd) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
218 g_mutex_lock(status_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
219 going = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
220 g_cond_signal(start_cond);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
221 g_mutex_unlock(status_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
222
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
223 /* wait for ctrlsocket_thread to terminate */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
224 g_thread_join(ctrlsocket_thread);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
225
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
226 /* close and remove socket */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
227 close(ctrl_fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
228 ctrl_fd = 0;
1444
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
229
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
230 if (socket_name != NULL)
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
231 {
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
232 unlink(socket_name);
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
233 g_free(socket_name);
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1443
diff changeset
234 }
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
235
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
236 g_cond_free(start_cond);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
237 g_mutex_free(status_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
238 g_mutex_free(packet_list_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
239 }
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 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
243 ctrlsocket_start(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
244 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
245 /* tell control socket thread to go 'live' i.e. start handling
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
246 * packets */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
247 g_mutex_lock(status_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
248 started = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
249 g_cond_signal(start_cond);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
250 g_mutex_unlock(status_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
251 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
252
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
253 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
254 ctrl_write_packet(gint fd, gpointer data, gint length)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
255 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
256 ServerPktHeader pkthdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
257
1766
6cbb9360e8e2 [svn] - always zero-out stack variables, as stack memory may be dirty on x86 and friends
nenolod
parents: 1761
diff changeset
258 memset(&pkthdr, '\0', sizeof(ServerPktHeader));
6cbb9360e8e2 [svn] - always zero-out stack variables, as stack memory may be dirty on x86 and friends
nenolod
parents: 1761
diff changeset
259
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
260 pkthdr.version = XMMS_PROTOCOL_VERSION;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
261 pkthdr.data_length = length;
1582
d7af2755a397 [svn] - gcc 4.1.0, 4.1.1, 4.1.2 tree optimization workaround:
nenolod
parents: 1580
diff changeset
262 if ((size_t)write(fd, &pkthdr, sizeof(ServerPktHeader)) < sizeof(pkthdr))
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
263 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
264 if (data && length > 0)
1582
d7af2755a397 [svn] - gcc 4.1.0, 4.1.1, 4.1.2 tree optimization workaround:
nenolod
parents: 1580
diff changeset
265 write(fd, data, length);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
266 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
267
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
268 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
269 ctrl_write_gint(gint fd, gint val)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
270 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
271 ctrl_write_packet(fd, &val, sizeof(gint));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
272 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
273
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
274 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
275 ctrl_write_gfloat(gint fd, gfloat val)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
276 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
277 ctrl_write_packet(fd, &val, sizeof(gfloat));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
278 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
279
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
280 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
281 ctrl_write_gboolean(gint fd, gboolean bool)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
282 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
283 ctrl_write_packet(fd, &bool, sizeof(gboolean));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
284 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
285
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
286 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
287 ctrl_write_string(gint fd, gchar * string)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
288 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
289 ctrl_write_packet(fd, string, string ? strlen(string) + 1 : 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
290 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
291
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
292 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
293 ctrl_ack_packet(PacketNode * pkt)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
294 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
295 ctrl_write_packet(pkt->fd, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
296 close(pkt->fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
297 if (pkt->data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
298 g_free(pkt->data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
299 g_free(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
300 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
301
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
302 static gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
303 ctrlsocket_is_going(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
304 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
305 gboolean result;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
306
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
307 g_mutex_lock(status_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
308 result = going;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
309 g_mutex_unlock(status_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
310
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
311 return result;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
312 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
313
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
314 static gpointer
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
315 ctrlsocket_func(gpointer arg)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
316 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
317 fd_set set;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
318 struct timeval tv;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
319 struct sockaddr_un saddr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
320 gint fd, b, i;
377
4e1d41a93cb3 [svn] Start caring about pointer signedness.
chainsaw
parents: 284
diff changeset
321 gint info[3];
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
322 gint32 v[2];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
323 PacketNode *pkt;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
324 socklen_t len;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
325 gfloat fval[11];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
326
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
327 g_mutex_lock(status_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
328 while (!started && going)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
329 g_cond_wait(start_cond, status_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
330 g_mutex_unlock(status_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
331
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
332 while (ctrlsocket_is_going()) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
333 FD_ZERO(&set);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
334 FD_SET(ctrl_fd, &set);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
335 tv.tv_sec = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
336 tv.tv_usec = CTRLSOCKET_TIMEOUT;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
337 len = sizeof(saddr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
338 if (select(ctrl_fd + 1, &set, NULL, NULL, &tv) <= 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
339 continue;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
340 if ((fd = accept(ctrl_fd, (struct sockaddr *) &saddr, &len)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
341 continue;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
342
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
343 pkt = g_new0(PacketNode, 1);
1582
d7af2755a397 [svn] - gcc 4.1.0, 4.1.1, 4.1.2 tree optimization workaround:
nenolod
parents: 1580
diff changeset
344 if ((size_t)read(fd, &pkt->hdr, sizeof(ClientPktHeader))
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
345 < sizeof(ClientPktHeader)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
346 g_free(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
347 continue;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
348 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
349
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
350 if (pkt->hdr.data_length) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
351 size_t data_length = pkt->hdr.data_length;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
352 pkt->data = g_malloc0(data_length);
1582
d7af2755a397 [svn] - gcc 4.1.0, 4.1.1, 4.1.2 tree optimization workaround:
nenolod
parents: 1580
diff changeset
353 if ((size_t)read(fd, pkt->data, data_length) < data_length) {
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
354 g_free(pkt->data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
355 g_free(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
356 g_warning("ctrlsocket_func(): Incomplete data packet dropped");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
357 continue;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
358 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
359 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
360
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
361 pkt->fd = fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
362 switch (pkt->hdr.command) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
363 case CMD_GET_VERSION:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
364 ctrl_write_gint(pkt->fd, 0x09a3);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
365 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
366 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
367 case CMD_IS_PLAYING:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
368 ctrl_write_gboolean(pkt->fd, bmp_playback_get_playing());
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
369 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
370 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
371 case CMD_IS_PAUSED:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
372 ctrl_write_gboolean(pkt->fd, bmp_playback_get_paused());
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
373 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
374 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
375 case CMD_GET_PLAYLIST_POS:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
376 ctrl_write_gint(pkt->fd, playlist_get_position());
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
377 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
378 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
379 case CMD_GET_PLAYLIST_LENGTH:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
380 ctrl_write_gint(pkt->fd, playlist_get_length());
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
381 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
382 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
383 case CMD_GET_PLAYQUEUE_LENGTH:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
384 ctrl_write_gint(pkt->fd, playlist_queue_get_length());
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
385 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
386 break;
984
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
387 case CMD_PLAYQUEUE_IS_QUEUED:
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
388 ctrl_write_gboolean(pkt->fd,
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
389 playlist_is_position_queued(*((guint32 *) pkt->data)));
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
390 ctrl_ack_packet(pkt);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
391 break;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
392 case CMD_PLAYQUEUE_GET_POS:
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
393 if (pkt->data)
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
394 ctrl_write_gint(pkt->fd,
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
395 playlist_get_queue_position_number(*
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
396 ((guint32 *) pkt->
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
397 data)));
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
398 else
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
399 ctrl_write_gint(pkt->fd, 0);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
400
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
401 ctrl_ack_packet(pkt);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
402 break;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
403 case CMD_PLAYQUEUE_GET_QPOS:
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
404 if (pkt->data)
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
405 ctrl_write_gint(pkt->fd,
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
406 playlist_get_queue_qposition_number(*
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
407 ((guint32 *) pkt->
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
408 data)));
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
409 else
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
410 ctrl_write_gint(pkt->fd, 0);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
411
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
412 ctrl_ack_packet(pkt);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
413 break;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
414 case CMD_GET_OUTPUT_TIME:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
415 if (bmp_playback_get_playing())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
416 ctrl_write_gint(pkt->fd, bmp_playback_get_time());
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
417 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
418 ctrl_write_gint(pkt->fd, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
419 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
420 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
421 case CMD_GET_VOLUME:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
422 input_get_volume(&v[0], &v[1]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
423 ctrl_write_packet(pkt->fd, v, sizeof(v));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
424 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
425 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
426 case CMD_GET_BALANCE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
427 input_get_volume(&v[0], &v[1]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
428 if (v[0] < 0 || v[1] < 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
429 b = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
430 else if (v[0] > v[1])
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
431 b = -100 + ((v[1] * 100) / v[0]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
432 else if (v[1] > v[0])
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
433 b = 100 - ((v[0] * 100) / v[1]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
434 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
435 b = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
436 ctrl_write_gint(pkt->fd, b);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
437 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
438 break;
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
439 case CMD_GET_SKIN:
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
440 ctrl_write_string(pkt->fd, bmp_active_skin->path);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
441 ctrl_ack_packet(pkt);
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
442 break;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
443 case CMD_GET_PLAYLIST_FILE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
444 if (pkt->data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
445 gchar *filename;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
446 filename = playlist_get_filename(*((guint32 *) pkt->data));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
447 ctrl_write_string(pkt->fd, filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
448 g_free(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
449 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
450 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
451 ctrl_write_string(pkt->fd, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
452 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
453 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
454 case CMD_GET_PLAYLIST_TITLE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
455 if (pkt->data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
456 gchar *title;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
457 title = playlist_get_songtitle(*((guint32 *) pkt->data));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
458 ctrl_write_string(pkt->fd, title);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
459 g_free(title);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
460 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
461 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
462 ctrl_write_string(pkt->fd, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
463 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
464 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
465 case CMD_GET_PLAYLIST_TIME:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
466 if (pkt->data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
467 ctrl_write_gint(pkt->fd,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
468 playlist_get_songtime(*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
469 ((guint32 *) pkt->
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
470 data)));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
471 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
472 ctrl_write_gint(pkt->fd, -1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
473
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
474 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
475 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
476 case CMD_GET_INFO:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
477 playback_get_sample_params(&info[0], &info[1], &info[2]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
478 ctrl_write_packet(pkt->fd, info, 3 * sizeof(gint));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
479 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
480 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
481 case CMD_GET_EQ_DATA:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
482 case CMD_SET_EQ_DATA:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
483 /* obsolete */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
484 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
485 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
486 case CMD_PING:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
487 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
488 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
489 case CMD_PLAYLIST_ADD:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
490 if (pkt->data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
491 guint32 *dataptr = pkt->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
492 while ((len = *dataptr) > 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
493 gchar *filename;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
494
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
495 dataptr++;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
496 filename = g_malloc0(len);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
497 memcpy(filename, dataptr, len);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
498
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
499 GDK_THREADS_ENTER();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
500 playlist_add_url(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
501 GDK_THREADS_LEAVE();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
502
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
503 g_free(filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
504 dataptr += (len + 3) / 4;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
505 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
506 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
507 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
508 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
509 case CMD_PLAYLIST_ADD_URL_STRING:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
510 GDK_THREADS_ENTER();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
511 playlist_add_url(pkt->data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
512 GDK_THREADS_LEAVE();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
513
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
514 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
515 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
516 case CMD_PLAYLIST_INS_URL_STRING:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
517 if (pkt->data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
518 gint pos = *(gint *) pkt->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
519 gchar *ptr = pkt->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
520 ptr += sizeof(gint);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
521 playlist_ins_url(ptr, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
522 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
523 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
524 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
525 case CMD_PLAYLIST_DELETE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
526 GDK_THREADS_ENTER();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
527 playlist_delete_index(*((guint32 *) pkt->data));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
528 GDK_THREADS_LEAVE();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
529 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
530 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
531 case CMD_PLAYLIST_CLEAR:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
532 GDK_THREADS_ENTER();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
533 playlist_clear();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
534 mainwin_clear_song_info();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
535 mainwin_set_info_text();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
536 GDK_THREADS_LEAVE();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
537 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
538 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
539 case CMD_IS_MAIN_WIN:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
540 ctrl_write_gboolean(pkt->fd, cfg.player_visible);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
541 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
542 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
543 case CMD_IS_PL_WIN:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
544 ctrl_write_gboolean(pkt->fd, cfg.playlist_visible);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
545 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
546 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
547 case CMD_IS_EQ_WIN:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
548 ctrl_write_gboolean(pkt->fd, cfg.equalizer_visible);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
549 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
550 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
551 case CMD_IS_REPEAT:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
552 ctrl_write_gboolean(pkt->fd, cfg.repeat);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
553 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
554 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
555 case CMD_IS_SHUFFLE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
556 ctrl_write_gboolean(pkt->fd, cfg.shuffle);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
557 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
558 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
559 case CMD_IS_ADVANCE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
560 ctrl_write_gboolean(pkt->fd, !cfg.no_playlist_advance);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
561 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
562 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
563 case CMD_GET_EQ:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
564 fval[0] = equalizerwin_get_preamp();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
565 for (i = 0; i < 10; i++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
566 fval[i + 1] = equalizerwin_get_band(i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
567 ctrl_write_packet(pkt->fd, fval, 11 * sizeof(gfloat));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
568 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
569 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
570 case CMD_GET_EQ_PREAMP:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
571 ctrl_write_gfloat(pkt->fd, equalizerwin_get_preamp());
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
572 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
573 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
574 case CMD_GET_EQ_BAND:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
575 i = *((guint32 *) pkt->data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
576 ctrl_write_gfloat(pkt->fd, equalizerwin_get_band(i));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
577 ctrl_ack_packet(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
578 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
579 default:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
580 g_mutex_lock(packet_list_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
581 packet_list = g_list_append(packet_list, pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
582 ctrl_write_packet(pkt->fd, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
583 close(pkt->fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
584 g_mutex_unlock(packet_list_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
585 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
586 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
587 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
588 g_thread_exit(NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
589
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
590 /* Used to suppress GCC warnings. Sometimes you'd wish C has
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
591 native threading support :p */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
592 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
593 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
594
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
595 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
596 ctrlsocket_check(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
597 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
598 GList *pkt_list, *next;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
599 PacketNode *pkt;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
600 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
601 guint32 v[2], i, num;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
602 gboolean tbool;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
603 gfloat *fval, f;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
604
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
605 g_mutex_lock(packet_list_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
606 for (pkt_list = packet_list; pkt_list; pkt_list = next) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
607 pkt = pkt_list->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
608 data = pkt->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
609
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
610 switch (pkt->hdr.command) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
611 case CMD_PLAY:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
612 if (bmp_playback_get_paused())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
613 bmp_playback_pause();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
614 else if (playlist_get_length())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
615 bmp_playback_initiate();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
616 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
617 mainwin_eject_pushed();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
618 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
619 case CMD_PAUSE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
620 bmp_playback_pause();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
621 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
622 case CMD_STOP:
906
704c0b2e5f6b [svn] - this should be it for now
nhjm449
parents: 680
diff changeset
623 ip_data.stop = TRUE;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
624 bmp_playback_stop();
906
704c0b2e5f6b [svn] - this should be it for now
nhjm449
parents: 680
diff changeset
625 ip_data.stop = FALSE;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
626 mainwin_clear_song_info();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
627 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
628 case CMD_PLAY_PAUSE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
629 if (bmp_playback_get_playing())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
630 bmp_playback_pause();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
631 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
632 bmp_playback_initiate();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
633 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
634 case CMD_PLAYQUEUE_ADD:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
635 num = *((guint32 *) data);
625
0a73d1faeb4e [svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents: 538
diff changeset
636 if (num < (guint)playlist_get_length())
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
637 playlist_queue_position(num);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
638 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
639 case CMD_PLAYQUEUE_REMOVE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
640 num = *((guint32 *) data);
625
0a73d1faeb4e [svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents: 538
diff changeset
641 if (num < (guint)playlist_get_length())
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
642 playlist_queue_remove(num);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
643 break;
984
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
644 case CMD_PLAYQUEUE_CLEAR:
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
645 playlist_clear_queue();
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
646 break;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
647 case CMD_SET_PLAYLIST_POS:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
648 num = *((guint32 *) data);
625
0a73d1faeb4e [svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents: 538
diff changeset
649 if (num < (guint)playlist_get_length())
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
650 playlist_set_position(num);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
651 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
652 case CMD_JUMP_TO_TIME:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
653 num = *((guint32 *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
654 if (playlist_get_current_length() > 0 &&
625
0a73d1faeb4e [svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents: 538
diff changeset
655 num < (guint)playlist_get_current_length())
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
656 bmp_playback_seek(num / 1000);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
657 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
658 case CMD_SET_VOLUME:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
659 v[0] = ((guint32 *) data)[0];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
660 v[1] = ((guint32 *) data)[1];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
661 for (i = 0; i < 2; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
662 if (v[i] > 100)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
663 v[i] = 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
664 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
665 input_set_volume(v[0], v[1]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
666 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
667 case CMD_SET_SKIN:
680
8282b365f6cb [svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents: 625
diff changeset
668 if (has_x11_connection == TRUE)
8282b365f6cb [svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents: 625
diff changeset
669 bmp_active_skin_load(data);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
670 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
671 case CMD_PL_WIN_TOGGLE:
680
8282b365f6cb [svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents: 625
diff changeset
672 if (has_x11_connection != TRUE)
8282b365f6cb [svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents: 625
diff changeset
673 break;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
674 tbool = *((gboolean *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
675 if (tbool)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
676 playlistwin_show();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
677 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
678 playlistwin_hide();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
679 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
680 case CMD_EQ_WIN_TOGGLE:
680
8282b365f6cb [svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents: 625
diff changeset
681 if (has_x11_connection != TRUE)
8282b365f6cb [svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents: 625
diff changeset
682 break;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
683 tbool = *((gboolean *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
684 equalizerwin_show(!!tbool);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
685 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
686 case CMD_SHOW_PREFS_BOX:
680
8282b365f6cb [svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents: 625
diff changeset
687 if (has_x11_connection != TRUE)
8282b365f6cb [svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents: 625
diff changeset
688 break;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
689 show_prefs_window();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
690 break;
984
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
691 case CMD_SHOW_JTF_BOX:
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
692 if (has_x11_connection != TRUE)
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
693 break;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
694 mainwin_jump_to_file();
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 906
diff changeset
695 break;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
696 case CMD_TOGGLE_AOT:
680
8282b365f6cb [svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents: 625
diff changeset
697 if (has_x11_connection != TRUE)
8282b365f6cb [svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents: 625
diff changeset
698 break;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
699 tbool = *((gboolean *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
700 mainwin_set_always_on_top(tbool);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
701 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
702 case CMD_SHOW_ABOUT_BOX:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
703 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
704 case CMD_EJECT:
680
8282b365f6cb [svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents: 625
diff changeset
705 if (has_x11_connection != TRUE)
8282b365f6cb [svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents: 625
diff changeset
706 break;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
707 mainwin_eject_pushed();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
708 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
709 case CMD_PLAYLIST_PREV:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
710 playlist_prev();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
711 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
712 case CMD_PLAYLIST_NEXT:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
713 playlist_next();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
714 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
715 case CMD_TOGGLE_REPEAT:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
716 mainwin_repeat_pushed(!cfg.repeat);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
717 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
718 case CMD_TOGGLE_SHUFFLE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
719 mainwin_shuffle_pushed(!cfg.shuffle);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
720 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
721 case CMD_TOGGLE_ADVANCE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
722 /* FIXME: to be implemented */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
723 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
724 case CMD_MAIN_WIN_TOGGLE:
680
8282b365f6cb [svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents: 625
diff changeset
725 if (has_x11_connection != TRUE)
8282b365f6cb [svn] - Add some sanity checking to make sure we can't do X11 stuff when running headless.
nenolod
parents: 625
diff changeset
726 break;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
727 tbool = *((gboolean *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
728 mainwin_show(!!tbool);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
729 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
730 case CMD_SET_EQ:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
731 if (pkt->hdr.data_length >= 11 * sizeof(gfloat)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
732 fval = (gfloat *) data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
733 equalizerwin_set_preamp(fval[0]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
734 for (i = 0; i < 10; i++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
735 equalizerwin_set_band(i, fval[i + 1]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
736 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
737 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
738 case CMD_SET_EQ_PREAMP:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
739 f = *((gfloat *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
740 equalizerwin_set_preamp(f);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
741 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
742 case CMD_SET_EQ_BAND:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
743 if (pkt->hdr.data_length >= sizeof(gint) + sizeof(gfloat)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
744 i = *((gint *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
745 f = *((gfloat *) ((gchar *) data + sizeof(gint)));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
746 equalizerwin_set_band(i, f);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
747 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
748 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
749 case CMD_QUIT:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
750 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
751 * We unlock the packet_list_mutex to
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
752 * avoid that cleanup_ctrlsocket() can
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
753 * deadlock, mainwin_quit_cb() will
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
754 * never return anyway, so this will
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
755 * work ok.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
756 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
757 g_mutex_unlock(packet_list_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
758 mainwin_quit_cb();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
759 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
760 case CMD_ACTIVATE:
1653
a6e6d3500c13 [svn] - revert back to r2216
nenolod
parents: 1649
diff changeset
761 gtk_window_present(GTK_WINDOW(mainwin));
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
762 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
763 default:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
764 g_message("Unknown socket command received");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
765 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
766 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
767 next = g_list_next(pkt_list);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
768 packet_list = g_list_remove_link(packet_list, pkt_list);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
769 g_list_free_1(pkt_list);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
770 if (pkt->data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
771 g_free(pkt->data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
772 g_free(pkt);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
773 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
774 g_mutex_unlock(packet_list_mutex);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
775 }