diff options
author | Jenkins2 <jenkins2@gerrit.asterisk.org> | 2017-07-17 08:03:40 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-07-17 08:03:40 -0500 |
commit | f1c2ba156ea90a3bb1fb135c8620ff99d9abea72 (patch) | |
tree | 80630725782ef5dfefd6c61bdc344679ecd46638 | |
parent | 9f66fb790122be8cc747e2465d72b66a7d7f3498 (diff) | |
parent | a4c85309f0059fa840bf351566dd897c02dbe353 (diff) |
Merge "res/res_stasis_snoop: generate silence when audiohook returns null" into 13
-rw-r--r-- | res/res_stasis_snoop.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/res/res_stasis_snoop.c b/res/res_stasis_snoop.c index abdef6e46..da66894f6 100644 --- a/res/res_stasis_snoop.c +++ b/res/res_stasis_snoop.c @@ -74,6 +74,8 @@ struct stasis_app_snoop { unsigned int whisper_active:1; /*! \brief Uniqueid of the channel this snoop is snooping on */ char uniqueid[AST_MAX_UNIQUEID]; + /*! \brief A frame of silence to use when the audiohook returns null */ + struct ast_frame silence; }; /*! \brief Destructor for snoop structure */ @@ -93,6 +95,11 @@ static void snoop_destroy(void *obj) ast_audiohook_destroy(&snoop->whisper); } + if (snoop->silence.data.ptr) { + ast_free(snoop->silence.data.ptr); + snoop->silence.data.ptr = NULL; + } + ast_free(snoop->app); ast_channel_cleanup(snoop->chan); @@ -199,7 +206,7 @@ static struct ast_frame *snoop_read(struct ast_channel *chan) frame = ast_audiohook_read_frame(&snoop->spy, snoop->spy_samples, snoop->spy_direction, snoop->spy_format); ast_audiohook_unlock(&snoop->spy); - return frame ? frame : &ast_null_frame; + return frame ? frame : &snoop->silence; } /*! \brief Callback function for hanging up a Snoop channel */ @@ -385,6 +392,19 @@ struct ast_channel *stasis_app_control_snoop(struct ast_channel *chan, snoop->spy_samples = ast_format_get_sample_rate(snoop->spy_format) / (1000 / SNOOP_INTERVAL); snoop->spy_active = 1; + + snoop->silence.frametype = AST_FRAME_VOICE, + snoop->silence.datalen = snoop->spy_samples * sizeof(uint16_t), + snoop->silence.samples = snoop->spy_samples, + snoop->silence.mallocd = 0, + snoop->silence.offset = 0, + snoop->silence.src = __PRETTY_FUNCTION__, + snoop->silence.subclass.format = snoop->spy_format, + snoop->silence.data.ptr = ast_calloc(snoop->spy_samples, sizeof(uint16_t)); + if (!snoop->silence.data.ptr) { + ast_hangup(snoop->chan); + return NULL; + } } /* If whispering is enabled set up the audiohook */ |