diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/audiohook.c | 10 | ||||
-rw-r--r-- | main/core_unreal.c | 7 |
2 files changed, 11 insertions, 6 deletions
diff --git a/main/audiohook.c b/main/audiohook.c index 217e176e9..5595e88b7 100644 --- a/main/audiohook.c +++ b/main/audiohook.c @@ -377,6 +377,16 @@ static struct ast_frame *audiohook_read_frame_helper(struct ast_audiohook *audio audiohook_set_internal_rate(audiohook, ast_format_get_sample_rate(format), 1); } + /* If the sample rate of the requested format differs from that of the underlying audiohook + * sample rate determine how many samples we actually need to get from the audiohook. This + * needs to occur as the signed linear factory stores them at the rate of the audiohook. + * We do this by determining the duration of audio they've requested and then determining + * how many samples that would be in the audiohook format. + */ + if (ast_format_get_sample_rate(format) != audiohook->hook_internal_samp_rate) { + samples = (audiohook->hook_internal_samp_rate / 1000) * (samples / (ast_format_get_sample_rate(format) / 1000)); + } + if (!(read_frame = (direction == AST_AUDIOHOOK_DIRECTION_BOTH ? audiohook_read_frame_both(audiohook, samples, read_reference, write_reference) : audiohook_read_frame_single(audiohook, samples, direction)))) { diff --git a/main/core_unreal.c b/main/core_unreal.c index 23d80328c..cbeb1d3ed 100644 --- a/main/core_unreal.c +++ b/main/core_unreal.c @@ -409,12 +409,7 @@ static int unreal_queue_indicate(struct ast_unreal_pvt *p, struct ast_channel *a int isoutbound; ao2_lock(p); - /* - * Block -1 stop tones events if we are to be optimized out. We - * don't need a flurry of these events on an unreal channel chain - * when initially connected to slow the optimization process. - */ - if (0 <= condition || ast_test_flag(p, AST_UNREAL_NO_OPTIMIZATION)) { + if (ast_test_flag(p, AST_UNREAL_NO_OPTIMIZATION)) { struct ast_frame f = { .frametype = AST_FRAME_CONTROL, .subclass.integer = condition, |