initialize variables to avoid possible junk values

Signed-off-by: Dave Horton <daveh@beachdognet.com>
This commit is contained in:
Dave Horton
2024-04-22 16:06:32 -04:00
parent 83a2d1d730
commit fea51d5ecf
2 changed files with 9 additions and 1 deletions

View File

@@ -764,7 +764,9 @@ extern "C" {
conn->file = d->file; conn->file = d->file;
conn->body = json; conn->body = json;
conn->flushed = false; conn->flushed = false;
conn->has_last_byte = false;
conn->last_byte = 0;
d->circularBuffer = (void *) new CircularBuffer_t(BUFFER_GROW_SIZE); d->circularBuffer = (void *) new CircularBuffer_t(BUFFER_GROW_SIZE);
// Always use deepgram at rate 8000 for helping cache audio from jambonz. // Always use deepgram at rate 8000 for helping cache audio from jambonz.

View File

@@ -394,6 +394,8 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, ConnInfo_t *conn) {
std::unique_ptr<uint8_t[]> combinedData; std::unique_ptr<uint8_t[]> combinedData;
if (conn->has_last_byte) { if (conn->has_last_byte) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "rimelabs write_cb: processing last byte from previous read\n");
conn->has_last_byte = false; // We'll handle the last_byte now, so toggle the flag off conn->has_last_byte = false; // We'll handle the last_byte now, so toggle the flag off
// Allocate memory for the new data array // Allocate memory for the new data array
@@ -415,6 +417,8 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, ConnInfo_t *conn) {
// If we now have an odd total, save the last byte for next time // If we now have an odd total, save the last byte for next time
if ((total_bytes_to_process % sizeof(int16_t)) != 0) { if ((total_bytes_to_process % sizeof(int16_t)) != 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "rimelabs write_cb: got odd number of bytes %d\n", total_bytes_to_process);
conn->last_byte = data[total_bytes_to_process - 1]; conn->last_byte = data[total_bytes_to_process - 1];
conn->has_last_byte = true; conn->has_last_byte = true;
total_bytes_to_process--; total_bytes_to_process--;
@@ -758,6 +762,8 @@ extern "C" {
conn->file = d->file; conn->file = d->file;
conn->body = json; conn->body = json;
conn->flushed = false; conn->flushed = false;
conn->has_last_byte = false;
conn->last_byte = 0;
d->circularBuffer = (void *) new CircularBuffer_t(BUFFER_GROW_SIZE); d->circularBuffer = (void *) new CircularBuffer_t(BUFFER_GROW_SIZE);