Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/ctrlm_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,21 +293,39 @@ void ctrlm_print_controller_status(const char *prefix, ctrlm_controller_status_t
ERR_CHK(safec_rc);
} else {
time_binding_str[0] = '\0';
strftime(time_binding_str, 20, "%F %T", localtime((time_t *)&status->time_binding));
struct tm time_info;
time_t time_binding = (time_t)status->time_binding;
if(NULL == localtime_r(&time_binding, &time_info)) {
XLOGD_ERROR("Failed to convert time_binding to local time");
} else {
strftime(time_binding_str, 20, "%F %T", &time_info);
}
}
Comment thread
dwolaver marked this conversation as resolved.
if(status->time_last_key == 0) {
safec_rc = strcpy_s(time_last_key_str, sizeof(time_last_key_str), "NEVER");
ERR_CHK(safec_rc);
} else {
time_last_key_str[0] = '\0';
strftime(time_last_key_str, 20, "%F %T", localtime((time_t *)&status->time_last_key));
struct tm time_info;
time_t time_last_key = (time_t)status->time_last_key;
if(NULL == localtime_r(&time_last_key, &time_info)) {
XLOGD_ERROR("Failed to convert time_last_key to local time");
} else {
strftime(time_last_key_str, 20, "%F %T", &time_info);
}
}
Comment thread
dwolaver marked this conversation as resolved.
if(status->time_battery_update == 0) {
safec_rc = strcpy_s(time_battery_update_str, sizeof(time_battery_update_str), "NEVER");
ERR_CHK(safec_rc);
} else {
time_battery_update_str[0] = '\0';
strftime(time_battery_update_str, 20, "%F %T", localtime((time_t *)&status->time_battery_update));
struct tm time_info;
time_t time_battery_update = (time_t)status->time_battery_update;
if(NULL == localtime_r(&time_battery_update, &time_info)) {
XLOGD_ERROR("Failed to convert time_battery_update to local time");
} else {
strftime(time_battery_update_str, 20, "%F %T", &time_info);
}
}
Comment thread
dwolaver marked this conversation as resolved.

