diff options
author | Joshua Colp <jcolp@digium.com> | 2014-12-12 17:01:42 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2014-12-12 17:01:42 +0000 |
commit | 8d325be50333b58fe659dd67d4b4932bca068344 (patch) | |
tree | a3a0577aa4e605cee757995df2d020c03a33354b /main/codec.c | |
parent | 72499dc6970e6679c35f8732a0a840f9e3f303b7 (diff) |
media: Fix crash when determining sample count of a frame during shutdown.
When shutting down Asterisk the codecs are cleaned up. As a result anything
attempting to get a codec based on ID or details will find that no codec
exists. This currently occurs when determining the sample count of a frame.
This code did not take this situation into account.
This change fixes this by getting the codec directly from the format and
eliminates the lookup. This is both faster and also provides a guarantee
that the codec will exist and will be valid.
ASTERISK-24604 #close
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/4260/
........
Merged revisions 429497 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@429498 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/codec.c')
-rw-r--r-- | main/codec.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/main/codec.c b/main/codec.c index e060efe3e..19e78fa67 100644 --- a/main/codec.c +++ b/main/codec.c @@ -355,10 +355,7 @@ unsigned int ast_codec_samples_count(struct ast_frame *frame) return 0; } - /* BUGBUG - why not just get the codec pointer off the format? - This is a bit roundabout - */ - codec = ast_codec_get_by_id(ast_format_get_codec_id(frame->subclass.format)); + codec = ast_format_get_codec(frame->subclass.format); if (codec->samples_count) { samples = codec->samples_count(frame); |