diff --git a/channel.c b/channel.c index a2ac46ff9c..952c7b6ad9 100644 --- a/channel.c +++ b/channel.c @@ -2472,10 +2472,6 @@ static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *fo /* Make sure we only consider audio */ fmt &= AST_FORMAT_AUDIO_MASK; - /* if already in the desired format nothing to do here */ - if (*format == fmt) - return 0; - native = chan->nativeformats; /* Find a translation path from the native format to one of the desired formats */ if (!direction) @@ -2493,6 +2489,13 @@ static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *fo /* Now we have a good choice for both. */ ast_channel_lock(chan); + + if ((*rawformat == native) && (*format == fmt)) { + /* the channel is already in these formats, so nothing to do */ + ast_channel_unlock(chan); + return 0; + } + *rawformat = native; /* User perspective is fmt */ *format = fmt;