Asterisk - The Open Source Telephony Project  18.5.0
Functions
control.h File Reference

Internal API for the Stasis application controller. More...

#include "asterisk/stasis_app.h"
Include dependency graph for control.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int control_add_channel_to_bridge (struct stasis_app_control *control, struct ast_channel *chan, void *data)
 Command callback for adding a channel to a bridge. More...
 
struct stasis_appcontrol_app (struct stasis_app_control *control)
 Returns the pointer (non-reffed) to the app associated with this control. More...
 
int control_command_count (struct stasis_app_control *control)
 Returns the count of items in a control's command queue. More...
 
struct stasis_app_controlcontrol_create (struct ast_channel *channel, struct stasis_app *app)
 Create a control object. More...
 
int control_dispatch_all (struct stasis_app_control *control, struct ast_channel *chan)
 Dispatch all commands enqueued to this control. More...
 
void control_flush_queue (struct stasis_app_control *control)
 Flush the control command queue. More...
 
int control_is_done (struct stasis_app_control *control)
 Returns true if control_continue() has been called on this control. More...
 
void control_mark_done (struct stasis_app_control *control)
 
void control_move_cleanup (struct stasis_app_control *control)
 Free any memory that was allocated for switching applications via /channels/{channelId}/move. More...
 
char * control_next_app (struct stasis_app_control *control)
 Returns the name of the application we are moving to. More...
 
char ** control_next_app_args (struct stasis_app_control *control)
 Returns the list of arguments to pass to the application we are moving to. More...
 
int control_next_app_args_size (struct stasis_app_control *control)
 Returns the number of arguments to be passed to the application we are moving to. More...
 
int control_prestart_dispatch_all (struct stasis_app_control *control, struct ast_channel *chan)
 Dispatch all queued prestart commands. More...
 
void control_set_app (struct stasis_app_control *control, struct stasis_app *app)
 Set the application the control object belongs to. More...
 
void control_silence_stop_now (struct stasis_app_control *control)
 Stop playing silence to a channel right now. More...
 
int control_swap_channel_in_bridge (struct stasis_app_control *control, struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap)
 Command for swapping a channel in a bridge. More...
 
void control_wait (struct stasis_app_control *control)
 Blocks until control's command queue has a command available. More...
 

Detailed Description

Internal API for the Stasis application controller.

Author
David M. Lee, II dlee@.nosp@m.digi.nosp@m.um.co.nosp@m.m
Since
12

Definition in file control.h.

Function Documentation

◆ control_add_channel_to_bridge()

int control_add_channel_to_bridge ( struct stasis_app_control control,
struct ast_channel chan,
void *  data 
)

Command callback for adding a channel to a bridge.

Parameters
controlThe control for chan
chanThe channel on which commands should be executed
dataBridge to be passed to the callback

Definition at line 1378 of file control.c.

References control_swap_channel_in_bridge(), and NULL.

Referenced by stasis_app_control_add_channel_to_bridge().

1379 {
1380  return control_swap_channel_in_bridge(control, data, chan, NULL);
1381 }
int control_swap_channel_in_bridge(struct stasis_app_control *control, struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap)
Command for swapping a channel in a bridge.
Definition: control.c:1284
#define NULL
Definition: resample.c:96

◆ control_app()

struct stasis_app* control_app ( struct stasis_app_control control)

Returns the pointer (non-reffed) to the app associated with this control.

Parameters
controlControl to query.
Returns
A pointer to the associated stasis_app

Definition at line 1563 of file control.c.

References stasis_app_control::app.

Referenced by bridge_stasis_moving(), bridge_stasis_push_peek(), channel_replaced_cb(), channel_stolen_cb(), and stasis_app_exec().

1564 {
1565  return control->app;
1566 }
struct stasis_app * app
Definition: control.c:90

◆ control_command_count()

int control_command_count ( struct stasis_app_control control)

Returns the count of items in a control's command queue.

Parameters
controlControl to count commands on
Return values
numberof commands in the command que

Definition at line 343 of file control.c.

References ao2_container_count(), and stasis_app_control::command_queue.

