void SetDeviceID(const int device_id) { device_id_ = device_id; }
private:
- int device_id_;
- int state_;
- int player_id_;
+ int device_id_ {};
+ int state_ {};
+ int player_id_ {};
};
/**
int GetVirtualID(void) { return virtual_id_; }
private:
- int zone_id_;
- int virtual_id_;
+ int zone_id_ {};
+ int virtual_id_ {};
};
#ifdef __cplusplus
bool Init(void);
- bool ready_;
+ bool ready_ {};
std::mutex init_mutex_;
shared::segment *shm_segment_;
Name: resource-manager
Summary: Resource manager
Version: 0.1
-Release: 1
+Release: 2
Group: Multimedia/Libraries
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
RMShmCache *RMShmCache::GetInstance(void)
{
- if (instance_ == nullptr) {
- std::lock_guard<std::mutex> guard(instance_mutex_);
- if (instance_ == nullptr) {
- instance_ = new RMShmCache();
- }
- }
+ std::lock_guard<std::mutex> guard(instance_mutex_);
+
+ if (instance_ == nullptr)
+ instance_ = new RMShmCache();
+
return instance_;
}
RMShmCache::RMShmCache(): ready_(false)
{
- Init();
+ if (!Init())
+ RM_ERR("Init is failed");
}
bool RMShmCache::Init(void)
{
+ std::lock_guard<std::mutex> guard(init_mutex_);
+
if (ready_)
return true;
- std::lock_guard<std::mutex> guard(init_mutex_);
-
try {
shm_segment_ = new shared::segment(boost::interprocess::open_read_only, "shm_rm");
players_ = shm_segment_->find<shared::unordered_map<int, shared::string>>("players").first;
}
ready_ = true;
+
return true;
}
};
rm_resource_list *result = (rm_resource_list*) calloc(1, sizeof(rm_resource_list));
+ if (!result) {
+ RM_ERR("rm_resource_list calloc failed");
+ return RM_ERROR;
+ }
+
result->n_rsc = 0;
for (unsigned int i = 0; i < ARRAY_SIZE(audio_main_out_devices); i++) {
continue;
rm_resource *resource = (rm_resource*) calloc(1, sizeof(rm_resource));
+ if (!resource)
+ continue;
+
resource->id = audio_main_out_devices[i];
resource->state = RM_RSC_STATE_EXCLUSIVE;
resource->consumer_id = it->second.GetPlayerID();
RM_INFO("Request for Allocation handle[%d] / pid[%d] / requested #[%d]",
handle, getpid(), requests->request_num);
- for (idx=0; idx < requests->request_num; idx++)
+ for (idx = 0; idx < requests->request_num; idx++)
RM_INFO("(%d) CatID[%d-%s] / CatOpt[%d]",
idx + 1, requests->category_id[idx], rm_convert_category_enum_to_string(requests->category_id[idx]), requests->category_option[idx]);
#include <pthread.h>
#include <assert.h>
#include <list>
-
-#include <glib.h>
+#include <gio/gio.h>
#include <rm_debug.h>
#include <rm_module_api.h>
if (main_loop != NULL)
g_main_loop_run(main_loop);
- RM_INFO("RM client thread finished\n");
+ RM_INFO("RM client thread finished");
return NULL;
}
// LCOV_EXCL_STOP
}
- return RM_OK;
+ RM_INFO("RM_OK");
+ return RM_OK;
}
int _create_cb_root_dir(void)
{
+ rm_return_code_e ret = RM_OK;
const char *cb_dir_path = "/run/rsc_mgr";
mode_t pmask;
mode_t dir_mode = 0666 | 0111;
pmask = umask(0);
- if (mkdir(cb_dir_path, dir_mode) !=0) {
+ if (mkdir(cb_dir_path, dir_mode) != 0) {
RM_ERR("failed to create cb directory (%d)", errno);
- umask(pmask);
- return RM_ERROR;
+ ret = RM_ERROR;
+ goto exit;
}
- chmod(cb_dir_path, dir_mode);
+
+ if (chmod(cb_dir_path, dir_mode) == -1) {
+ RM_ERR("failed to create cb directory (%d)", errno);
+ ret = RM_ERROR;
+ }
+
+exit:
umask(pmask);
- return RM_OK;
+ return ret;
// LCOV_EXCL_STOP
}
pmask = umask(0);
- if (mknod(cb_path_s2c, S_IFIFO|0666, 0)) {
+ if (mknod(cb_path_s2c, S_IFIFO | 0666, 0)) {
RM_ERR("failed to create cb for S2C(%s)-(%d)", cb_path_s2c, errno);
umask(pmask);
return RM_ERROR;
snprintf(cb_path_s2c, 256, "/run/rsc_mgr/%d.%d.s2c.cb", pid, cid);
if ((fd = open(cb_path_s2c, O_RDWR|O_NONBLOCK)) < 0) {
- RM_ERR("open error (%s), errno(%d)\n", cb_path_s2c, errno);
+ RM_ERR("open error (%s), errno(%d)", cb_path_s2c, errno);
pthread_mutex_unlock(&rm_cb_mutex);
return RM_ERROR;
}
TCCallbackListener::TCCallbackListener()
{
- m_n_notification = 0;
}
TCCallbackListener::~TCCallbackListener()
private:
std::map<int, int> m_scalers;
- int m_n_notification;
+ int m_n_notification {};
};
#endif //__TC_CALLBACK_LISTENER_H__
TCPlayer::TCPlayer()
{
- m_handle = 0;
- m_allocated_rsc_index = 0;
- m_rsc_index = 0;
- m_query_index = 0;
- m_n_conflict = 0;
- m_n_conflicted_rsc = 0;
}
TCPlayer::~TCPlayer()
std::map<int, TCResource *> m_queries;
std::string m_app_id;
- int m_handle;
- int m_rsc_index;
- int m_query_index;
- int m_allocated_rsc_index;
- int m_n_conflict;
- int m_n_conflicted_rsc;
+ int m_handle {};
+ int m_rsc_index {};
+ int m_query_index {};
+ int m_allocated_rsc_index {};
+ int m_n_conflict {};
+ int m_n_conflicted_rsc {};
};
#endif //__TC_PLAYER_H__
TCResource::TCResource(int category_id, int category_option, int state)
{
- m_category_id = category_id;
- m_category_option = category_option;
- m_state = state;
}
TCResource::~TCResource()
class TCResource
{
public:
- TCResource(int category_id, int category_option, int state);
+ TCResource(int category_id, int category_option, int state)
+ : m_category_id(category_id), m_category_option(category_option), m_state(state) {}
~TCResource();
int GetCategoryId(void) {return m_category_id;}
int GetState(void) {return m_state;}
private:
- int m_category_id;
- int m_category_option;
- int m_state;
+ int m_category_id {};
+ int m_category_option {};
+ int m_state {};
};
#endif //__TC_RESOURCE_H__
GTEST_API_ int main(int argc, char **argv)
{
- RM_TEST_MSG("Running main() from ut_main.cpp\n");
+ RM_TEST_MSG("Running main() from ut_main.cpp");
//GMainContext *context = g_main_context_new();
g_main_loop = g_main_loop_new(NULL, FALSE);
return RM_CB_RESULT_OK;
}
-int flag1=0;
-int flag2=0;
-int endflag=0;
+int flag1 = 0;
+int flag2 = 0;
+int endflag = 0;
pthread_t t1,t2,t3;
rm_cb_result cb1(int handle, rm_callback_type event, rm_device_request_s *info, void *data)
{
void *thread_main1(void*)
{
- int handle=0;
+ int handle = 0;
EXPECT_EQ(RM_OK,rm_register(cb1, NULL, &handle, NULL));
//alloc
}
void *thread_main2(void*)
{
- int handle=0;
+ int handle = 0;
while (true) {
if (flag1) {
EXPECT_EQ(RM_OK,rm_register(cb2, NULL, &handle, NULL));
rm_device_return_s *allocated = (rm_device_return_s*) malloc (sizeof(rm_device_return_s));
memset((void*)allocated, 0, sizeof(rm_device_return_s));
EXPECT_EQ(RM_OK,rm_allocate_resources(handle, request, allocated));
- flag1=0;
+ flag1 = 0;
}
if (endflag) {
void *thread_main3(void*)
{
- int handle=0;
+ int handle = 0;
while (true) {
if (flag2) {
EXPECT_EQ(RM_OK,rm_register(cb2, NULL, &handle, NULL));
pthread_create(&t1,NULL,&thread_main1,(void*)1);
pthread_create(&t2,NULL,&thread_main2,(void*)2);
pthread_create(&t3,NULL,&thread_main3,(void*)3);
- int status=0;
+ int status = 0;
pthread_join(t1,(void**)&status);
pthread_join(t2,(void**)&status);
pthread_join(t3,(void**)&status);