mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 20:56:39 +00:00
Backport of AUDIOHOOK_INHERIT for Asterisk 1.4
(closes issue #13538) Reported by: mbit Patches: 13538.patch uploaded by putnopvut (license 60) Tested by: putnopvut git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@166157 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -451,6 +451,25 @@ static struct ast_audiohook *find_audiohook_by_source(struct ast_audiohook_list
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ast_audiohook_move_by_source (struct ast_channel *old_chan, struct ast_channel *new_chan, const char *source)
|
||||
{
|
||||
struct ast_audiohook *audiohook = find_audiohook_by_source(old_chan->audiohooks, source);
|
||||
|
||||
if (!audiohook) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* By locking both channels and the audiohook, we can assure that
|
||||
* another thread will not have a chance to read the audiohook's status
|
||||
* as done, even though ast_audiohook_remove signals the trigger
|
||||
* condition
|
||||
*/
|
||||
ast_audiohook_lock(audiohook);
|
||||
ast_audiohook_remove(old_chan, audiohook);
|
||||
ast_audiohook_attach(new_chan, audiohook);
|
||||
ast_audiohook_unlock(audiohook);
|
||||
}
|
||||
|
||||
/*! \brief Detach specified source audiohook from channel
|
||||
* \param chan Channel to detach from
|
||||
* \param source Name of source to detach
|
||||
@@ -478,6 +497,42 @@ int ast_audiohook_detach_source(struct ast_channel *chan, const char *source)
|
||||
return (audiohook ? 0 : -1);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Remove an audiohook from a specified channel
|
||||
*
|
||||
* \param chan Channel to remove from
|
||||
* \param audiohook Audiohook to remove
|
||||
*
|
||||
* \return Returns 0 on success, -1 on failure
|
||||
*
|
||||
* \note The channel does not need to be locked before calling this function
|
||||
*/
|
||||
int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audiohook)
|
||||
{
|
||||
ast_channel_lock(chan);
|
||||
|
||||
if (!chan->audiohooks) {
|
||||
ast_channel_unlock(chan);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (audiohook->type == AST_AUDIOHOOK_TYPE_SPY)
|
||||
AST_LIST_REMOVE(&chan->audiohooks->spy_list, audiohook, list);
|
||||
else if (audiohook->type == AST_AUDIOHOOK_TYPE_WHISPER)
|
||||
AST_LIST_REMOVE(&chan->audiohooks->whisper_list, audiohook, list);
|
||||
else if (audiohook->type == AST_AUDIOHOOK_TYPE_MANIPULATE)
|
||||
AST_LIST_REMOVE(&chan->audiohooks->manipulate_list, audiohook, list);
|
||||
|
||||
ast_audiohook_lock(audiohook);
|
||||
audiohook->status = AST_AUDIOHOOK_STATUS_DONE;
|
||||
ast_cond_signal(&audiohook->trigger);
|
||||
ast_audiohook_unlock(audiohook);
|
||||
|
||||
ast_channel_unlock(chan);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! \brief Pass a DTMF frame off to be handled by the audiohook core
|
||||
* \param chan Channel that the list is coming off of
|
||||
* \param audiohook_list List of audiohooks
|
||||
|
@@ -3665,11 +3665,11 @@ int ast_do_masquerade(struct ast_channel *original)
|
||||
/* Move data stores over */
|
||||
if (AST_LIST_FIRST(&clone->datastores)) {
|
||||
struct ast_datastore *ds;
|
||||
AST_LIST_APPEND_LIST(&original->datastores, &clone->datastores, entry);
|
||||
AST_LIST_TRAVERSE(&original->datastores, ds, entry) {
|
||||
AST_LIST_TRAVERSE(&clone->datastores, ds, entry) {
|
||||
if (ds->info->chan_fixup)
|
||||
ds->info->chan_fixup(ds->data, clone, original);
|
||||
}
|
||||
AST_LIST_APPEND_LIST(&original->datastores, &clone->datastores, entry);
|
||||
}
|
||||
|
||||
clone_variables(original, clone);
|
||||
|
Reference in New Issue
Block a user