report_fax_status(chan, details, "Allocating Resources");
if (details->caps & AST_FAX_TECH_AUDIO) {
- expected_frametype = AST_FRAME_VOICE;;
+ expected_frametype = AST_FRAME_VOICE;
ast_format_set(&expected_framesubclass.format, AST_FORMAT_SLINEAR, 0);
ast_format_copy(&orig_write_format, ast_channel_writeformat(chan));
if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
static int fax_gateway_start(struct fax_gateway *gateway, struct ast_fax_session_details *details, struct ast_channel *chan)
{
struct ast_fax_session *s;
+ int start_res;
/* create the FAX session */
if (!(s = fax_session_new(details, chan, gateway->s, gateway->token))) {
gateway->s = s;
gateway->token = NULL;
- if (gateway->s->tech->start_session(gateway->s) < 0) {
+ ast_channel_unlock(chan);
+ start_res = gateway->s->tech->start_session(gateway->s);
+ ast_channel_lock(chan);
+ if (start_res < 0) {
ast_string_field_set(details, result, "FAILED");
ast_string_field_set(details, resultstr, "error starting gateway session");
ast_string_field_set(details, error, "INIT_ERROR");
struct ast_fax_session_details *details;
struct ast_control_t38_parameters *control_params;
struct ast_channel *peer;
+ RAII_VAR(struct ast_channel *, chan_ref, chan, ao2_cleanup);
int result = 0;
+ /* Ref bump the channel for when we have to unlock it */
+ ao2_ref(chan, 1);
+
details = faxdetect->details;
switch (event) {
case AST_FRAMEHOOK_EVENT_DETACHED:
/* restore audio formats when we are detached */
ast_set_read_format(chan, &faxdetect->orig_format);
- if ((peer = ast_bridged_channel(chan))) {
+ peer = ast_bridged_channel(chan);
+ if (peer) {
+ ao2_ref(peer, +1);
+ ast_channel_unlock(chan);
ast_channel_make_compatible(chan, peer);
+ ast_channel_lock(chan);
+ ao2_ref(peer, -1);
}
return NULL;
case AST_FRAMEHOOK_EVENT_READ:
p->ist38 = 1;
p->ast_t38_state = ast_channel_get_t38_state(s->chan);
- if (!(peer = ast_bridged_channel(s->chan))) {
+ ast_channel_lock(s->chan);
+ peer = ast_bridged_channel(s->chan);
+ if (!peer) {
ast_channel_unlock(s->chan);
return -1;
}
+ ao2_ref(peer, +1);
+ ast_channel_unlock(s->chan);
/* we can be in T38_STATE_NEGOTIATING or T38_STATE_NEGOTIATED when the
* gateway is started. We treat both states the same. */
}
ast_activate_generator(p->ast_t38_state == T38_STATE_NEGOTIATED ? peer : s->chan, &t30_gen , s);
+ ao2_ref(peer, -1);
set_logging(&p->t38_gw_state.logging, s->details);
set_logging(&p->t38_core_state->logging, s->details);