Referenced by stasis_app_control_execute_until_exhausted().

344 {
345  return ao2_container_count(control->command_queue);
346 }
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
struct ao2_container * command_queue
Definition: control.c:54

◆ control_create()

struct stasis_app_control* control_create ( struct ast_channel channel,
struct stasis_app app 
)

Create a control object.

Parameters
channelChannel to control.
appstasis_app for which this control is being created.
Returns
New control object.
NULL on error.

Definition at line 123 of file control.c.

References stasis_app_control::add_rules, ao2_alloc, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_bump, ao2_container_alloc_list, ao2_ref, stasis_app_control::app, ast_channel_ref, ast_cond_init, AST_LIST_HEAD_INIT, ast_log, AST_VECTOR_INIT, stasis_app_control::channel, stasis_app_control::command_queue, control_dtor(), errno, LOG_ERROR, stasis_app_control::next_app, NULL, stasis_app_control::remove_rules, and stasis_app_control::wait_cond.

Referenced by stasis_app_control_create(), and stasis_app_exec().

124 {
125  struct stasis_app_control *control;
126  int res;
127 
128  control = ao2_alloc(sizeof(*control), control_dtor);
129  if (!control) {
130  return NULL;
131  }
132 
133  AST_LIST_HEAD_INIT(&control->add_rules);
134  AST_LIST_HEAD_INIT(&control->remove_rules);
135 
136  res = ast_cond_init(&control->wait_cond, NULL);
137  if (res != 0) {
138  ast_log(LOG_ERROR, "Error initializing ast_cond_t: %s\n",
139  strerror(errno));
140  ao2_ref(control, -1);
141  return NULL;
142  }
143 
144  control->app = ao2_bump(app);
145 
146  ast_channel_ref(channel);
147  control->channel = channel;
148 
151  if (!control->command_queue) {
152  ao2_ref(control, -1);
153  return NULL;
154  }
155 
156  control->next_app = NULL;
157  AST_VECTOR_INIT(&control->next_app_args, 0);
158 
159  return control;
160 }
ast_cond_t wait_cond
Definition: control.c:52
char * next_app
Definition: control.c:94
struct app_control_rules remove_rules
Definition: control.c:80
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Definition: astobj2.h:1335
#define ast_cond_init(cond, attr)
Definition: lock.h:199
#define NULL
Definition: resample.c:96
struct stasis_app * app
Definition: control.c:90
#define ao2_bump(obj)
Definition: astobj2.h:491
#define ast_log
Definition: astobj2.c:42
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_channel * channel
Definition: control.c:60
struct ao2_container * command_queue
Definition: control.c:54
#define LOG_ERROR
Definition: logger.h:285
int errno
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
Definition: linkedlists.h:625
#define ast_channel_ref(c)
Increase channel reference count.
Definition: channel.h:2970
static void control_dtor(void *obj)
Definition: control.c:105
struct app_control_rules add_rules
Definition: control.c:76

◆ control_dispatch_all()

int control_dispatch_all ( struct stasis_app_control control,
struct ast_channel chan 
)

Dispatch all commands enqueued to this control.

Parameters
controlControl object to dispatch.
chanAssociated channel.
Returns
Number of commands executed

Definition at line 1495 of file control.c.

References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, AO2_ITERATOR_UNLINK, ao2_ref, ast_assert, stasis_app_control::channel, command_invoke(), and stasis_app_control::command_queue.

Referenced by stasis_app_control_execute_until_exhausted(), and stasis_app_exec().

1497 {
1498  int count = 0;
1499  struct ao2_iterator iter;
1500  struct stasis_app_command *command;
1501 
1502  ast_assert(control->channel == chan);
1503 
1505  while ((command = ao2_iterator_next(&iter))) {
1506  command_invoke(command, control, chan);
1507  ao2_ref(command, -1);
1508  ++count;
1509  }
1510  ao2_iterator_destroy(&iter);
1511 
1512  return count;
1513 }
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ast_assert(a)
Definition: utils.h:695
void command_invoke(struct stasis_app_command *command, struct stasis_app_control *control, struct ast_channel *chan)
Definition: command.c:101
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_channel * channel
Definition: control.c:60
struct ao2_container * command_queue
Definition: control.c:54
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1841
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.

