if (multiplexed_thread->pipe[1] > -1) {
close(multiplexed_thread->pipe[1]);
}
-
- return;
}
/*! \brief Create function which finds/reserves/references a multiplexed thread structure */
while (multiplexed_thread->waiting) {
sched_yield();
}
-
- return;
}
/*! \brief Destroy function which unreserves/unreferences/removes a multiplexed thread structure */
}
}
}
- if (winner && winner->bridge) {
- struct ast_bridge *bridge = winner->bridge;
+ if (winner && ast_channel_internal_bridge(winner)) {
+ struct ast_bridge *bridge = ast_channel_internal_bridge(winner);
int stop = 0;
ao2_unlock(multiplexed_thread);
- while ((bridge = winner->bridge) && ao2_trylock(bridge)) {
+ while ((bridge = ast_channel_internal_bridge(winner)) && ao2_trylock(bridge)) {
sched_yield();
if (multiplexed_thread->thread == AST_PTHREADT_STOP) {
stop = 1;
ao2_ref(multiplexed_thread, +1);
if (ast_pthread_create(&multiplexed_thread->thread, NULL, multiplexed_thread_function, multiplexed_thread)) {
ao2_ref(multiplexed_thread, -1);
- ast_debug(1, "Failed to create an actual thread for multiplexed thread '%p', trying next time\n", multiplexed_thread);
+ ast_log(LOG_WARNING, "Failed to create the bridge thread for multiplexed thread '%p', trying next time\n",
+ multiplexed_thread);
}
} else if (!multiplexed_thread->service_count && multiplexed_thread->thread != AST_PTHREADT_NULL) {
thread = multiplexed_thread->thread;
if (thread != AST_PTHREADT_NULL) {
pthread_join(thread, NULL);
}
-
- return;
}
/*! \brief Join function which actually adds the channel into the array to be monitored */
return 0;
}
- if ((ast_format_cmp(&c0->writeformat, &c1->readformat) == AST_FORMAT_CMP_EQUAL) &&
- (ast_format_cmp(&c0->readformat, &c1->writeformat) == AST_FORMAT_CMP_EQUAL) &&
+ if ((ast_format_cmp(ast_channel_writeformat(c0), ast_channel_readformat(c1)) == AST_FORMAT_CMP_EQUAL) &&
+ (ast_format_cmp(ast_channel_readformat(c0), ast_channel_writeformat(c1)) == AST_FORMAT_CMP_EQUAL) &&
(ast_format_cap_identical(ast_channel_nativeformats(c0), ast_channel_nativeformats(c1)))) {
return 0;
}
ast_debug(1, "Suspending channel '%s' from multiplexed thread '%p'\n", ast_channel_name(bridge_channel->chan), multiplexed_thread);
multiplexed_add_or_remove(multiplexed_thread, bridge_channel->chan, 0);
-
- return;
}
/*! \brief Unsuspend function which means control of the channel is coming back to us */
ast_debug(1, "Unsuspending channel '%s' from multiplexed thread '%p'\n", ast_channel_name(bridge_channel->chan), multiplexed_thread);
multiplexed_add_or_remove(multiplexed_thread, bridge_channel->chan, 1);
-
- return;
}
/*! \brief Write function for writing frames into the bridge */
{
struct ast_bridge_channel *other;
+ /* If this is the only channel in this bridge then immediately exit */
if (AST_LIST_FIRST(&bridge->channels) == AST_LIST_LAST(&bridge->channels)) {
return AST_BRIDGE_WRITE_FAILED;
}
+ /* Find the channel we actually want to write to */
if (!(other = (AST_LIST_FIRST(&bridge->channels) == bridge_channel ? AST_LIST_LAST(&bridge->channels) : AST_LIST_FIRST(&bridge->channels)))) {
return AST_BRIDGE_WRITE_FAILED;
}
+ /* Write the frame out if they are in the waiting state... don't worry about freeing it, the bridging core will take care of it */
if (other->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
ast_write(other->chan, frame);
}