- wait for answered line on fax action
This commit is contained in:
parent
d8c24f23e9
commit
ca207a4ded
39
chan_capi.c
39
chan_capi.c
|
@ -417,6 +417,31 @@ MESSAGE_EXCHANGE_ERROR _capi_put_cmsg_wait_conf(struct capi_pvt *i, _cmsg *CMSG)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wait for finishing answering state
|
||||||
|
*/
|
||||||
|
static void capi_wait_for_answered(struct capi_pvt *i)
|
||||||
|
{
|
||||||
|
struct timespec abstime;
|
||||||
|
|
||||||
|
cc_mutex_lock(&i->lock);
|
||||||
|
if (i->state == CAPI_STATE_ANSWERING) {
|
||||||
|
i->waitevent = CAPI_WAITEVENT_ANSWER_FINISH;
|
||||||
|
abstime.tv_sec = time(NULL) + 2;
|
||||||
|
abstime.tv_nsec = 0;
|
||||||
|
cc_verbose(4, 1, "%s: wait for finish answer.\n",
|
||||||
|
i->vname);
|
||||||
|
if (ast_cond_timedwait(&i->event_trigger, &i->lock, &abstime) != 0) {
|
||||||
|
cc_log(LOG_WARNING, "%s: timed out waiting for finish answer.\n",
|
||||||
|
i->vname);
|
||||||
|
} else {
|
||||||
|
cc_verbose(4, 1, "%s: cond signal received for finish answer.\n",
|
||||||
|
i->vname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cc_mutex_unlock(&i->lock);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wait some time for a new capi message
|
* wait some time for a new capi message
|
||||||
*/
|
*/
|
||||||
|
@ -2187,6 +2212,8 @@ static int pbx_capi_receive_fax(struct ast_channel *c, char *data)
|
||||||
if (!headline)
|
if (!headline)
|
||||||
headline = emptyid;
|
headline = emptyid;
|
||||||
|
|
||||||
|
capi_wait_for_answered(i);
|
||||||
|
|
||||||
if ((i->fFax = fopen(filename, "wb")) == NULL) {
|
if ((i->fFax = fopen(filename, "wb")) == NULL) {
|
||||||
cc_log(LOG_WARNING, "can't create fax output file (%s)\n", strerror(errno));
|
cc_log(LOG_WARNING, "can't create fax output file (%s)\n", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -2269,6 +2296,8 @@ static int pbx_capi_send_fax(struct ast_channel *c, char *data)
|
||||||
if (!headline)
|
if (!headline)
|
||||||
headline = emptyid;
|
headline = emptyid;
|
||||||
|
|
||||||
|
capi_wait_for_answered(i);
|
||||||
|
|
||||||
if ((i->fFax = fopen(filename, "rb")) == NULL) {
|
if ((i->fFax = fopen(filename, "rb")) == NULL) {
|
||||||
cc_log(LOG_WARNING, "can't open fax file (%s)\n", strerror(errno));
|
cc_log(LOG_WARNING, "can't open fax file (%s)\n", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -3754,11 +3783,21 @@ static void capidev_post_handling(struct capi_pvt *i, _cmsg *CMSG)
|
||||||
{
|
{
|
||||||
unsigned short capicommand = ((CMSG->Subcommand << 8)|(CMSG->Command));
|
unsigned short capicommand = ((CMSG->Subcommand << 8)|(CMSG->Command));
|
||||||
|
|
||||||
|
if ((i->waitevent == CAPI_WAITEVENT_ANSWER_FINISH) &&
|
||||||
|
(i->state != CAPI_STATE_ANSWERING)) {
|
||||||
|
i->waitevent = 0;
|
||||||
|
ast_cond_signal(&i->event_trigger);
|
||||||
|
cc_verbose(4, 1, "%s: found and signal for finished ANSWER state.\n",
|
||||||
|
i->vname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (i->waitevent == capicommand) {
|
if (i->waitevent == capicommand) {
|
||||||
i->waitevent = 0;
|
i->waitevent = 0;
|
||||||
ast_cond_signal(&i->event_trigger);
|
ast_cond_signal(&i->event_trigger);
|
||||||
cc_verbose(4, 1, "%s: found and signal for %s\n",
|
cc_verbose(4, 1, "%s: found and signal for %s\n",
|
||||||
i->vname, capi_cmd2str(CMSG->Command, CMSG->Subcommand));
|
i->vname, capi_cmd2str(CMSG->Command, CMSG->Subcommand));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,6 +221,10 @@ struct cc_capi_gains {
|
||||||
|
|
||||||
#define CAPI_CHANNELTYPE_B 0
|
#define CAPI_CHANNELTYPE_B 0
|
||||||
#define CAPI_CHANNELTYPE_D 1
|
#define CAPI_CHANNELTYPE_D 1
|
||||||
|
#define CAPI_CHANNELTYPE_NONE 2
|
||||||
|
|
||||||
|
/* the lower word is reserved for capi commands */
|
||||||
|
#define CAPI_WAITEVENT_ANSWER_FINISH 0x80000000
|
||||||
|
|
||||||
/* ! Private data for a capi device */
|
/* ! Private data for a capi device */
|
||||||
struct capi_pvt {
|
struct capi_pvt {
|
||||||
|
|
Loading…
Reference in New Issue