[Freeswitch-svn] [commit] r10589 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
FreeSWITCH SVN
gmaruzz at freeswitch.org
Thu Dec 4 01:32:53 PST 2008
Author: gmaruzz
Date: Thu Dec 4 04:32:52 2008
New Revision: 10589
Log:
skypiax: converting to use APR pipes, compiles and works. Now let's eliminate strsep
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Thu Dec 4 04:32:52 2008
@@ -130,7 +130,7 @@
Window skype_win;
Display *disp;
Window win;
- int fdesc[2];
+ switch_file_t *fdesc[2];
};
#else //WIN32_SKYPIAX
@@ -812,6 +812,7 @@
//fdselect = p->audioskypepipe[0];
+ fdselect=1;
FD_ZERO(&fs);
FD_SET(fdselect, &fs);
to.tv_usec = 100;
@@ -863,7 +864,18 @@
int skypiax_skypeaudio_init(struct skypiax_interface *p)
{
- int c;
+
+//switch_file_t *readp = NULL;
+//switch_file_t *writep = NULL;
+
+ switch_status_t rv;
+
+ //rv = switch_file_pipe_create_ex(&readp, &writep, APR_FULL_NONBLOCK, module_pool);
+ rv = switch_file_pipe_create_ex(&p->audiopipe[0], &p->audiopipe[1], 2, module_pool);
+ //rv = switch_file_pipe_create(&readp, &writep, module_pool);
+
+
+ //FIXME int c;
#if 0
/* build the pipe that will be polled on by pbx */
c = pipe(p->audiopipe);
@@ -891,6 +903,7 @@
}
*/
+ rv = switch_file_pipe_create_ex(&p->audioskypepipe[0], &p->audioskypepipe[1], 2, module_pool);
#ifdef NOTDEF_WIN32_SKYPIAX
c = pipe(p->audioskypepipe);
if (c) {
@@ -913,11 +926,11 @@
{
struct skypiax_interface *p;
short buf[640];
- int samples;
- int fd;
+ unsigned int samples;
+ //int fd;
int rt;
- fd_set fs;
- struct timeval to;
+ //fd_set fs;
+ //struct timeval to;
p = tech_pvt->p;
@@ -926,17 +939,24 @@
memset(buf, '\0', sizeof(buf));
+#if 0
fd = p->audiopipe[0];
FD_ZERO(&fs);
FD_SET(fd, &fs);
to.tv_usec = 100000;
to.tv_sec = 0;
rt = select(fd + 1, &fs, NULL, NULL, &to);
+#endif
+ rt=1;
if (rt > 0) {
+ samples = SAMPLES_PER_FRAME * sizeof(short);
+
+ switch_file_read(p->audiopipe[0], tech_pvt->read_frame.data, &samples);
+
//if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320)
- if ((samples = read(p->audiopipe[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
+ if (samples != 320) {
DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples,
320);
switch_sleep(1000);
@@ -957,7 +977,7 @@
return SWITCH_STATUS_SUCCESS;
}
-#ifdef NOTDEF
+#if 0
//cicopet
struct ast_frame *skypiax_skypeaudio_read(struct skypiax_interface *p)
{
@@ -1007,7 +1027,7 @@
}
return &f;
}
-#endif //NOTDEF
+#endif //0
#endif /* SKYPE_AUDIO */
static void tech_init(private_t *tech_pvt, switch_core_session_t *session, skypiax_interface_t *p)
@@ -1254,7 +1274,7 @@
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
//switch_frame_t *pframe;
- int sent;
+ unsigned int sent;
struct skypiax_interface *p=NULL;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL WRITE FRAME\n");
@@ -1278,7 +1298,8 @@
}
#endif
- sent = write(p->audioskypepipe[1], (short *) frame->data, frame->datalen);
+ sent = frame->datalen;
+ switch_file_write(p->audioskypepipe[1], (short *) frame->data, &sent);
//ERRORA("sent %d\n", SKYPIAX_P_LOG, sent);
@@ -1286,7 +1307,7 @@
}
-#if 1
+#if 0
switch_file_t *readp = NULL;
switch_file_t *writep = NULL;
@@ -1561,7 +1582,7 @@
return SWITCH_STATUS_SUCCESS;
}
-#ifdef NOTDEF //FIXME: moved below
+#if 0
/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
*/
@@ -1612,7 +1633,7 @@
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
-#endif // NOTDEF //FIXME: moved below
+#endif // 0 //FIXME: moved below
static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event)
{
@@ -1793,7 +1814,7 @@
Display *disp = NULL;
Window root = -1;
Window win = -1;
-int res;
+//int res;
p = obj;
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -1808,6 +1829,9 @@
}
*/
+ switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], 2, module_pool);
+
+#if 0
res = pipe(p->AsteriskHandlesAst.fdesc);
if (res) {
ERRORA("Unable to create skype pipe, exiting skype thread\n", SKYPIAX_P_LOG);
@@ -1816,6 +1840,7 @@
}
fcntl(p->AsteriskHandlesAst.fdesc[0], F_SETFL, O_NONBLOCK);
fcntl(p->AsteriskHandlesAst.fdesc[1], F_SETFL, O_NONBLOCK);
+#endif
AsteriskHandlesAst = &p->AsteriskHandlesAst;
@@ -1903,7 +1928,11 @@
strcat(buffer, buf);
if (i < 20) { /* last fragment */
- write(AsteriskHandlesAst->fdesc[1], b, strlen(b) + 1);
+ unsigned int howmany;
+
+ howmany = strlen(b) + 1;
+
+ switch_file_write(AsteriskHandlesAst->fdesc[1], b, &howmany);
//write(AsteriskHandlesAst->fdesc[1], "\0", 1);
//FIXME DEBUGA_SKYPE("SKYPE pipewrite: |||%s|||len=%d serial=%ld\n\n\n", SKYPIAX_P_LOG, b, strlen(b) + 1, an_event.xclient.serial);
//switch_sleep(1000);
@@ -2021,28 +2050,33 @@
char messaggio_2[4096];
char *buf, obj[512] = "", id[512] = "", prop[512] = "", value[512] = "", *where;
char **stringp = NULL;
- int fd;
+ //int fd;
int rt;
- fd_set fs;
- struct timeval to;
- int howmany, i, a;
+ //fd_set fs;
+ //struct timeval to;
+ int i, a;
+ unsigned int howmany;
if (option_debug > 100) {
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
}
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
memset(read_from_pipe, 0, 4096);
memset(messaggio, 0, 4096);
memset(messaggio_2, 0, 4096);
+#if 0
fd = p->AsteriskHandlesAst.fdesc[0];
FD_ZERO(&fs);
FD_SET(fd, &fs);
to.tv_usec = 100;
to.tv_sec = 0;
rt = select(fd + 1, &fs, NULL, NULL, &to);
+#endif
+ rt=1;
if (rt > 0) {
- howmany =
- read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, sizeof(read_from_pipe));
+ howmany = sizeof(read_from_pipe);
+ switch_file_read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, &howmany);
a = 0;
for (i = 0; i < howmany; i++) {
@@ -2051,7 +2085,7 @@
if (read_from_pipe[i] == '\0') {
- if (option_debug > 101)
+ //if (option_debug > 101)
DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG,
howmany, i, a, messaggio);
@@ -2556,6 +2590,7 @@
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return 0;
}
More information about the Freeswitch-svn
mailing list