Skip to content

Commit

Permalink
Remove switch_zmalloc from each data loop
Browse files Browse the repository at this point in the history
Relates to signalwire#244
  • Loading branch information
yois615 committed Jul 29, 2022
1 parent a0c5067 commit d03523c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/switch_ivr_play_say.c
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
short sp_ovrlap[32];
short sp_has_overlap = 0;
int sp_prev_idx = 0;
short sp_prev[SWITCH_RECOMMENDED_BUFFER_SIZE];
short sp_prev[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};

file = argv[cur];
eof = 0;
Expand Down Expand Up @@ -1862,9 +1862,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
int src_rng = (fh->speed > 0 ? supplement : sp_cut_src_rng)* sp_has_overlap;
int datalen = newlen + src_rng + sp_fadeLen;
int extra = datalen - olen;
short* data = NULL;
short data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
short* currp = NULL;
switch_zmalloc(data, datalen * 2);
if (!fh->sp_audio_buffer) {
switch_buffer_create_dynamic(&fh->sp_audio_buffer, 1024, 1024, 0);
}
Expand Down Expand Up @@ -1896,10 +1895,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
} else {
cont = 1;
}


if (cont) {
switch_safe_free(data);
continue;
}
} else {
Expand Down Expand Up @@ -1939,7 +1936,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
}

last_speed = fh->speed;
switch_safe_free(data);
continue;
}

Expand Down

0 comments on commit d03523c

Please sign in to comment.