提交 1fcb884e authored 作者: Giovanni Maruzzelli's avatar Giovanni Maruzzelli

skypiax: nothing to see here

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16636 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 0a2ee53b
Index: skypiax_protocol.c
===================================================================
--- skypiax_protocol.c (revision 16633)
+++ skypiax_protocol.c (working copy)
@@ -813,11 +813,14 @@
to.tv_usec = 60000; //60 msec
to.tv_sec = 0;
+ if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) {
+ switch_core_timer_next(&tech_pvt->timer_read);
+ }
rt = select(fdselect + 1, &fs, NULL, NULL, &to);
if (rt > 0) {
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
- len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
+ len = recv(fd, (char *) srv_in, 640, 0); //seems that Skype only sends 320 bytes at time
} else {
len = 0;
}
@@ -825,6 +828,7 @@
if (len == 320) {
unsigned int howmany;
+ ERRORA("320!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", SKYPIAX_P_LOG);
if (samplerate_skypiax == 8000) {
/* we're downsampling from 16khz to 8khz, srv_out will contain each other sample from srv_in */
a = 0;
@@ -869,10 +873,12 @@
if (tech_pvt->flag_audio_srv == 1) {
switch_sleep(1000); //1 millisec
}
- if (tech_pvt->flag_audio_srv == 0) {
+ //if (tech_pvt->flag_audio_srv == 0) {
+ switch_mutex_lock(tech_pvt->mutex_audio_srv);
memcpy(tech_pvt->audiobuf_srv, totalbuf, SAMPLES_PER_FRAME * sizeof(short));
tech_pvt->flag_audio_srv = 1;
- }
+ switch_mutex_unlock(tech_pvt->mutex_audio_srv);
+ //}
//NOTICA("read \n", SKYPIAX_P_LOG);
if (howmany != SAMPLES_PER_FRAME * sizeof(short)) {
ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG,
@@ -882,10 +888,19 @@
tech_pvt->audiobuf_is_loaded = 0;
}
+ } else if (len == 640) {
+
+ if (tech_pvt->flag_audio_srv == 1) {
+ switch_sleep(1000); //1 millisec
+ }
+ switch_mutex_lock(tech_pvt->mutex_audio_srv);
+ memcpy(tech_pvt->audiobuf_srv, srv_in, SAMPLES_PER_FRAME * sizeof(short));
+ tech_pvt->flag_audio_srv = 1;
+ switch_mutex_unlock(tech_pvt->mutex_audio_srv);
} else if (len == 0) {
skypiax_sleep(1000);
} else {
- DEBUGA_SKYPE("len=%d, expected 320\n", SKYPIAX_P_LOG, len);
+ ERRORA("len=%d, expected 640\n", SKYPIAX_P_LOG, len);
}
} else {
@@ -1017,6 +1032,10 @@
int rt;
fd_set fs;
struct timeval to;
+ int waitin;
+ int big_waitin=40;
+ int lil_waitin=20;
+ int big_waited;
if (!(running && tech_pvt->running))
break;
@@ -1040,15 +1059,37 @@
FD_SET(fdselect, &fs);
//FIXME rt = select(fdselect + 1, NULL, &fs, NULL, &to);
+ waitin=0;
+ big_waited=0;
while (tech_pvt->flag_audio_cli == 0) {
#ifdef WIN32
skypiax_sleep(100); //0.1 millisec
#else
skypiax_sleep(1000); //1 millisec
#endif //WIN32
- //WARNINGA("write now is 0\n", SKYPIAX_P_LOG);
+ waitin++;
+ if(big_waited == 1 && waitin==lil_waitin && tech_pvt->flag_audio_cli == 0){
+ memset(cli_out, 255, SAMPLES_PER_FRAME * sizeof(short));
+ send(fd, (char *) cli_out, SAMPLES_PER_FRAME * sizeof(short), 0);
+ //WARNINGA("write buffer filled at %d\n", SKYPIAX_P_LOG, waitin);
+ waitin=0;
+ continue;
+ }
+ if(big_waited == 0 && waitin==big_waitin && tech_pvt->flag_audio_cli == 0){
+ memset(cli_out, 255, SAMPLES_PER_FRAME * sizeof(short));
+ send(fd, (char *) cli_out, SAMPLES_PER_FRAME * sizeof(short), 0);
+ send(fd, (char *) cli_out, SAMPLES_PER_FRAME * sizeof(short), 0);
+ WARNINGA("write buffer filled at %d\n", SKYPIAX_P_LOG, waitin);
+ waitin=0;
+ big_waited=1;
+ continue;
+ }
+
}
- //ERRORA("write is now 1\n", SKYPIAX_P_LOG);
+ if(waitin > 21)
+ ERRORA("waitin is now %d\n", SKYPIAX_P_LOG, waitin);
+ if(!waitin)
+ NOTICA("waitin is now %d\n", SKYPIAX_P_LOG, waitin);
rt = 1;
@@ -1149,22 +1190,28 @@
int skypiax_audio_read(private_t * tech_pvt)
{
unsigned int samples;
+ int waitin;
+ waitin=0;
while (tech_pvt->flag_audio_srv == 0) {
#ifdef WIN32
skypiax_sleep(100); //0.1 millisec
#else
skypiax_sleep(1000); //1 millisec
#endif //WIN32
+ waitin++;
//WARNINGA("read now is 0\n", SKYPIAX_P_LOG);
}
- //ERRORA("read is now 1\n", SKYPIAX_P_LOG);
+ if(waitin > 21)
+ NOTICA("read is now %d\n", SKYPIAX_P_LOG, waitin);
//samples = skypiax_pipe_read(tech_pvt->audiopipe_srv[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short));
- samples = SAMPLES_PER_FRAME * sizeof(short);
+ switch_mutex_lock(tech_pvt->mutex_audio_srv);
memcpy(tech_pvt->read_frame.data, tech_pvt->audiobuf_srv, SAMPLES_PER_FRAME * sizeof(short));
tech_pvt->flag_audio_srv = 0;
+ switch_mutex_unlock(tech_pvt->mutex_audio_srv);
+ samples = SAMPLES_PER_FRAME * sizeof(short);
if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
if (samples)
WARNINGA("read samples=%u expected=%u\n", SKYPIAX_P_LOG, samples, (int) (SAMPLES_PER_FRAME * sizeof(short)));
Index: mod_skypiax.c
===================================================================
--- mod_skypiax.c (revision 16633)
+++ mod_skypiax.c (working copy)
@@ -719,7 +719,6 @@
DEBUGA_SKYPE("CHANNEL READ CONTINUE\n", SKYPIAX_P_LOG);
continue;
}
- switch_core_timer_check(&tech_pvt->timer_read, SWITCH_TRUE);
*frame = &tech_pvt->read_frame;
#if SWITCH_BYTE_ORDER == __BIG_ENDIAN
if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
@@ -1393,6 +1392,7 @@
switch_sleep(100000);
skypiax_audio_init(&globals.SKYPIAX_INTERFACES[interface_id]);
+ switch_mutex_init(&globals.SKYPIAX_INTERFACES[interface_id].mutex_audio_srv, SWITCH_MUTEX_NESTED, skypiax_module_pool);
NOTICA
("WAITING roughly 10 seconds to find a running Skype client and connect to its SKYPE API for interface_id=%d\n",
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论