loader: Correct overly strict startup checks.
[asterisk/asterisk.git] / main / channel.c
index 632d472..7eb40d1 100644 (file)
@@ -4060,7 +4060,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio, int
                                }
 #else
                                int jump = calc_monitor_jump((ast_channel_outsmpl(chan) - ast_channel_insmpl(chan)),
-                                       ast_format_get_sample_rate(f->subclass.codec),
+                                       ast_format_get_sample_rate(f->subclass.format),
                                        ast_format_get_sample_rate(ast_channel_monitor(chan)->read_stream->fmt->format));
                                if (jump - MONITOR_DELAY >= 0) {
                                        if (ast_seekstream(ast_channel_monitor(chan)->read_stream, jump - f->samples, SEEK_FORCECUR) == -1) {
@@ -4228,6 +4228,7 @@ static int attribute_const is_visible_indication(enum ast_control_frame_type con
        case AST_CONTROL_MASQUERADE_NOTIFY:
        case AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE:
        case AST_CONTROL_STREAM_TOPOLOGY_CHANGED:
+       case AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED:
        case AST_CONTROL_STREAM_STOP:
        case AST_CONTROL_STREAM_SUSPEND:
        case AST_CONTROL_STREAM_REVERSE:
@@ -4528,6 +4529,7 @@ static int indicate_data_internal(struct ast_channel *chan, int _condition, cons
        case AST_CONTROL_UPDATE_RTP_PEER:
        case AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE:
        case AST_CONTROL_STREAM_TOPOLOGY_CHANGED:
+       case AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED:
        case AST_CONTROL_STREAM_STOP:
        case AST_CONTROL_STREAM_SUSPEND:
        case AST_CONTROL_STREAM_REVERSE:
@@ -5052,7 +5054,11 @@ int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame
        case AST_FRAME_VIDEO:
                /* XXX Handle translation of video codecs one day XXX */
                if (ast_channel_tech(chan)->write_stream) {
-                       res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
+                       if (stream) {
+                               res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
+                       } else {
+                               res = 0;
+                       }
                } else if ((stream == default_stream) && ast_channel_tech(chan)->write_video) {
                        res = ast_channel_tech(chan)->write_video(chan, fr);
                } else {
@@ -5061,7 +5067,11 @@ int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame
                break;
        case AST_FRAME_MODEM:
                if (ast_channel_tech(chan)->write_stream) {
-                       res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
+                       if (stream) {
+                               res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), fr);
+                       } else {
+                               res = 0;
+                       }
                } else if ((stream == default_stream) && ast_channel_tech(chan)->write) {
                        res = ast_channel_tech(chan)->write(chan, fr);
                } else {
@@ -5201,7 +5211,7 @@ int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame
                                }
 #else
                                int jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)),
-                                                            ast_format_get_sample_rate(f->subclass.codec),
+                                                            ast_format_get_sample_rate(f->subclass.format),
                                                             ast_format_get_sample_rate(ast_channel_monitor(chan)->read_stream->fmt->format));
                                if (jump - MONITOR_DELAY >= 0) {
                                        if (ast_seekstream(ast_channel_monitor(chan)->write_stream, jump - cur->samples, SEEK_FORCECUR) == -1) {
@@ -5249,7 +5259,11 @@ int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame
                        f = NULL;
                } else {
                        if (ast_channel_tech(chan)->write_stream) {
-                               res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), f);
+                               if (stream) {
+                                       res = ast_channel_tech(chan)->write_stream(chan, ast_stream_get_position(stream), f);
+                               } else {
+                                       res = 0;
+                               }
                        } else if ((stream == default_stream) && ast_channel_tech(chan)->write) {
                                res = ast_channel_tech(chan)->write(chan, f);
                        } else {
@@ -10843,22 +10857,29 @@ enum ast_channel_error ast_channel_errno(void)
 int ast_channel_request_stream_topology_change(struct ast_channel *chan,
                struct ast_stream_topology *topology, void *change_source)
 {
+       int res;
+
        ast_assert(chan != NULL);
        ast_assert(topology != NULL);
 
+       ast_channel_lock(chan);
        if (!ast_channel_is_multistream(chan) || !ast_channel_tech(chan)->indicate) {
+               ast_channel_unlock(chan);
                return -1;
        }
 
        if (ast_stream_topology_equal(ast_channel_get_stream_topology(chan), topology)) {
                ast_debug(3, "Topology of %s already matches what is requested so ignoring topology change request\n",
                                ast_channel_name(chan));
+               ast_channel_unlock(chan);
                return 0;
        }
 
        ast_channel_internal_set_stream_topology_change_source(chan, change_source);
 
-       return ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, topology, sizeof(topology));
+       res = ast_channel_tech(chan)->indicate(chan, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, topology, sizeof(topology));
+       ast_channel_unlock(chan);
+       return res;
 }
 
 int ast_channel_stream_topology_changed(struct ast_channel *chan, struct ast_stream_topology *topology)