const xlog_args_t xlog_args_info = {.options = XLOG_OPTS_DEFAULT, .color = XLOG_COLOR_NONE, .function = prefix, .line = XLOG_LINE_NONE, .level = XLOG_LEVEL_INFO, .id = XLOG_MODULE_ID, .size_max = XLOG_BUF_SIZE_DEFAULT};
Expand Down
3 changes: 2 additions & 1 deletion src/database/ctrlm_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,8 @@ void ctrlm_db_print() {
ctrlm_db_rf4ce_read_validation_type(*it_network, *it_controller, &validation_type);
ctrlm_db_rf4ce_read_time_binding(*it_network, *it_controller, &time_binding);

const tm* loc_time = localtime(&time_binding);
struct tm time_info;
const tm* loc_time = localtime_r(&time_binding, &time_info);
if (loc_time != 0) {
strftime(time_str, 40, "%x - %I:%M:%S %p", loc_time);
}
Expand Down
3 changes: 2 additions & 1 deletion src/factory/ctrlmf_audio_capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <new>
#include <sstream>
#include <vector>
#include <algorithm>
Expand Down Expand Up @@ -48,7 +49,7 @@ static ctrlmf_audio_cap_global_t g_audio_cap;

bool ctrlmf_audio_capture_init(uint32_t audio_frame_size, bool *has_local_mic_tap) {

g_audio_cap.obj_ctrlm = new Iarm::ControlManager::ctrlm_iarm_client_control_manager_t;
g_audio_cap.obj_ctrlm = new(std::nothrow) Iarm::ControlManager::ctrlm_iarm_client_control_manager_t;
Comment thread
dwolaver marked this conversation as resolved.

if(g_audio_cap.obj_ctrlm == NULL) {
XLOGD_ERROR("out of memory");
Expand Down
4 changes: 2 additions & 2 deletions src/factory/ctrlmf_audio_playback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <ctrlmf_audio_playback.h>
#include <ctrlmf_thunder_plugin_system_audio_player.h>
#include <unistd.h>

#include <new>

typedef struct {
Thunder::SystemAudioPlayer::ctrlm_thunder_plugin_system_audio_player_t *obj_sap;
Expand All @@ -20,7 +20,7 @@ static void ctrlmf_audio_playback_event_handler(system_audio_player_event_t even
static ctrlmf_audio_play_global_t g_audio_play;

bool ctrlmf_audio_playback_init(void) {
g_audio_play.obj_sap = new Thunder::SystemAudioPlayer::ctrlm_thunder_plugin_system_audio_player_t;
g_audio_play.obj_sap = new(std::nothrow) Thunder::SystemAudioPlayer::ctrlm_thunder_plugin_system_audio_player_t;

if(g_audio_play.obj_sap == NULL) {
XLOGD_ERROR("out of memory");
Comment thread
dwolaver marked this conversation as resolved.
Expand Down
14 changes: 12 additions & 2 deletions src/factory/ctrlmf_mic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <stdbool.h>
#include <math.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <ctrlm_log.h>
Expand Down Expand Up @@ -306,12 +308,20 @@ void ctrlmf_mic_test_audio_export(const char *filename, ctrlmf_audio_frame_t aud
uint32_t pcm_data_size = frame_qty * SAMPLES_PER_FRAME * channel_qty * sample_size;

errno = 0;
FILE *fh = fopen(filename, "w");
if(NULL == fh) {
int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR);
if(fd < 0) {
int errsv = errno;
XLOGD_ERROR("Unable to open file <%s> <%s>", filename, strerror(errsv));
Comment thread
dwolaver marked this conversation as resolved.
return;
}
errno = 0;
FILE *fh = fdopen(fd, "w");
if(NULL == fh) {
int errsv = errno;
XLOGD_ERROR("Unable to fdopen file <%s> <%s>", filename, strerror(errsv));
close(fd);
return;
}

XLOGD_INFO("write wave header - %u-bit PCM %u hz %u chans %lu bytes", sample_size * 8, sample_rate, channel_qty, pcm_data_size);

Expand Down
14 changes: 12 additions & 2 deletions src/rf4ce/ctrlm_rf4ce_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2783,7 +2783,12 @@ void ctrlm_obj_controller_rf4ce_t::log_binding_for_telemetry() {
} else {
time_binding_str[0] = '\0';
time_t time_binding = this->time_binding_get();
strftime(time_binding_str, 20, "%F %T", localtime((time_t *)&time_binding));
struct tm time_info;
if(NULL == localtime_r(&time_binding, &time_info)) {
XLOGD_ERROR("Failed to convert time_binding to local time");
} else {
strftime(time_binding_str, 20, "%F %T", &time_info);
}
}
XLOGD_INFO("Model <%s>, Binding <%s>, Remote Bound (%u,%u), Time <%s>", product_name_->to_string().c_str(), ctrlm_rcu_binding_type_str(binding_type_), network_id_get(), controller_id_get(), time_binding_str);
ctrlm_update_last_key_info(controller_id, CTRLM_KEY_SOURCE_RF, 0, product_name_->to_string().c_str(), false, true);
Expand All @@ -2794,7 +2799,12 @@ void ctrlm_obj_controller_rf4ce_t::log_unbinding_for_telemetry() {
time_t time_unbinding = time(NULL);

time_unbinding_str[0] = '\0';
strftime(time_unbinding_str, 20, "%F %T", localtime((time_t *)&time_unbinding));
struct tm time_info;
if(NULL == localtime_r(&time_unbinding, &time_info)) {
XLOGD_ERROR("Failed to convert time_unbinding to local time");
} else {
strftime(time_unbinding_str, 20, "%F %T", &time_info);
}
XLOGD_INFO("Model <%s>, Remote Unbound (%u,%u), Time <%s>", product_name_->to_string().c_str(), network_id_get(), controller_id_get(), time_unbinding_str);
}

Expand Down
5 changes: 3 additions & 2 deletions src/rf4ce/ctrlm_rf4ce_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <openssl/err.h>
#include <openssl/conf.h>
#endif
#include <new>
#include <iostream>
#include <sstream>
#include <fstream>
Expand Down Expand Up @@ -2249,7 +2250,7 @@ json_t *ctrlm_obj_network_rf4ce_t::xconf_export_controllers() {
}
else {
// we dont have type in map so add it;
controller_type_details_t *new_type = new controller_type_details_t();
controller_type_details_t *new_type = new(std::nothrow) controller_type_details_t();
Comment thread
dwolaver marked this conversation as resolved.
if(new_type==NULL){
XLOGD_ERROR("error on allocating.. aborting" );
// if we could not malloc memory then we need to free our current mallocs and get out
Comment thread
dwolaver marked this conversation as resolved.
Expand Down Expand Up @@ -3987,7 +3988,7 @@ vector<rf4ce_device_update_session_resume_info_t> *ctrlm_obj_network_rf4ce_t::de
}

if(sessions == NULL) {
sessions = new vector<rf4ce_device_update_session_resume_info_t>;
sessions = new(std::nothrow) vector<rf4ce_device_update_session_resume_info_t>;
if(sessions == NULL) {
XLOGD_ERROR("out of memory");
break;
Expand Down
5 changes: 4 additions & 1 deletion src/thunder/ctrlm_thunder_plugin_powermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ ctrlm_thunder_plugin_powermanager_t::ctrlm_thunder_plugin_powermanager_t() : ctr
}

ctrlm_thunder_plugin_powermanager_t::~ctrlm_thunder_plugin_powermanager_t() {
free(instance);
sem_destroy(&this->semaphore);
if(instance == this) {
instance = NULL;
}
}
Comment thread
dwolaver marked this conversation as resolved.

ctrlm_thunder_plugin_powermanager_t *ctrlm_thunder_plugin_powermanager_t::get_instance() {
Expand Down
4 changes: 1 addition & 3 deletions src/voice/ctrlm_voice_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1299,11 +1299,9 @@ ctrlm_voice_session_response_status_t ctrlm_voice_t::voice_session_req(ctrlm_net
request_params.type = XRSR_SESSION_REQUEST_TYPE_AUDIO_FILE;
request_params.value.audio_file.path = audio_file_in;

xrsr_audio_format_t xrsr_format;
xrsr_audio_format_t xrsr_format = { .type = XRSR_AUDIO_FORMAT_PCM};
if(format.type == CTRLM_VOICE_FORMAT_OPUS) {
xrsr_format.type = XRSR_AUDIO_FORMAT_OPUS;
} else {
xrsr_format.type = XRSR_AUDIO_FORMAT_PCM;
}

if (false == xrsr_session_request(voice_device_to_xrsr(device_type), dst_index, xrsr_format, request_params, uuid, false, false)) {
Expand Down
Loading