src/manager/CResource.cpp
src/manager/CResourceCategory.cpp
src/manager/CResourceDB.cpp
- src/manager/CResourceState.cpp
src/manager/CResourceManager.cpp
src/manager/CVirtualResource.cpp
src/manager/CConsumerContainer.cpp
int length(void);
private:
- GAsyncQueue *queue;
+ GAsyncQueue *queue {};
};
#endif // __C_ASYNC_QUEUE_H__
static const std::string m_methods;
static const GDBusInterfaceVTable m_vtable;
- GDBusConnection *m_conn;
- unsigned int m_reg_id;
- unsigned int m_own_id;
+ GDBusConnection *m_conn {};
+ unsigned int m_reg_id {};
+ unsigned int m_own_id {};
- CAsyncQueue *m_async_queue;
+ CAsyncQueue *m_async_queue {};
bool MakeDbusConnection(void);
void RegisterObjects(void);
class CHandle
{
public:
- CHandle() {}
+ CHandle() : handle(0), is_used(0), pid(0), main_priority(0), sub_priority(0), app_pid(0), app_id(nullptr) {}
CHandle(int handle, int is_used, int pid);
~CHandle() {}
- int handle;
- int is_used;
- int pid;
- int main_priority;
- int sub_priority;
- int app_pid;
- char *app_id;
+ int handle {};
+ int is_used {};
+ int pid {};
+ int main_priority {};
+ int sub_priority {};
+ int app_pid {};
+ char *app_id {};
char process_name[RMS_NAME_BUF_SIZE];
};
void m_PrintHandleList(void);
CHandle *findHandle(int id);
- CResourceManager *m_rsc_mgr;
- int m_next_handle;
+ CResourceManager *m_rsc_mgr {};
+ int m_next_handle {};
std::map<int, CHandle*> m_handles;
};
void PrintInfo(void);
private:
- rms_msg_request *m_msgq_req;
- GDBusMethodInvocation *m_invoc;
- msg_sender_e m_sender;
+ rms_msg_request *m_msgq_req {};
+ GDBusMethodInvocation *m_invoc {};
+ msg_sender_e m_sender { MSG_SENDER_MSGQ };
std::string m_name;
void PrintDbus(void);
unsigned long m_req_timeout = 5;
- CMessageQueue *msgq_rx;
- CMessageQueue *msgq_tx;
- CAsyncQueue *async_queue;
- CAsyncQueue *async_pending_queue;
- CLockController *m_lock_ctr;
- CResourceManager *m_rsc_mgr;
- CHandleManager *m_handle_mgr;
- CQueryHandler *m_query_h;
- CDbusHandler *m_dbus_h;
+ CMessageQueue *msgq_rx {};
+ CMessageQueue *msgq_tx {};
+ CAsyncQueue *async_queue {};
+ CAsyncQueue *async_pending_queue {};
+ CLockController *m_lock_ctr {};
+ CResourceManager *m_rsc_mgr {};
+ CHandleManager *m_handle_mgr {};
+ CQueryHandler *m_query_h {};
+ CDbusHandler *m_dbus_h {};
typedef void (CMessageHandler::*msg_handler)(rms_msg_request *request, rms_msg_response *response);
static msg_handler handlers[RMS_REQUEST_MAX];
int recover(void);
static int getKey(msgq_type_e type);
- msgq_type_e msgq_type;
- int msgq_id;
+ msgq_type_e msgq_type { MSG_QUEUE_RX };
+ int msgq_id {};
static const long msgq_size = 131072; // 128KB
static const int key_rx = 8211;
class CRequest
{
public:
- CRequest(CRequester *requester);
- ~CRequest();
+ CRequest(CRequester *requester) : m_requester(requester) {}
+ ~CRequest() {}
CRequester *getRequester(void);
int UnmaskMVZoneInfo(int category_option);
int UnmaskForceOptions(int category_option);
- CRequester *m_requester;
+ CRequester *m_requester {};
- int m_category_id;
- int m_category_option;
- rms_rsc_category_e m_category;
- rms_requests_resource_state_e m_state;
- rms_mixing_mode_e m_mixing_mode;
- int m_device_id;
+ int m_category_id {};
+ int m_category_option {};
+ rms_rsc_category_e m_category { RMS_CATEGORY_NONE };
+ rms_requests_resource_state_e m_state { RMS_STATE_PASSIVE };
+ rms_mixing_mode_e m_mixing_mode { RMS_MIXING_MODE_DEFAULT };
+ int m_device_id {};
- rms_return_code_e m_result;
- int m_candidate_device;
- int m_allocated_device;
- int m_virtual_device;
- int m_mv_zone_id;
- rms_error_type_e m_reason;
+ rms_return_code_e m_result { RMS_OK };
+ int m_candidate_device {};
+ int m_allocated_device {};
+ int m_virtual_device {};
+ int m_mv_zone_id {};
+ rms_error_type_e m_reason { RMS_ERR_TYPE_NONE };
};
#endif //__CREQUEST_H__
std::string GetCmdName(void) { return m_cmd_name; }
private:
- int m_handle;
- int m_pid;
- int m_main_priority;
- int m_sub_priority;
+ int m_handle {};
+ int m_pid {};
+ int m_main_priority {};
+ int m_sub_priority {};
std::string m_app_id;
std::string m_cmd_name;
};
class CResourceService
{
public:
- CResourceService(void) {}
+ CResourceService(void) : m_msg_h(nullptr) {}
~CResourceService(void) {}
int Init(GMainLoop *main_loop);
private:
- CMessageHandler *m_msg_h;
+ CMessageHandler *m_msg_h {};
int IsFirstLaunch(void);
void RequestColdPowerOff(void);
void SetVIPProcess(void);
static gboolean WatchDogCallback(gpointer data);
static gboolean InvalidResourceTableMsgCallback(gpointer data);
+ static void create_ready_file();
};
#endif //__RMS_CRESOURCE_SERVICE_H__
std::set<int> m_resources;
- int m_consumerID;
- rms_priority_s m_priority;
- long m_pid;
+ int m_consumerID {};
+ rms_priority_s m_priority {};
+ long m_pid {};
std::string m_app_id;
std::string m_cmd_name;
};
std::set<int> m_shared_consumers;
std::set<int> m_consumer_ids;
- int m_id;
- int m_vrsc_id;
- int m_virtual_id;
- int m_dedicated_virtual_id;
- rms_resource_internal_state_e m_state;
- rms_rsc_category_e m_category_type;
- const char *m_device_name;
- const char *m_device_path;
- int m_category_class;
- int m_cur_category;
-
- unsigned int m_occupied_bw;
- unsigned int m_default_bw;
- int m_is_main_device;
- int m_sharable_count;
-
- bool m_is_reserved;
- bool m_is_scaler;
- int m_reserved_consumer_id;
- unsigned long m_allocated_time;
-
- int m_shared_count;
- int m_reserved_count;
- int m_mv_zone_id;
+ int m_id {};
+ int m_vrsc_id {};
+ int m_virtual_id {};
+ int m_dedicated_virtual_id {};
+ rms_resource_internal_state_e m_state { RMS_INTERNAL_STATE_FREE };
+ rms_rsc_category_e m_category_type { RMS_CATEGORY_NONE };
+ const char *m_device_name {};
+ const char *m_device_path {};
+ int m_category_class {};
+ int m_cur_category {};
+
+ unsigned int m_occupied_bw {};
+ unsigned int m_default_bw {};
+ int m_is_main_device {};
+ int m_sharable_count {};
+
+ bool m_is_reserved {};
+ bool m_is_scaler {};
+ int m_reserved_consumer_id {};
+ unsigned long m_allocated_time {};
+
+ int m_shared_count {};
+ int m_reserved_count {};
+ int m_mv_zone_id {};
std::string m_audio_codec;
std::vector<CResourceObserver*> m_observers;
std::set<unsigned int> m_mem_clusters;
- rms_mixing_mode_e m_mixing_mode;
+ rms_mixing_mode_e m_mixing_mode { RMS_MIXING_MODE_DEFAULT };
};
#endif // __RSC_MGR_SERVER_RESOURCE_H__
{
public:
CResourceCategory(rms_rsc_category_e resource_category_id, int category_class);
- virtual ~CResourceCategory() {}
+ virtual ~CResourceCategory();
rms_rsc_category_e GetCategoryID(void) { return m_categoryID; }
void AddVirtualResource(IN int device_id, IN CVirtualResource *vresource);
private:
std::map<int, CVirtualResource *> m_device_id_to_vresource_map;
- rms_rsc_category_e m_categoryID;
- CAllocateStrategy *m_alloc_strategy;
+ rms_rsc_category_e m_categoryID { RMS_CATEGORY_NONE };
+ CAllocateStrategy *m_alloc_strategy {};
void MakeResourceMapSortedByAllocTime(std::multimap<unsigned long, CVirtualResource *> *time_resource_map);
};
std::map<int, CResource*> m_rscs_has_zone_id;
static CResourceDB *m_instance;
- unsigned int m_device_id; //for virtual resource
- int m_max_vdecs;
+ unsigned int m_device_id {}; //for virtual resource
+ int m_max_vdecs {};
std::set<int> m_reclaim_rscs; // resources reclaiming
std::map<int, int> m_active_vdecs; // device id, consumer id
void MakeConsumerInfoToBeReturned(consumer_reclaim_s *return_consumer, std::map<int, std::set<int> > *consumer_id_to_resource_set_map);
void PrintConsumerInfoToBeReturned(consumer_reclaim_s *consumer_info);
- CResourceDB *m_db;
+ CResourceDB *m_db {};
- int m_is_db_created;
- rms_error_type_e m_error_type;
- CConsumerContainer *m_consumers;
+ int m_is_db_created {};
+ rms_error_type_e m_error_type {};
+ CConsumerContainer *m_consumers {};
};
class CResourceState
{
public:
- CResourceState(int device_id, int category_type, int consumer_id, int state, std::string app_id);
+ CResourceState(int device_id, int category_type, int consumer_id, int state, std::string app_id)
+ : m_device_id(device_id), m_consumer_id(consumer_id), m_state(state), m_category_type(category_type), m_app_id(app_id) {}
~CResourceState() = default;
int GetDeviceId(void) { return m_device_id; }
std::string GetAppId(void) { return m_app_id; }
private:
- int m_device_id;
- int m_consumer_id;
- int m_state;
- int m_category_type;
+ int m_device_id {};
+ int m_consumer_id {};
+ int m_state {};
+ int m_category_type {};
std::string m_app_id;
};
bool IsMainDevice(void) { return m_is_main_device; }
bool IsAIDevice(void) { return m_is_ai_device; }
private:
- int m_vir_rsc_id;
- rms_rsc_category_e m_category_type;
- unsigned int m_vir_rsc_bw;
- bool m_is_main_device;
- bool m_is_ai_device;
- int m_category_class;
+ int m_vir_rsc_id {};
+ rms_rsc_category_e m_category_type { RMS_CATEGORY_NONE };
+ unsigned int m_vir_rsc_bw {};
+ bool m_is_main_device {};
+ bool m_is_ai_device {};
+ int m_category_class {};
std::set<unsigned int> m_mem_clusters;
std::string m_audio_codec;
- CResource *m_rsc;
+ CResource *m_rsc {};
};
#endif // _RM_VIRTUAL_RESOURCE_H_INCLUDED
private:\r
bool isUnknownCodec(void) { return (m_name.length() == 0); }\r
std::string m_name;\r
- unsigned int m_ref_count;\r
- unsigned int m_ref_count_max;\r
+ unsigned int m_ref_count {};\r
+ unsigned int m_ref_count_max {};\r
std::map<int, int> m_consumers; // consumer id, ref_count\r
std::map<int, int> m_resources; // device_id, consumer id\r
};\r
\r
-#endif //__CAUDIO_CODEC_H__
\ No newline at end of file
+#endif //__CAUDIO_CODEC_H__\r
\r
std::map<int, int> m_consumers; // device_id, consumer_id\r
std::map<int, std::map<int, int>> m_ndec_consumers; // category id, <device_id, consumer_id>\r
- unsigned int m_max;\r
- unsigned int m_avail;\r
+ unsigned int m_max {};\r
+ unsigned int m_avail {};\r
};\r
\r
#endif //__CBANDWIDTH_H__\r
void ClearConsumers(void);\r
std::set<int> GetConsumers(void);\r
private:\r
- unsigned int m_id;\r
+ unsigned int m_id {};\r
std::map<int, std::set<int>> m_consumers; // consumer, device ids\r
- int m_category_class;\r
- int m_category_id;\r
+ int m_category_class {};\r
+ int m_category_id {};\r
};\r
\r
#endif //__CMEM_CLUSTER_H__\r
rms_mixing_mode_e getMode(void) { return m_mode; }\r
std::map<int, int> GetConsumers(void) { return m_consumers; }\r
private:\r
- rms_mixing_mode_e m_mode;\r
+ rms_mixing_mode_e m_mode { RMS_MIXING_MODE_DEFAULT };\r
std::map<std::string, CAudioCodec*> m_audio_codecs;\r
std::map<int, int> m_consumers; // device id, consumer id\r
};\r
Name: rscmgr-service
Summary: Daemon for resource manager
Version: 0.1
-Release: 4
+Release: 5
Group: Multimedia/Libraries
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
return;
}
- chmod(cb_path, dir_mode);
+ if (chmod(cb_path, dir_mode) == -1)
+ SERVER_ERR("chmod is failed errno(%d)", errno);
}
int CCallback::SendCallbackMessage(int cid, int pid, void *callback_data, int size, int *err)
snprintf(callback_path, 256, "/run/rsc_mgr/%d.%d.s2c.cb", pid, cid);
if ((fd = open(callback_path, O_WRONLY|O_NONBLOCK)) < 0) {
- SERVER_ERR("open error (%s), errno(%d)\n", callback_path, errno);
+ SERVER_ERR("open error (%s), errno(%d)", callback_path, errno);
*err = errno;
return RMS_ERROR;
}
ret = write(fd, callback_data, size);
if (ret <= 0) {
- SERVER_ERR("failed to write callback.(%s) ret(%d), errno(%d)\n", callback_path, ret, errno);
+ SERVER_ERR("failed to write callback.(%s) ret(%d), errno(%d)", callback_path, ret, errno);
*err = errno;
close(fd);
return RMS_ERROR;
"</interface>"
"</node>";
-CDbusHandler::CDbusHandler(CAsyncQueue *queue)
+CDbusHandler::CDbusHandler(CAsyncQueue *queue) : m_own_id()
{
assert(queue);
m_async_queue = queue;
m_name = name;
}
-CMessage::CMessage(rms_msg_request *req)
+CMessage::CMessage(rms_msg_request *req) : m_invoc()
{
assert(req);
CMessageHandler::~CMessageHandler(void)
{
-
+ if (m_handle_mgr)
+ delete m_handle_mgr;
+ if (m_query_h)
+ delete m_query_h;
+ if (async_pending_queue)
+ delete async_pending_queue;
+ if (async_queue)
+ delete async_queue;
+ if (msgq_tx)
+ delete msgq_tx;
+ if (msgq_rx)
+ delete msgq_rx;
}
void CMessageHandler::InitDbusHandlers(void)
int CMessageHandler::Run(void)
{
- if (g_thread_new("rms_msgq_thread", msgQThread, this) == NULL) {
+ GThread *_msgQThread = g_thread_new("rms_msgq_thread", msgQThread, this);
+ if (!_msgQThread) {
SERVER_ERR("failed to create rms_msgq thread");
assert(0);
return RMS_ERROR;
}
- if (g_thread_new("rms_msg_thread", msgThread, this) == NULL) {
- SERVER_ERR("event loop thread create failed\n");
+ GThread *_msgThread = g_thread_new("rms_msg_thread", msgThread, this);
+ if (!_msgThread) {
+ SERVER_ERR("event loop thread create failed");
assert(0);
return RMS_ERROR;
}
m_dbus_h = new CDbusHandler(async_queue);
+
+ // g_thread_join to release resources
+ gpointer _msgQResult = g_thread_join(_msgQThread);
+ if (_msgQResult)
+ g_free(_msgQResult);
+
+ gpointer _msgResult = g_thread_join(_msgThread);
+ if (_msgResult)
+ g_free(_msgResult);
+
+ delete m_dbus_h;
+
+ SERVER_INFO("RMS_OK");
+
return RMS_OK;
}
void CMessageHandler::ProcessMessage(CAsyncQueue *queue, CMessage *msg, int cid_requester, int cid_releaser)
{
rms_msg_request *req = msg->GetRequest();
- rms_msg_response resp;
+ rms_msg_response resp {};
int handle;
char cmd[RMS_NAME_BUF_SIZE] = {0,};
consumer_id = conflict_info->consumer_info[i].consumer_id;
consumer = CConsumerContainer::getInstance()->findConsumer(consumer_id);
+ if (!consumer) {
+ SERVER_WARN("Consumer %d not found", consumer_id);
+ continue;
+ }
+
for (int j = 0; j < conflict_info->consumer_info[i].n_conflicted; j++) {
device_id = conflict_info->consumer_info[i].conflicted_resources[j].device_id;
app_zone_id = m_rsc_mgr->GetZoneId(device_id);
(consumer->GetAppID().empty()) ? consumer->GetCmdName().c_str() : consumer->GetAppID().c_str(), app_zone_id, zone_id),
&error)) {
SERVER_ERR("failed to send resource conflict (%d:%d:%d:%s)-%s", category_id, device_id, consumer_id,
- (consumer->GetAppID().empty()) ? consumer->GetCmdName().c_str():consumer->GetAppID().c_str(), (error) ? error->message : "unknown");
+ (consumer->GetAppID().empty()) ? consumer->GetCmdName().c_str() : consumer->GetAppID().c_str(), (error) ? error->message : "unknown");
}
}
}
#include "CRequester.h"
#include "CRequest.h"
-CRequest::CRequest(CRequester *requester)
-:m_requester(requester)
-{
- m_device_id = 0;
- m_category_id = 0;
- m_category_option = 0;
- m_category = RMS_CATEGORY_NONE;
- m_result = RMS_ERROR;
- m_candidate_device = RMS_DEVICE_NONE;
- m_allocated_device = RMS_DEVICE_NONE;
- m_virtual_device = RMS_DEVICE_NONE;
-}
-
-CRequest::~CRequest()
-{
-}
-
CRequester *CRequest::getRequester(void)
{
return m_requester;
return RMS_CATEGORY_SCALER;
if (category > RMS_CATEGORY_SCALER_OPTION && category < RMS_CATEGORY_SCALER_OPTION_MAX)
- return (rms_rsc_category_e) category_option;
+ return (rms_rsc_category_e) category;
if (category_option > RMS_CATEGORY_SCALER_OPTION && category_option < RMS_CATEGORY_SCALER_OPTION_MAX)
return (rms_rsc_category_e) category_option;
{
if (category != RMS_CATEGORY_AUDIO_DECODER && category != RMS_CATEGORY_AUDIO_DECODER_SUB)
return RMS_MIXING_MODE_DEFAULT;
-
- if (category_option & RMS_MIXING_OPT_MULTIVIEW)
- return RMS_MIXING_MODE_MULTIVIEW;
-
- if (category_option & RMS_MIXING_OPT_INTERACTION_SOUND)
+ else if (category_option & RMS_MIXING_OPT_INTERACTION_SOUND)
return RMS_MIXING_MODE_INTERACTION_SOUND;
+ SERVER_INFO("RMS_MIXING_MODE_DEFAULT");
return RMS_MIXING_MODE_DEFAULT;
}
if (rsc_mgr->RegisterResources() != RMS_OK) {
SERVER_ERR("RegisterResources is failed");
g_timeout_add(RM_SERVER_INVALID_TABLE_TIME_30000_MSEC, InvalidResourceTableMsgCallback, NULL);
+ delete rsc_mgr;
return RMS_ERROR;
}
m_msg_h = new CMessageHandler(rsc_mgr);
if (m_msg_h->Run() != RMS_OK) {
SERVER_ERR("RUN failed");
+ delete m_msg_h;
+ m_msg_h = nullptr;
+ delete rsc_mgr;
return RMS_ERROR;
}
SERVER_INFO("Done");
+
return RMS_OK;
}
size_t sz;\r
\r
snprintf(name, sizeof(name), "/proc/%d/cmdline", pid);\r
+ // Check if the process exists and is accessible\r
+ if (access(name, R_OK) != 0) {\r
+ SERVER_ERR("failed to access (%s) : %d", name, errno);\r
+ return RMS_ERROR;\r
+ }\r
+\r
f = fopen(name, "r");\r
if (!f) {\r
SERVER_ERR("failed to open cmdline(%s) : %d", name, errno);\r
return RMS_ERROR;\r
- } else {\r
- sz = fread(name, sizeof(char), sizeof(name)-1, f);\r
- name[sz] = '\0';\r
- fclose(f);\r
}\r
\r
+ sz = fread(name, sizeof(char), sizeof(name)-1, f);\r
+ name[sz] = '\0';\r
+ fclose(f);\r
+\r
snprintf(name_out, size, "%s", name);\r
+\r
return RMS_OK;\r
}\r
\r
}\r
\r
ret = clock_gettime(CLOCK_MONOTONIC, &tnow);\r
- snprintf(output, RMS_CONSOLE_BUF_SIZE, "[RMS][%ld.%6ld] %s\n", tnow.tv_sec, tnow.tv_nsec/1000, buf);\r
+ snprintf(output, RMS_CONSOLE_BUF_SIZE, "[RMS][%ld.%6ld] %s", tnow.tv_sec, tnow.tv_nsec/1000, buf);\r
ret = write(fd, output, strlen(output));\r
\r
if (ret < 0) {\r
return 1;\r
}\r
\r
- SERVER_ERR("pid(%d)/errno(%d)", pid, errno);\r
+ SERVER_ERR("pid(%d) / errno(%d)", pid, errno);\r
\r
return (errno == ESRCH) ? 0 : 1;\r
}\r
g_string_append_printf(gstr, "%sProduct type : %d%s", indent, rm_get_product_type(), " <br>");\r
\r
if (system_info_get_custom_string("com.samsung/featureconf/product.chipset", &chipset_info)!= SYSTEM_INFO_ERROR_NONE) {\r
- SERVER_ERR("Failed to get chipset from system-info\n");\r
+ SERVER_ERR("Failed to get chipset from system-info");\r
goto end;\r
}\r
\r
}\r
\r
CResource::CResource(const int device_id, const rms_rsc_category_e category_type, const char *name, const char *path,\r
- std::set<unsigned int> mem_cluster, int is_main_device, const char *audio_codec, int sharable_count)\r
+ std::set<unsigned int> mem_cluster, int is_main_device, const char *audio_codec, int sharable_count)\r
:m_id(device_id), m_device_name(name), m_device_path(path), m_is_main_device(is_main_device), m_sharable_count(sharable_count)\r
{\r
- m_state = RMS_INTERNAL_STATE_FREE;\r
- m_occupied_bw = 0;\r
- m_default_bw = 0;\r
- m_is_reserved = false;\r
- m_reserved_consumer_id = 0;\r
- m_mixing_mode = RMS_MIXING_MODE_DEFAULT;\r
m_mem_clusters = mem_cluster;\r
- m_virtual_id = 0;\r
- m_mv_zone_id = -1;\r
\r
if (audio_codec)\r
m_audio_codec.assign(audio_codec);\r
assert(m_alloc_strategy);\r
}\r
\r
+CResourceCategory::~CResourceCategory()\r
+{\r
+ delete m_alloc_strategy;\r
+}\r
+\r
void CResourceCategory::AddVirtualResource(IN int device_id, IN CVirtualResource *vresource)\r
{\r
std::map<int, CVirtualResource *>::iterator it = m_device_id_to_vresource_map.find(device_id);\r
{\r
int device_id = resource->GetDeviceID();\r
CConsumer *consumer = CConsumerContainer::getInstance()->findConsumer(consumer_id);\r
+\r
+ if (!consumer) {\r
+ SERVER_WARN("Consumer %d is not found", consumer_id);\r
+ return;\r
+ }\r
+\r
std::string app_id = consumer->GetAppID();\r
\r
if (app_id.empty())\r
\r
void CResourceDB::FindMainResources(IN std::map<int, CResource*> *resource_map)\r
{\r
- rms_rsc_category_e categories[5] = {RMS_CATEGORY_VIDEO_DECODER, RMS_CATEGORY_VIDEO_DECODER_UHD, RMS_CATEGORY_SCALER, RMS_CATEGORY_AUDIO_DECODER, RMS_CATEGORY_AUDIO_MAIN_OUT};\r
+ rms_rsc_category_e categories[5] = {RMS_CATEGORY_VIDEO_DECODER,\r
+ RMS_CATEGORY_VIDEO_DECODER_UHD,\r
+ RMS_CATEGORY_SCALER,\r
+ RMS_CATEGORY_AUDIO_DECODER,\r
+ RMS_CATEGORY_AUDIO_MAIN_OUT};\r
CResource *resource = NULL;\r
\r
- for (int i = 0; i < 6; i++) {\r
+ for (int i = 0; i < 5; i++) {\r
resource = FindMainResource(categories[i]);\r
if (!resource) {\r
SERVER_INFO("no main resource for (%d)", categories[i]);\r
continue;\r
}\r
\r
- SERVER_INFO("swap resource (%d):(%d>%d)", it, cur_device_id, new_device_id);\r
+ SERVER_INFO("swap resource (%d) :(%d>%d)", it, cur_device_id, new_device_id);\r
\r
if (consumer->IsUsingResource(new_device_id)) {\r
SERVER_INFO("no need to swap (%d:%d)", it, new_device_id);\r
rsc->RemoveConsumer(consumer_id, false);
rsc->ResetBW();
SERVER_INFO("result (0) - con(%d:%s) / devId(%d) / rId(%d)",
- consumer_id, consumer->GetAppID().empty() ? consumer->GetCmdName().c_str():consumer->GetAppID().c_str(), req->devices[i].device_id, device_id);
+ consumer_id, consumer->GetAppID().empty() ? consumer->GetCmdName().c_str() :consumer->GetAppID().c_str(), req->devices[i].device_id, device_id);
}
SERVER_WARN("Request for Deallocation - cid[%d] / requested #[%d] / REMAINING[%d] : SUCCESS", consumer_id, req->resources_num, consumer->GetResourceNum());
consumer = CConsumerContainer::getInstance()->findConsumer(cid);
if (consumer)
- app_id = (consumer->GetAppID().empty()) ? consumer->GetCmdName():consumer->GetAppID();
+ app_id = (consumer->GetAppID().empty()) ? consumer->GetCmdName() : consumer->GetAppID();
SERVER_INFO("(%d:%d:%d:%d:%d:%d:%s)", category_id, rsc->GetCurCategory(), rsc->GetDeviceID(), rsc->GetState(), cid, rsc->GetZoneId(), (app_id.empty() ? "" : app_id.c_str()));
+++ /dev/null
-/*\r
- * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-#include <iostream>\r
-#include <CResourceState.h>\r
-\r
-CResourceState::CResourceState(int device_id, int category_type, int consumer_id, int state, std::string app_id)\r
-{\r
- m_device_id = device_id;\r
- m_category_type = category_type;\r
- m_consumer_id = consumer_id;\r
- m_state = state;\r
- m_app_id = app_id;\r
-}
\ No newline at end of file
#include <CResource.h>\r
\r
CVirtualResource::CVirtualResource(const int virtual_device_id, const rms_rsc_category_e category_type, unsigned int bw, std::set<unsigned int> dependent, bool is_main_device, const char *audio_codec, int category_class)\r
-:m_vir_rsc_id(virtual_device_id), m_category_type(category_type), m_vir_rsc_bw(bw), m_is_main_device(is_main_device), m_category_class(category_class)\r
+:m_vir_rsc_id(virtual_device_id), m_category_type(category_type), m_vir_rsc_bw(bw), m_is_main_device(is_main_device), m_category_class(category_class), m_rsc()\r
{\r
m_mem_clusters = dependent;\r
\r
\r
for (auto const &it_consumer : consumers) {\r
consumer = c_container->findConsumer(it_consumer);\r
+ if (!consumer) {\r
+ SERVER_WARN("Consumer not found");\r
+ continue;\r
+ }\r
+\r
if (!consumer->GetAppID().compare(app_id)) {\r
SERVER_INFO("skip to check priority against same app (%s:%s)", consumer->GetAppID().c_str(), app_id.c_str());\r
continue;\r
if (m_consumers.size() == 0)\r
return false;\r
\r
- for (auto it : m_consumers) {\r
+ for (const auto& it : m_consumers) {\r
c = cc->findConsumer(it.first);\r
if (!c)\r
continue;\r
{\r
std::set<int> consumers;\r
\r
- for (auto it : m_consumers)\r
+ for (const auto& it : m_consumers)\r
consumers.insert(it.first);\r
\r
return consumers;\r
allocated_devices->device_ids = (int*) calloc(requests.size(), sizeof(int));\r
assert(allocated_devices->device_ids);\r
allocated_devices->devices = (rms_return_device_info_s*) calloc(requests.size(), sizeof(rms_return_device_info_s));\r
+ assert(allocated_devices->devices);\r
\r
int i = 0;\r
\r
\r
allocated_devices->resources_num = requests.size();\r
allocated_devices->device_ids = (int*) calloc(requests.size(), sizeof(int));\r
+ assert(allocated_devices->device_ids);\r
allocated_devices->devices = (rms_return_device_info_s*) calloc(requests.size(), sizeof(rms_return_device_info_s));\r
+ assert(allocated_devices->devices);\r
\r
int i = 0;\r
\r
#include <iostream>
+using namespace std;
+
int main(void)
{
- SERVER_INFO("RscMgr server main loop\n");
- trace_begin("[RSC_MGR] main start");
- trace_end();
+ try {
+ SERVER_INFO("RscMgr server main loop");
- GMainLoop *main_loop;
- main_loop = g_main_loop_new(NULL, FALSE);
+ GMainLoop *main_loop;
+ main_loop = g_main_loop_new(NULL, FALSE);
- if (!main_loop) {
- SERVER_ERR("failed to create a main loop\n");
- return 0;
- }
+ if (!main_loop) {
+ throw runtime_error("Failed to create a main loop");
+ }
- CResourceService *service = new(std::nothrow) CResourceService;
- service->Init(main_loop);
+ CResourceService *service = new(std::nothrow) CResourceService;
+ service->Init(main_loop);
- g_main_loop_ref(main_loop);
- g_main_loop_run(main_loop);
+ g_main_loop_ref(main_loop);
+ g_main_loop_run(main_loop);
+ } catch (const exception& e) {
+ SERVER_ERR("Exception occurred %s", e.what());
+ return -1;
+ }
return 0;
}