◆ control_flush_queue()

void control_flush_queue ( struct stasis_app_control control)

Flush the control command queue.

Since
13.9.0
Parameters
controlControl object to flush command queue.
Returns
Nothing

Definition at line 1482 of file control.c.

References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, AO2_ITERATOR_UNLINK, ao2_ref, command_complete(), and stasis_app_control::command_queue.

Referenced by stasis_app_control_flush_queue(), and stasis_app_exec().

1483 {
1484  struct ao2_iterator iter;
1485  struct stasis_app_command *command;
1486 
1488  while ((command = ao2_iterator_next(&iter))) {
1489  command_complete(command, -1);
1490  ao2_ref(command, -1);
1491  }
1492  ao2_iterator_destroy(&iter);
1493 }
void command_complete(struct stasis_app_command *command, int retval)
Definition: command.c:77
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ao2_container * command_queue
Definition: control.c:54
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1841
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.

◆ control_is_done()

int control_is_done ( struct stasis_app_control control)

Returns true if control_continue() has been called on this control.

Parameters
controlControl to query.
Returns
True (non-zero) if control_continue() has been called.
False (zero) otherwise.

Definition at line 348 of file control.c.

Referenced by stasis_app_control_execute_until_exhausted(), stasis_app_control_is_done(), and stasis_app_exec().

349 {
350  /* Called from stasis_app_exec thread; no lock needed */
351  return control->is_done;
352 }

◆ control_mark_done()

void control_mark_done ( struct stasis_app_control control)

Definition at line 354 of file control.c.

References ao2_lock, ao2_unlock, and stasis_app_control::command_queue.

Referenced by app_control_continue(), stasis_app_control_execute_until_exhausted(), and stasis_app_exec().

