switch_core_session_message_t *message = NULL;
switch_frame_t *read_frame = NULL;
switch_status_t status = SWITCH_STATUS_SUCCESS;
- uint8_t *abuf = NULL;
int timelimit = 60;
const char *var = switch_channel_get_variable(caller_channel, "call_timeout");
switch_time_t start = 0;
+
+ write_frame.data = malloc(SWITCH_RECOMMENDED_BUFFER_SIZE);
+ write_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
if (var) {
timelimit = atoi(var);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_frame / 1000);
- write_frame.data = abuf = malloc(SWITCH_RECOMMENDED_BUFFER_SIZE);
- write_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
write_frame.codec = &write_codec;
write_frame.datalen = read_codec->implementation->bytes_per_frame;
if (ringback.fh) {
switch_size_t mlen, olen;
unsigned int pos = 0;
- uint8_t *fbuf = malloc(SWITCH_RECOMMENDED_BUFFER_SIZE);
-
+
if (ringback.asis) {
mlen = write_frame.codec->implementation->encoded_bytes_per_frame;
} else {
}
olen = mlen;
- switch_core_file_read(ringback.fh, fbuf, &olen);
+ switch_core_file_read(ringback.fh, write_frame.data, &olen);
if (olen == 0) {
olen = mlen;
ringback.fh->speed = 0;
switch_core_file_seek(ringback.fh, &pos, 0, SEEK_SET);
- switch_core_file_read(ringback.fh, fbuf, &olen);
+ switch_core_file_read(ringback.fh, write_frame.data, &olen);
if (olen == 0) {
break;
}
}
- write_frame.data = fbuf;
write_frame.datalen = (uint32_t) (ringback.asis ? olen : olen * 2);
- switch_safe_free(fbuf);
} else if (ringback.audio_buffer) {
if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(ringback.audio_buffer,
write_frame.data,
}
switch_core_codec_destroy(&write_codec);
}
- switch_safe_free(abuf);
+
+ switch_safe_free(write_frame.data);
return status;
}
int32_t sleep_ms = 1000, try = 0, retries = 1, idx = IDX_NADA;
switch_codec_t write_codec = { 0 };
switch_frame_t write_frame = { 0 };
- uint8_t *fdata;
uint8_t pass = 0;
char key[80] = SWITCH_BLANK_STRING, file[512] = SWITCH_BLANK_STRING, *odata, *var;
switch_call_cause_t reason = SWITCH_CAUSE_UNALLOCATED;
uint8_t ring_ready = 0;
char *loop_data = NULL;
- write_frame.data = fdata = malloc(SWITCH_RECOMMENDED_BUFFER_SIZE);
+ write_frame.data = malloc(SWITCH_RECOMMENDED_BUFFER_SIZE);
+ write_frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
*bleg = NULL;
odata = strdup(bridgeto);
if (ringback.fh) {
switch_size_t mlen, olen;
unsigned int pos = 0;
- uint8_t *abuf = malloc(SWITCH_RECOMMENDED_BUFFER_SIZE);
+
if (ringback.asis) {
mlen = write_frame.codec->implementation->encoded_bytes_per_frame;
}
olen = mlen;
- switch_core_file_read(ringback.fh, abuf, &olen);
+ switch_core_file_read(ringback.fh, write_frame.data, &olen);
if (olen == 0) {
olen = mlen;
ringback.fh->speed = 0;
switch_core_file_seek(ringback.fh, &pos, 0, SEEK_SET);
- switch_core_file_read(ringback.fh, abuf, &olen);
+ switch_core_file_read(ringback.fh, write_frame.data, &olen);
if (olen == 0) {
break;
}
}
- write_frame.data = abuf;
write_frame.datalen = (uint32_t) (ringback.asis ? olen : olen * 2);
- switch_safe_free(abuf);
} else if (ringback.audio_buffer) {
if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(ringback.audio_buffer,
write_frame.data,
if (var_event) {
switch_event_destroy(&var_event);
}
- switch_safe_free(fdata);
+ switch_safe_free(write_frame.data);
return status;
}