diff options
author | Richard Mudgett <rmudgett@digium.com> | 2014-08-14 16:01:39 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2014-08-14 16:01:39 +0000 |
commit | e4b32731b910cdbcc1f9de49dbc8b5fe34d938a5 (patch) | |
tree | e5c4d9f9090b1dc6b2120d21f4af2e12dd4ef7b3 /main/channel_internal_api.c | |
parent | dd41d0ff01097dda0fcade4a22e989de5f1b5619 (diff) |
channel_internal_api.c: Replace some code with ao2_replace().
Use ao2_replace() instead of ao2_cleanup(); ao2_bump().
ao2_replace() has the advantange of not altering the ref count if the
replaced pointer is the same.
Review: https://reviewboard.asterisk.org/r/3904/
........
Merged revisions 420992 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@420993 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/channel_internal_api.c')
-rw-r--r-- | main/channel_internal_api.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c index e32a52791..c62812ea7 100644 --- a/main/channel_internal_api.c +++ b/main/channel_internal_api.c @@ -196,9 +196,9 @@ struct ast_channel { int alertpipe[2]; struct ast_format_cap *nativeformats; /*!< Kinds of data this channel can natively handle */ struct ast_format *readformat; /*!< Requested read format (after translation) */ - struct ast_format *writeformat; /*!< Requested write format (after translation) */ + struct ast_format *writeformat; /*!< Requested write format (before translation) */ struct ast_format *rawreadformat; /*!< Raw read format (before translation) */ - struct ast_format *rawwriteformat; /*!< Raw write format (before translation) */ + struct ast_format *rawwriteformat; /*!< Raw write format (after translation) */ unsigned int emulate_dtmf_duration; /*!< Number of ms left to emulate DTMF for */ #ifdef HAVE_EPOLL int epfd; @@ -828,8 +828,7 @@ struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan) } void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value) { - ao2_cleanup(chan->nativeformats); - chan->nativeformats = ao2_bump(value); + ao2_replace(chan->nativeformats, value); } struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan) { @@ -954,28 +953,23 @@ void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state valu } void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format) { - ao2_cleanup(chan->oldwriteformat); - chan->oldwriteformat = ao2_bump(format); + ao2_replace(chan->oldwriteformat, format); } void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format) { - ao2_cleanup(chan->rawreadformat); - chan->rawreadformat = ao2_bump(format); + ao2_replace(chan->rawreadformat, format); } void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format) { - ao2_cleanup(chan->rawwriteformat); - chan->rawwriteformat = ao2_bump(format); + ao2_replace(chan->rawwriteformat, format); } void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format) { - ao2_cleanup(chan->readformat); - chan->readformat = ao2_bump(format); + ao2_replace(chan->readformat, format); } void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format) { - ao2_cleanup(chan->writeformat); - chan->writeformat = ao2_bump(format); + ao2_replace(chan->writeformat, format); } struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan) { |