355 {
356  /* Locking necessary to sync with other threads adding commands to the queue. */
357  ao2_lock(control->command_queue);
358  control->is_done = 1;
359  ao2_unlock(control->command_queue);
360 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ao2_container * command_queue
Definition: control.c:54

◆ control_move_cleanup()

void control_move_cleanup ( struct stasis_app_control control)

Free any memory that was allocated for switching applications via /channels/{channelId}/move.

Parameters
controlThe control for the channel

Definition at line 1702 of file control.c.

References ast_free, ast_free_ptr(), AST_VECTOR_RESET, stasis_app_control::next_app, and NULL.

Referenced by app_control_move(), control_dtor(), and stasis_app_exec().

1703 {
1704  ast_free(control->next_app);
1705  control->next_app = NULL;
1706 
1707  AST_VECTOR_RESET(&control->next_app_args, ast_free_ptr);
1708 }
char * next_app
Definition: control.c:94
#define NULL
Definition: resample.c:96
void ast_free_ptr(void *ptr)
free() wrapper
Definition: astmm.c:1771
#define ast_free(a)
Definition: astmm.h:182
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
Definition: vector.h:627

◆ control_next_app()

char* control_next_app ( struct stasis_app_control control)

Returns the name of the application we are moving to.

Parameters
controlThe control for the channel
Returns
The name of the application we are moving to

Definition at line 1697 of file control.c.

References stasis_app_control::next_app.

Referenced by stasis_app_exec().

1698 {
1699  return control->next_app;
1700 }
char * next_app
Definition: control.c:94

◆ control_next_app_args()

char** control_next_app_args ( struct stasis_app_control control)

Returns the list of arguments to pass to the application we are moving to.

Note
If you wish to get the size of the list, control_next_app_args_size should be called before this, as this function will steal the elements from the string vector and set the size to 0.
Parameters
controlThe control for the channel
Returns
The arguments to pass to the application we are moving to

Definition at line 1710 of file control.c.

References AST_VECTOR_STEAL_ELEMENTS.

Referenced by stasis_app_exec().

1711 {
1712  return AST_VECTOR_STEAL_ELEMENTS(&control->next_app_args);
1713 }
#define AST_VECTOR_STEAL_ELEMENTS(vec)
Steal the elements from a vector and reinitialize.
Definition: vector.h:140

◆ control_next_app_args_size()

int control_next_app_args_size ( struct stasis_app_control control)

Returns the number of arguments to be passed to the application we are moving to.

Note
This should always be called before control_next_app_args, as calling that function will steal all elements from the string vector and set the size to 0.
Parameters
controlThe control for the channel
Returns
The number of arguments to be passed to the application we are moving to

Definition at line 1715 of file control.c.

References AST_VECTOR_SIZE.

Referenced by stasis_app_exec().

1716 {
1717  return AST_VECTOR_SIZE(&control->next_app_args);
1718 }
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ control_prestart_dispatch_all()

int control_prestart_dispatch_all ( struct stasis_app_control control,
struct ast_channel chan 
)

Dispatch all queued prestart commands.

Parameters
controlThe control for chan
channelThe channel on which commands should be executed
Returns
The number of commands executed

Definition at line 1535 of file control.c.

References ao2_cleanup, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, AO2_ITERATOR_UNLINK, ast_channel_lock, ast_channel_unlock, command_invoke(), command_prestart_get_container(), and stasis_app_control::command_queue.

Referenced by stasis_app_exec().

1537 {
1538  struct ao2_container *command_queue;
1539  int count = 0;
1540  struct ao2_iterator iter;
1541  struct stasis_app_command *command;
1542 
1543  ast_channel_lock(chan);
1544  command_queue = command_prestart_get_container(chan);
1545  ast_channel_unlock(chan);
1546  if (!command_queue) {
1547  return 0;
1548  }
1549 
1550  iter = ao2_iterator_init(command_queue, AO2_ITERATOR_UNLINK);
1551 
1552  while ((command = ao2_iterator_next(&iter))) {
1553  command_invoke(command, control, chan);
1554  ao2_cleanup(command);
1555  ++count;
1556  }
1557 
1558  ao2_iterator_destroy(&iter);
1559  ao2_cleanup(command_queue);
1560  return count;
1561 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
struct ao2_container * command_prestart_get_container(struct ast_channel *chan)
Get the Stasis() prestart commands for a channel.
Definition: command.c:160
void command_invoke(struct stasis_app_command *command, struct stasis_app_control *control, struct ast_channel *chan)
Definition: command.c:101
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
#define ast_channel_unlock(chan)
Definition: channel.h:2946
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1841
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Generic container type.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.

◆ control_set_app()

void control_set_app ( struct stasis_app_control control,
struct stasis_app app 
)

Set the application the control object belongs to.

Parameters
controlThe control for the channel
appThe application this control will now belong to
Note
This will unref control's previous app by 1, and bump app by 1

Definition at line 1691 of file control.c.

References ao2_bump, ao2_cleanup, and stasis_app_control::app.

Referenced by stasis_app_exec().

1692 {
1693  ao2_cleanup(control->app);
1694  control->app = ao2_bump(app);
1695 }
struct stasis_app * app
Definition: control.c:90
#define ao2_bump(obj)
Definition: astobj2.h:491
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ control_silence_stop_now()

void control_silence_stop_now ( struct stasis_app_control control)

Stop playing silence to a channel right now.

Since
13.9.0
Parameters
controlThe control for chan

Definition at line 837 of file control.c.

References ast_channel_stop_silence_generator(), ast_debug, stasis_app_control::channel, NULL, stasis_app_control::silgen, and stasis_app_control_get_channel_id().

Referenced by app_control_silence_stop(), and stasis_app_exec().

838 {
839  if (control->silgen) {
840  ast_debug(3, "%s: Stopping silence generator\n",
843  control->channel, control->silgen);
844  control->silgen = NULL;
845  }
846 }
#define NULL
Definition: resample.c:96
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
struct ast_channel * channel
Definition: control.c:60
const char * stasis_app_control_get_channel_id(const struct stasis_app_control *control)
Returns the uniqueid of the channel associated with this control.
Definition: control.c:1430
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
Stops a previously-started silence generator on the given channel.
Definition: channel.c:8312
struct ast_silence_generator * silgen
Definition: control.c:84

◆ control_swap_channel_in_bridge()

int control_swap_channel_in_bridge ( struct stasis_app_control control,
struct ast_bridge bridge,
struct ast_channel chan,
struct ast_channel swap 
)

Command for swapping a channel in a bridge.

Parameters
controlThe control for chan
chanThe channel on which commands should be executed
bridgeBridge to be passed to the callback
swapChannel to swap with when joining the bridge

Definition at line 1284 of file control.c.

References ao2_lock, ao2_unlock, stasis_app_control::app, app_subscribe_bridge(), ast_assert, ast_bridge_depart(), ast_bridge_impart(), AST_BRIDGE_IMPART_CHAN_DEPARTABLE, AST_BRIDGE_IMPART_INHIBIT_JOIN_COLP, ast_bridge_set_after_callback(), ast_channel_lock, ast_channel_pbx(), ast_channel_pbx_set(), ast_channel_unlock, ast_debug, ast_log, stasis_app_control::bridge, bridge_after_cb(), bridge_after_cb_failed(), stasis_app_control::bridge_features, ast_bridge_features::inhibit_colp, LOG_ERROR, NULL, stasis_app_control::pbx, set_interval_hook(), stasis_app_control_get_channel_id(), stasis_app_get_bridge(), and ast_bridge::uniqueid.

Referenced by control_add_channel_to_bridge(), and defer_bridge_add().

1285 {
1286  int res;
1287  struct ast_bridge_features *features;
1289 
1290  if (!control || !bridge) {
1291  return -1;
1292  }
1293 
1294  ast_debug(3, "%s: Adding to bridge %s\n",
1296  bridge->uniqueid);
1297 
1298  ast_assert(chan != NULL);
1299 
1300  /* Depart whatever Stasis bridge we're currently in. */
1301  if (stasis_app_get_bridge(control)) {
1302  /* Note that it looks like there's a race condition here, since
1303  * we don't have control locked. But this happens from the
1304  * control callback thread, so there won't be any other
1305  * concurrent attempts to bridge.
1306  */
1307  ast_bridge_depart(chan);
1308  }
1309 
1310 
1312  bridge_after_cb_failed, control);
1313  if (res != 0) {
1314  ast_log(LOG_ERROR, "Error setting after-bridge callback\n");
1315  return -1;
1316  }
1317 
1318  ao2_lock(control);
1319 
1320  /* Ensure the controlling application is subscribed early enough
1321  * to receive the ChannelEnteredBridge message. This works in concert
1322  * with the subscription handled in the Stasis application execution
1323  * loop */
1324  app_subscribe_bridge(control->app, bridge);
1325 
1326  /* Save off the channel's PBX */
1327  ast_assert(control->pbx == NULL);
1328  if (!control->pbx) {
1329  control->pbx = ast_channel_pbx(chan);
1330  ast_channel_pbx_set(chan, NULL);
1331  }
1332 
1333  /* Pull bridge features from the control */
1334  features = control->bridge_features;
1335  control->bridge_features = NULL;
1336  if (features && features->inhibit_colp) {
1338  }
1339 
1340  ast_assert(stasis_app_get_bridge(control) == NULL);
1341  /* We need to set control->bridge here since bridge_after_cb may be run
1342  * before ast_bridge_impart returns. bridge_after_cb gets a reason
1343  * code so it can tell if the bridge is actually valid or not.
1344  */
1345  control->bridge = bridge;
1346 
1347  /* We can't be holding the control lock while impart is running
1348  * or we could create a deadlock with bridge_after_cb which also
1349  * tries to lock control.
1350  */
1351  ao2_unlock(control);
1352  res = ast_bridge_impart(bridge,
1353  chan,
1354  swap,
1355  features, /* features */
1356  flags);
1357  if (res != 0) {
1358  /* ast_bridge_impart failed before it could spawn the depart
1359  * thread. The callbacks aren't called in this case.
1360  * The impart could still fail even if ast_bridge_impart returned
1361  * ok but that's handled by bridge_after_cb.
1362  */
1363  ast_log(LOG_ERROR, "Error adding channel to bridge\n");
1364  ao2_lock(control);
1365  ast_channel_pbx_set(chan, control->pbx);
1366  control->pbx = NULL;
1367  control->bridge = NULL;
1368  ao2_unlock(control);
1369  } else {
1370  ast_channel_lock(chan);
1371  set_interval_hook(chan);
1372  ast_channel_unlock(chan);
1373  }
1374 
1375  return res;
1376 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
unsigned int inhibit_colp
const ast_string_field uniqueid
Definition: bridge.h:409
Structure that contains features information.
static void bridge_after_cb(struct ast_channel *chan, void *data)
Definition: control.c:1163
struct ast_bridge * stasis_app_get_bridge(struct stasis_app_control *control)
Gets the bridge currently associated with a control object.
Definition: control.c:931
#define ast_assert(a)
Definition: utils.h:695
#define ao2_unlock(a)
Definition: astobj2.h:730
#define NULL
Definition: resample.c:96
int ast_bridge_set_after_callback(struct ast_channel *chan, ast_bridge_after_cb callback, ast_bridge_after_cb_failed failed, void *data)
Setup an after bridge callback for when the channel leaves the bridging system.
Definition: bridge_after.c:259
int app_subscribe_bridge(struct stasis_app *app, struct ast_bridge *bridge)
Add a bridge subscription to an existing channel subscription.
struct stasis_app * app
Definition: control.c:90
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, enum ast_bridge_impart_flags flags) attribute_warn_unused_result
Impart a channel to a bridge (non-blocking)
Definition: bridge.c:1924
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_bridge_features * bridge_features
Definition: control.c:68
#define LOG_ERROR
Definition: logger.h:285
static void set_interval_hook(struct ast_channel *chan)
Set a dial timeout interval hook on the channel.
Definition: control.c:1254
int ast_bridge_depart(struct ast_channel *chan)
Depart a channel from a bridge.
Definition: bridge.c:1952
static void bridge_after_cb_failed(enum ast_bridge_after_cb_reason reason, void *data)
Definition: control.c:1170
struct ast_pbx * pbx
Definition: control.c:72
const char * stasis_app_control_get_channel_id(const struct stasis_app_control *control)
Returns the uniqueid of the channel associated with this control.
Definition: control.c:1430
#define ast_channel_unlock(chan)
Definition: channel.h:2946
struct ast_bridge * bridge
Definition: control.c:64
void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value)

