switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
unsigned int sent;
-
+//cicopet
channel = switch_core_session_get_channel(session);
switch_assert(channel != NULL);
}
#endif
+tech_pvt->begin_to_write=1;
sent = frame->datalen;
#ifdef WIN32
//switch_file_write(tech_pvt->audiopipe_cli[1], frame->data, &sent);
#else /* WIN32 */
//sent = write(tech_pvt->audiopipe_cli[1], frame->data, sent);
#endif /* WIN32 */
- if (tech_pvt->flag_audio_cli == 1) {
- switch_sleep(1000); //1 millisec
- }
- if (tech_pvt->flag_audio_cli == 0) {
+ //if (tech_pvt->flag_audio_cli == 1) {
+ //switch_sleep(1000); //1 millisec
+ //}
+ //if (tech_pvt->flag_audio_cli == 0) {
#ifdef TIMER_WRITE
- switch_core_timer_next(&tech_pvt->timer_write);
+ //switch_core_timer_next(&tech_pvt->timer_write);
#endif // TIMER_WRITE
+memset(tech_pvt->audiobuf_cli, 255, sizeof(tech_pvt->audiobuf_cli));
+ switch_mutex_lock(tech_pvt->mutex_audio_cli);
memcpy(tech_pvt->audiobuf_cli, frame->data, frame->datalen);
tech_pvt->flag_audio_cli = 1;
- }
+ switch_mutex_unlock(tech_pvt->mutex_audio_cli);
+ //}
//NOTICA("write \n", SKYPIAX_P_LOG);
if (sent != frame->datalen && sent != -1) {
switch_mutex_unlock(globals.mutex);
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
- switch_channel_set_variable(channel, "send_silence_when_idle", "1500");
+ //switch_channel_set_variable(channel, "send_silence_when_idle", "1500");
switch_channel_set_variable(channel, "waste", "false");
if (skypiax_tech_init(tech_pvt, *new_session) != SWITCH_STATUS_SUCCESS) {
ERRORA("Doh! no tech_init?\n", SKYPIAX_P_LOG);
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);
+ switch_mutex_init(&globals.SKYPIAX_INTERFACES[interface_id].mutex_audio_cli, 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",
{
switch_threadattr_t *thd_attr = NULL;
+tech_pvt->begin_to_write=0;
+
switch_threadattr_create(&thd_attr, skypiax_module_pool);
switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_core_session_destroy(&session);
return 0;
}
- switch_channel_set_variable(channel, "send_silence_when_idle", "1500");
+ //switch_channel_set_variable(channel, "send_silence_when_idle", "1500");
switch_channel_set_variable(channel, "waste", "false");
if (skypiax_tech_init(tech_pvt, session) != SWITCH_STATUS_SUCCESS) {
ERRORA("Doh! no tech_init?\n", SKYPIAX_P_LOG);
int rt;
fd_set fs;
struct timeval to;
+#if 0
int waitin;
-#if 1
int big_waitin=40;
int lil_waitin=20;
-#endif//0
int big_waited;
+#endif//0
if (!(running && tech_pvt->running))
break;
fdselect = fd;
FD_SET(fdselect, &fs);
+#if 0
//rt = select(fdselect + 1, NULL, &fs, NULL, &to);
waitin=0;
big_waited=0;
skypiax_sleep(1000); //1 millisec
#endif //WIN32
waitin++;
-#if 1
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);
big_waited=1;
continue;
}
-#endif //0
}
if(waitin > 21){
NOTICA("waitin is now %d\n", SKYPIAX_P_LOG, waitin);
}
+#endif //0
+
+
+if(tech_pvt->begin_to_write==0){
+skypiax_sleep(1000);
+continue;
+}
+ if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next) {
+ switch_core_timer_next(&tech_pvt->timer_write);
+}
rt = 1;
if (rt > 0) {
got = SAMPLES_PER_FRAME * sizeof(short);
+ switch_mutex_lock(tech_pvt->mutex_audio_cli);
+//if(tech_pvt->flag_audio_cli == 0){
+//memset(tech_pvt->audiobuf_cli, 255, sizeof(tech_pvt->audiobuf_cli));
+//}
memcpy(cli_in, tech_pvt->audiobuf_cli, SAMPLES_PER_FRAME * sizeof(short));
tech_pvt->flag_audio_cli = 0;
+ switch_mutex_unlock(tech_pvt->mutex_audio_cli);