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 */
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 */
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);
}