*** channels.orig/chan_alsa.c Mon Jul 26 20:54:35 2004 --- channels/chan_alsa.c Mon Jul 26 20:54:21 2004 *************** *** 485,490 **** --- 485,492 ---- } write(sndcmd[1], &res, sizeof(res)); } + snd_pcm_prepare(alsa.icard); + snd_pcm_start(alsa.icard); ast_mutex_unlock(&alsalock); return 0; } *************** *** 505,510 **** --- 507,514 ---- answer_sound(); ast_setstate(c, AST_STATE_UP); cursound = -1; + snd_pcm_prepare(alsa.icard); + snd_pcm_start(alsa.icard); ast_mutex_unlock(&alsalock); return 0; } *************** *** 524,529 **** --- 528,534 ---- res = 2; write(sndcmd[1], &res, sizeof(res)); } + snd_pcm_drop(alsa.icard); ast_mutex_unlock(&alsalock); return 0; } *************** *** 616,624 **** f.delivery.tv_sec = 0; f.delivery.tv_usec = 0; ! state = snd_pcm_state(alsa.ocard); ! if (state == SND_PCM_STATE_XRUN) { ! snd_pcm_prepare(alsa.ocard); } buf = __buf + AST_FRIENDLY_OFFSET/2; --- 621,630 ---- f.delivery.tv_sec = 0; f.delivery.tv_usec = 0; ! state = snd_pcm_state(alsa.icard); ! if ((state != SND_PCM_STATE_PREPARED) && ! (state != SND_PCM_STATE_RUNNING)) { ! snd_pcm_prepare(alsa.icard); } buf = __buf + AST_FRIENDLY_OFFSET/2; *************** *** 832,837 **** --- 838,845 ---- } answer_sound(); } + snd_pcm_prepare(alsa.icard); + snd_pcm_start(alsa.icard); ast_mutex_unlock(&alsalock); return RESULT_SUCCESS; } *************** *** 977,982 **** --- 985,1013 ---- int x; struct ast_config *cfg; struct ast_variable *v; + if ((cfg = ast_load(config))) { + v = ast_variable_browse(cfg, "general"); + while(v) { + if (!strcasecmp(v->name, "autoanswer")) + autoanswer = ast_true(v->value); + else if (!strcasecmp(v->name, "silencesuppression")) + silencesuppression = ast_true(v->value); + else if (!strcasecmp(v->name, "silencethreshold")) + silencethreshold = atoi(v->value); + else if (!strcasecmp(v->name, "context")) + strncpy(context, v->value, sizeof(context)-1); + else if (!strcasecmp(v->name, "language")) + strncpy(language, v->value, sizeof(language)-1); + else if (!strcasecmp(v->name, "extension")) + strncpy(exten, v->value, sizeof(exten)-1); + else if (!strcasecmp(v->name, "input_device")) + strncpy(indevname, v->value, sizeof(indevname)-1); + else if (!strcasecmp(v->name, "output_device")) + strncpy(outdevname, v->value, sizeof(outdevname)-1); + v=v->next; + } + ast_destroy(cfg); + } res = pipe(sndcmd); if (res) { ast_log(LOG_ERROR, "Unable to create pipe\n"); *************** *** 1001,1029 **** } for (x=0;xname, "autoanswer")) - autoanswer = ast_true(v->value); - else if (!strcasecmp(v->name, "silencesuppression")) - silencesuppression = ast_true(v->value); - else if (!strcasecmp(v->name, "silencethreshold")) - silencethreshold = atoi(v->value); - else if (!strcasecmp(v->name, "context")) - strncpy(context, v->value, sizeof(context)-1); - else if (!strcasecmp(v->name, "language")) - strncpy(language, v->value, sizeof(language)-1); - else if (!strcasecmp(v->name, "extension")) - strncpy(exten, v->value, sizeof(exten)-1); - else if (!strcasecmp(v->name, "input_device")) - strncpy(indevname, v->value, sizeof(indevname)-1); - else if (!strcasecmp(v->name, "output_device")) - strncpy(outdevname, v->value, sizeof(outdevname)-1); - v=v->next; - } - ast_destroy(cfg); - } pthread_create(&sthread, NULL, sound_thread, NULL); #ifdef ALSA_MONITOR if (alsa_monitor_start()) { --- 1032,1037 ----