summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/m_fixed.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2009-05-24 21:28:16 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2009-05-24 21:28:16 +0000
commit526b5580dabbfed7cfe5439dc3a90ec727f563c2 (patch)
tree22b1af92348785daad16714ee5e2b633017e0e48 /apps/plugins/pdbox/PDa/src/m_fixed.c
parent4f2dfcc01b260d946044ef2b6af5fe36cb772c8d (diff)
downloadrockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.tar.gz
rockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.zip
Cut the files in half and it might work better (note to self: check your tree is really clean before patching)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21070 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/m_fixed.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/m_fixed.c127
1 files changed, 0 insertions, 127 deletions
diff --git a/apps/plugins/pdbox/PDa/src/m_fixed.c b/apps/plugins/pdbox/PDa/src/m_fixed.c
index c91fa0512e..7beaa8077a 100644
--- a/apps/plugins/pdbox/PDa/src/m_fixed.c
+++ b/apps/plugins/pdbox/PDa/src/m_fixed.c
@@ -122,131 +122,4 @@ void pd_checkgui(t_pd *x, t_symbol *s)
122 pd_bind(&ipod->x_obj.ob_pd,s); 122 pd_bind(&ipod->x_obj.ob_pd,s);
123 } 123 }
124} 124}
125
126
127
128#include <sys/socket.h>
129#include <netinet/in.h>
130#include <netinet/tcp.h>
131#include <netdb.h>
132#include <stdio.h>
133
134#include "m_pd.h"
135#include "m_imp.h"
136
137static t_class *ipod_class = 0;
138
139typedef struct _ipod
140{
141 t_object x_obj;
142 t_symbol* x_what;
143} t_ipod;
144
145static t_ipod* ipod;
146static t_int x_fd = -1;
147
148
149
150static void ipod_connect()
151{
152 struct sockaddr_in server;
153 struct hostent *hp;
154 int sockfd;
155 int portno = 3334;
156 char hostname[] = "127.0.0.1";
157 int intarg;
158 if (x_fd >= 0)
159 {
160 error("ipod_connect: already connected");
161 return;
162 }
163
164 /* create a socket */
165 sockfd = socket(AF_INET, SOCK_DGRAM, 0);
166
167 if (sockfd < 0)
168 {
169 sys_sockerror("socket");
170 return;
171 }
172
173 /* connect socket using hostname provided in command line */
174
175 server.sin_family = AF_INET;
176 hp = gethostbyname(hostname);
177 if (hp == 0)
178 {
179 post("bad host?\n");
180 return;
181 }
182
183 memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length);
184
185 server.sin_port = htons((u_short)portno);
186 if (connect(sockfd, (struct sockaddr *) &server, sizeof (server)) < 0)
187 {
188 sys_sockerror("connecting stream socket");
189 sys_closesocket(sockfd);
190 return;
191 }
192 post("connected %s %d",hostname,portno);
193 x_fd = sockfd;
194}
195
196
197
198static void ipod_bang(t_ipod *x)
199{
200 static char sendme[200];
201 sprintf(sendme,"%s bang;\n",x->x_what->s_name);
202 send(x_fd,sendme,strlen(sendme),0);
203
204// if (x->x_sym->s_thing) pd_bang(x->x_sym->s_thing);
205}
206
207static void ipod_float(t_ipod *x, t_float f)
208{
209 static char sendme[200];
210
211 sprintf(sendme,"%s %f;\n",x->x_what->s_name,f);
212 send(x_fd,sendme,strlen(sendme),0);
213
214// post("forwarding float %s",x->x_what->s_name);
215// if (x->x_sym->s_thing) pd_float(x->x_sym->s_thing, f);
216}
217
218static void *ipod_new(t_symbol* what)
219{
220 t_ipod *x = (t_ipod *)pd_new(ipod_class);
221 post("new ipod %s",what->s_name);
222 x->x_what = what;
223 return (x);
224}
225
226static void ipod_setup(void)
227{
228 ipod_class = class_new(gensym("ipod"), (t_newmethod)ipod_new, 0,
229 sizeof(t_ipod), 0, A_DEFSYM, 0);
230 class_addbang(ipod_class, ipod_bang);
231 class_addfloat(ipod_class, ipod_float);
232 ipod_connect();
233}
234
235void pd_checkgui(t_pd *x, t_symbol *s)
236{
237 if (!strncmp(s->s_name,"pod_",4))
238 if (!strcmp((*x)->c_name->s_name,"gatom") ||
239 !strcmp((*x)->c_name->s_name,"vsl") ||
240 !strcmp((*x)->c_name->s_name,"hsl") ||
241 !strcmp((*x)->c_name->s_name,"bng") ||
242 !strcmp((*x)->c_name->s_name,"vradio") ||
243 !strcmp((*x)->c_name->s_name,"hradio")) {
244
245 post("binding %s to %s",s->s_name,(*x)->c_name->s_name);
246 if (!ipod_class) ipod_setup();
247 ipod = ipod_new(s);
248 pd_bind(&ipod->x_obj.ob_pd,s);
249 }
250}
251
252 125