◆ control_wait()

void control_wait ( struct stasis_app_control control)

Blocks until control's command queue has a command available.

Parameters
controlControl to block on.

Definition at line 1515 of file control.c.

References ao2_container_count(), ao2_lock, ao2_object_get_lockaddr(), ao2_unlock, ast_assert, ast_cond_wait, ast_log, stasis_app_control::command_queue, LOG_ERROR, NULL, and stasis_app_control::wait_cond.

Referenced by stasis_app_exec().

1516 {
1517  if (!control) {
1518  return;
1519  }
1520 
1521  ast_assert(control->command_queue != NULL);
1522 
1523  ao2_lock(control->command_queue);
1524  while (ao2_container_count(control->command_queue) == 0) {
1525  int res = ast_cond_wait(&control->wait_cond,
1527  if (res < 0) {
1528  ast_log(LOG_ERROR, "Error waiting on command queue\n");
1529  break;
1530  }
1531  }
1532  ao2_unlock(control->command_queue);
1533 }
ast_cond_t wait_cond
Definition: control.c:52
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ast_cond_wait(cond, mutex)
Definition: lock.h:203
#define ast_assert(a)
Definition: utils.h:695
#define ao2_unlock(a)
Definition: astobj2.h:730
#define NULL
Definition: resample.c:96
void * ao2_object_get_lockaddr(void *obj)
Return the mutex lock address of an object.
Definition: astobj2.c:476
#define ast_log
Definition: astobj2.c:42
#define ao2_lock(a)
Definition: astobj2.h:718
struct ao2_container * command_queue
Definition: control.c:54
#define LOG_ERROR
Definition: logger.h:285