printk("giova: timer_func %d %d NULL: continue\n", __LINE__, i);
continue;
}
- if (in_irq())
- printk("giova: timer_func %d %d we are in HARDWARE IRQ\n", __LINE__, i);
+ //if (in_irq())
+ //printk("giova: timer_func %d %d we are in HARDWARE IRQ\n", __LINE__, i);
//if(in_softirq())
//printk("giova: timer_func %d %d we are in SOFT IRQ\n", __LINE__, i);
//printk("giova: timer_func %d %d\n", __LINE__, i);
struct snd_dummy_pcm *dpcm = runtime->private_data;
//printk("giova: pointer %d %p\n", __LINE__, dpcm);
- //return bytes_to_frames(runtime, dpcm->pcm_buf_pos / dpcm->pcm_hz);
- return (dpcm->pcm_buf_pos / dpcm->pcm_hz) / 2;
+ return bytes_to_frames(runtime, dpcm->pcm_buf_pos / dpcm->pcm_hz);
+ //return (dpcm->pcm_buf_pos / dpcm->pcm_hz) / 2;
}
static struct snd_pcm_hardware snd_card_dummy_playback = {
--- /dev/null
+cp -a skypiax101/* skypiax102/
+cp -a skypiax101/* skypiax103/
+cp -a skypiax101/* skypiax104/
+cp -a skypiax101/* skypiax105/
+cp -a skypiax101/* skypiax106/
+cp -a skypiax101/* skypiax107/
+cp -a skypiax101/* skypiax108/
+cp -a skypiax101/* skypiax109/
+cp -a skypiax101/* skypiax110/
+cp -a skypiax101/* skypiax111/
+cp -a skypiax101/* skypiax112/
+cp -a skypiax101/* skypiax113/
+cp -a skypiax101/* skypiax114/
+cp -a skypiax101/* skypiax115/
+cp -a skypiax101/* skypiax116/
+cp -a skypiax101/* skypiax117/
+cp -a skypiax101/* skypiax118/
+cp -a skypiax101/* skypiax119/
+cp -a skypiax101/* skypiax120/
+cp -a skypiax101/* skypiax121/
+cp -a skypiax101/* skypiax122/
+cp -a skypiax101/* skypiax123/
+cp -a skypiax101/* skypiax124/
+cp -a skypiax101/* skypiax125/
+cp -a skypiax101/* skypiax126/
+cp -a skypiax101/* skypiax127/
+cp -a skypiax101/* skypiax128/
+cp -a skypiax101/* skypiax129/
+cp -a skypiax101/* skypiax130/
+cp -a skypiax101/* skypiax131/
+cp -a skypiax101/* skypiax132/
+cp -a skypiax101/* skypiax133/
+cp -a skypiax101/* skypiax134/
+cp -a skypiax101/* skypiax135/
+cp -a skypiax101/* skypiax136/
+cp -a skypiax101/* skypiax137/
+cp -a skypiax101/* skypiax138/
+cp -a skypiax101/* skypiax139/
+cp -a skypiax101/* skypiax140/
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)) {
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",
if (channel) {
- if (!switch_channel_test_flag(channel, CF_BRIDGED)) {
+ //if (!switch_channel_test_flag(channel, CF_BRIDGED)) {
switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) };
DEBUGA_SKYPE("received DTMF %c on channel %s\n", SKYPIAX_P_LOG, dtmf.digit, switch_channel_get_name(channel));
switch_channel_queue_dtmf(channel, &dtmf);
switch_set_flag(tech_pvt, TFLAG_DTMF);
switch_mutex_unlock(tech_pvt->flag_mutex);
- } else {
- NOTICA
- ("received a DTMF on channel %s, but we're BRIDGED, so let's NOT relay it out of band\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
- }
+ //} else {
+ //NOTICA
+ //("received a DTMF on channel %s, but we're BRIDGED, so let's NOT relay it out of band\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
+ //}
} else {
WARNINGA("received %c DTMF, but no channel?\n", SKYPIAX_P_LOG, value[0]);
}
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;
}
if (len == 320) {
unsigned int howmany;
+ //DEBUGA_SKYPE("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;
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,
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 {
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;
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);
+ //DEBUGA_SKYPE("write buffer filled at %d\n", SKYPIAX_P_LOG, waitin);
+ waitin=0;
+ big_waited=1;
+ continue;
+ }
+
+ }
+ if(waitin > 21){
+ //DEBUGA_SKYPE("waitin is now %d\n", SKYPIAX_P_LOG, waitin);
}
- //ERRORA("write is now 1\n", SKYPIAX_P_LOG);
rt = 1;
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){
+ //DEBUGA_SKYPE("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)));