return res;
}
rfmt = c->readformat;
- res = ast_set_read_format(c, AST_FORMAT_SLINEAR);
+ res = ast_set_read_format(c, AST_FORMAT_SLINEAR, 1);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
return -1;
ast_frfree(f);
}
}
- res = ast_set_read_format(c, rfmt);
+ res = ast_set_read_format(c, rfmt, 1);
if (res)
ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", c->name);
ast_dsp_free(sildet);
if (silence > 0) {
rfmt = chan->readformat;
- res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+ res = ast_set_read_format(chan, AST_FORMAT_SLINEAR, 1);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
return -1;
fdprintf(agi->fd, "200 result=%d (randomerror) endpos=%ld\n", res, sample_offset);
if (silence > 0) {
- res = ast_set_read_format(chan, rfmt);
+ res = ast_set_read_format(chan, rfmt, 1);
if (res)
ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name);
ast_dsp_free(sildet);
int readformat;
int res;
readformat = chan->readformat;
- if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) {
+ if (ast_set_read_format(chan, AST_FORMAT_SLINEAR, 1)) {
ast_log(LOG_WARNING, "Unable to set channel '%s' to linear mode\n", chan->name);
return -1;
}
res = agi_exec_full(chan, data, 1, 0);
if (!res) {
- if (ast_set_read_format(chan, readformat)) {
+ if (ast_set_read_format(chan, readformat, 1)) {
ast_log(LOG_WARNING, "Unable to restore channel '%s' to format %s\n", chan->name, ast_getformatname(readformat));
}
}
FILE *fp;
char *stringp=NULL;
- if (ast_set_write_format(chan,AST_FORMAT_ULAW))
+ if (ast_set_write_format(chan,AST_FORMAT_ULAW, 1))
{
ast_log(LOG_WARNING, "Unable to set write format to Mu-law on %s\n",chan->name);
return -1;
}
- if (ast_set_read_format(chan,AST_FORMAT_ULAW))
+ if (ast_set_read_format(chan,AST_FORMAT_ULAW, 1))
{
ast_log(LOG_WARNING, "Unable to set read format to Mu-law on %s\n",chan->name);
return -1;
struct localuser *u;
struct ast_frame *f;
LOCAL_USER_ADD(u);
- ast_set_write_format(chan, ast_best_codec(chan->nativeformats));
- ast_set_read_format(chan, ast_best_codec(chan->nativeformats));
+ ast_set_write_format(chan, ast_best_codec(chan->nativeformats), 1);
+ ast_set_read_format(chan, ast_best_codec(chan->nativeformats), 1);
/* Do our thing here */
while(ast_waitfor(chan, -1) > -1) {
f = ast_read(chan);
if (!f)
break;
+ f->delivery.tv_sec = 0;
+ f->delivery.tv_usec = 0;
if (f->frametype == AST_FRAME_VOICE) {
if (ast_write(chan, f))
break;
ast_stopstream(chan);
owriteformat = chan->writeformat;
- res = ast_set_write_format(chan, AST_FORMAT_SLINEAR);
+ res = ast_set_write_format(chan, AST_FORMAT_SLINEAR, 1);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
return -1;
// if (pid > -1)
// kill(pid, SIGKILL);
if (!res && owriteformat)
- ast_set_write_format(chan, owriteformat);
+ ast_set_write_format(chan, owriteformat, 1);
return res;
}
/* Remember original read format */
oreadformat = chan->readformat;
/* Set mode to signed linear */
- res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+ res = ast_set_read_format(chan, AST_FORMAT_SLINEAR, 1);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set format to signed linear on channel %s\n", chan->name);
return -1;
}
LOCAL_USER_REMOVE(u);
if (!res)
- ast_set_read_format(chan, oreadformat);
+ ast_set_read_format(chan, oreadformat, 1);
return res;
}
if (confflags & CONFFLAG_VIDEO) {
/* Set it into linear mode (write) */
- if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
+ if (ast_set_write_format(chan, AST_FORMAT_SLINEAR, 1) < 0) {
ast_log(LOG_WARNING, "Unable to set '%s' to write linear mode\n", chan->name);
goto outrun;
}
/* Set it into linear mode (read) */
- if (ast_set_read_format(chan, AST_FORMAT_SLINEAR) < 0) {
+ if (ast_set_read_format(chan, AST_FORMAT_SLINEAR, 1) < 0) {
ast_log(LOG_WARNING, "Unable to set '%s' to read linear mode\n", chan->name);
goto outrun;
}
} else {
/* Set it into U-law mode (write) */
- if (ast_set_write_format(chan, AST_FORMAT_ULAW) < 0) {
+ if (ast_set_write_format(chan, AST_FORMAT_ULAW, 1) < 0) {
ast_log(LOG_WARNING, "Unable to set '%s' to write ulaw mode\n", chan->name);
goto outrun;
}
/* Set it into U-law mode (read) */
- if (ast_set_read_format(chan, AST_FORMAT_ULAW) < 0) {
+ if (ast_set_read_format(chan, AST_FORMAT_ULAW, 1) < 0) {
ast_log(LOG_WARNING, "Unable to set '%s' to read ulaw mode\n", chan->name);
goto outrun;
}
struct localuser *u;
LOCAL_USER_ADD(u);
- ast_set_write_format(chan, AST_FORMAT_ULAW);
- ast_set_read_format(chan, AST_FORMAT_ULAW);
+ ast_set_write_format(chan, AST_FORMAT_ULAW, 1);
+ ast_set_read_format(chan, AST_FORMAT_ULAW, 1);
if (chan->_state != AST_STATE_UP)
{
ast_answer(chan);
ast_stopstream(chan);
owriteformat = chan->writeformat;
- res = ast_set_write_format(chan, AST_FORMAT_SLINEAR);
+ res = ast_set_write_format(chan, AST_FORMAT_SLINEAR, 1);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
return -1;
if (pid > -1)
kill(pid, SIGKILL);
if (!res && owriteformat)
- ast_set_write_format(chan, owriteformat);
+ ast_set_write_format(chan, owriteformat, 1);
return res;
}
channel = ast_request(dialstr,AST_FORMAT_SLINEAR,tele);
if (channel)
{
- ast_set_read_format(channel,AST_FORMAT_SLINEAR);
- ast_set_write_format(channel,AST_FORMAT_SLINEAR);
+ ast_set_read_format(channel,AST_FORMAT_SLINEAR, 1);
+ ast_set_write_format(channel,AST_FORMAT_SLINEAR, 1);
#ifdef OURCLID
if (channel->callerid)
free(channel->callerid);
if (silence > 0) {
rfmt = chan->readformat;
- res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+ res = ast_set_read_format(chan, AST_FORMAT_SLINEAR, 1);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
return -1;
LOCAL_USER_REMOVE(u);
if (silence > 0) {
- res = ast_set_read_format(chan, rfmt);
+ res = ast_set_read_format(chan, rfmt, 1);
if (res)
ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name);
if (sildet)
if (maxsilence > 0) {
rfmt = chan->readformat;
- res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+ res = ast_set_read_format(chan, AST_FORMAT_SLINEAR, 1);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
return -1;
}
}
if (rfmt) {
- if (ast_set_read_format(chan, rfmt)) {
+ if (ast_set_read_format(chan, rfmt, 1)) {
ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt), chan->name);
}
}
if (maxsilence > 0) {
rfmt = chan->readformat;
- res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+ res = ast_set_read_format(chan, AST_FORMAT_SLINEAR, 1);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
return -1;
ast_closestream(others[x]);
}
if (rfmt) {
- if (ast_set_read_format(chan, rfmt)) {
+ if (ast_set_read_format(chan, rfmt, 1)) {
ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt), chan->name);
}
}
char *buf = __buf + AST_FRIENDLY_OFFSET;
/* Set it into U-law mode (write) */
- if (ast_set_write_format(chan, AST_FORMAT_ULAW) < 0) {
+ if (ast_set_write_format(chan, AST_FORMAT_ULAW, 1) < 0) {
ast_log(LOG_WARNING, "Unable to set '%s' to write ulaw mode\n", chan->name);
goto outrun;
}
/* Set it into U-law mode (read) */
- if (ast_set_read_format(chan, AST_FORMAT_ULAW) < 0) {
+ if (ast_set_read_format(chan, AST_FORMAT_ULAW, 1) < 0) {
ast_log(LOG_WARNING, "Unable to set '%s' to read ulaw mode\n", chan->name);
goto outrun;
}
char *buf = __buf + AST_FRIENDLY_OFFSET;
/* Set it into U-law mode (write) */
- if (ast_set_write_format(chan, AST_FORMAT_ULAW) < 0) {
+ if (ast_set_write_format(chan, AST_FORMAT_ULAW, 1) < 0) {
ast_log(LOG_WARNING, "Unable to set '%s' to write ulaw mode\n", chan->name);
goto outrun;
}
/* Set it into U-law mode (read) */
- if (ast_set_read_format(chan, AST_FORMAT_ULAW) < 0) {
+ if (ast_set_read_format(chan, AST_FORMAT_ULAW, 1) < 0) {
ast_log(LOG_WARNING, "Unable to set '%s' to read ulaw mode\n", chan->name);
goto outrun;
}
return res;
}
-int ast_set_write_format(struct ast_channel *chan, int fmts)
+int ast_set_write_format(struct ast_channel *chan, int fmts, int needlock)
{
int fmt;
int native;
int res;
+ ast_mutex_lock(&chan->lock);
native = chan->nativeformats;
fmt = fmts;
if (res < 0) {
ast_log(LOG_NOTICE, "Unable to find a path from %s to %s\n",
ast_getformatname(fmts), ast_getformatname(chan->nativeformats));
+ ast_mutex_unlock(&chan->lock);
return -1;
}
chan->pvt->writetrans = ast_translator_build_path(chan->pvt->rawwriteformat, chan->writeformat);
if (option_debug)
ast_log(LOG_DEBUG, "Set channel %s to write format %s\n", chan->name, ast_getformatname(chan->writeformat));
+ ast_mutex_unlock(&chan->lock);
return 0;
}
-int ast_set_read_format(struct ast_channel *chan, int fmts)
+int ast_set_read_format(struct ast_channel *chan, int fmts, int needlock)
{
int fmt;
int native;
int res;
+ if (needlock)
+ ast_mutex_lock(&chan->lock);
native = chan->nativeformats;
fmt = fmts;
/* Find a translation path from the native read format to one of the user's read formats */
if (res < 0) {
ast_log(LOG_NOTICE, "Unable to find a path from %s to %s\n",
ast_getformatname(chan->nativeformats), ast_getformatname(fmts));
+ ast_mutex_unlock(&chan->lock);
return -1;
}
if (option_debug)
ast_log(LOG_DEBUG, "Set channel %s to read format %s\n",
chan->name, ast_getformatname(chan->readformat));
+ ast_mutex_unlock(&chan->lock);
return 0;
}
int peerf;
int chanf;
int res;
+ ast_mutex_lock(&peer->lock);
peerf = peer->nativeformats;
+ ast_mutex_unlock(&peer->lock);
+ ast_mutex_lock(&chan->lock);
chanf = chan->nativeformats;
+ ast_mutex_unlock(&chan->lock);
res = ast_translator_best_choice(&peerf, &chanf);
if (res < 0) {
ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", chan->name, chan->nativeformats, peer->name, peer->nativeformats);
return -1;
}
/* Set read format on channel */
- res = ast_set_read_format(chan, peerf);
+ res = ast_set_read_format(chan, peerf, 1);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", chan->name, chanf);
return -1;
}
/* Set write format on peer channel */
- res = ast_set_write_format(peer, peerf);
+ res = ast_set_write_format(peer, peerf, 1);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", peer->name, peerf);
return -1;
return -1;
}
/* Set writeformat on channel */
- res = ast_set_write_format(chan, chanf);
+ res = ast_set_write_format(chan, chanf, 1);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", chan->name, chanf);
return -1;
}
/* Set read format on peer channel */
- res = ast_set_read_format(peer, chanf);
+ res = ast_set_read_format(peer, chanf, 1);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", peer->name, peerf);
return -1;
/* pvt switches. pbx stays the same, as does next */
/* Set the write format */
- ast_set_write_format(original, wformat);
+ ast_set_write_format(original, wformat, 0);
/* Set the read format */
- ast_set_read_format(original, rformat);
+ ast_set_read_format(original, rformat, 0);
ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
{
struct tonepair_state *ts = params;
if (chan) {
- ast_set_write_format(chan, ts->origwfmt);
+ ast_set_write_format(chan, ts->origwfmt, 0);
}
free(ts);
}
return NULL;
memset(ts, 0, sizeof(struct tonepair_state));
ts->origwfmt = chan->writeformat;
- if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
+ if (ast_set_write_format(chan, AST_FORMAT_SLINEAR, 1)) {
ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", chan->name);
tonepair_release(NULL, ts);
ts = NULL;
/* Native formats changed, reset things */ \
ast->nativeformats = p->chan->nativeformats; \
ast_log(LOG_DEBUG, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\
- ast_set_read_format(ast, ast->readformat); \
- ast_set_write_format(ast, ast->writeformat); \
+ ast_set_read_format(ast, ast->readformat, 0); \
+ ast_set_write_format(ast, ast->writeformat, 0); \
} \
if (p->chan->readformat != ast->pvt->rawreadformat) \
- ast_set_read_format(p->chan, ast->pvt->rawreadformat); \
+ ast_set_read_format(p->chan, ast->pvt->rawreadformat, 0); \
if (p->chan->writeformat != ast->pvt->rawwriteformat) \
- ast_set_write_format(p->chan, ast->pvt->rawwriteformat); \
+ ast_set_write_format(p->chan, ast->pvt->rawwriteformat, 0); \
} \
} while(0)
ast_log( LOG_DEBUG, "Waited for stream, result '%d'\n", res);
}
if (!res) {
- res = ast_set_read_format(p->chan, ast_best_codec(p->chan->nativeformats));
+ res = ast_set_read_format(p->chan, ast_best_codec(p->chan->nativeformats), 0);
ast_log( LOG_DEBUG, "Set read format, result '%d'\n", res);
if (res)
ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
}
if (!res) {
- ast_set_write_format(p->chan, ast_best_codec(p->chan->nativeformats));
+ ast_set_write_format(p->chan, ast_best_codec(p->chan->nativeformats), 0);
ast_log( LOG_DEBUG, "Set write format, result '%d'\n", res);
if (res)
ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
ast_mutex_lock(&agentlock);
ast_mutex_lock(&p->lock);
if (!res) {
- res = ast_set_read_format(chan, ast_best_codec(chan->nativeformats));
+ res = ast_set_read_format(chan, ast_best_codec(chan->nativeformats), 0);
if (res)
ast_log(LOG_WARNING, "Unable to set read format to %d\n", ast_best_codec(chan->nativeformats));
}
if (!res) {
- ast_set_write_format(chan, ast_best_codec(chan->nativeformats));
+ ast_set_write_format(chan, ast_best_codec(chan->nativeformats), 0);
if (res)
ast_log(LOG_WARNING, "Unable to set write format to %d\n", ast_best_codec(chan->nativeformats));
}
orignative = iaxs[fr.callno]->owner->nativeformats;
iaxs[fr.callno]->owner->nativeformats = f.subclass;
if (iaxs[fr.callno]->owner->readformat)
- ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat);
+ ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat, 0);
iaxs[fr.callno]->owner->nativeformats = orignative;
ast_mutex_unlock(&iaxs[fr.callno]->owner->lock);
}
if (iaxs[fr.callno] && iaxs[fr.callno]->owner) {
/* Setup read/write formats properly. */
if (iaxs[fr.callno]->owner->writeformat)
- ast_set_write_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->writeformat);
+ ast_set_write_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->writeformat, 0);
if (iaxs[fr.callno]->owner->readformat)
- ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat);
+ ast_set_read_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->readformat, 0);
ast_mutex_unlock(&iaxs[fr.callno]->owner->lock);
}
}
if (f->subclass != sub->owner->nativeformats) {
ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
sub->owner->nativeformats = f->subclass;
- ast_set_read_format(sub->owner, sub->owner->readformat);
- ast_set_write_format(sub->owner, sub->owner->writeformat);
+ ast_set_read_format(sub->owner, sub->owner->readformat, 0);
+ ast_set_write_format(sub->owner, sub->owner->writeformat, 0);
}
/* Courtesy fearnor aka alex@pilosoft.com */
if (sub->parent->dtmfinband) {
if (f->subclass != p->owner->nativeformats) {
ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
p->owner->nativeformats = f->subclass;
- ast_set_read_format(p->owner, p->owner->readformat);
- ast_set_write_format(p->owner, p->owner->writeformat);
+ ast_set_read_format(p->owner, p->owner->readformat, 0);
+ ast_set_write_format(p->owner, p->owner->writeformat, 0);
}
if (p->dtmfmode & SIP_DTMF_INBAND) {
f = ast_dsp_process(p->owner,p->vad,f,0);
if (!(p->owner->nativeformats & p->jointcapability)) {
ast_log(LOG_DEBUG, "Oooh, we need to change our formats since our peer supports only %d and not %d\n", p->jointcapability, p->owner->nativeformats);
p->owner->nativeformats = sip_codec_choose(p->jointcapability);
- ast_set_read_format(p->owner, p->owner->readformat);
- ast_set_write_format(p->owner, p->owner->writeformat);
+ ast_set_read_format(p->owner, p->owner->readformat, 0);
+ ast_set_write_format(p->owner, p->owner->writeformat, 0);
}
if (p->owner->bridge) {
/* Turn on/off music on hold if we are holding/unholding */
if (f->subclass != sub->owner->nativeformats) {
ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
sub->owner->nativeformats = f->subclass;
- ast_set_read_format(sub->owner, sub->owner->readformat);
- ast_set_write_format(sub->owner, sub->owner->writeformat);
+ ast_set_read_format(sub->owner, sub->owner->readformat, 0);
+ ast_set_write_format(sub->owner, sub->owner->writeformat, 0);
}
}
}
ast_closestream(tmp->vstream);
if (tmp->stream) {
ast_closestream(tmp->stream);
- if (tmp->oldwriteformat && ast_set_write_format(tmp, tmp->oldwriteformat))
+ if (tmp->oldwriteformat && ast_set_write_format(tmp, tmp->oldwriteformat, 1))
ast_log(LOG_WARNING, "Unable to restore format back to %d\n", tmp->oldwriteformat);
}
return 0;
}
chan->oldwriteformat = chan->writeformat;
/* Set the channel to a format we can work with */
- res = ast_set_write_format(chan, fmts);
+ res = ast_set_write_format(chan, fmts, 1);
fd = ast_filehelper(filename2, (char *)chan, NULL, ACTION_OPEN);
if(fd >= 0)
* Set read format for channel to whichever component of "format" is best.
* Returns 0 on success, -1 on failure
*/
-int ast_set_read_format(struct ast_channel *chan, int format);
+int ast_set_read_format(struct ast_channel *chan, int format, int needlock);
//! Sets write format on channel chan
/*!
* Set write format for channel to whichever compoent of "format" is best.
* Returns 0 on success, -1 on failure
*/
-int ast_set_write_format(struct ast_channel *chan, int format);
+int ast_set_write_format(struct ast_channel *chan, int format, int needlock);
//! Sends text to a channel
/*!
{
struct playtones_state *ps = params;
if (chan) {
- ast_set_write_format(chan, ps->origwfmt);
+ ast_set_write_format(chan, ps->origwfmt, 0);
}
if (ps->items) free(ps->items);
free(ps);
return NULL;
memset(ps, 0, sizeof(struct playtones_state));
ps->origwfmt = chan->writeformat;
- if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
+ if (ast_set_write_format(chan, AST_FORMAT_SLINEAR, 1)) {
ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", chan->name);
playtones_release(NULL, ps);
ps = NULL;
ast_stopstream(chan);
- if (ast_set_write_format(chan, AST_FORMAT_ULAW)) {
+ if (ast_set_write_format(chan, AST_FORMAT_ULAW, 1)) {
ast_log(LOG_WARNING, "Unable to set write format to ULAW\n");
return -1;
}
- if (ast_set_read_format(chan, AST_FORMAT_ULAW)) {
+ if (ast_set_read_format(chan, AST_FORMAT_ULAW, 1)) {
ast_log(LOG_WARNING, "Unable to set read format to ULAW\n");
if (writeformat) {
- if (ast_set_write_format(chan, writeformat))
+ if (ast_set_write_format(chan, writeformat, 1))
ast_log(LOG_WARNING, "Unable to restore write format to %d\n", writeformat);
}
return -1;
chan->adsicpe = (chan->adsicpe & ~ADSI_FLAG_DATAMODE) | newdatamode;
if (writeformat)
- ast_set_write_format(chan, writeformat);
+ ast_set_write_format(chan, writeformat, 1);
if (readformat)
- ast_set_read_format(chan, readformat);
+ ast_set_read_format(chan, readformat, 1);
return res;
}
oldwfmt = moh->origwfmt;
free(moh);
if (chan) {
- if (oldwfmt && ast_set_write_format(chan, oldwfmt))
+ if (oldwfmt && ast_set_write_format(chan, oldwfmt, 0))
ast_log(LOG_WARNING, "Unable to restore channel '%s' to format %s\n", chan->name, ast_getformatname(oldwfmt));
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Stopped music on hold on %s\n", chan->name);
ast_mutex_unlock(&moh_lock);
if (res) {
res->origwfmt = chan->writeformat;
- if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) {
+ if (ast_set_write_format(chan, AST_FORMAT_SLINEAR, 1)) {
ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format\n", chan->name);
moh_release(NULL, res);
res = NULL;