-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
-\r
- Apache License\r
- Version 2.0, January 2004\r
- http://www.apache.org/licenses/\r
-\r
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
-\r
- 1. Definitions.\r
-\r
- "License" shall mean the terms and conditions for use, reproduction,\r
- and distribution as defined by Sections 1 through 9 of this document.\r
-\r
- "Licensor" shall mean the copyright owner or entity authorized by\r
- the copyright owner that is granting the License.\r
-\r
- "Legal Entity" shall mean the union of the acting entity and all\r
- other entities that control, are controlled by, or are under common\r
- control with that entity. For the purposes of this definition,\r
- "control" means (i) the power, direct or indirect, to cause the\r
- direction or management of such entity, whether by contract or\r
- otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
- outstanding shares, or (iii) beneficial ownership of such entity.\r
-\r
- "You" (or "Your") shall mean an individual or Legal Entity\r
- exercising permissions granted by this License.\r
-\r
- "Source" form shall mean the preferred form for making modifications,\r
- including but not limited to software source code, documentation\r
- source, and configuration files.\r
-\r
- "Object" form shall mean any form resulting from mechanical\r
- transformation or translation of a Source form, including but\r
- not limited to compiled object code, generated documentation,\r
- and conversions to other media types.\r
-\r
- "Work" shall mean the work of authorship, whether in Source or\r
- Object form, made available under the License, as indicated by a\r
- copyright notice that is included in or attached to the work\r
- (an example is provided in the Appendix below).\r
-\r
- "Derivative Works" shall mean any work, whether in Source or Object\r
- form, that is based on (or derived from) the Work and for which the\r
- editorial revisions, annotations, elaborations, or other modifications\r
- represent, as a whole, an original work of authorship. For the purposes\r
- of this License, Derivative Works shall not include works that remain\r
- separable from, or merely link (or bind by name) to the interfaces of,\r
- the Work and Derivative Works thereof.\r
-\r
- "Contribution" shall mean any work of authorship, including\r
- the original version of the Work and any modifications or additions\r
- to that Work or Derivative Works thereof, that is intentionally\r
- submitted to Licensor for inclusion in the Work by the copyright owner\r
- or by an individual or Legal Entity authorized to submit on behalf of\r
- the copyright owner. For the purposes of this definition, "submitted"\r
- means any form of electronic, verbal, or written communication sent\r
- to the Licensor or its representatives, including but not limited to\r
- communication on electronic mailing lists, source code control systems,\r
- and issue tracking systems that are managed by, or on behalf of, the\r
- Licensor for the purpose of discussing and improving the Work, but\r
- excluding communication that is conspicuously marked or otherwise\r
- designated in writing by the copyright owner as "Not a Contribution."\r
-\r
- "Contributor" shall mean Licensor and any individual or Legal Entity\r
- on behalf of whom a Contribution has been received by Licensor and\r
- subsequently incorporated within the Work.\r
-\r
- 2. Grant of Copyright License. Subject to the terms and conditions of\r
- this License, each Contributor hereby grants to You a perpetual,\r
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
- copyright license to reproduce, prepare Derivative Works of,\r
- publicly display, publicly perform, sublicense, and distribute the\r
- Work and such Derivative Works in Source or Object form.\r
-\r
- 3. Grant of Patent License. Subject to the terms and conditions of\r
- this License, each Contributor hereby grants to You a perpetual,\r
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
- (except as stated in this section) patent license to make, have made,\r
- use, offer to sell, sell, import, and otherwise transfer the Work,\r
- where such license applies only to those patent claims licensable\r
- by such Contributor that are necessarily infringed by their\r
- Contribution(s) alone or by combination of their Contribution(s)\r
- with the Work to which such Contribution(s) was submitted. If You\r
- institute patent litigation against any entity (including a\r
- cross-claim or counterclaim in a lawsuit) alleging that the Work\r
- or a Contribution incorporated within the Work constitutes direct\r
- or contributory patent infringement, then any patent licenses\r
- granted to You under this License for that Work shall terminate\r
- as of the date such litigation is filed.\r
-\r
- 4. Redistribution. You may reproduce and distribute copies of the\r
- Work or Derivative Works thereof in any medium, with or without\r
- modifications, and in Source or Object form, provided that You\r
- meet the following conditions:\r
-\r
- (a) You must give any other recipients of the Work or\r
- Derivative Works a copy of this License; and\r
-\r
- (b) You must cause any modified files to carry prominent notices\r
- stating that You changed the files; and\r
-\r
- (c) You must retain, in the Source form of any Derivative Works\r
- that You distribute, all copyright, patent, trademark, and\r
- attribution notices from the Source form of the Work,\r
- excluding those notices that do not pertain to any part of\r
- the Derivative Works; and\r
-\r
- (d) If the Work includes a "NOTICE" text file as part of its\r
- distribution, then any Derivative Works that You distribute must\r
- include a readable copy of the attribution notices contained\r
- within such NOTICE file, excluding those notices that do not\r
- pertain to any part of the Derivative Works, in at least one\r
- of the following places: within a NOTICE text file distributed\r
- as part of the Derivative Works; within the Source form or\r
- documentation, if provided along with the Derivative Works; or,\r
- within a display generated by the Derivative Works, if and\r
- wherever such third-party notices normally appear. The contents\r
- of the NOTICE file are for informational purposes only and\r
- do not modify the License. You may add Your own attribution\r
- notices within Derivative Works that You distribute, alongside\r
- or as an addendum to the NOTICE text from the Work, provided\r
- that such additional attribution notices cannot be construed\r
- as modifying the License.\r
-\r
- You may add Your own copyright statement to Your modifications and\r
- may provide additional or different license terms and conditions\r
- for use, reproduction, or distribution of Your modifications, or\r
- for any such Derivative Works as a whole, provided Your use,\r
- reproduction, and distribution of the Work otherwise complies with\r
- the conditions stated in this License.\r
-\r
- 5. Submission of Contributions. Unless You explicitly state otherwise,\r
- any Contribution intentionally submitted for inclusion in the Work\r
- by You to the Licensor shall be under the terms and conditions of\r
- this License, without any additional terms or conditions.\r
- Notwithstanding the above, nothing herein shall supersede or modify\r
- the terms of any separate license agreement you may have executed\r
- with Licensor regarding such Contributions.\r
-\r
- 6. Trademarks. This License does not grant permission to use the trade\r
- names, trademarks, service marks, or product names of the Licensor,\r
- except as required for reasonable and customary use in describing the\r
- origin of the Work and reproducing the content of the NOTICE file.\r
-\r
- 7. Disclaimer of Warranty. Unless required by applicable law or\r
- agreed to in writing, Licensor provides the Work (and each\r
- Contributor provides its Contributions) on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
- implied, including, without limitation, any warranties or conditions\r
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
- PARTICULAR PURPOSE. You are solely responsible for determining the\r
- appropriateness of using or redistributing the Work and assume any\r
- risks associated with Your exercise of permissions under this License.\r
-\r
- 8. Limitation of Liability. In no event and under no legal theory,\r
- whether in tort (including negligence), contract, or otherwise,\r
- unless required by applicable law (such as deliberate and grossly\r
- negligent acts) or agreed to in writing, shall any Contributor be\r
- liable to You for damages, including any direct, indirect, special,\r
- incidental, or consequential damages of any character arising as a\r
- result of this License or out of the use or inability to use the\r
- Work (including but not limited to damages for loss of goodwill,\r
- work stoppage, computer failure or malfunction, or any and all\r
- other commercial damages or losses), even if such Contributor\r
- has been advised of the possibility of such damages.\r
-\r
- 9. Accepting Warranty or Additional Liability. While redistributing\r
- the Work or Derivative Works thereof, You may choose to offer,\r
- and charge a fee for, acceptance of support, warranty, indemnity,\r
- or other liability obligations and/or rights consistent with this\r
- License. However, in accepting such obligations, You may act only\r
- on Your own behalf and on Your sole responsibility, not on behalf\r
- of any other Contributor, and only if You agree to indemnify,\r
- defend, and hold each Contributor harmless for any liability\r
- incurred by, or claims asserted against, such Contributor by reason\r
- of your accepting any such warranty or additional liability.\r
-\r
- END OF TERMS AND CONDITIONS\r
-\r
- APPENDIX: How to apply the Apache License to your work.\r
-\r
- To apply the Apache License to your work, attach the following\r
- boilerplate notice, with the fields enclosed by brackets "[]"\r
- replaced with your own identifying information. (Don't include\r
- the brackets!) The text should be enclosed in the appropriate\r
- comment syntax for the file format. We also recommend that a\r
- file or class name and description of purpose be included on the\r
- same "printed page" as the copyright notice for easier\r
- identification within third-party archives.\r
-\r
- Copyright [yyyy] [name of copyright owner]\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
-\r
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
-/*\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
-#ifndef __C_ASYNC_QUEUE_H__\r
-#define __C_ASYNC_QUEUE_H__\r
-\r
-#include <glib.h>\r
-\r
-typedef void (*destoryNotify)(void *data);\r
-\r
-class CAsyncQueue{\r
-public:\r
- CAsyncQueue();\r
- CAsyncQueue(destoryNotify destory_cb);\r
- ~CAsyncQueue();\r
-\r
- void push(void *data);\r
- void push(CAsyncQueue *src_queue);\r
- void push_front(void *data);\r
- void push_front(CAsyncQueue *src_queue);\r
-\r
- void *pop(void);\r
- void *pop(unsigned int timeout_ms);\r
-\r
- int length(void);\r
-\r
-private:\r
- GAsyncQueue *queue;\r
-};\r
-\r
-#endif // __C_ASYNC_QUEUE_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __C_ASYNC_QUEUE_H__
+#define __C_ASYNC_QUEUE_H__
+
+#include <glib.h>
+
+typedef void (*destoryNotify)(void *data);
+
+class CAsyncQueue{
+public:
+ CAsyncQueue();
+ CAsyncQueue(destoryNotify destory_cb);
+ ~CAsyncQueue();
+
+ void push(void *data);
+ void push(CAsyncQueue *src_queue);
+ void push_front(void *data);
+ void push_front(CAsyncQueue *src_queue);
+
+ void *pop(void);
+ void *pop(unsigned int timeout_ms);
+
+ int length(void);
+
+private:
+ GAsyncQueue *queue;
+};
+
+#endif // __C_ASYNC_QUEUE_H__
-/*\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
-#ifndef __RMS_CCALLBACK_H__\r
-#define __RMS_CCALLBACK_H__\r
-\r
-class CCallback\r
-{\r
-public:\r
- CCallback() {}\r
- ~CCallback() {}\r
-\r
- static void InitCallback(void);\r
- static int SendCallbackMessage(int cid, int pid, void *callback_data, int size, int *err);\r
- static int RemoveFIFOServerToClient(int pid, int cid);\r
- static int ConvertCallbackType(int rm_return_type);\r
- static unsigned int GetTimeout(void);\r
-};\r
-\r
-#endif //__RMS_CCALLBACK_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RMS_CCALLBACK_H__
+#define __RMS_CCALLBACK_H__
+
+class CCallback
+{
+public:
+ CCallback() {}
+ ~CCallback() {}
+
+ static void InitCallback(void);
+ static int SendCallbackMessage(int cid, int pid, void *callback_data, int size, int *err);
+ static int RemoveFIFOServerToClient(int pid, int cid);
+ static int ConvertCallbackType(int rm_return_type);
+ static unsigned int GetTimeout(void);
+};
+
+#endif //__RMS_CCALLBACK_H__
-/*\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
-#ifndef __CDBUS_HANDLER_H__\r
-#define __CDBUS_HANDLER_H__\r
-\r
-#include <glib.h>\r
-#include <gio/gio.h>\r
-\r
-#include <CAsyncQueue.h>\r
-\r
-class CDbusHandler\r
-{\r
-public:\r
- CDbusHandler(CAsyncQueue *queue);\r
- ~CDbusHandler() = default;\r
-\r
- static void OnMethodCall(GDBusConnection *conn, const gchar *sender, const gchar *obj_path, const gchar *ifname, const gchar *method_name, GVariant *params, GDBusMethodInvocation *invoc, gpointer data);\r
- static void OnBusAcquired(GDBusConnection *conn, const gchar *bus_name, gpointer data);\r
- static void OnNameLost(GDBusConnection *conn, const gchar *bus_name, gpointer data);\r
-\r
-private:\r
-\r
- static const std::string m_methods;\r
- static const GDBusInterfaceVTable m_vtable;\r
-\r
- GDBusConnection *m_conn;\r
- unsigned int m_reg_id;\r
- unsigned int m_own_id;\r
-\r
- CAsyncQueue *m_async_queue;\r
-\r
- bool MakeDbusConnection(void);\r
- void RegisterObjects(void);\r
- void GenerateReadyEvent(void);\r
-};\r
-\r
-#endif // __CDBUS_HANDLER_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CDBUS_HANDLER_H__
+#define __CDBUS_HANDLER_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <CAsyncQueue.h>
+
+class CDbusHandler
+{
+public:
+ CDbusHandler(CAsyncQueue *queue);
+ ~CDbusHandler() = default;
+
+ static void OnMethodCall(GDBusConnection *conn, const gchar *sender, const gchar *obj_path, const gchar *ifname, const gchar *method_name, GVariant *params, GDBusMethodInvocation *invoc, gpointer data);
+ static void OnBusAcquired(GDBusConnection *conn, const gchar *bus_name, gpointer data);
+ static void OnNameLost(GDBusConnection *conn, const gchar *bus_name, gpointer data);
+
+private:
+
+ static const std::string m_methods;
+ static const GDBusInterfaceVTable m_vtable;
+
+ GDBusConnection *m_conn;
+ unsigned int m_reg_id;
+ unsigned int m_own_id;
+
+ CAsyncQueue *m_async_queue;
+
+ bool MakeDbusConnection(void);
+ void RegisterObjects(void);
+ void GenerateReadyEvent(void);
+};
+
+#endif // __CDBUS_HANDLER_H__
-/*\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
-#ifndef __RMS_CHANDLE_H__\r
-#define __RMS_CHANDLE_H__\r
-#include <rms_type.h>\r
-class CHandle\r
-{\r
-public:\r
- CHandle() {}\r
- CHandle(int handle, int is_used, int pid);\r
- ~CHandle() {}\r
-\r
- int handle;\r
- int is_used;\r
- int pid;\r
- int main_priority;\r
- int sub_priority;\r
- int app_pid;\r
- char *app_id;\r
- char process_name[RMS_NAME_BUF_SIZE];\r
-};\r
-\r
-#endif //__RMS_CHANDLE_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RMS_CHANDLE_H__
+#define __RMS_CHANDLE_H__
+#include <rms_type.h>
+class CHandle
+{
+public:
+ CHandle() {}
+ 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;
+ char process_name[RMS_NAME_BUF_SIZE];
+};
+
+#endif //__RMS_CHANDLE_H__
-/*\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
-#ifndef __RMS_CHANDLE_MANAGER_H__\r
-#define __RMS_CHANDLE_MANAGER_H__\r
-\r
-#include <map>\r
-#include <CResourceManager.h>\r
-#include <CHandle.h>\r
-\r
-class CHandleManager\r
-{\r
-public:\r
- CHandleManager(CResourceManager *rsc_mgr);\r
- ~CHandleManager() {}\r
-\r
- int GetNewHandle(int pid, int main_priority, int sub_priority, int app_pid, char *app_id);\r
- int RemoveHandle(int handle, int pid);\r
- int SetPriority(int handle, int main_priority, int sub_priority);\r
- int GetPriority(int handle, int *main_priority, int *sub_priority);\r
- int SetAppID(int handle, char *app_id);\r
- char *GetAppID(int handle);\r
- void ReclaimAllInvalidCustomer(int request_pid);\r
-\r
-private:\r
- int m_RemoveHandle(int handle, int pid);\r
- int m_IsValidHandle(int handle);\r
- int m_ReclaimHandle(void);\r
- int m_AddNewHandle(int handle, int pid, int main_priority, int sub_priority, int app_pid, char *app_id);\r
- int m_PrintHandleInfo(int handle, int pid);\r
- void m_PrintHandleList(void);\r
- CHandle *findHandle(int id);\r
-\r
- CResourceManager *m_rsc_mgr;\r
- int m_next_handle;\r
- std::map<int, CHandle*> m_handles;\r
-};\r
-\r
-#endif //__RMS_CHANDLE_MANAGER_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RMS_CHANDLE_MANAGER_H__
+#define __RMS_CHANDLE_MANAGER_H__
+
+#include <map>
+#include <CResourceManager.h>
+#include <CHandle.h>
+
+class CHandleManager
+{
+public:
+ CHandleManager(CResourceManager *rsc_mgr);
+ ~CHandleManager() {}
+
+ int GetNewHandle(int pid, int main_priority, int sub_priority, int app_pid, char *app_id);
+ int RemoveHandle(int handle, int pid);
+ int SetPriority(int handle, int main_priority, int sub_priority);
+ int GetPriority(int handle, int *main_priority, int *sub_priority);
+ int SetAppID(int handle, char *app_id);
+ char *GetAppID(int handle);
+ void ReclaimAllInvalidCustomer(int request_pid);
+
+private:
+ int m_RemoveHandle(int handle, int pid);
+ int m_IsValidHandle(int handle);
+ int m_ReclaimHandle(void);
+ int m_AddNewHandle(int handle, int pid, int main_priority, int sub_priority, int app_pid, char *app_id);
+ int m_PrintHandleInfo(int handle, int pid);
+ void m_PrintHandleList(void);
+ CHandle *findHandle(int id);
+
+ CResourceManager *m_rsc_mgr;
+ int m_next_handle;
+ std::map<int, CHandle*> m_handles;
+};
+
+#endif //__RMS_CHANDLE_MANAGER_H__
-/*\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
-#ifndef __CMESSAGE_H__\r
-#define __CMESSAGE_H__\r
-\r
-#include <iostream>\r
-#include <gio/gio.h>\r
-#include <rms_type.h>\r
-\r
-typedef enum {\r
- MSG_SENDER_MSGQ,\r
- MSG_SENDER_DBUS,\r
- MSG_SENDER_INTERNAL\r
-} msg_sender_e;\r
-\r
-class CMessage\r
-{\r
-public:\r
- CMessage(std::string name);\r
- CMessage(rms_msg_request *msgq_req);\r
- CMessage(GDBusMethodInvocation *invoc);\r
- ~CMessage();\r
-\r
- int GetReqType(void);\r
- std::string GetName(void) { return m_name; }\r
- msg_sender_e GetSender(void) { return m_sender; }\r
- rms_msg_request *GetRequest(void) { return m_msgq_req; }\r
- GDBusMethodInvocation *GetMethodInvocation(void) { return m_invoc; }\r
-\r
- bool IsUnlockMsg(void);\r
- bool IsMsgFor(ResourceType rsc_type);\r
- void PrintInfo(void);\r
-\r
-private:\r
- rms_msg_request *m_msgq_req;\r
- GDBusMethodInvocation *m_invoc;\r
- msg_sender_e m_sender;\r
- std::string m_name;\r
-\r
- void PrintDbus(void);\r
- void PrintInternal(void);\r
- void PrintMsgQ(void);\r
-\r
- bool IsMsgForScaler(void);\r
- bool IsMsgForScalerDbus(void);\r
- bool IsMsgForScalerMsgQ(void);\r
-};\r
-\r
-#endif //__CMESSAGE_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CMESSAGE_H__
+#define __CMESSAGE_H__
+
+#include <iostream>
+#include <gio/gio.h>
+#include <rms_type.h>
+
+typedef enum {
+ MSG_SENDER_MSGQ,
+ MSG_SENDER_DBUS,
+ MSG_SENDER_INTERNAL
+} msg_sender_e;
+
+class CMessage
+{
+public:
+ CMessage(std::string name);
+ CMessage(rms_msg_request *msgq_req);
+ CMessage(GDBusMethodInvocation *invoc);
+ ~CMessage();
+
+ int GetReqType(void);
+ std::string GetName(void) { return m_name; }
+ msg_sender_e GetSender(void) { return m_sender; }
+ rms_msg_request *GetRequest(void) { return m_msgq_req; }
+ GDBusMethodInvocation *GetMethodInvocation(void) { return m_invoc; }
+
+ bool IsUnlockMsg(void);
+ bool IsMsgFor(ResourceType rsc_type);
+ void PrintInfo(void);
+
+private:
+ rms_msg_request *m_msgq_req;
+ GDBusMethodInvocation *m_invoc;
+ msg_sender_e m_sender;
+ std::string m_name;
+
+ void PrintDbus(void);
+ void PrintInternal(void);
+ void PrintMsgQ(void);
+
+ bool IsMsgForScaler(void);
+ bool IsMsgForScalerDbus(void);
+ bool IsMsgForScalerMsgQ(void);
+};
+
+#endif //__CMESSAGE_H__
-/*\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
-#ifndef __RMS_CMESSAGE_HANDLER_H__\r
-#define __RMS_CMESSAGE_HANDLER_H__\r
-\r
-#include <rms_type.h>\r
-#include <gio/gio.h>\r
-#include <glib.h>\r
-#include <map>\r
-\r
-#include <CMessage.h>\r
-#include <CQueryHandler.h>\r
-#include <CResourceManager.h>\r
-#include <CHandleManager.h>\r
-#include <CDbusHandler.h>\r
-#include <CLockController.h>\r
-#include <CMessageQueue.h>\r
-#include <CAsyncQueue.h>\r
-\r
-class CMessageHandler\r
-{\r
-public:\r
- typedef GVariant *(CMessageHandler::*MsgHandler)(GVariant *params);\r
-\r
- CMessageHandler(CResourceManager *rsc_mgr);\r
- ~CMessageHandler(void);\r
-\r
- int Run(void);\r
- void NotifyWatchdog(void);\r
-\r
-private:\r
- void InitDbusHandlers(void);\r
- void InitInternalMsgHandlers(void);\r
-\r
- static gpointer msgThread(gpointer data);\r
- static gpointer msgQThread(gpointer data);\r
-\r
- int ProcessMessage(void);\r
- int ProcessCallbackMessage(rms_consumer_tobe_returned_s *consumer_info, int requester_cid);\r
- void ProcessMessage(CAsyncQueue *queue, CMessage *msg, int cid_requester, int cid_releaser);\r
- void ProcessMsgQMessage(CMessage *msg);\r
- void ProcessDbusMessage(CMessage *msg);\r
- void ProcessInternalMessage(CMessage *msg);\r
-\r
- void EmptyPendingQueue(void);\r
- void InsertPendingQueue(CMessage *msg);\r
-\r
- int SendResponse(rms_msg_response *response);\r
- int PushMessage(CAsyncQueue *queue, CMessage *msg);\r
-\r
- bool IsRegisteredHandle(int handle);\r
- bool IsValidProcess(int pid);\r
- bool IsValidRequest(int req_type);\r
- bool IsAllResourcesReclaimed(rms_consumer_tobe_returned_s *consumer_info);\r
-\r
- int ReleaseInvalidProcessResources(int pid, int handle);\r
- int ReclaimResources(int reason, int requester_cid, int requester_zone_id, consumer_reclaim_s *conflict_info, bool *need_response);\r
-\r
- void SetRequesterInfo(rms_msg_request *request);\r
-\r
- void m_ConstructResponse(rms_msg_response *response, int data_type, rms_response_type_e msg_type, int handle, int pid);\r
- void m_ConstructRequestedDevice(rms_msg_request *request, rms_requests_device_s *requested_resource);\r
- void m_FreeAllocatedDevice(rms_return_device_s *allocated_device);\r
- int *m_SerializeCallbackData(const rms_consumer_tobe_returned_s *consumer_info, int reason, int *data_size);\r
- void m_Free(consumer_reclaim_s *consumer_info);\r
-\r
- void m_RegisterConsumer(rms_msg_request *request, rms_msg_response *response);\r
- void m_UnregisterConsumer(rms_msg_request *request, rms_msg_response *response);\r
- void m_AllocateResources(rms_msg_request *request, rms_msg_response *response);\r
- void m_ReleaseResources(rms_msg_request *request, rms_msg_response *response);\r
- void m_Query(rms_msg_request *request, rms_msg_response *response);\r
- void m_SetConsumerPriority(rms_msg_request *request, rms_msg_response *response);\r
- void m_SetAppID(rms_msg_request *request, rms_msg_response *response);\r
-\r
- GVariant *RegisterResource(GVariant *params);\r
- GVariant *GetResourceState(GVariant *params);\r
- GVariant *GetResourceList(GVariant *params);\r
- GVariant *GetResourceCollectionState(GVariant *params);\r
- GVariant *FindDeviceId(GVariant *params);\r
- GVariant *SwapResources(GVariant *params);\r
- GVariant *GetScalerState(GVariant *params);\r
- GVariant *GetAppId(GVariant *params);\r
- GVariant *GetActiveAudioOut(GVariant *params);\r
- GVariant *GetScalerHWID(GVariant *params);\r
- GVariant *RestoreResources(GVariant *params);\r
- GVariant *NotifyResourcePolicy(GVariant *params);\r
- GVariant *NotifyAppZoneInfo(GVariant *params);\r
- GVariant *NotifyWatchdog(GVariant *params);\r
-\r
- void NotifyConflict(consumer_reclaim_s *conflict_info, int zone_id);\r
-\r
- unsigned long m_req_timeout = 5;\r
-\r
- CMessageQueue *msgq_rx;\r
- CMessageQueue *msgq_tx;\r
- CAsyncQueue *async_queue;\r
- CAsyncQueue *async_pending_queue;\r
- CLockController *m_lock_ctr;\r
- CResourceManager *m_rsc_mgr;\r
- CHandleManager *m_handle_mgr;\r
- CQueryHandler *m_query_h;\r
- CDbusHandler *m_dbus_h;\r
-\r
- typedef void (CMessageHandler::*msg_handler)(rms_msg_request *request, rms_msg_response *response);\r
- static msg_handler handlers[RMS_REQUEST_MAX];\r
- std::map<std::string, MsgHandler> m_dbus_handlers;\r
- std::map<std::string, MsgHandler> m_internal_msg_handlers;\r
-};\r
-\r
-#endif //__RMS_CMESSAGE_HANDLER_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RMS_CMESSAGE_HANDLER_H__
+#define __RMS_CMESSAGE_HANDLER_H__
+
+#include <rms_type.h>
+#include <gio/gio.h>
+#include <glib.h>
+#include <map>
+
+#include <CMessage.h>
+#include <CQueryHandler.h>
+#include <CResourceManager.h>
+#include <CHandleManager.h>
+#include <CDbusHandler.h>
+#include <CLockController.h>
+#include <CMessageQueue.h>
+#include <CAsyncQueue.h>
+
+class CMessageHandler
+{
+public:
+ typedef GVariant *(CMessageHandler::*MsgHandler)(GVariant *params);
+
+ CMessageHandler(CResourceManager *rsc_mgr);
+ ~CMessageHandler(void);
+
+ int Run(void);
+ void NotifyWatchdog(void);
+
+private:
+ void InitDbusHandlers(void);
+ void InitInternalMsgHandlers(void);
+
+ static gpointer msgThread(gpointer data);
+ static gpointer msgQThread(gpointer data);
+
+ int ProcessMessage(void);
+ int ProcessCallbackMessage(rms_consumer_tobe_returned_s *consumer_info, int requester_cid);
+ void ProcessMessage(CAsyncQueue *queue, CMessage *msg, int cid_requester, int cid_releaser);
+ void ProcessMsgQMessage(CMessage *msg);
+ void ProcessDbusMessage(CMessage *msg);
+ void ProcessInternalMessage(CMessage *msg);
+
+ void EmptyPendingQueue(void);
+ void InsertPendingQueue(CMessage *msg);
+
+ int SendResponse(rms_msg_response *response);
+ int PushMessage(CAsyncQueue *queue, CMessage *msg);
+
+ bool IsRegisteredHandle(int handle);
+ bool IsValidProcess(int pid);
+ bool IsValidRequest(int req_type);
+ bool IsAllResourcesReclaimed(rms_consumer_tobe_returned_s *consumer_info);
+
+ int ReleaseInvalidProcessResources(int pid, int handle);
+ int ReclaimResources(int reason, int requester_cid, int requester_zone_id, consumer_reclaim_s *conflict_info, bool *need_response);
+
+ void SetRequesterInfo(rms_msg_request *request);
+
+ void m_ConstructResponse(rms_msg_response *response, int data_type, rms_response_type_e msg_type, int handle, int pid);
+ void m_ConstructRequestedDevice(rms_msg_request *request, rms_requests_device_s *requested_resource);
+ void m_FreeAllocatedDevice(rms_return_device_s *allocated_device);
+ int *m_SerializeCallbackData(const rms_consumer_tobe_returned_s *consumer_info, int reason, int *data_size);
+ void m_Free(consumer_reclaim_s *consumer_info);
+
+ void m_RegisterConsumer(rms_msg_request *request, rms_msg_response *response);
+ void m_UnregisterConsumer(rms_msg_request *request, rms_msg_response *response);
+ void m_AllocateResources(rms_msg_request *request, rms_msg_response *response);
+ void m_ReleaseResources(rms_msg_request *request, rms_msg_response *response);
+ void m_Query(rms_msg_request *request, rms_msg_response *response);
+ void m_SetConsumerPriority(rms_msg_request *request, rms_msg_response *response);
+ void m_SetAppID(rms_msg_request *request, rms_msg_response *response);
+
+ GVariant *RegisterResource(GVariant *params);
+ GVariant *GetResourceState(GVariant *params);
+ GVariant *GetResourceList(GVariant *params);
+ GVariant *GetResourceCollectionState(GVariant *params);
+ GVariant *FindDeviceId(GVariant *params);
+ GVariant *SwapResources(GVariant *params);
+ GVariant *GetScalerState(GVariant *params);
+ GVariant *GetAppId(GVariant *params);
+ GVariant *GetActiveAudioOut(GVariant *params);
+ GVariant *GetScalerHWID(GVariant *params);
+ GVariant *RestoreResources(GVariant *params);
+ GVariant *NotifyResourcePolicy(GVariant *params);
+ GVariant *NotifyAppZoneInfo(GVariant *params);
+ GVariant *NotifyWatchdog(GVariant *params);
+
+ void NotifyConflict(consumer_reclaim_s *conflict_info, int zone_id);
+
+ 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;
+
+ typedef void (CMessageHandler::*msg_handler)(rms_msg_request *request, rms_msg_response *response);
+ static msg_handler handlers[RMS_REQUEST_MAX];
+ std::map<std::string, MsgHandler> m_dbus_handlers;
+ std::map<std::string, MsgHandler> m_internal_msg_handlers;
+};
+
+#endif //__RMS_CMESSAGE_HANDLER_H__
-/*\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
-#ifndef __CMESSAGE_QUEUE_H__\r
-#define __CMESSAGE_QUEUE_H__\r
-\r
-#include <rms_type.h>\r
-#include <CAsyncQueue.h>\r
-\r
-typedef enum {\r
- MSG_QUEUE_RX = 0,\r
- MSG_QUEUE_TX\r
-} msgq_type_e;\r
-\r
-class CMessageQueue{\r
-public:\r
- CMessageQueue(msgq_type_e type);\r
- ~CMessageQueue();\r
-\r
- int receive(rms_msg_request *req, int msg_type);\r
- int send(rms_msg_response *response);\r
-\r
-private:\r
- int init(void);\r
- int recover(void);\r
- static int getKey(msgq_type_e type);\r
-\r
- msgq_type_e msgq_type;\r
- int msgq_id;\r
-\r
- static const long msgq_size = 131072; // 128KB\r
- static const int key_rx = 8211;\r
- static const int key_tx = 8212;\r
-};\r
-\r
-#endif //__CMESSAGE_QUEUE_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CMESSAGE_QUEUE_H__
+#define __CMESSAGE_QUEUE_H__
+
+#include <rms_type.h>
+#include <CAsyncQueue.h>
+
+typedef enum {
+ MSG_QUEUE_RX = 0,
+ MSG_QUEUE_TX
+} msgq_type_e;
+
+class CMessageQueue{
+public:
+ CMessageQueue(msgq_type_e type);
+ ~CMessageQueue();
+
+ int receive(rms_msg_request *req, int msg_type);
+ int send(rms_msg_response *response);
+
+private:
+ int init(void);
+ int recover(void);
+ static int getKey(msgq_type_e type);
+
+ msgq_type_e msgq_type;
+ int msgq_id;
+
+ static const long msgq_size = 131072; // 128KB
+ static const int key_rx = 8211;
+ static const int key_tx = 8212;
+};
+
+#endif //__CMESSAGE_QUEUE_H__
-/*\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
-#ifndef __CQUERY_HANDLER_H__\r
-#define __CQUERY_HANDLER_H__\r
-\r
-#include <rms_type.h>\r
-#include <CResourceManager.h>\r
-\r
-class CQueryHandler\r
-{\r
-public:\r
- CQueryHandler(CResourceManager *rsc_mgr);\r
- ~CQueryHandler();\r
-\r
- int GetAnswer(rms_msg_request *request, int *answer_out);\r
-private:\r
- CResourceManager *m_rsc_mgr;\r
-};\r
-\r
-#endif //__CQUERY_HANDLER_H__
\ No newline at end of file
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CQUERY_HANDLER_H__
+#define __CQUERY_HANDLER_H__
+
+#include <rms_type.h>
+#include <CResourceManager.h>
+
+class CQueryHandler
+{
+public:
+ CQueryHandler(CResourceManager *rsc_mgr);
+ ~CQueryHandler();
+
+ int GetAnswer(rms_msg_request *request, int *answer_out);
+private:
+ CResourceManager *m_rsc_mgr;
+};
+
+#endif //__CQUERY_HANDLER_H__
-/*\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
-#ifndef __CREQUEST_H__\r
-#define __CREQUEST_H__\r
-\r
-#include "rms_type.h"\r
-\r
-class CRequester;\r
-class CRequest\r
-{\r
-public:\r
- CRequest(CRequester *requester);\r
- ~CRequest();\r
-\r
- CRequester *getRequester(void);\r
-\r
- void SetCategory(int category_id, int category_option);\r
- void SetState(int req_state);\r
-\r
- void SetResult(rms_return_code_e req_result);\r
- void SetReason(rms_error_type_e reason) { m_reason = reason; }\r
- void ResetResult(void) { m_result = RMS_ERROR; }\r
- void SetCandidateDevice(int device_id) { m_candidate_device = device_id; }\r
- void SetAllocatedDevice(int device_id) { m_allocated_device = device_id; }\r
- void SetAllocatedVirtualDevice(int virtual_id) { m_virtual_device = virtual_id; }\r
-\r
- bool IsRequestByDevice(void) { return (m_device_id > 0); }\r
- bool IsMainDeviceRequest(void);\r
- bool IsSubDeviceRequest(void);\r
- bool IsAIDeviceRequest(void);\r
-\r
- rms_rsc_category_e GetCategory(void);\r
- int GetDevice(void) { return m_device_id; }\r
- rms_requests_resource_state_e GetState(void) { return m_state; }\r
- rms_error_type_e GetReason(void) { return m_reason; }\r
-\r
- rms_return_code_e GetResult(void);\r
- int GetCandidateDevice(void) { return m_candidate_device; }\r
- int GetAllocatedDevice(void) { return m_allocated_device; }\r
- int GetAllocatedVirtualDevice(void) { return m_virtual_device; }\r
- rms_mixing_mode_e GetMixingMode(void) { return m_mixing_mode; }\r
-\r
- int GetMultiviewZoneId(void) { return m_mv_zone_id; }\r
- void PrintResult(void);\r
-\r
-private:\r
- rms_rsc_category_e ToVideoDecoderCategory(int category, int category_option, bool force_main, bool force_sub);\r
- rms_rsc_category_e ToJpegDecoderCategory(int category, int category_option);\r
- rms_rsc_category_e ToMJpegDecoderCategory(int category, int category_option);\r
- rms_rsc_category_e ToAudioDecoderCategory(int category, int category_option, bool force_main, bool force_sub);\r
- rms_rsc_category_e ToScalerCategory(int category, int category_option, bool force_main, bool force_sub);\r
- rms_rsc_category_e ToAudioOutCategory(int category, int category_option, bool force_main, bool force_sub);\r
- rms_rsc_category_e ToResourceCategory(int category, int category_option);\r
- rms_rsc_category_e ToImageDecoderCategory(int category, int category_option);\r
- rms_mixing_mode_e ToMixingMode(int category, int category_option);\r
- int ToMultiviewZoneId(int category_option);\r
- bool IsSupportedCategory(int category_option);\r
- int UnmaskMainSubOptions(int category_option);\r
- int UnmaskMixingOptions(int category_option);\r
- int UnmaskMVZoneInfo(int category_option);\r
- int UnmaskForceOptions(int category_option);\r
-\r
- CRequester *m_requester;\r
-\r
- int m_category_id;\r
- int m_category_option;\r
- rms_rsc_category_e m_category;\r
- rms_requests_resource_state_e m_state;\r
- rms_mixing_mode_e m_mixing_mode;\r
- int m_device_id;\r
-\r
- rms_return_code_e m_result;\r
- int m_candidate_device;\r
- int m_allocated_device;\r
- int m_virtual_device;\r
- int m_mv_zone_id;\r
- rms_error_type_e m_reason;\r
-};\r
-\r
-#endif //__CREQUEST_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CREQUEST_H__
+#define __CREQUEST_H__
+
+#include "rms_type.h"
+
+class CRequester;
+class CRequest
+{
+public:
+ CRequest(CRequester *requester);
+ ~CRequest();
+
+ CRequester *getRequester(void);
+
+ void SetCategory(int category_id, int category_option);
+ void SetState(int req_state);
+
+ void SetResult(rms_return_code_e req_result);
+ void SetReason(rms_error_type_e reason) { m_reason = reason; }
+ void ResetResult(void) { m_result = RMS_ERROR; }
+ void SetCandidateDevice(int device_id) { m_candidate_device = device_id; }
+ void SetAllocatedDevice(int device_id) { m_allocated_device = device_id; }
+ void SetAllocatedVirtualDevice(int virtual_id) { m_virtual_device = virtual_id; }
+
+ bool IsRequestByDevice(void) { return (m_device_id > 0); }
+ bool IsMainDeviceRequest(void);
+ bool IsSubDeviceRequest(void);
+ bool IsAIDeviceRequest(void);
+
+ rms_rsc_category_e GetCategory(void);
+ int GetDevice(void) { return m_device_id; }
+ rms_requests_resource_state_e GetState(void) { return m_state; }
+ rms_error_type_e GetReason(void) { return m_reason; }
+
+ rms_return_code_e GetResult(void);
+ int GetCandidateDevice(void) { return m_candidate_device; }
+ int GetAllocatedDevice(void) { return m_allocated_device; }
+ int GetAllocatedVirtualDevice(void) { return m_virtual_device; }
+ rms_mixing_mode_e GetMixingMode(void) { return m_mixing_mode; }
+
+ int GetMultiviewZoneId(void) { return m_mv_zone_id; }
+ void PrintResult(void);
+
+private:
+ rms_rsc_category_e ToVideoDecoderCategory(int category, int category_option, bool force_main, bool force_sub);
+ rms_rsc_category_e ToJpegDecoderCategory(int category, int category_option);
+ rms_rsc_category_e ToMJpegDecoderCategory(int category, int category_option);
+ rms_rsc_category_e ToAudioDecoderCategory(int category, int category_option, bool force_main, bool force_sub);
+ rms_rsc_category_e ToScalerCategory(int category, int category_option, bool force_main, bool force_sub);
+ rms_rsc_category_e ToAudioOutCategory(int category, int category_option, bool force_main, bool force_sub);
+ rms_rsc_category_e ToResourceCategory(int category, int category_option);
+ rms_rsc_category_e ToImageDecoderCategory(int category, int category_option);
+ rms_mixing_mode_e ToMixingMode(int category, int category_option);
+ int ToMultiviewZoneId(int category_option);
+ bool IsSupportedCategory(int category_option);
+ int UnmaskMainSubOptions(int category_option);
+ int UnmaskMixingOptions(int category_option);
+ int UnmaskMVZoneInfo(int category_option);
+ int UnmaskForceOptions(int category_option);
+
+ 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;
+
+ 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;
+};
+
+#endif //__CREQUEST_H__
-/*\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
-#ifndef __CREQUESTER_H__\r
-#define __CREQUESTER_H__\r
-\r
-#include <string>\r
-\r
-#include "rms_type.h"\r
-\r
-class CRequester\r
-{\r
-public:\r
- CRequester();\r
- CRequester(rms_msg_request *req);\r
- ~CRequester();\r
-\r
- int getHandle(void);\r
- int getPid(void);\r
- int getMainPriority(void);\r
- int getSubPriority(void);\r
- std::string getAppId(void) { return m_app_id; }\r
- void SetCmdName(int pid);\r
- std::string GetCmdName(void) { return m_cmd_name; }\r
-\r
-private:\r
- int m_handle;\r
- int m_pid;\r
- int m_main_priority;\r
- int m_sub_priority;\r
- std::string m_app_id;\r
- std::string m_cmd_name;\r
-};\r
-\r
-#endif // __CREQUESTER_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CREQUESTER_H__
+#define __CREQUESTER_H__
+
+#include <string>
+
+#include "rms_type.h"
+
+class CRequester
+{
+public:
+ CRequester();
+ CRequester(rms_msg_request *req);
+ ~CRequester();
+
+ int getHandle(void);
+ int getPid(void);
+ int getMainPriority(void);
+ int getSubPriority(void);
+ std::string getAppId(void) { return m_app_id; }
+ void SetCmdName(int pid);
+ std::string GetCmdName(void) { return m_cmd_name; }
+
+private:
+ int m_handle;
+ int m_pid;
+ int m_main_priority;
+ int m_sub_priority;
+ std::string m_app_id;
+ std::string m_cmd_name;
+};
+
+#endif // __CREQUESTER_H__
-/*\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
-#ifndef __RMS_CRESOURCE_SERVICE_H__\r
-#define __RMS_CRESOURCE_SERVICE_H__\r
-\r
-#include <gio/gio.h>\r
-#include <CMessageHandler.h>\r
-\r
-class CResourceService\r
-{\r
-public:\r
- CResourceService(void) {}\r
- ~CResourceService(void) {}\r
- int Init(GMainLoop *main_loop);\r
-\r
-private:\r
-\r
- CMessageHandler *m_msg_h;\r
-\r
- int IsFirstLaunch(void);\r
- void RequestColdPowerOff(void);\r
- void CreateWatchDogTimer(void);\r
- void SetVIPProcess(void);\r
- static gboolean WatchDogCallback(gpointer data);\r
- static gboolean InvalidResourceTableMsgCallback(gpointer data);\r
-};\r
-\r
-#endif //__RMS_CRESOURCE_SERVICE_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RMS_CRESOURCE_SERVICE_H__
+#define __RMS_CRESOURCE_SERVICE_H__
+
+#include <gio/gio.h>
+#include <CMessageHandler.h>
+
+class CResourceService
+{
+public:
+ CResourceService(void) {}
+ ~CResourceService(void) {}
+ int Init(GMainLoop *main_loop);
+
+private:
+
+ CMessageHandler *m_msg_h;
+
+ int IsFirstLaunch(void);
+ void RequestColdPowerOff(void);
+ void CreateWatchDogTimer(void);
+ void SetVIPProcess(void);
+ static gboolean WatchDogCallback(gpointer data);
+ static gboolean InvalidResourceTableMsgCallback(gpointer data);
+};
+
+#endif //__RMS_CRESOURCE_SERVICE_H__
-/*\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
-#ifndef __CSYS_INFO_H__\r
-#define __CSYS_INFO_H__\r
-\r
-class CSysInfo\r
-{\r
-public:\r
- ~CSysInfo() = default;\r
-\r
- static CSysInfo *GetInstance(void);\r
- bool IsAudioMixingSupported(void);\r
-private:\r
- CSysInfo() = default;\r
-\r
- static CSysInfo *m_instance;\r
- bool m_support_audio_mixing;\r
-};\r
-\r
-#endif //__CSYS_INFO_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CSYS_INFO_H__
+#define __CSYS_INFO_H__
+
+class CSysInfo
+{
+public:
+ ~CSysInfo() = default;
+
+ static CSysInfo *GetInstance(void);
+ bool IsAudioMixingSupported(void);
+private:
+ CSysInfo() = default;
+
+ static CSysInfo *m_instance;
+ bool m_support_audio_mixing;
+};
+
+#endif //__CSYS_INFO_H__
-/*\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
-#ifndef __CCACHE_H__\r
-#define __CCACHE_H__\r
-\r
-#include <map>\r
-#include <string>\r
-\r
-class CCache\r
-{\r
-public:\r
- static CCache *getInstance(void);\r
- ~CCache() = default;\r
-\r
- void Drop(void);\r
- int GetAppStatus(std::string app_id);\r
- void SetAppStatus(std::string app_id, int status);\r
-\r
-private:\r
- CCache() = default;\r
-\r
- static CCache *m_instance;\r
- std::map<std::string, int> m_visibility; // app id, app status\r
-};\r
-\r
-#endif //__CCACHE_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CCACHE_H__
+#define __CCACHE_H__
+
+#include <map>
+#include <string>
+
+class CCache
+{
+public:
+ static CCache *getInstance(void);
+ ~CCache() = default;
+
+ void Drop(void);
+ int GetAppStatus(std::string app_id);
+ void SetAppStatus(std::string app_id, int status);
+
+private:
+ CCache() = default;
+
+ static CCache *m_instance;
+ std::map<std::string, int> m_visibility; // app id, app status
+};
+
+#endif //__CCACHE_H__
-/*\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
-#ifndef __RSC_MGR_SERVER_CONSUMER_H__\r
-#define __RSC_MGR_SERVER_CONSUMER_H__\r
-\r
-#include <string>\r
-#include <rms_type.h>\r
-#include <set>\r
-\r
-class CConsumer\r
-{\r
-public:\r
- CConsumer(IN const rms_consumer_s *consumer);\r
- virtual ~CConsumer() {}\r
-\r
- long GetPid(void) { return m_pid; }\r
- int GetId(void) { return m_consumerID; }\r
- void SetAppID(IN const char *app_id);\r
- std::string GetAppID(void) { return m_app_id; }\r
- std::string GetCmdName(void) { return m_cmd_name; }\r
-\r
- bool AddResource(IN int device_id);\r
- int ReleaseResource(IN int device_id);\r
- bool IsUsingResource(IN int device_id);\r
- std::set<int> GetResources(void) { return m_resources; }\r
- int GetResourceNum(void) { return m_resources.size(); }\r
-\r
- void SetPriority(rms_priority_s priority) { m_priority = priority; }\r
- rms_error_type_e ComparePriority(CConsumer *requester);\r
-\r
-private:\r
- rms_priority_s GetPriority(void) { return m_priority; }\r
- bool ComparePriority(IN rms_priority_s priority1, IN rms_priority_s priority2);\r
- bool CheckVisibility(IN std::string app_id_requester);\r
- bool GetAppVisibility(IN std::string app_id, bool requester);\r
- bool CheckWebAppState(IN std::string app_id_requesting);\r
- bool IsVisibleStatus(int status);\r
- bool NeedStatusUpdate(std::string app_id);\r
- int UpdateAppStatus(std::string app_id);\r
- void SetCmdName(long pid);\r
- std::string GetAppId(int pid);\r
-\r
- std::set<int> m_resources;\r
-\r
- int m_consumerID;\r
- rms_priority_s m_priority;\r
- long m_pid;\r
- std::string m_app_id;\r
- std::string m_cmd_name;\r
-};\r
-\r
-\r
-#endif // __RSC_MGR_SERVER_CONSUMER_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RSC_MGR_SERVER_CONSUMER_H__
+#define __RSC_MGR_SERVER_CONSUMER_H__
+
+#include <string>
+#include <rms_type.h>
+#include <set>
+
+class CConsumer
+{
+public:
+ CConsumer(IN const rms_consumer_s *consumer);
+ virtual ~CConsumer() {}
+
+ long GetPid(void) { return m_pid; }
+ int GetId(void) { return m_consumerID; }
+ void SetAppID(IN const char *app_id);
+ std::string GetAppID(void) { return m_app_id; }
+ std::string GetCmdName(void) { return m_cmd_name; }
+
+ bool AddResource(IN int device_id);
+ int ReleaseResource(IN int device_id);
+ bool IsUsingResource(IN int device_id);
+ std::set<int> GetResources(void) { return m_resources; }
+ int GetResourceNum(void) { return m_resources.size(); }
+
+ void SetPriority(rms_priority_s priority) { m_priority = priority; }
+ rms_error_type_e ComparePriority(CConsumer *requester);
+
+private:
+ rms_priority_s GetPriority(void) { return m_priority; }
+ bool ComparePriority(IN rms_priority_s priority1, IN rms_priority_s priority2);
+ bool CheckVisibility(IN std::string app_id_requester);
+ bool GetAppVisibility(IN std::string app_id, bool requester);
+ bool CheckWebAppState(IN std::string app_id_requesting);
+ bool IsVisibleStatus(int status);
+ bool NeedStatusUpdate(std::string app_id);
+ int UpdateAppStatus(std::string app_id);
+ void SetCmdName(long pid);
+ std::string GetAppId(int pid);
+
+ std::set<int> m_resources;
+
+ int m_consumerID;
+ rms_priority_s m_priority;
+ long m_pid;
+ std::string m_app_id;
+ std::string m_cmd_name;
+};
+
+
+#endif // __RSC_MGR_SERVER_CONSUMER_H__
-/*\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
-#ifndef __CCONSUMER_CONTAINER_H__\r
-#define __CCONSUMER_CONTAINER_H__\r
-\r
-#include <map>\r
-#include <string>\r
-\r
-class CConsumer;\r
-class CConsumerContainer\r
-{\r
-public:\r
- static CConsumerContainer *getInstance(void);\r
- ~CConsumerContainer() = default;\r
-\r
- bool AddConsumer(int consumer_id, CConsumer *consumer);\r
- void RemoveConsumer(int consumer_id);\r
- CConsumer *findConsumer(int consumer_id);\r
- std::map<int, CConsumer*> FindConsumers(std::string app_id);\r
- std::map<int, CConsumer*> findConsumers(int pid);\r
-\r
-private:\r
- CConsumerContainer() = default;\r
-\r
- static CConsumerContainer *m_instance;\r
- std::map<int, CConsumer*> m_consumers;\r
-};\r
-\r
-#endif // __CCONSUMER_CONTAINER_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CCONSUMER_CONTAINER_H__
+#define __CCONSUMER_CONTAINER_H__
+
+#include <map>
+#include <string>
+
+class CConsumer;
+class CConsumerContainer
+{
+public:
+ static CConsumerContainer *getInstance(void);
+ ~CConsumerContainer() = default;
+
+ bool AddConsumer(int consumer_id, CConsumer *consumer);
+ void RemoveConsumer(int consumer_id);
+ CConsumer *findConsumer(int consumer_id);
+ std::map<int, CConsumer*> FindConsumers(std::string app_id);
+ std::map<int, CConsumer*> findConsumers(int pid);
+
+private:
+ CConsumerContainer() = default;
+
+ static CConsumerContainer *m_instance;
+ std::map<int, CConsumer*> m_consumers;
+};
+
+#endif // __CCONSUMER_CONTAINER_H__
-/*\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
-#ifndef __RSC_MGR_SERVER_DEBUGUTILS_H__\r
-#define __RSC_MGR_SERVER_DEBUGUTILS_H__\r
-\r
-#include <rms_type.h>\r
-#include <sys/types.h>\r
-#include <assert.h>\r
-\r
-#define RMS_CONSOLE_BUF_SIZE 256\r
-\r
-typedef enum {\r
- RMS_ALARM_NO_CALLBACK_RESPONSE,\r
- RMS_ALARM_NO_DEALLOCATION,\r
-} rms_alarm_reason_e;\r
-\r
-const char *rm_convert_state_enum_to_string(rms_resource_internal_state_e state_enum);\r
-const char *rm_convert_requested_state_enum_to_string(rms_requests_resource_state_e state_enum);\r
-const char *rm_convert_category_enum_to_string(rms_rsc_category_e category_enum);\r
-const char *rm_print_allocation_failure_reason(int ret_value);\r
-const char *rm_convert_device_enum_to_string(rms_device_e device_enum);\r
-\r
-int rms_get_cmd_name(pid_t pid, char *name_out, int size);\r
-void rms_print_log_console(char *buf);\r
-\r
-int rm_get_product_type(void);\r
-int rm_is_valid_pid(int pid);\r
-int rms_report_emergency(IN int cid, IN int pid, IN int requester);\r
-\r
-int is_symlink_file(const char *path);\r
-const char *rm_convert_error_type_to_string(rms_error_type_e error_type);\r
-\r
-void rms_display_timeout_error_popup(rms_alarm_reason_e reason, rms_consumer_tobe_returned_s info);\r
-void rms_display_resource_table_error_popup(void);\r
-void rms_print_model_info(void);\r
-\r
-bool process_htable_contains(const char *name);\r
-\r
-#endif //__RSC_MGR_SERVER_DEBUGUTILS_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RSC_MGR_SERVER_DEBUGUTILS_H__
+#define __RSC_MGR_SERVER_DEBUGUTILS_H__
+
+#include <rms_type.h>
+#include <sys/types.h>
+#include <assert.h>
+
+#define RMS_CONSOLE_BUF_SIZE 256
+
+typedef enum {
+ RMS_ALARM_NO_CALLBACK_RESPONSE,
+ RMS_ALARM_NO_DEALLOCATION,
+} rms_alarm_reason_e;
+
+const char *rm_convert_state_enum_to_string(rms_resource_internal_state_e state_enum);
+const char *rm_convert_requested_state_enum_to_string(rms_requests_resource_state_e state_enum);
+const char *rm_convert_category_enum_to_string(rms_rsc_category_e category_enum);
+const char *rm_print_allocation_failure_reason(int ret_value);
+const char *rm_convert_device_enum_to_string(rms_device_e device_enum);
+
+int rms_get_cmd_name(pid_t pid, char *name_out, int size);
+void rms_print_log_console(char *buf);
+
+int rm_get_product_type(void);
+int rm_is_valid_pid(int pid);
+int rms_report_emergency(IN int cid, IN int pid, IN int requester);
+
+int is_symlink_file(const char *path);
+const char *rm_convert_error_type_to_string(rms_error_type_e error_type);
+
+void rms_display_timeout_error_popup(rms_alarm_reason_e reason, rms_consumer_tobe_returned_s info);
+void rms_display_resource_table_error_popup(void);
+void rms_print_model_info(void);
+
+bool process_htable_contains(const char *name);
+
+#endif //__RSC_MGR_SERVER_DEBUGUTILS_H__
-/*\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
-#ifndef __CLOCK_CONTROLLER_H__\r
-#define __CLOCK_CONTROLLER_H__\r
-\r
-#include <map>\r
-#include <CAsyncQueue.h>\r
-#include <CMessage.h>\r
-\r
-class CLockController\r
-{\r
-public:\r
- static CLockController *GetInstance(void);\r
- void SetMsgQ(CAsyncQueue *queue) { m_msg_q = queue; }\r
-\r
- void Lock(ResourceType rsc_type);\r
- void Unlock(ResourceType rsc_type);\r
- unsigned int GetLockCount(void);\r
- bool IsLocked(CMessage *msg);\r
-\r
-private:\r
- CLockController() = default;\r
- ~CLockController() = default;\r
- void NotifyUnlock(void);\r
-\r
- static CLockController *m_instance;\r
- std::map<ResourceType, unsigned int> m_locks;\r
- CAsyncQueue *m_msg_q;\r
-};\r
-\r
-#endif //__CLOCK_CONTROLLER_H__S\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CLOCK_CONTROLLER_H__
+#define __CLOCK_CONTROLLER_H__
+
+#include <map>
+#include <CAsyncQueue.h>
+#include <CMessage.h>
+
+class CLockController
+{
+public:
+ static CLockController *GetInstance(void);
+ void SetMsgQ(CAsyncQueue *queue) { m_msg_q = queue; }
+
+ void Lock(ResourceType rsc_type);
+ void Unlock(ResourceType rsc_type);
+ unsigned int GetLockCount(void);
+ bool IsLocked(CMessage *msg);
+
+private:
+ CLockController() = default;
+ ~CLockController() = default;
+ void NotifyUnlock(void);
+
+ static CLockController *m_instance;
+ std::map<ResourceType, unsigned int> m_locks;
+ CAsyncQueue *m_msg_q;
+};
+
+#endif //__CLOCK_CONTROLLER_H__S
-/*\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
-#ifndef __CPRIORITY_H__\r
-#define __CPRIORITY_H__\r
-\r
-#include <rms_type.h>\r
-\r
-enum {\r
- LOW_PRIORITY = -1,\r
- SAME_PRIORITY = 0,\r
- HIGH_PRIORITY = 1\r
-};\r
-\r
-class CPriority\r
-{\r
-public:;\r
- ~CPriority();\r
-\r
- static bool isReclaimableConsumer(int consumer_id, int requester_id, rms_error_type_e *err_type);\r
- static int compareCurConsumers(int device_id, int consumer_id);\r
- static int compare(int cur_consumer_id, int consumer_id);\r
- static int getReclaimableConsumers(int device_id, int consumer_id, std::multimap<int, int>* reclaimables, rms_error_type_e *err_type);\r
- static int getReclaimableConsumersShare(int device_id, int consumer_id, std::multimap<int, int>* reclaimables, rms_error_type_e *err_type);\r
-private:\r
- CPriority();\r
-};\r
-\r
-#endif //__CPRIORITY_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CPRIORITY_H__
+#define __CPRIORITY_H__
+
+#include <rms_type.h>
+
+enum {
+ LOW_PRIORITY = -1,
+ SAME_PRIORITY = 0,
+ HIGH_PRIORITY = 1
+};
+
+class CPriority
+{
+public:;
+ ~CPriority();
+
+ static bool isReclaimableConsumer(int consumer_id, int requester_id, rms_error_type_e *err_type);
+ static int compareCurConsumers(int device_id, int consumer_id);
+ static int compare(int cur_consumer_id, int consumer_id);
+ static int getReclaimableConsumers(int device_id, int consumer_id, std::multimap<int, int>* reclaimables, rms_error_type_e *err_type);
+ static int getReclaimableConsumersShare(int device_id, int consumer_id, std::multimap<int, int>* reclaimables, rms_error_type_e *err_type);
+private:
+ CPriority();
+};
+
+#endif //__CPRIORITY_H__
-/*\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
-#ifndef __RSC_MGR_SERVER_RESOURCE_H__\r
-#define __RSC_MGR_SERVER_RESOURCE_H__\r
-\r
-#include <vector>\r
-#include <map>\r
-#include <set>\r
-#include <string>\r
-\r
-#include <rms_type.h>\r
-#include <CResourceSubject.h>\r
-\r
-class CResource : public CResourceSubject\r
-{\r
-public:\r
- CResource(IN const int device_id, IN const rms_rsc_category_e category_type, IN const char *name, IN const char *path, \r
- IN std::set<unsigned int> mem_cluster, IN int is_main_device, IN const char *audio_codec, IN int sharable_count);\r
- ~CResource();\r
-\r
- std::string GetName(void) { return std::string(m_device_name); }\r
- int GetDeviceID(void) { return m_id; }\r
- int GetVirtualResourceID(void) { return m_vrsc_id; }\r
- const char *GetDevicePath(void) { return m_device_path; }\r
- std::string GetAudioCodec(void) { return m_audio_codec; }\r
- rms_mixing_mode_e GetMixingMode(void) { return m_mixing_mode; }\r
- rms_rsc_category_e GetCategoryType(void) { return m_category_type; }\r
- int GetCurCategory(void) { return m_cur_category; }\r
- int getSharableCount(void) { return (m_sharable_count - m_shared_count - m_reserved_count); }\r
- int GetCategoryClass(void) { return m_category_class; }\r
-\r
- bool IsFreeState(void) { return m_state == RMS_INTERNAL_STATE_FREE; };\r
- bool IsAllocatableState(IN rms_requests_resource_state_e requested_state);\r
- bool IsSharableState(void) { return (m_state == RMS_INTERNAL_STATE_FREE || m_state == RMS_INTERNAL_STATE_SHARABLE); }\r
- bool IsReserved(void) { return m_is_reserved; }\r
- bool IsSharableDevice(void) { return (m_sharable_count >= 2); }\r
- bool IsMainDevice(void) { return m_is_main_device; }\r
- bool IsAudioDevice(void);\r
- bool IsVideoDecoder(void);\r
- bool IsScaler(void) { return m_is_scaler; }\r
- bool IsJpegDecoder(void);\r
-\r
- void AddConsumer(IN int consumer_id, IN rms_requests_resource_state_e state);\r
- void ResetConsumer(std::set<int> new_consumers);\r
- int RemoveConsumer(IN int consumer_id, IN bool force);\r
- std::set<int> GetConsumers(void) { return m_consumer_ids; }\r
- int GetFirstConsumer(void);\r
-\r
- int Reserve(IN int consumer_id, rms_requests_resource_state_e state);\r
- void CancelReservation(rms_requests_resource_state_e state);\r
-\r
- void SetDefaultBW(unsigned int bw);\r
- unsigned int GetBW(void) { return m_occupied_bw; }\r
- int GetDefaultBW(void) { return m_default_bw; }\r
- void ResetBW(void) { m_occupied_bw = m_default_bw; }\r
- void SetAllocatedTime(void);\r
- unsigned long GetAllocatedTime(void) { return m_allocated_time; }\r
-\r
- void SetVirtualDeviceId(int id) { m_virtual_id = id; }\r
- int GetVirtualDeviceId(void);\r
- void SetDedicatedVirtualDeviceId(int id) { m_dedicated_virtual_id = id; }\r
- int GetDedicatedVirtualDeviceId(void) { return m_dedicated_virtual_id; }\r
-\r
- std::set<unsigned int> GetMemClusters(void) { return m_mem_clusters; }\r
- void UpdateProperties(std::set<unsigned int> mem_clusters, int bw, int category, int category_class, int vrsc_id);\r
- void UpdateAudioCodec(std::string codec_name);\r
- void updateMixingMode(rms_mixing_mode_e mode) { m_mixing_mode = mode; }\r
-\r
- void RegisterObserver(CResourceObserver *observer);\r
- void UnregisterObserver(CResourceObserver *observer);\r
-\r
- bool Allocate(const int consumer_id, rms_requests_resource_state_e state, int mv_zone_id);\r
- int GetState(void) { return (int) m_state; }\r
- int GetZoneId(void) { return m_mv_zone_id; }\r
- void SetZoneId(int zone_id);\r
-\r
- void ChangeState(rms_resource_internal_state_e next_state);\r
-\r
-private:\r
- void m_SetSubScalerFlag(int next_state);\r
- bool IsRegisteredConsumer(int consumer_id);\r
- int IncreaseRefCount(int consumer_id);\r
- int DecreaseRefCount(int consumer_id);\r
- void NotifyObservers(resource_update_type_e type, int consumer_id);\r
- bool ChangeStateByAllocation(IN rms_requests_resource_state_e state, const int consumer_id, int mv_zone_id);\r
- bool ChangeStateByRelease(int consumer_id);\r
- bool IsScaler(rms_rsc_category_e category);\r
-\r
- int ReserveExclusive(int consumer_id);\r
- int ReserveShared(int consumer_id);\r
-\r
- std::map<int, int> m_consumers; // consumer id, cnt\r
- std::set<int> m_shared_consumers;\r
- std::set<int> m_consumer_ids;\r
-\r
- int m_id;\r
- int m_vrsc_id;\r
- int m_virtual_id;\r
- int m_dedicated_virtual_id;\r
- rms_resource_internal_state_e m_state;\r
- rms_rsc_category_e m_category_type;\r
- const char *m_device_name;\r
- const char *m_device_path;\r
- int m_category_class;\r
- int m_cur_category;\r
-\r
- unsigned int m_occupied_bw;\r
- unsigned int m_default_bw;\r
- int m_is_main_device;\r
- int m_sharable_count;\r
-\r
- bool m_is_reserved;\r
- bool m_is_scaler;\r
- int m_reserved_consumer_id;\r
- unsigned long m_allocated_time;\r
-\r
- int m_shared_count;\r
- int m_reserved_count;\r
- int m_mv_zone_id;\r
-\r
- std::string m_audio_codec;\r
- std::vector<CResourceObserver*> m_observers;\r
- std::set<unsigned int> m_mem_clusters;\r
- rms_mixing_mode_e m_mixing_mode;\r
-};\r
-\r
-#endif // __RSC_MGR_SERVER_RESOURCE_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RSC_MGR_SERVER_RESOURCE_H__
+#define __RSC_MGR_SERVER_RESOURCE_H__
+
+#include <vector>
+#include <map>
+#include <set>
+#include <string>
+
+#include <rms_type.h>
+#include <CResourceSubject.h>
+
+class CResource : public CResourceSubject
+{
+public:
+ CResource(IN const int device_id, IN const rms_rsc_category_e category_type, IN const char *name, IN const char *path,
+ IN std::set<unsigned int> mem_cluster, IN int is_main_device, IN const char *audio_codec, IN int sharable_count);
+ ~CResource();
+
+ std::string GetName(void) { return std::string(m_device_name); }
+ int GetDeviceID(void) { return m_id; }
+ int GetVirtualResourceID(void) { return m_vrsc_id; }
+ const char *GetDevicePath(void) { return m_device_path; }
+ std::string GetAudioCodec(void) { return m_audio_codec; }
+ rms_mixing_mode_e GetMixingMode(void) { return m_mixing_mode; }
+ rms_rsc_category_e GetCategoryType(void) { return m_category_type; }
+ int GetCurCategory(void) { return m_cur_category; }
+ int getSharableCount(void) { return (m_sharable_count - m_shared_count - m_reserved_count); }
+ int GetCategoryClass(void) { return m_category_class; }
+
+ bool IsFreeState(void) { return m_state == RMS_INTERNAL_STATE_FREE; };
+ bool IsAllocatableState(IN rms_requests_resource_state_e requested_state);
+ bool IsSharableState(void) { return (m_state == RMS_INTERNAL_STATE_FREE || m_state == RMS_INTERNAL_STATE_SHARABLE); }
+ bool IsReserved(void) { return m_is_reserved; }
+ bool IsSharableDevice(void) { return (m_sharable_count >= 2); }
+ bool IsMainDevice(void) { return m_is_main_device; }
+ bool IsAudioDevice(void);
+ bool IsVideoDecoder(void);
+ bool IsScaler(void) { return m_is_scaler; }
+ bool IsJpegDecoder(void);
+
+ void AddConsumer(IN int consumer_id, IN rms_requests_resource_state_e state);
+ void ResetConsumer(std::set<int> new_consumers);
+ int RemoveConsumer(IN int consumer_id, IN bool force);
+ std::set<int> GetConsumers(void) { return m_consumer_ids; }
+ int GetFirstConsumer(void);
+
+ int Reserve(IN int consumer_id, rms_requests_resource_state_e state);
+ void CancelReservation(rms_requests_resource_state_e state);
+
+ void SetDefaultBW(unsigned int bw);
+ unsigned int GetBW(void) { return m_occupied_bw; }
+ int GetDefaultBW(void) { return m_default_bw; }
+ void ResetBW(void) { m_occupied_bw = m_default_bw; }
+ void SetAllocatedTime(void);
+ unsigned long GetAllocatedTime(void) { return m_allocated_time; }
+
+ void SetVirtualDeviceId(int id) { m_virtual_id = id; }
+ int GetVirtualDeviceId(void);
+ void SetDedicatedVirtualDeviceId(int id) { m_dedicated_virtual_id = id; }
+ int GetDedicatedVirtualDeviceId(void) { return m_dedicated_virtual_id; }
+
+ std::set<unsigned int> GetMemClusters(void) { return m_mem_clusters; }
+ void UpdateProperties(std::set<unsigned int> mem_clusters, int bw, int category, int category_class, int vrsc_id);
+ void UpdateAudioCodec(std::string codec_name);
+ void updateMixingMode(rms_mixing_mode_e mode) { m_mixing_mode = mode; }
+
+ void RegisterObserver(CResourceObserver *observer);
+ void UnregisterObserver(CResourceObserver *observer);
+
+ bool Allocate(const int consumer_id, rms_requests_resource_state_e state, int mv_zone_id);
+ int GetState(void) { return (int) m_state; }
+ int GetZoneId(void) { return m_mv_zone_id; }
+ void SetZoneId(int zone_id);
+
+ void ChangeState(rms_resource_internal_state_e next_state);
+
+private:
+ void m_SetSubScalerFlag(int next_state);
+ bool IsRegisteredConsumer(int consumer_id);
+ int IncreaseRefCount(int consumer_id);
+ int DecreaseRefCount(int consumer_id);
+ void NotifyObservers(resource_update_type_e type, int consumer_id);
+ bool ChangeStateByAllocation(IN rms_requests_resource_state_e state, const int consumer_id, int mv_zone_id);
+ bool ChangeStateByRelease(int consumer_id);
+ bool IsScaler(rms_rsc_category_e category);
+
+ int ReserveExclusive(int consumer_id);
+ int ReserveShared(int consumer_id);
+
+ std::map<int, int> m_consumers; // consumer id, cnt
+ 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;
+
+ std::string m_audio_codec;
+ std::vector<CResourceObserver*> m_observers;
+ std::set<unsigned int> m_mem_clusters;
+ rms_mixing_mode_e m_mixing_mode;
+};
+
+#endif // __RSC_MGR_SERVER_RESOURCE_H__
-/*\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
-#ifndef __RSC_MGR_SERVER_CATEGORY_H__\r
-#define __RSC_MGR_SERVER_CATEGORY_H__\r
-\r
-#include <rms_type.h>\r
-#include <CResource.h>\r
-#include <map>\r
-#include <vector>\r
-\r
-#include <CRequest.h>\r
-\r
-class CConsumer;\r
-class CVirtualResource;\r
-class CRequest;\r
-class CAllocateStrategy;\r
-class CResourceCategory\r
-{\r
-public:\r
- CResourceCategory(rms_rsc_category_e resource_category_id, int category_class);\r
- virtual ~CResourceCategory() {}\r
-\r
- rms_rsc_category_e GetCategoryID(void) { return m_categoryID; }\r
- void AddVirtualResource(IN int device_id, IN CVirtualResource *vresource);\r
-\r
- CResource *ReserveCandidate(CRequest *req, bool apply_promotion);\r
- void GetRetirableConsumers(CRequest *req, std::multimap<int, int>* return_ids_in_category, rms_error_type_e *err_type);\r
- bool hasFreeStateResource(void);\r
- bool IsAvailableToUse(rms_requests_resource_state_e request_state);\r
- void GetResources(std::map<int, CResource*> *resource_map);\r
- CResource *FindMainResource(void);\r
-private:\r
- std::map<int, CVirtualResource *> m_device_id_to_vresource_map;\r
-\r
- rms_rsc_category_e m_categoryID;\r
- CAllocateStrategy *m_alloc_strategy;\r
-\r
- void MakeResourceMapSortedByAllocTime(std::multimap<unsigned long, CVirtualResource *> *time_resource_map);\r
-};\r
-\r
-#endif // __RSC_MGR_SERVER_CATEGORY_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RSC_MGR_SERVER_CATEGORY_H__
+#define __RSC_MGR_SERVER_CATEGORY_H__
+
+#include <rms_type.h>
+#include <CResource.h>
+#include <map>
+#include <vector>
+
+#include <CRequest.h>
+
+class CConsumer;
+class CVirtualResource;
+class CRequest;
+class CAllocateStrategy;
+class CResourceCategory
+{
+public:
+ CResourceCategory(rms_rsc_category_e resource_category_id, int category_class);
+ virtual ~CResourceCategory() {}
+
+ rms_rsc_category_e GetCategoryID(void) { return m_categoryID; }
+ void AddVirtualResource(IN int device_id, IN CVirtualResource *vresource);
+
+ CResource *ReserveCandidate(CRequest *req, bool apply_promotion);
+ void GetRetirableConsumers(CRequest *req, std::multimap<int, int>* return_ids_in_category, rms_error_type_e *err_type);
+ bool hasFreeStateResource(void);
+ bool IsAvailableToUse(rms_requests_resource_state_e request_state);
+ void GetResources(std::map<int, CResource*> *resource_map);
+ CResource *FindMainResource(void);
+private:
+ std::map<int, CVirtualResource *> m_device_id_to_vresource_map;
+
+ rms_rsc_category_e m_categoryID;
+ CAllocateStrategy *m_alloc_strategy;
+
+ void MakeResourceMapSortedByAllocTime(std::multimap<unsigned long, CVirtualResource *> *time_resource_map);
+};
+
+#endif // __RSC_MGR_SERVER_CATEGORY_H__
-/*\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
-#ifndef __RSC_MGR_SERVER_DB_H__\r
-#define __RSC_MGR_SERVER_DB_H__\r
-\r
-#include <map>\r
-#include <string>\r
-#include <glib.h>\r
-#include <rms_type.h>\r
-#include <CResourceObserver.h>\r
-#include <CResourceCategory.h>\r
-\r
-class CResourceCategory;\r
-class CVirtualResource;\r
-class CResource;\r
-class CResourceDB : public CResourceObserver\r
-{\r
-public:\r
- CResourceDB(void) = default;\r
- virtual ~CResourceDB(void) {}\r
- static CResourceDB *getInstance(void);\r
-\r
- void AddVirtualResource(IN CVirtualResource *vrsc, IN rms_rsc_category_e resource_category_id, IN const char *name,\r
- IN const char *path, IN std::set<unsigned int> mem_cluster_info,\r
- IN unsigned int device_id_unique, IN int is_main_device, IN const char *audio_codec,\r
- IN int sharable_count, IN int mixing_count, IN CResourceObserver *observer);\r
-\r
- void AddResourceCategory(IN rms_rsc_category_e category_id, IN CResourceCategory *resource_category);\r
-\r
- CResourceCategory *FindResourceCategory(IN rms_rsc_category_e category_id);\r
- CResource *FindResource(IN const int device_id);\r
- CVirtualResource *FindVirtualResource(const int vid);\r
- int FindRealDeviceId(int virtual_id);\r
- void FindMainResources(IN std::map<int, CResource*> *resource_map);\r
- void FindActiveVideoDecoders(IN std::map<int, CResource*> *resource_map);\r
-\r
- void SetMaxVideoDecoders(int n_decs) { m_max_vdecs = n_decs; }\r
- std::map<int, int> GetActiveVideoDecoders(void) { return m_active_vdecs; }\r
- std::map<int, int> GetActiveNVideoDecoders(void) { return m_active_nvdecs; }\r
- int GetActiveDecoderNum(void);\r
- bool HasAvailableDecoder(void);\r
- bool HasAvailableDecoderNDecoding(void);\r
- bool HasAvailableDecoder(std::multimap<int, int> retirables);\r
- bool HasAvailableDecoderNDecoding(std::multimap<int, int> retirables);\r
- void AddReclaimResources(consumer_reclaim_s *consumers);\r
- void ClearReclaimResources(void);\r
- void Update(resource_update_type_e type, const int device_id, const int consumer_id);\r
-\r
- void InitScalerTable(void);\r
- int SwapScaler(int id_a, int id_b);\r
- void GetScalerList(std::map<int, CResource*> *scalers);\r
- int ToScalerId(int device_id);\r
- void UpdateVirtualScalerIds(void);\r
- void ResetZoneIds(void);\r
-\r
- static gboolean NotifyResourceStateUpdated(gpointer data);\r
-private:\r
- CResource *FindResource(const char *device_name);\r
- CResource *FindMainResource(rms_rsc_category_e category_id);\r
-\r
- void AddDeviceID(IN int device_id, IN CResource *resource);\r
- void AddDeviceName(IN const char *device_name, IN CResource *resource);\r
- void AddVirtualDeviceID(IN CVirtualResource *vresource);\r
-\r
- void UpdateBWbyRelease(CResource *resource);\r
- void UpdateBWbyAllocation(const unsigned int bandwidth, CResource *resource);\r
- void UpdateByRelease(CResource *resource, const int device_id, const int consumer_id);\r
- void UpdateByAllocation(CResource *resource, const int device_id, const int consumer_id);\r
- void SetVirtualScalerId(CResource *resource);\r
- int GetVirtualScalerId(CResource *resource);\r
- int GetDedicatedVirtualScalerId(int device_id);\r
- void PrintVirtualScalerMap(void);\r
-\r
- void AddActiveVideoDecoder(const int device_id, const int consumer_id, const int category_class);\r
- void RemoveActiveVideoDecoder(const int device_id, const int category_class);\r
- void AddActiveJpegDecoder(const int device_id, const int consumer_id);\r
- void RemoveActiveJpegDecoder(const int device_id);\r
- void PrintVideoDecoderConsumers(void);\r
-\r
- void NotifyResourceStateUpdatedAsync(CResource *resource, int consumer_id);\r
-\r
- CResource *FindScaler(int id);\r
- void InsertVirtualScaler(int virtual_id, CResource *resource);\r
- void SwapResource(std::set<int> consumers, int cur_device_id, int new_device_id);\r
- void UpdateConsumerInfoOfResource(CResource *resource, std::set<int> new_consumers, int new_virtual_id);\r
-\r
- int CountNDecoders(std::map<int, int> retirables);\r
- void InsertResourceHasZoneId(CResource *resource);\r
- void RemoveResourceHasZoneId(int device_id);\r
- std::map<rms_rsc_category_e, CResourceCategory*> m_resourceCategoryMap; //category info\r
- std::map<int, CVirtualResource *> m_v_deviceid_to_rsc;\r
- std::map<int, CResource*> m_deviceid_to_rsc;\r
- std::map<std::string, CResource*> m_devicename_to_rsc;\r
- std::map<int, CResource*> m_scaler_map;\r
- std::map<int, CResource*> m_rscs_has_zone_id;\r
-\r
- static CResourceDB *m_instance;\r
- unsigned int m_device_id; //for virtual resource\r
- int m_max_vdecs;\r
-\r
- std::set<int> m_reclaim_rscs; // resources reclaiming\r
- std::map<int, int> m_active_vdecs; // device id, consumer id\r
- std::map<int, int> m_active_jdecs; // device id, consumer id\r
- std::map<int, int> m_active_nvdecs; // device id, consumer id\r
-};\r
-\r
-#endif // __RSC_MGR_SERVER_DB_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RSC_MGR_SERVER_DB_H__
+#define __RSC_MGR_SERVER_DB_H__
+
+#include <map>
+#include <string>
+#include <glib.h>
+#include <rms_type.h>
+#include <CResourceObserver.h>
+#include <CResourceCategory.h>
+
+class CResourceCategory;
+class CVirtualResource;
+class CResource;
+class CResourceDB : public CResourceObserver
+{
+public:
+ CResourceDB(void) = default;
+ virtual ~CResourceDB(void) {}
+ static CResourceDB *getInstance(void);
+
+ void AddVirtualResource(IN CVirtualResource *vrsc, IN rms_rsc_category_e resource_category_id, IN const char *name,
+ IN const char *path, IN std::set<unsigned int> mem_cluster_info,
+ IN unsigned int device_id_unique, IN int is_main_device, IN const char *audio_codec,
+ IN int sharable_count, IN int mixing_count, IN CResourceObserver *observer);
+
+ void AddResourceCategory(IN rms_rsc_category_e category_id, IN CResourceCategory *resource_category);
+
+ CResourceCategory *FindResourceCategory(IN rms_rsc_category_e category_id);
+ CResource *FindResource(IN const int device_id);
+ CVirtualResource *FindVirtualResource(const int vid);
+ int FindRealDeviceId(int virtual_id);
+ void FindMainResources(IN std::map<int, CResource*> *resource_map);
+ void FindActiveVideoDecoders(IN std::map<int, CResource*> *resource_map);
+
+ void SetMaxVideoDecoders(int n_decs) { m_max_vdecs = n_decs; }
+ std::map<int, int> GetActiveVideoDecoders(void) { return m_active_vdecs; }
+ std::map<int, int> GetActiveNVideoDecoders(void) { return m_active_nvdecs; }
+ int GetActiveDecoderNum(void);
+ bool HasAvailableDecoder(void);
+ bool HasAvailableDecoderNDecoding(void);
+ bool HasAvailableDecoder(std::multimap<int, int> retirables);
+ bool HasAvailableDecoderNDecoding(std::multimap<int, int> retirables);
+ void AddReclaimResources(consumer_reclaim_s *consumers);
+ void ClearReclaimResources(void);
+ void Update(resource_update_type_e type, const int device_id, const int consumer_id);
+
+ void InitScalerTable(void);
+ int SwapScaler(int id_a, int id_b);
+ void GetScalerList(std::map<int, CResource*> *scalers);
+ int ToScalerId(int device_id);
+ void UpdateVirtualScalerIds(void);
+ void ResetZoneIds(void);
+
+ static gboolean NotifyResourceStateUpdated(gpointer data);
+private:
+ CResource *FindResource(const char *device_name);
+ CResource *FindMainResource(rms_rsc_category_e category_id);
+
+ void AddDeviceID(IN int device_id, IN CResource *resource);
+ void AddDeviceName(IN const char *device_name, IN CResource *resource);
+ void AddVirtualDeviceID(IN CVirtualResource *vresource);
+
+ void UpdateBWbyRelease(CResource *resource);
+ void UpdateBWbyAllocation(const unsigned int bandwidth, CResource *resource);
+ void UpdateByRelease(CResource *resource, const int device_id, const int consumer_id);
+ void UpdateByAllocation(CResource *resource, const int device_id, const int consumer_id);
+ void SetVirtualScalerId(CResource *resource);
+ int GetVirtualScalerId(CResource *resource);
+ int GetDedicatedVirtualScalerId(int device_id);
+ void PrintVirtualScalerMap(void);
+
+ void AddActiveVideoDecoder(const int device_id, const int consumer_id, const int category_class);
+ void RemoveActiveVideoDecoder(const int device_id, const int category_class);
+ void AddActiveJpegDecoder(const int device_id, const int consumer_id);
+ void RemoveActiveJpegDecoder(const int device_id);
+ void PrintVideoDecoderConsumers(void);
+
+ void NotifyResourceStateUpdatedAsync(CResource *resource, int consumer_id);
+
+ CResource *FindScaler(int id);
+ void InsertVirtualScaler(int virtual_id, CResource *resource);
+ void SwapResource(std::set<int> consumers, int cur_device_id, int new_device_id);
+ void UpdateConsumerInfoOfResource(CResource *resource, std::set<int> new_consumers, int new_virtual_id);
+
+ int CountNDecoders(std::map<int, int> retirables);
+ void InsertResourceHasZoneId(CResource *resource);
+ void RemoveResourceHasZoneId(int device_id);
+ std::map<rms_rsc_category_e, CResourceCategory*> m_resourceCategoryMap; //category info
+ std::map<int, CVirtualResource *> m_v_deviceid_to_rsc;
+ std::map<int, CResource*> m_deviceid_to_rsc;
+ std::map<std::string, CResource*> m_devicename_to_rsc;
+ std::map<int, CResource*> m_scaler_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;
+
+ std::set<int> m_reclaim_rscs; // resources reclaiming
+ std::map<int, int> m_active_vdecs; // device id, consumer id
+ std::map<int, int> m_active_jdecs; // device id, consumer id
+ std::map<int, int> m_active_nvdecs; // device id, consumer id
+};
+
+#endif // __RSC_MGR_SERVER_DB_H__
-/*\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
-#ifndef __RSC_MGR_SERVER_MANAGER_H__\r
-#define __RSC_MGR_SERVER_MANAGER_H__\r
-#include <glib.h>\r
-#include <CConsumer.h>\r
-#include <rms_type.h>\r
-#include <map>\r
-#include <CResourceDB.h>\r
-#include <CConsumerContainer.h>\r
-\r
-class CResourceManager\r
-{\r
-public:\r
- CResourceManager();\r
- ~CResourceManager() = default;\r
-\r
- int AllocateResources(rms_msg_request *req, rms_return_device_s *allocated_devices);\r
- int ReleaseResourcesOfPid(IN const int pid);\r
- int ReleaseResources(IN int consumer_id, IN const rms_requests_device_s *req);\r
- int RegisterResources(void);\r
-\r
- int SetAppId(IN int consumer_id, IN const char *app_id);\r
- int RegisterConsumer(int consumer_id, int process_id, const char *app_id, int main_priority, int sub_priority);\r
- int UnregisterConsumer(IN int consumer_id);\r
- int FindReclaimableConsumers(rms_msg_request *req, consumer_reclaim_s *return_consumer, int *zone_id);\r
- int GetActiveDecoderNum(void);\r
- int GetActiveAudioOut(int consumer_id);\r
-\r
- int IsCategoryAvailableToUse(rms_msg_request *request, int *is_available);\r
- bool IsReclaimed(IN const int device_id, IN const int consumer_id);\r
-\r
- int GetResourceState(int device_id);\r
- int FindDeviceId(int virtual_id);\r
- int GetResourceList(int category_id, GVariantBuilder *builder);\r
- int GetScalerState(GVariantBuilder *builder);\r
- int GetResourceCollectionState(int collection, GVariantBuilder *builder);\r
- int SwapResources(int device_id_a, int device_id_b);\r
- int RestoreResources(int category_id);\r
- int GetScalerHWId(int zone_id);\r
- int GetZoneId(int device_id);\r
- void ResetZoneIds(void);\r
- void UpdateZoneIds(std::string app_id, int zone_id);\r
-\r
-private:\r
- void MakeRequests(CRequester *requester, rms_msg_request *reqs, std::vector<CRequest*> *requests);\r
- void AllocateCandidates(std::vector<CRequest *> requests);\r
- void ReleaseResources(const int consumer_id);\r
- int GetScalerState(int category_id, GVariantBuilder *builder);\r
-\r
- void MakeResourceMapPerConsumer(std::multimap<int, int> *device_id_to_consumer_id_map, std::map<int, std::set<int> > *consumer_id_to_resource_set_map);\r
- void MakeConsumerInfoToBeReturned(consumer_reclaim_s *return_consumer, std::map<int, std::set<int> > *consumer_id_to_resource_set_map);\r
- void PrintConsumerInfoToBeReturned(consumer_reclaim_s *consumer_info);\r
-\r
- CResourceDB *m_db;\r
-\r
- int m_is_db_created;\r
- rms_error_type_e m_error_type;\r
- CConsumerContainer *m_consumers;\r
-\r
-};\r
-\r
-#endif // __RSC_MGR_SERVER_MANAGER_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RSC_MGR_SERVER_MANAGER_H__
+#define __RSC_MGR_SERVER_MANAGER_H__
+#include <glib.h>
+#include <CConsumer.h>
+#include <rms_type.h>
+#include <map>
+#include <CResourceDB.h>
+#include <CConsumerContainer.h>
+
+class CResourceManager
+{
+public:
+ CResourceManager();
+ ~CResourceManager() = default;
+
+ int AllocateResources(rms_msg_request *req, rms_return_device_s *allocated_devices);
+ int ReleaseResourcesOfPid(IN const int pid);
+ int ReleaseResources(IN int consumer_id, IN const rms_requests_device_s *req);
+ int RegisterResources(void);
+
+ int SetAppId(IN int consumer_id, IN const char *app_id);
+ int RegisterConsumer(int consumer_id, int process_id, const char *app_id, int main_priority, int sub_priority);
+ int UnregisterConsumer(IN int consumer_id);
+ int FindReclaimableConsumers(rms_msg_request *req, consumer_reclaim_s *return_consumer, int *zone_id);
+ int GetActiveDecoderNum(void);
+ int GetActiveAudioOut(int consumer_id);
+
+ int IsCategoryAvailableToUse(rms_msg_request *request, int *is_available);
+ bool IsReclaimed(IN const int device_id, IN const int consumer_id);
+
+ int GetResourceState(int device_id);
+ int FindDeviceId(int virtual_id);
+ int GetResourceList(int category_id, GVariantBuilder *builder);
+ int GetScalerState(GVariantBuilder *builder);
+ int GetResourceCollectionState(int collection, GVariantBuilder *builder);
+ int SwapResources(int device_id_a, int device_id_b);
+ int RestoreResources(int category_id);
+ int GetScalerHWId(int zone_id);
+ int GetZoneId(int device_id);
+ void ResetZoneIds(void);
+ void UpdateZoneIds(std::string app_id, int zone_id);
+
+private:
+ void MakeRequests(CRequester *requester, rms_msg_request *reqs, std::vector<CRequest*> *requests);
+ void AllocateCandidates(std::vector<CRequest *> requests);
+ void ReleaseResources(const int consumer_id);
+ int GetScalerState(int category_id, GVariantBuilder *builder);
+
+ void MakeResourceMapPerConsumer(std::multimap<int, int> *device_id_to_consumer_id_map, std::map<int, std::set<int> > *consumer_id_to_resource_set_map);
+ 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;
+
+ int m_is_db_created;
+ rms_error_type_e m_error_type;
+ CConsumerContainer *m_consumers;
+
+};
+
+#endif // __RSC_MGR_SERVER_MANAGER_H__
-/*\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
-#ifndef __CRESOURCE_OBSERVER_H__\r
-#define __CRESOURCE_OBSERVER_H__\r
-\r
-typedef enum _resource_update_type_e {\r
- UPDATED_BY_ALLOC = 0,\r
- UPDATED_BY_RELEASE\r
-} resource_update_type_e;\r
-\r
-class CResourceObserver\r
-{\r
-public:\r
- virtual ~CResourceObserver() {}\r
- virtual void Update(resource_update_type_e type, const int device_id, const int consumer_id) = 0;\r
-};\r
-\r
-#endif // __CRESOURCE_OBSERVER_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CRESOURCE_OBSERVER_H__
+#define __CRESOURCE_OBSERVER_H__
+
+typedef enum _resource_update_type_e {
+ UPDATED_BY_ALLOC = 0,
+ UPDATED_BY_RELEASE
+} resource_update_type_e;
+
+class CResourceObserver
+{
+public:
+ virtual ~CResourceObserver() {}
+ virtual void Update(resource_update_type_e type, const int device_id, const int consumer_id) = 0;
+};
+
+#endif // __CRESOURCE_OBSERVER_H__
-/*\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
-#ifndef __CRESOURCE_STATE_H__\r
-#include <iostream>\r
-\r
-class CResourceState\r
-{\r
-public:\r
- CResourceState(int device_id, int category_type, int consumer_id, int state, std::string app_id);\r
- ~CResourceState() = default;\r
-\r
- int GetDeviceId(void) { return m_device_id; }\r
- int GetConsumerId(void) { return m_consumer_id; }\r
- int GetState(void) { return m_state; }\r
- int GetCategoryType(void) { return m_category_type; }\r
- std::string GetAppId(void) { return m_app_id; }\r
-\r
-private:\r
- int m_device_id;\r
- int m_consumer_id;\r
- int m_state;\r
- int m_category_type;\r
- std::string m_app_id;\r
-};\r
-\r
-#endif //__CRESOURCE_STATE_H__
\ No newline at end of file
+/*
+* Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __CRESOURCE_STATE_H__
+#include <iostream>
+
+class CResourceState
+{
+public:
+ CResourceState(int device_id, int category_type, int consumer_id, int state, std::string app_id);
+ ~CResourceState() = default;
+
+ int GetDeviceId(void) { return m_device_id; }
+ int GetConsumerId(void) { return m_consumer_id; }
+ int GetState(void) { return m_state; }
+ int GetCategoryType(void) { return m_category_type; }
+ std::string GetAppId(void) { return m_app_id; }
+
+private:
+ int m_device_id;
+ int m_consumer_id;
+ int m_state;
+ int m_category_type;
+ std::string m_app_id;
+};
+
+#endif //__CRESOURCE_STATE_H__
-/*\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
-#ifndef __CRESOURCE_SUBJECT_H__\r
-#define __CRESOURCE_SUBJECT_H__\r
-\r
-#include <CResourceObserver.h>\r
-\r
-class CResourceObserver;\r
-class CResourceSubject\r
-{\r
-public:\r
- virtual ~CResourceSubject() {}\r
-\r
- virtual void RegisterObserver(CResourceObserver *observer) = 0;\r
- virtual void UnregisterObserver(CResourceObserver *observer) = 0;\r
- virtual void NotifyObservers(resource_update_type_e type, const int consumer_id) = 0;\r
-};\r
-\r
-#endif // __CRESOURCE_SUBJECT_H__\r
-\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CRESOURCE_SUBJECT_H__
+#define __CRESOURCE_SUBJECT_H__
+
+#include <CResourceObserver.h>
+
+class CResourceObserver;
+class CResourceSubject
+{
+public:
+ virtual ~CResourceSubject() {}
+
+ virtual void RegisterObserver(CResourceObserver *observer) = 0;
+ virtual void UnregisterObserver(CResourceObserver *observer) = 0;
+ virtual void NotifyObservers(resource_update_type_e type, const int consumer_id) = 0;
+};
+
+#endif // __CRESOURCE_SUBJECT_H__
+
-/*\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
-#ifndef __C_VIDEO_CONTROLLER_H__\r
-#define __C_VIDEO_CONTROLLER_H__\r
-\r
-#include <map>\r
-#include <glib.h>\r
-#include <wayland-client.h>\r
-#include <CLockController.h>\r
-\r
-class CVideoController\r
-{\r
-public:\r
- ~CVideoController(void);\r
- static CVideoController *GetInstance(void);\r
- void UpdateVirtualScalerIds(std::map<int, int> scaler_id_map);\r
-\r
-private:\r
- typedef struct _scaler_id_pair {\r
- unsigned int virtual_scaler_id;\r
- unsigned int scaler_id;\r
- } scaler_id_pair_t;\r
-\r
- CVideoController(void);\r
- void WaylandDisplayCreate(void);\r
- void WaylandDisplayDestroy(void);\r
- void RunWaitingThread(void);\r
- static gpointer WaitingThread(gpointer data);\r
-\r
- static CVideoController *m_instance;\r
- struct wl_display *m_wl_display;\r
- struct wl_registry *m_wl_registry;\r
- struct tizen_video_rsc *m_tizen_video_rsc;\r
- struct wl_registry_listener m_registry_listener;\r
-\r
- GThread *m_waiting_thread;\r
- CLockController *m_lock_ctr;\r
-};\r
-\r
-#endif //__C_VIDEO_CONTROLLER_H__\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __C_VIDEO_CONTROLLER_H__
+#define __C_VIDEO_CONTROLLER_H__
+
+#include <map>
+#include <glib.h>
+#include <wayland-client.h>
+#include <CLockController.h>
+
+class CVideoController
+{
+public:
+ ~CVideoController(void);
+ static CVideoController *GetInstance(void);
+ void UpdateVirtualScalerIds(std::map<int, int> scaler_id_map);
+
+private:
+ typedef struct _scaler_id_pair {
+ unsigned int virtual_scaler_id;
+ unsigned int scaler_id;
+ } scaler_id_pair_t;
+
+ CVideoController(void);
+ void WaylandDisplayCreate(void);
+ void WaylandDisplayDestroy(void);
+ void RunWaitingThread(void);
+ static gpointer WaitingThread(gpointer data);
+
+ static CVideoController *m_instance;
+ struct wl_display *m_wl_display;
+ struct wl_registry *m_wl_registry;
+ struct tizen_video_rsc *m_tizen_video_rsc;
+ struct wl_registry_listener m_registry_listener;
+
+ GThread *m_waiting_thread;
+ CLockController *m_lock_ctr;
+};
+
+#endif //__C_VIDEO_CONTROLLER_H__
-/*\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
-#ifndef _RM_VIRTUAL_RESOURCE_H_INCLUDED\r
-#define _RM_VIRTUAL_RESOURCE_H_INCLUDED\r
-\r
-#include <rms_type.h>\r
-#include <map>\r
-#include <set>\r
-#include <string>\r
-\r
-class CResource;\r
-class CVirtualResource\r
-{\r
-public:\r
- 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
- virtual ~CVirtualResource(void) {}\r
-\r
- CResource *GetResource(void) { return m_rsc; }\r
- void SetResource(CResource *resource);\r
-\r
- int GetVResourceID(void) { return m_vir_rsc_id; }\r
- rms_rsc_category_e GetCategoryType(void) { return m_category_type; }\r
- int GetCategoryClass(void) { return m_category_class; }\r
- unsigned int GetBW(void) { return m_vir_rsc_bw; }\r
- std::set<unsigned int> GetMemClusters(void) { return m_mem_clusters; }\r
- std::string GetAudioCodec(void) { return m_audio_codec; }\r
-\r
- bool IsMainDevice(void) { return m_is_main_device; }\r
- bool IsAIDevice(void) { return m_is_ai_device; }\r
-private:\r
- int m_vir_rsc_id;\r
- rms_rsc_category_e m_category_type;\r
- unsigned int m_vir_rsc_bw;\r
- bool m_is_main_device;\r
- bool m_is_ai_device;\r
- int m_category_class;\r
- std::set<unsigned int> m_mem_clusters;\r
- std::string m_audio_codec;\r
-\r
- CResource *m_rsc;\r
-};\r
-\r
-#endif // _RM_VIRTUAL_RESOURCE_H_INCLUDED\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _RM_VIRTUAL_RESOURCE_H_INCLUDED
+#define _RM_VIRTUAL_RESOURCE_H_INCLUDED
+
+#include <rms_type.h>
+#include <map>
+#include <set>
+#include <string>
+
+class CResource;
+class CVirtualResource
+{
+public:
+ 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);
+ virtual ~CVirtualResource(void) {}
+
+ CResource *GetResource(void) { return m_rsc; }
+ void SetResource(CResource *resource);
+
+ int GetVResourceID(void) { return m_vir_rsc_id; }
+ rms_rsc_category_e GetCategoryType(void) { return m_category_type; }
+ int GetCategoryClass(void) { return m_category_class; }
+ unsigned int GetBW(void) { return m_vir_rsc_bw; }
+ std::set<unsigned int> GetMemClusters(void) { return m_mem_clusters; }
+ std::string GetAudioCodec(void) { return m_audio_codec; }
+
+ 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;
+ std::set<unsigned int> m_mem_clusters;
+ std::string m_audio_codec;
+
+ CResource *m_rsc;
+};
+
+#endif // _RM_VIRTUAL_RESOURCE_H_INCLUDED
-/*\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
-#ifndef __RMS_DEBUG_H__\r
-#define __RMS_DEBUG_H__\r
-\r
-#include <dlog.h>\r
-\r
-\r
-#ifdef LOG_TAG\r
-#undef LOG_TAG\r
-#endif//LOG_TAG\r
-\r
-#define LOG_TAG "RSC_MGR_SERVER"\r
-\r
-#ifndef SERVER_ERR\r
-#define SERVER_ERR(fmt, args...)SLOGE(fmt, ##args)\r
-#endif\r
-\r
-#ifndef SERVER_DBG\r
-#define SERVER_DBG(fmt, args...)SLOGD(fmt, ##args)\r
-#endif\r
-\r
-#ifndef SERVER_INFO\r
-#define SERVER_INFO(fmt, args...)SLOGI(fmt, ##args)\r
-#endif\r
-\r
-#ifndef SERVER_WARN\r
-#define SERVER_WARN(fmt, args...)SLOGW(fmt, ##args)\r
-#endif\r
-\r
-\r
-#endif//__RMS_DEBUG_H__\r
-\r
+/*
+* Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __RMS_DEBUG_H__
+#define __RMS_DEBUG_H__
+
+#include <dlog.h>
+
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif//LOG_TAG
+
+#define LOG_TAG "RSC_MGR_SERVER"
+
+#ifndef SERVER_ERR
+#define SERVER_ERR(fmt, args...)SLOGE(fmt, ##args)
+#endif
+
+#ifndef SERVER_DBG
+#define SERVER_DBG(fmt, args...)SLOGD(fmt, ##args)
+#endif
+
+#ifndef SERVER_INFO
+#define SERVER_INFO(fmt, args...)SLOGI(fmt, ##args)
+#endif
+
+#ifndef SERVER_WARN
+#define SERVER_WARN(fmt, args...)SLOGW(fmt, ##args)
+#endif
+
+
+#endif//__RMS_DEBUG_H__
+
-/*\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
-#ifndef __RMS_LOG_H__\r
-#define __RMS_LOG_H__\r
-\r
-#include <stdio.h>\r
-\r
-static char g_rms_dlog_msg[4096] = {0,};\r
-static int g_rms_dlog_msg_pose = 0;\r
-\r
-static void rms_log_reset() { g_rms_dlog_msg_pose = 0; }\r
-static void rms_log_add(const char *format_str, ...) __attribute__ ((format (printf, 1, 2)));\r
-static void rms_log_add(const char *format_str, ...) {\r
- va_list argptr;\r
- va_start(argptr, format_str);\r
- g_rms_dlog_msg_pose += vsnprintf(g_rms_dlog_msg + g_rms_dlog_msg_pose, sizeof(g_rms_dlog_msg) - 1 - g_rms_dlog_msg_pose, format_str, argptr);\r
- va_end(argptr);\r
-}\r
-\r
-#define RMS_LOGE_FLUSH() SLOGE("%s", g_rms_dlog_msg); g_rms_dlog_msg_pose = 0\r
-#define RMS_LOGI_FLUSH() SLOGI("%s", g_rms_dlog_msg); g_rms_dlog_msg_pose = 0\r
-#define RMS_LOGD_FLUSH() SLOGD("%s", g_rms_dlog_msg); g_rms_dlog_msg_pose = 0\r
-\r
-#endif //__RMS_LOG_H__\r
-\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RMS_LOG_H__
+#define __RMS_LOG_H__
+
+#include <stdio.h>
+
+static char g_rms_dlog_msg[4096] = {0,};
+static int g_rms_dlog_msg_pose = 0;
+
+static void rms_log_reset() { g_rms_dlog_msg_pose = 0; }
+static void rms_log_add(const char *format_str, ...) __attribute__ ((format (printf, 1, 2)));
+static void rms_log_add(const char *format_str, ...) {
+ va_list argptr;
+ va_start(argptr, format_str);
+ g_rms_dlog_msg_pose += vsnprintf(g_rms_dlog_msg + g_rms_dlog_msg_pose, sizeof(g_rms_dlog_msg) - 1 - g_rms_dlog_msg_pose, format_str, argptr);
+ va_end(argptr);
+}
+
+#define RMS_LOGE_FLUSH() SLOGE("%s", g_rms_dlog_msg); g_rms_dlog_msg_pose = 0
+#define RMS_LOGI_FLUSH() SLOGI("%s", g_rms_dlog_msg); g_rms_dlog_msg_pose = 0
+#define RMS_LOGD_FLUSH() SLOGD("%s", g_rms_dlog_msg); g_rms_dlog_msg_pose = 0
+
+#endif //__RMS_LOG_H__
+
Name: rscmgr-service
Summary: Daemon for resource manager
Version: 0.1
-Release: 1
+Release: 2
Group: Multimedia/Libraries
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
-/*\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 <rms_debug.h>\r
-#include <CAsyncQueue.h>\r
-\r
-CAsyncQueue::CAsyncQueue(void)\r
-{\r
- queue = g_async_queue_new();\r
-}\r
-\r
-CAsyncQueue::CAsyncQueue(destoryNotify destory_cb)\r
-{\r
- queue = g_async_queue_new_full(destory_cb);\r
-}\r
-\r
-CAsyncQueue::~CAsyncQueue(void)\r
-{\r
- g_async_queue_unref(queue);\r
-}\r
-\r
-void CAsyncQueue::push(void *data)\r
-{\r
- g_async_queue_push(queue, data);\r
-}\r
-\r
-void CAsyncQueue::push(CAsyncQueue *src_queue)\r
-{\r
- if (src_queue->length() <= 0)\r
- return;\r
-\r
- SERVER_INFO("push given queue (%d)", src_queue->length());\r
-\r
- g_async_queue_lock(queue);\r
-\r
- while (src_queue->length() > 0) {\r
- g_async_queue_push_unlocked(queue, src_queue->pop());\r
- }\r
-\r
- g_async_queue_unlock(queue);\r
-}\r
-\r
-void CAsyncQueue::push_front(void *data)\r
-{\r
- g_async_queue_push_front(queue, data);\r
-}\r
-\r
-void CAsyncQueue::push_front(CAsyncQueue *src_queue)\r
-{\r
- if (src_queue->length() <= 0)\r
- return;\r
-\r
- SERVER_INFO("push_front given queue (%d)", src_queue->length());\r
-\r
- g_async_queue_lock(queue);\r
-\r
- while (src_queue->length() > 0) {\r
- g_async_queue_push_front_unlocked(queue, src_queue->pop());\r
- }\r
-\r
- g_async_queue_unlock(queue);\r
-}\r
-\r
-void *CAsyncQueue::pop(void)\r
-{\r
- return g_async_queue_pop(queue);\r
-}\r
-\r
-void *CAsyncQueue::pop(unsigned int timeout_ms)\r
-{\r
- guint64 timeout_us = (guint64)((guint64) timeout_ms * 1000);\r
-\r
- return g_async_queue_timeout_pop(queue, timeout_us);\r
-}\r
-\r
-int CAsyncQueue::length(void)\r
-{\r
- return g_async_queue_length(queue);\r
-}\r
-\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <rms_debug.h>
+#include <CAsyncQueue.h>
+
+CAsyncQueue::CAsyncQueue(void)
+{
+ queue = g_async_queue_new();
+}
+
+CAsyncQueue::CAsyncQueue(destoryNotify destory_cb)
+{
+ queue = g_async_queue_new_full(destory_cb);
+}
+
+CAsyncQueue::~CAsyncQueue(void)
+{
+ g_async_queue_unref(queue);
+}
+
+void CAsyncQueue::push(void *data)
+{
+ g_async_queue_push(queue, data);
+}
+
+void CAsyncQueue::push(CAsyncQueue *src_queue)
+{
+ if (src_queue->length() <= 0)
+ return;
+
+ SERVER_INFO("push given queue (%d)", src_queue->length());
+
+ g_async_queue_lock(queue);
+
+ while (src_queue->length() > 0) {
+ g_async_queue_push_unlocked(queue, src_queue->pop());
+ }
+
+ g_async_queue_unlock(queue);
+}
+
+void CAsyncQueue::push_front(void *data)
+{
+ g_async_queue_push_front(queue, data);
+}
+
+void CAsyncQueue::push_front(CAsyncQueue *src_queue)
+{
+ if (src_queue->length() <= 0)
+ return;
+
+ SERVER_INFO("push_front given queue (%d)", src_queue->length());
+
+ g_async_queue_lock(queue);
+
+ while (src_queue->length() > 0) {
+ g_async_queue_push_front_unlocked(queue, src_queue->pop());
+ }
+
+ g_async_queue_unlock(queue);
+}
+
+void *CAsyncQueue::pop(void)
+{
+ return g_async_queue_pop(queue);
+}
+
+void *CAsyncQueue::pop(unsigned int timeout_ms)
+{
+ guint64 timeout_us = (guint64)((guint64) timeout_ms * 1000);
+
+ return g_async_queue_timeout_pop(queue, timeout_us);
+}
+
+int CAsyncQueue::length(void)
+{
+ return g_async_queue_length(queue);
+}
+
-/*\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 <CCallback.h>\r
-\r
-#include <rms_debug.h>\r
-#include <rms_type.h>\r
-#include <CDebugUtils.h>\r
-\r
-#include <errno.h>\r
-#include <sys/stat.h>\r
-#include <stdio.h>\r
-#include <fcntl.h>\r
-#include <poll.h>\r
-#include <unistd.h>\r
-#include <system_info.h>\r
-\r
-#define CB_TIMEOUT_3_SEC_IN_MS 3000\r
-#define CB_TIMEOUT_10_SEC_IN_MS 10000\r
-\r
-#define RMS_IS_DEBUG_IMAGE (access("/etc/debug", F_OK) == 0)\r
-\r
-unsigned int CCallback::GetTimeout(void)\r
-{\r
- return (RMS_IS_DEBUG_IMAGE) ? CB_TIMEOUT_10_SEC_IN_MS : CB_TIMEOUT_3_SEC_IN_MS;\r
-}\r
-\r
-void CCallback::InitCallback(void)\r
-{\r
- const char *cb_path = "/run/rsc_mgr";\r
- mode_t dir_mode = 0666 | 0111;\r
-\r
- if (mkdir(cb_path, dir_mode) !=0) {\r
- SERVER_ERR("failed to create cb directory (%d)", errno);\r
- return;\r
- }\r
-\r
- chmod(cb_path, dir_mode);\r
-}\r
-\r
-int CCallback::SendCallbackMessage(int cid, int pid, void *callback_data, int size, int *err)\r
-{\r
- int fd = -1;\r
- int ret = 0;\r
-\r
- char callback_path[256] = {0,};\r
-\r
- snprintf(callback_path, 256, "/run/rsc_mgr/%d.%d.s2c.cb", pid, cid);\r
-\r
- if ((fd = open(callback_path, O_WRONLY|O_NONBLOCK)) < 0) {\r
- SERVER_ERR("open error (%s), errno(%d)\n", callback_path, errno);\r
- *err = errno;\r
- return RMS_ERROR;\r
- }\r
-\r
- if (is_symlink_file(callback_path)) {\r
- SERVER_ERR("%s is symbolic link file", callback_path);\r
- *err = EPERM;\r
- close(fd);\r
- return RMS_ERROR;\r
- }\r
-\r
- ret = write(fd, callback_data, size);\r
-\r
- if (ret <= 0) {\r
- SERVER_ERR("failed to write callback.(%s) ret(%d), errno(%d)\n", callback_path, ret, errno);\r
- *err = errno;\r
- close(fd);\r
- return RMS_ERROR;\r
- }\r
-\r
- SERVER_DBG("succeeded to write callback.(%s)", callback_path);\r
-\r
- close(fd);\r
-\r
- return RMS_OK;\r
-}\r
-\r
-int CCallback::RemoveFIFOServerToClient(int pid, int cid)\r
-{\r
- struct stat stat_info;\r
- char cb_path_s2c[256] = {0, };\r
-\r
- snprintf(cb_path_s2c, 256, "/run/rsc_mgr/%d.%d.s2c.cb", pid, cid);\r
-\r
- if (stat(cb_path_s2c, &stat_info) != 0) {\r
- SERVER_INFO("%s not exists", cb_path_s2c);\r
- return RMS_OK;\r
- }\r
-\r
- if (remove(cb_path_s2c) != 0) {\r
- SERVER_ERR("failed to remove cb for S2C(%s)-(%d)", cb_path_s2c, errno);\r
- return RMS_ERROR;\r
- }\r
-\r
- SERVER_DBG("Removed cb for S2C(%s)", cb_path_s2c);\r
- return RMS_OK;\r
-}\r
-\r
-int CCallback::ConvertCallbackType(int rm_return_type)\r
-{\r
- switch (rm_return_type) {\r
- case RMS_ERROR_TAKE_RESOURCE_FROM_OTHER_CONSUMER:\r
- return RMS_CALLBACK_TYPE_RESOURCE_CONFLICT;\r
- case RMS_OK_UHD_RESOURCE_CONFLICT:\r
- return RMS_CALLBACK_TYPE_RESOURCE_CONFLICT_UD;\r
- default:\r
- break;\r
- }\r
-\r
- SERVER_ERR("return RMS_CALLBACK_TYPE_UNKNOWN(%d)", RMS_CALLBACK_TYPE_UNKNOWN);\r
-\r
- return RMS_CALLBACK_TYPE_UNKNOWN;\r
-}\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <CCallback.h>
+
+#include <rms_debug.h>
+#include <rms_type.h>
+#include <CDebugUtils.h>
+
+#include <errno.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <unistd.h>
+#include <system_info.h>
+
+#define CB_TIMEOUT_3_SEC_IN_MS 3000
+#define CB_TIMEOUT_10_SEC_IN_MS 10000
+
+#define RMS_IS_DEBUG_IMAGE (access("/etc/debug", F_OK) == 0)
+
+unsigned int CCallback::GetTimeout(void)
+{
+ return (RMS_IS_DEBUG_IMAGE) ? CB_TIMEOUT_10_SEC_IN_MS : CB_TIMEOUT_3_SEC_IN_MS;
+}
+
+void CCallback::InitCallback(void)
+{
+ const char *cb_path = "/run/rsc_mgr";
+ mode_t dir_mode = 0666 | 0111;
+
+ if (mkdir(cb_path, dir_mode) !=0) {
+ SERVER_ERR("failed to create cb directory (%d)", errno);
+ return;
+ }
+
+ chmod(cb_path, dir_mode);
+}
+
+int CCallback::SendCallbackMessage(int cid, int pid, void *callback_data, int size, int *err)
+{
+ int fd = -1;
+ int ret = 0;
+
+ char callback_path[256] = {0,};
+
+ 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);
+ *err = errno;
+ return RMS_ERROR;
+ }
+
+ if (is_symlink_file(callback_path)) {
+ SERVER_ERR("%s is symbolic link file", callback_path);
+ *err = EPERM;
+ close(fd);
+ 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);
+ *err = errno;
+ close(fd);
+ return RMS_ERROR;
+ }
+
+ SERVER_DBG("succeeded to write callback.(%s)", callback_path);
+
+ close(fd);
+
+ return RMS_OK;
+}
+
+int CCallback::RemoveFIFOServerToClient(int pid, int cid)
+{
+ struct stat stat_info;
+ char cb_path_s2c[256] = {0, };
+
+ snprintf(cb_path_s2c, 256, "/run/rsc_mgr/%d.%d.s2c.cb", pid, cid);
+
+ if (stat(cb_path_s2c, &stat_info) != 0) {
+ SERVER_INFO("%s not exists", cb_path_s2c);
+ return RMS_OK;
+ }
+
+ if (remove(cb_path_s2c) != 0) {
+ SERVER_ERR("failed to remove cb for S2C(%s)-(%d)", cb_path_s2c, errno);
+ return RMS_ERROR;
+ }
+
+ SERVER_DBG("Removed cb for S2C(%s)", cb_path_s2c);
+ return RMS_OK;
+}
+
+int CCallback::ConvertCallbackType(int rm_return_type)
+{
+ switch (rm_return_type) {
+ case RMS_ERROR_TAKE_RESOURCE_FROM_OTHER_CONSUMER:
+ return RMS_CALLBACK_TYPE_RESOURCE_CONFLICT;
+ case RMS_OK_UHD_RESOURCE_CONFLICT:
+ return RMS_CALLBACK_TYPE_RESOURCE_CONFLICT_UD;
+ default:
+ break;
+ }
+
+ SERVER_ERR("return RMS_CALLBACK_TYPE_UNKNOWN(%d)", RMS_CALLBACK_TYPE_UNKNOWN);
+
+ return RMS_CALLBACK_TYPE_UNKNOWN;
+}
-/*\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 <stdio.h>\r
-#include <assert.h>\r
-#include <iostream>\r
-#include <glib.h>\r
-#include <gio/gio.h>\r
-#include <trace.h>\r
-\r
-#include <rms_type.h>\r
-#include <rms_debug.h>\r
-#include <CMessage.h>\r
-#include <CAsyncQueue.h>\r
-#include <CDbusHandler.h>\r
-\r
-const GDBusInterfaceVTable CDbusHandler::m_vtable = { CDbusHandler::OnMethodCall, NULL, NULL, {0} };\r
-\r
-const std::string CDbusHandler::m_methods =\r
- "<node>"\r
- "<interface name = 'rscmgr.resource'>"\r
- "<method name = 'GetResourceState'>"\r
- "<arg direction='in' type='i' name='device_id'/>"\r
- "<arg direction='out' type='i' name='state'/>"\r
- "</method>"\r
- "<method name = 'GetResourceList'>"\r
- "<arg direction='in' type='i' name='category_id'/>"\r
- "<arg direction='out' type='a(iissi)'/>"\r
- "</method>"\r
- "<method name = 'GetRscCollectionState'>"\r
- "<arg direction='in' type='i' name='collection'/>"\r
- "<arg direction='out' type='a(isiiis)'/>"\r
- "</method>"\r
- "<method name = 'FindDeviceId'>"\r
- "<arg direction='in' type='i' name='virtual_id'/>"\r
- "<arg direction='out' type='i' name='real_id'/>"\r
- "</method>"\r
- "<method name = 'SwapResources'>"\r
- "<arg direction='in' type='i' name='device_id_a'/>"\r
- "<arg direction='in' type='i' name='device_id_b'/>"\r
- "<arg direction='out' type='i' name='result'/>"\r
- "</method>"\r
- "<method name = 'GetScalerState'>"\r
- "<arg direction='in' type='i' name='category_id'/>"\r
- "<arg direction='out' type='a(iiiiis)'/>"\r
- "</method>"\r
- "<method name = 'GetAppId'>"\r
- "<arg direction='in' type='i' name='handle'/>"\r
- "<arg direction='out' type='i' name='result'/>"\r
- "<arg direction='out' type='s' name='app_id'/>"\r
- "</method>"\r
- "<method name = 'GetActiveAudioOut'>"\r
- "<arg direction='in' type='i' name='handle'/>"\r
- "<arg direction='out' type='i' name='audio_out'/>"\r
- "</method>"\r
- "<method name = 'GetScalerHWID'>"\r
- "<arg direction='in' type='i' name='zone_id'/>"\r
- "<arg direction='out' type='i' name='hw_id'/>"\r
- "</method>"\r
- "<method name = 'RestoreResources'>"\r
- "<arg direction='in' type='i' name='category_id'/>"\r
- "<arg direction='out' type='i' name='result'/>"\r
- "</method>"\r
- "<method name = 'NotifyResourcePolicy'>"\r
- "<arg direction='in' type='i' name='policy'/>"\r
- "<arg direction='out' type='i' name='result'/>"\r
- "</method>"\r
- "<method name = 'NotifyAppZoneInfo'>"\r
- "<arg direction='in' type='s' name='appid'/>"\r
- "<arg direction='in' type='i' name='zoneid'/>"\r
- "<arg direction='out' type='i' name='reply'/>"\r
- "</method>"\r
- "</interface>"\r
- "</node>";\r
-\r
-CDbusHandler::CDbusHandler(CAsyncQueue *queue)\r
-{\r
- assert(queue);\r
- m_async_queue = queue;\r
- m_reg_id = 0;\r
-\r
- if (!MakeDbusConnection())\r
- return;\r
-\r
- RegisterObjects();\r
-}\r
-\r
-bool CDbusHandler::MakeDbusConnection(void)\r
-{\r
- m_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);\r
-\r
- if (!m_conn) {\r
- SERVER_ERR("failed to make dbus connection");\r
- return false;\r
- }\r
-\r
- SERVER_INFO("making dbus connection success");\r
- return true;\r
-}\r
-\r
-void CDbusHandler::OnMethodCall(GDBusConnection *conn, const gchar *sender, const gchar *obj_path, const gchar *ifname, const gchar *method_name, GVariant *params, GDBusMethodInvocation *invoc, gpointer data)\r
-{\r
- CDbusHandler *handler = static_cast<CDbusHandler*>(data);\r
- CAsyncQueue *queue = handler->m_async_queue;\r
- CMessage *msg = new CMessage(invoc);\r
-\r
- SERVER_INFO("push msg(%s)", method_name);\r
-\r
- queue->push(msg);\r
-}\r
-\r
-void CDbusHandler::GenerateReadyEvent(void)\r
-{\r
- SERVER_INFO("We will notify clients when the server is ready by generating a ready event");\r
-}\r
-\r
-void CDbusHandler::OnBusAcquired(GDBusConnection *conn, const gchar *bus_name, gpointer data)\r
-{\r
- trace_begin("[RSC_MGR] OnBusAcquired");\r
- trace_end();\r
- SERVER_INFO("bus acquired (%s)", bus_name);\r
-\r
- CDbusHandler *handler = static_cast<CDbusHandler*>(data);\r
- handler->GenerateReadyEvent();\r
-}\r
-\r
-void CDbusHandler::OnNameLost(GDBusConnection *conn, const gchar *bus_name, gpointer data)\r
-{\r
- SERVER_ERR("name lost (%s)", bus_name);\r
-}\r
-\r
-void CDbusHandler::RegisterObjects(void)\r
-{\r
- assert(m_conn);\r
- GError *err = NULL;\r
-\r
- GDBusNodeInfo *node_info = g_dbus_node_info_new_for_xml(m_methods.c_str(), &err);\r
-\r
- if (!node_info) {\r
- SERVER_ERR("failed to get node_info (%s)", err ? err->message : "unknown");\r
- g_clear_error(&err);\r
- return;\r
- }\r
-\r
- m_reg_id = g_dbus_connection_register_object(m_conn, RM_DBUS_OBJ_PATH, *(node_info->interfaces), &m_vtable, this, NULL, &err);\r
-\r
- if (m_reg_id == 0) {\r
- SERVER_ERR("failed to register objects (%s)", err ? err->message : "unknown");\r
- g_clear_error(&err);\r
- return;\r
- }\r
-\r
- m_own_id = g_bus_own_name_on_connection(m_conn, RM_DBUS_BUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, CDbusHandler::OnBusAcquired, CDbusHandler::OnNameLost, this, NULL);\r
-\r
- if (m_own_id == 0) {\r
- SERVER_ERR("failed to own dbus name (%s)", RM_DBUS_BUS_NAME);\r
- return;\r
- }\r
-\r
- SERVER_INFO("registering dbus objects success");\r
-}\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <assert.h>
+#include <iostream>
+#include <glib.h>
+#include <gio/gio.h>
+#include <trace.h>
+
+#include <rms_type.h>
+#include <rms_debug.h>
+#include <CMessage.h>
+#include <CAsyncQueue.h>
+#include <CDbusHandler.h>
+
+const GDBusInterfaceVTable CDbusHandler::m_vtable = { CDbusHandler::OnMethodCall, NULL, NULL, {0} };
+
+const std::string CDbusHandler::m_methods =
+ "<node>"
+ "<interface name = 'rscmgr.resource'>"
+ "<method name = 'GetResourceState'>"
+ "<arg direction='in' type='i' name='device_id'/>"
+ "<arg direction='out' type='i' name='state'/>"
+ "</method>"
+ "<method name = 'GetResourceList'>"
+ "<arg direction='in' type='i' name='category_id'/>"
+ "<arg direction='out' type='a(iissi)'/>"
+ "</method>"
+ "<method name = 'GetRscCollectionState'>"
+ "<arg direction='in' type='i' name='collection'/>"
+ "<arg direction='out' type='a(isiiis)'/>"
+ "</method>"
+ "<method name = 'FindDeviceId'>"
+ "<arg direction='in' type='i' name='virtual_id'/>"
+ "<arg direction='out' type='i' name='real_id'/>"
+ "</method>"
+ "<method name = 'SwapResources'>"
+ "<arg direction='in' type='i' name='device_id_a'/>"
+ "<arg direction='in' type='i' name='device_id_b'/>"
+ "<arg direction='out' type='i' name='result'/>"
+ "</method>"
+ "<method name = 'GetScalerState'>"
+ "<arg direction='in' type='i' name='category_id'/>"
+ "<arg direction='out' type='a(iiiiis)'/>"
+ "</method>"
+ "<method name = 'GetAppId'>"
+ "<arg direction='in' type='i' name='handle'/>"
+ "<arg direction='out' type='i' name='result'/>"
+ "<arg direction='out' type='s' name='app_id'/>"
+ "</method>"
+ "<method name = 'GetActiveAudioOut'>"
+ "<arg direction='in' type='i' name='handle'/>"
+ "<arg direction='out' type='i' name='audio_out'/>"
+ "</method>"
+ "<method name = 'GetScalerHWID'>"
+ "<arg direction='in' type='i' name='zone_id'/>"
+ "<arg direction='out' type='i' name='hw_id'/>"
+ "</method>"
+ "<method name = 'RestoreResources'>"
+ "<arg direction='in' type='i' name='category_id'/>"
+ "<arg direction='out' type='i' name='result'/>"
+ "</method>"
+ "<method name = 'NotifyResourcePolicy'>"
+ "<arg direction='in' type='i' name='policy'/>"
+ "<arg direction='out' type='i' name='result'/>"
+ "</method>"
+ "<method name = 'NotifyAppZoneInfo'>"
+ "<arg direction='in' type='s' name='appid'/>"
+ "<arg direction='in' type='i' name='zoneid'/>"
+ "<arg direction='out' type='i' name='reply'/>"
+ "</method>"
+ "</interface>"
+ "</node>";
+
+CDbusHandler::CDbusHandler(CAsyncQueue *queue)
+{
+ assert(queue);
+ m_async_queue = queue;
+ m_reg_id = 0;
+
+ if (!MakeDbusConnection())
+ return;
+
+ RegisterObjects();
+}
+
+bool CDbusHandler::MakeDbusConnection(void)
+{
+ m_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
+
+ if (!m_conn) {
+ SERVER_ERR("failed to make dbus connection");
+ return false;
+ }
+
+ SERVER_INFO("making dbus connection success");
+ return true;
+}
+
+void CDbusHandler::OnMethodCall(GDBusConnection *conn, const gchar *sender, const gchar *obj_path, const gchar *ifname, const gchar *method_name, GVariant *params, GDBusMethodInvocation *invoc, gpointer data)
+{
+ CDbusHandler *handler = static_cast<CDbusHandler*>(data);
+ CAsyncQueue *queue = handler->m_async_queue;
+ CMessage *msg = new CMessage(invoc);
+
+ SERVER_INFO("push msg(%s)", method_name);
+
+ queue->push(msg);
+}
+
+void CDbusHandler::GenerateReadyEvent(void)
+{
+ SERVER_INFO("We will notify clients when the server is ready by generating a ready event");
+}
+
+void CDbusHandler::OnBusAcquired(GDBusConnection *conn, const gchar *bus_name, gpointer data)
+{
+ trace_begin("[RSC_MGR] OnBusAcquired");
+ trace_end();
+ SERVER_INFO("bus acquired (%s)", bus_name);
+
+ CDbusHandler *handler = static_cast<CDbusHandler*>(data);
+ handler->GenerateReadyEvent();
+}
+
+void CDbusHandler::OnNameLost(GDBusConnection *conn, const gchar *bus_name, gpointer data)
+{
+ SERVER_ERR("name lost (%s)", bus_name);
+}
+
+void CDbusHandler::RegisterObjects(void)
+{
+ assert(m_conn);
+ GError *err = NULL;
+
+ GDBusNodeInfo *node_info = g_dbus_node_info_new_for_xml(m_methods.c_str(), &err);
+
+ if (!node_info) {
+ SERVER_ERR("failed to get node_info (%s)", err ? err->message : "unknown");
+ g_clear_error(&err);
+ return;
+ }
+
+ m_reg_id = g_dbus_connection_register_object(m_conn, RM_DBUS_OBJ_PATH, *(node_info->interfaces), &m_vtable, this, NULL, &err);
+
+ if (m_reg_id == 0) {
+ SERVER_ERR("failed to register objects (%s)", err ? err->message : "unknown");
+ g_clear_error(&err);
+ return;
+ }
+
+ m_own_id = g_bus_own_name_on_connection(m_conn, RM_DBUS_BUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, CDbusHandler::OnBusAcquired, CDbusHandler::OnNameLost, this, NULL);
+
+ if (m_own_id == 0) {
+ SERVER_ERR("failed to own dbus name (%s)", RM_DBUS_BUS_NAME);
+ return;
+ }
+
+ SERVER_INFO("registering dbus objects success");
+}
-/*\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 <CHandle.h>\r
-#include <stdlib.h>\r
-#include <rms_type.h>\r
-#include <CDebugUtils.h>\r
-CHandle::CHandle(int in_handle, int in_is_used, int in_pid)\r
-{\r
- handle = in_handle;\r
- is_used = in_is_used;\r
- pid = in_pid;\r
- rms_get_cmd_name(pid,process_name,RMS_NAME_BUF_SIZE);\r
-}\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <CHandle.h>
+#include <stdlib.h>
+#include <rms_type.h>
+#include <CDebugUtils.h>
+CHandle::CHandle(int in_handle, int in_is_used, int in_pid)
+{
+ handle = in_handle;
+ is_used = in_is_used;
+ pid = in_pid;
+ rms_get_cmd_name(pid,process_name,RMS_NAME_BUF_SIZE);
+}
-/*\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 <CHandleManager.h>\r
-#include <CHandle.h>\r
-#include <CConsumer.h>\r
-#include <CConsumerContainer.h>\r
-#include <CCallback.h>\r
-#include <CDebugUtils.h>\r
-\r
-#include <rms_type.h>\r
-#include <rms_debug.h>\r
-#include <rms_log.h>\r
-\r
-#include <map>\r
-#include <stdio.h>\r
-#include <fcntl.h>\r
-#include <signal.h>\r
-#include <stdlib.h>\r
-\r
-\r
-static const int M_MIN_HANDLE = 101;\r
-static const int M_MAX_HANDLE = 200;\r
-\r
-CHandleManager::CHandleManager(CResourceManager *rsc_mgr)\r
-{\r
- assert(rsc_mgr);\r
- m_rsc_mgr = rsc_mgr;\r
- m_next_handle = M_MIN_HANDLE;\r
-}\r
-\r
-int CHandleManager::m_IsValidHandle(int handle)\r
-{\r
- return ((handle >= M_MIN_HANDLE) && (handle <= M_MAX_HANDLE)) ? 1 : 0;\r
-}\r
-\r
-int CHandleManager::m_ReclaimHandle(void)\r
-{\r
- for (int i = M_MIN_HANDLE; i < M_MAX_HANDLE; i++) {\r
- CHandle *handle_info = findHandle(i);\r
-\r
- if (!handle_info)\r
- return i;\r
-\r
- if (!rm_is_valid_pid(handle_info->pid)) {\r
- SERVER_INFO("reclaim pid(%d)/handle(%d)", handle_info->pid, handle_info->handle);\r
-\r
- // release resources allocated to terminated process\r
- m_rsc_mgr->UnregisterConsumer(handle_info->handle);\r
- m_RemoveHandle(handle_info->handle, handle_info->pid);\r
- return i;\r
- }\r
- }\r
-\r
- return RMS_HANDLE_NOT_AVAILABLE;\r
-}\r
-\r
-void CHandleManager::m_PrintHandleList(void)\r
-{\r
- for (int i = M_MIN_HANDLE; i < M_MAX_HANDLE; i++) {\r
- std::map<int, CHandle*>::iterator it = m_handles.find(i);\r
-\r
- if (it == m_handles.end())\r
- return ;\r
-\r
- CHandle *handle_info = (*it).second;\r
- m_PrintHandleInfo(handle_info->handle, handle_info->pid);\r
- }\r
-}\r
-\r
-int CHandleManager::m_AddNewHandle(int handle, int pid, int main_priority, int sub_priority, int app_pid, char *app_id)\r
-{\r
- CHandle *handle_info = new(std::nothrow) CHandle(handle, RMS_HANDLE_USE, pid);\r
- if (!handle_info) {\r
- SERVER_ERR("cannot create handle class");\r
- return RMS_ERROR;\r
- }\r
-\r
- handle_info->main_priority = main_priority;\r
- handle_info->sub_priority = sub_priority;\r
- handle_info->app_pid = app_pid;\r
- handle_info->app_id = strndup(app_id, strlen(app_id));\r
-\r
- m_handles.insert(std::pair<int, CHandle*>(handle, handle_info));\r
- SERVER_DBG("handle(%d) pid(%d) inserted", handle, pid);\r
-\r
- return RMS_OK;\r
-}\r
-int CHandleManager::m_RemoveHandle(int handle, int pid)\r
-{\r
- CHandle *handle_info = findHandle(handle);\r
-\r
- if (!handle_info) {\r
- SERVER_ERR("can't find handle (%d) in list. no need to remove", handle);\r
- return RMS_OK;\r
- }\r
-\r
- if (handle_info->pid != pid) {\r
- SERVER_ERR("cannot remove handle (%d) - owner(%d)/requester(%d)", handle, handle_info->pid, pid);\r
- return RMS_ERROR;\r
- }\r
-\r
- if (handle_info->app_id) {\r
- free(handle_info->app_id);\r
- handle_info->app_id = NULL;\r
- }\r
-\r
- for (int i = 0; i < RMS_NAME_BUF_SIZE; i++) {\r
- handle_info->process_name[i] = 0;\r
- }\r
-\r
- delete handle_info;\r
- m_handles.erase(handle);\r
-\r
- CCallback::RemoveFIFOServerToClient(pid, handle);\r
-\r
- return RMS_OK;\r
-}\r
-int CHandleManager::GetNewHandle(int pid, int main_priority, int sub_priority, int app_pid, char *app_id)\r
-{\r
- int handle = -1;\r
-\r
- if (m_next_handle >= (M_MAX_HANDLE - 1))\r
- m_next_handle = M_MIN_HANDLE;\r
-\r
- std::map<int, CHandle*>::iterator it = m_handles.find(m_next_handle);\r
-\r
- handle = (it == m_handles.end()) ? m_next_handle:m_ReclaimHandle();\r
-\r
- if (handle == RMS_HANDLE_NOT_AVAILABLE) {\r
- SERVER_ERR("ERROR! can't assign new handle (FULL)");\r
- m_PrintHandleList();\r
- return RMS_HANDLE_NOT_AVAILABLE;\r
- }\r
-\r
- m_AddNewHandle(handle, pid, main_priority, sub_priority, app_pid, app_id);\r
- ++m_next_handle;\r
-\r
- return handle;\r
-}\r
-\r
-int CHandleManager::RemoveHandle(int handle, int pid)\r
-{\r
- return m_RemoveHandle(handle, pid);\r
-}\r
-\r
-int CHandleManager::SetPriority(int handle, int main_priority, int sub_priority)\r
-{\r
- CHandle *handle_info = findHandle(handle);\r
-\r
- if (!handle_info) {\r
- SERVER_ERR("can't find handle (%d)", handle);\r
- return RMS_ERROR;\r
- }\r
-\r
- CConsumer *consumer = CConsumerContainer::getInstance()->findConsumer(handle);\r
-\r
- if (!consumer) {\r
- SERVER_ERR("handle[%d] not registered consumer", handle);\r
- return RMS_ERROR;\r
- }\r
-\r
- handle_info->main_priority = main_priority;\r
- handle_info->sub_priority = sub_priority;\r
-\r
- rms_priority_s priority;\r
- priority.main = main_priority;\r
- priority.sub = sub_priority;\r
-\r
- consumer->SetPriority(priority);\r
-\r
- return RMS_OK;\r
-}\r
-\r
-CHandle *CHandleManager::findHandle(int id)\r
-{\r
- auto it = m_handles.find(id);\r
-\r
- return (it == m_handles.end()) ? NULL:it->second;\r
-}\r
-\r
-int CHandleManager::GetPriority(int handle, int *main_priority, int *sub_priority)\r
-{\r
- CHandle *handle_info = findHandle(handle);\r
-\r
- if (!handle_info) {\r
- SERVER_ERR("can't find handle (%d)", handle);\r
- return RMS_ERROR;\r
- }\r
-\r
- *main_priority = handle_info->main_priority;\r
- *sub_priority = handle_info->sub_priority;\r
-\r
- return RMS_OK;\r
-}\r
-\r
-int CHandleManager::SetAppID(int handle, char *app_id)\r
-{\r
- CHandle *handle_info = findHandle(handle);\r
-\r
- if (!handle_info) {\r
- SERVER_ERR("can't find handle (%d)", handle);\r
- return RMS_ERROR;\r
- }\r
-\r
- if (handle_info->app_id) {\r
- free(handle_info->app_id);\r
- handle_info->app_id = NULL;\r
- }\r
-\r
- handle_info->app_id = strndup(app_id, strlen(app_id));\r
-\r
- return RMS_OK;\r
-}\r
-\r
-char *CHandleManager::GetAppID(int handle)\r
-{\r
- CHandle *handle_info = findHandle(handle);\r
-\r
- if (!handle_info) {\r
- SERVER_ERR("can't find handle (%d)", handle);\r
- return NULL;\r
- }\r
-\r
- return strndup(handle_info->app_id, strlen(handle_info->app_id));\r
-}\r
-\r
-int CHandleManager::m_PrintHandleInfo(int handle, int pid)\r
-{\r
- char name[RMS_NAME_BUF_SIZE] = {0,};\r
- rms_get_cmd_name(pid, name, sizeof(name));\r
-\r
- rms_log_reset();\r
- rms_log_add("handle(%d) pid(%d) name(%s)", handle, pid, name);\r
-\r
- CConsumer *consumer = CConsumerContainer::getInstance()->findConsumer(handle);\r
-\r
- if (!consumer) {\r
- rms_log_add(": no consumer info");\r
-\r
- RMS_LOGE_FLUSH();\r
- return RMS_OK;\r
- }\r
-\r
- rms_log_add(": using %d resource(s)", consumer->GetResourceNum());\r
-\r
- RMS_LOGE_FLUSH();\r
- return RMS_OK;\r
-}\r
-\r
-void CHandleManager::ReclaimAllInvalidCustomer(int request_pid)\r
-{\r
- for (std::map<int, CHandle*>::iterator it = m_handles.begin(); it != m_handles.end(); it++) {\r
- CHandle *handle_info = (*it).second;\r
- int cid = handle_info->handle;\r
- int pid = handle_info->pid;\r
-\r
- if ((pid != request_pid) &&(!rm_is_valid_pid(pid))) {\r
- SERVER_ERR("Reclaim handle(%d)/pid(%d)", cid, pid);\r
- m_rsc_mgr->ReleaseResourcesOfPid(pid);\r
- RemoveHandle(cid, pid);\r
- CCallback::RemoveFIFOServerToClient(pid, cid);\r
- }\r
- }\r
-}\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <CHandleManager.h>
+#include <CHandle.h>
+#include <CConsumer.h>
+#include <CConsumerContainer.h>
+#include <CCallback.h>
+#include <CDebugUtils.h>
+
+#include <rms_type.h>
+#include <rms_debug.h>
+#include <rms_log.h>
+
+#include <map>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdlib.h>
+
+
+static const int M_MIN_HANDLE = 101;
+static const int M_MAX_HANDLE = 200;
+
+CHandleManager::CHandleManager(CResourceManager *rsc_mgr)
+{
+ assert(rsc_mgr);
+ m_rsc_mgr = rsc_mgr;
+ m_next_handle = M_MIN_HANDLE;
+}
+
+int CHandleManager::m_IsValidHandle(int handle)
+{
+ return ((handle >= M_MIN_HANDLE) && (handle <= M_MAX_HANDLE)) ? 1 : 0;
+}
+
+int CHandleManager::m_ReclaimHandle(void)
+{
+ for (int i = M_MIN_HANDLE; i < M_MAX_HANDLE; i++) {
+ CHandle *handle_info = findHandle(i);
+
+ if (!handle_info)
+ return i;
+
+ if (!rm_is_valid_pid(handle_info->pid)) {
+ SERVER_INFO("reclaim pid(%d)/handle(%d)", handle_info->pid, handle_info->handle);
+
+ // release resources allocated to terminated process
+ m_rsc_mgr->UnregisterConsumer(handle_info->handle);
+ m_RemoveHandle(handle_info->handle, handle_info->pid);
+ return i;
+ }
+ }
+
+ return RMS_HANDLE_NOT_AVAILABLE;
+}
+
+void CHandleManager::m_PrintHandleList(void)
+{
+ for (int i = M_MIN_HANDLE; i < M_MAX_HANDLE; i++) {
+ std::map<int, CHandle*>::iterator it = m_handles.find(i);
+
+ if (it == m_handles.end())
+ return ;
+
+ CHandle *handle_info = (*it).second;
+ m_PrintHandleInfo(handle_info->handle, handle_info->pid);
+ }
+}
+
+int CHandleManager::m_AddNewHandle(int handle, int pid, int main_priority, int sub_priority, int app_pid, char *app_id)
+{
+ CHandle *handle_info = new(std::nothrow) CHandle(handle, RMS_HANDLE_USE, pid);
+ if (!handle_info) {
+ SERVER_ERR("cannot create handle class");
+ return RMS_ERROR;
+ }
+
+ handle_info->main_priority = main_priority;
+ handle_info->sub_priority = sub_priority;
+ handle_info->app_pid = app_pid;
+ handle_info->app_id = strndup(app_id, strlen(app_id));
+
+ m_handles.insert(std::pair<int, CHandle*>(handle, handle_info));
+ SERVER_DBG("handle(%d) pid(%d) inserted", handle, pid);
+
+ return RMS_OK;
+}
+int CHandleManager::m_RemoveHandle(int handle, int pid)
+{
+ CHandle *handle_info = findHandle(handle);
+
+ if (!handle_info) {
+ SERVER_ERR("can't find handle (%d) in list. no need to remove", handle);
+ return RMS_OK;
+ }
+
+ if (handle_info->pid != pid) {
+ SERVER_ERR("cannot remove handle (%d) - owner(%d)/requester(%d)", handle, handle_info->pid, pid);
+ return RMS_ERROR;
+ }
+
+ if (handle_info->app_id) {
+ free(handle_info->app_id);
+ handle_info->app_id = NULL;
+ }
+
+ for (int i = 0; i < RMS_NAME_BUF_SIZE; i++) {
+ handle_info->process_name[i] = 0;
+ }
+
+ delete handle_info;
+ m_handles.erase(handle);
+
+ CCallback::RemoveFIFOServerToClient(pid, handle);
+
+ return RMS_OK;
+}
+int CHandleManager::GetNewHandle(int pid, int main_priority, int sub_priority, int app_pid, char *app_id)
+{
+ int handle = -1;
+
+ if (m_next_handle >= (M_MAX_HANDLE - 1))
+ m_next_handle = M_MIN_HANDLE;
+
+ std::map<int, CHandle*>::iterator it = m_handles.find(m_next_handle);
+
+ handle = (it == m_handles.end()) ? m_next_handle:m_ReclaimHandle();
+
+ if (handle == RMS_HANDLE_NOT_AVAILABLE) {
+ SERVER_ERR("ERROR! can't assign new handle (FULL)");
+ m_PrintHandleList();
+ return RMS_HANDLE_NOT_AVAILABLE;
+ }
+
+ m_AddNewHandle(handle, pid, main_priority, sub_priority, app_pid, app_id);
+ ++m_next_handle;
+
+ return handle;
+}
+
+int CHandleManager::RemoveHandle(int handle, int pid)
+{
+ return m_RemoveHandle(handle, pid);
+}
+
+int CHandleManager::SetPriority(int handle, int main_priority, int sub_priority)
+{
+ CHandle *handle_info = findHandle(handle);
+
+ if (!handle_info) {
+ SERVER_ERR("can't find handle (%d)", handle);
+ return RMS_ERROR;
+ }
+
+ CConsumer *consumer = CConsumerContainer::getInstance()->findConsumer(handle);
+
+ if (!consumer) {
+ SERVER_ERR("handle[%d] not registered consumer", handle);
+ return RMS_ERROR;
+ }
+
+ handle_info->main_priority = main_priority;
+ handle_info->sub_priority = sub_priority;
+
+ rms_priority_s priority;
+ priority.main = main_priority;
+ priority.sub = sub_priority;
+
+ consumer->SetPriority(priority);
+
+ return RMS_OK;
+}
+
+CHandle *CHandleManager::findHandle(int id)
+{
+ auto it = m_handles.find(id);
+
+ return (it == m_handles.end()) ? NULL:it->second;
+}
+
+int CHandleManager::GetPriority(int handle, int *main_priority, int *sub_priority)
+{
+ CHandle *handle_info = findHandle(handle);
+
+ if (!handle_info) {
+ SERVER_ERR("can't find handle (%d)", handle);
+ return RMS_ERROR;
+ }
+
+ *main_priority = handle_info->main_priority;
+ *sub_priority = handle_info->sub_priority;
+
+ return RMS_OK;
+}
+
+int CHandleManager::SetAppID(int handle, char *app_id)
+{
+ CHandle *handle_info = findHandle(handle);
+
+ if (!handle_info) {
+ SERVER_ERR("can't find handle (%d)", handle);
+ return RMS_ERROR;
+ }
+
+ if (handle_info->app_id) {
+ free(handle_info->app_id);
+ handle_info->app_id = NULL;
+ }
+
+ handle_info->app_id = strndup(app_id, strlen(app_id));
+
+ return RMS_OK;
+}
+
+char *CHandleManager::GetAppID(int handle)
+{
+ CHandle *handle_info = findHandle(handle);
+
+ if (!handle_info) {
+ SERVER_ERR("can't find handle (%d)", handle);
+ return NULL;
+ }
+
+ return strndup(handle_info->app_id, strlen(handle_info->app_id));
+}
+
+int CHandleManager::m_PrintHandleInfo(int handle, int pid)
+{
+ char name[RMS_NAME_BUF_SIZE] = {0,};
+ rms_get_cmd_name(pid, name, sizeof(name));
+
+ rms_log_reset();
+ rms_log_add("handle(%d) pid(%d) name(%s)", handle, pid, name);
+
+ CConsumer *consumer = CConsumerContainer::getInstance()->findConsumer(handle);
+
+ if (!consumer) {
+ rms_log_add(": no consumer info");
+
+ RMS_LOGE_FLUSH();
+ return RMS_OK;
+ }
+
+ rms_log_add(": using %d resource(s)", consumer->GetResourceNum());
+
+ RMS_LOGE_FLUSH();
+ return RMS_OK;
+}
+
+void CHandleManager::ReclaimAllInvalidCustomer(int request_pid)
+{
+ for (std::map<int, CHandle*>::iterator it = m_handles.begin(); it != m_handles.end(); it++) {
+ CHandle *handle_info = (*it).second;
+ int cid = handle_info->handle;
+ int pid = handle_info->pid;
+
+ if ((pid != request_pid) &&(!rm_is_valid_pid(pid))) {
+ SERVER_ERR("Reclaim handle(%d)/pid(%d)", cid, pid);
+ m_rsc_mgr->ReleaseResourcesOfPid(pid);
+ RemoveHandle(cid, pid);
+ CCallback::RemoveFIFOServerToClient(pid, cid);
+ }
+ }
+}
-/*\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 <stdlib.h>\r
-#include <assert.h>\r
-#include <ri-api.h>\r
-#include <ri-module-api.h>\r
-#include <rms_debug.h>\r
-#include <CMessage.h>\r
-\r
-CMessage::CMessage(std::string name)\r
-{\r
- m_sender = MSG_SENDER_INTERNAL;\r
- m_msgq_req = NULL;\r
- m_name = name;\r
-}\r
-\r
-CMessage::CMessage(rms_msg_request *req)\r
-{\r
- assert(req);\r
-\r
- m_msgq_req = (rms_msg_request*) calloc(1, sizeof(rms_msg_request));\r
- assert(m_msgq_req);\r
- memcpy(m_msgq_req, req, sizeof(rms_msg_request));\r
-\r
- m_sender = MSG_SENDER_MSGQ;\r
-}\r
-\r
-CMessage::CMessage(GDBusMethodInvocation *invoc)\r
-{\r
- assert(invoc);\r
-\r
- m_invoc = invoc;\r
- m_sender = MSG_SENDER_DBUS;\r
- m_msgq_req = NULL;\r
-}\r
-\r
-CMessage::~CMessage(void)\r
-{\r
- if (m_msgq_req)\r
- free(m_msgq_req);\r
-}\r
-\r
-int CMessage::GetReqType(void)\r
-{\r
- int req_type = RMS_REQUEST_MAX;\r
- assert(m_msgq_req);\r
-\r
- switch (m_sender) {\r
- case MSG_SENDER_MSGQ:\r
- req_type = m_msgq_req->type;\r
- break;\r
- case MSG_SENDER_DBUS:\r
- case MSG_SENDER_INTERNAL:\r
- break;\r
- default:\r
- SERVER_ERR("undefined sender(%d)", m_sender);\r
- break;\r
- }\r
-\r
- return req_type;\r
-}\r
-\r
-bool CMessage::IsMsgForScalerDbus(void)\r
-{\r
- std::string method_name = g_dbus_method_invocation_get_method_name(m_invoc);\r
-\r
- if (!method_name.compare("FindDeviceId"))\r
- return true;\r
- if (!method_name.compare("SwapResources"))\r
- return true;\r
- if (!method_name.compare("GetScalerState"))\r
- return true;\r
- if (!method_name.compare("GetScalerHWID"))\r
- return true;\r
- if (!method_name.compare("RestoreResources"))\r
- return true;\r
-\r
- return false;\r
-}\r
-\r
-bool CMessage::IsMsgForScalerMsgQ(void)\r
-{\r
- bool result = false;\r
- switch (m_msgq_req->type) {\r
- case RMS_REQUEST_ALLOCATE_RESOURCE:\r
- for (int i = 0; i < m_msgq_req->request_num; i++) {\r
- if (ri_is_video_scaler_category(m_msgq_req->resource[i]))\r
- {\r
- result = true;\r
- break;\r
- }\r
- }\r
- break;\r
- case RMS_REQUEST_RELEASE_RESOURCES:\r
- int category_type;\r
- for (int i = 0; i < m_msgq_req->request_num; i++) {\r
- ri_get_category_type_by_device_id(m_msgq_req->resource[i], &category_type);\r
- if (ri_is_video_scaler_category(category_type))\r
- {\r
- result = true;\r
- break;\r
- }\r
- }\r
- break;\r
- case RMS_REQUEST_UNREGISTER:\r
- case RMS_REQUEST_REGISTER:\r
- case RMS_REQUEST_QUERY:\r
- case RMS_REQUEST_SET_PRIORITY:\r
- case RMS_REQUEST_SET_APPID:\r
- result = false;\r
- break;\r
- default:\r
- SERVER_ERR("undefined req type(%d)", m_msgq_req->type);\r
- break;\r
- }\r
-\r
- return result;\r
-}\r
-\r
-void CMessage::PrintInfo(void)\r
-{\r
- switch (m_sender) {\r
- case MSG_SENDER_MSGQ:\r
- PrintMsgQ();\r
- break;\r
- case MSG_SENDER_DBUS:\r
- PrintDbus();\r
- break;\r
- case MSG_SENDER_INTERNAL:\r
- PrintInternal();\r
- break;\r
- default:\r
- SERVER_ERR("undefined sender(%d)", m_sender);\r
- break;\r
- }\r
-}\r
-\r
-void CMessage::PrintDbus(void)\r
-{\r
- SERVER_ERR("Sender:Dbus/%s", g_dbus_method_invocation_get_method_name(m_invoc));\r
-}\r
-\r
-void CMessage::PrintInternal(void)\r
-{\r
- SERVER_ERR("Sender:Internal/%s", m_name.c_str());\r
-}\r
-\r
-void CMessage::PrintMsgQ(void)\r
-{\r
- SERVER_ERR("Sender:MsgQ/type(%d)/cid(%d)/num(%d)", m_msgq_req->type, m_msgq_req->handle, m_msgq_req->request_num);\r
-}\r
-\r
-bool CMessage::IsUnlockMsg(void)\r
-{\r
- if (m_sender != MSG_SENDER_INTERNAL)\r
- return false;\r
-\r
- return (!m_name.compare("NotifyUnlock"));\r
-}\r
-\r
-bool CMessage::IsMsgForScaler(void)\r
-{\r
- bool result = false;\r
-\r
- switch (m_sender) {\r
- case MSG_SENDER_MSGQ:\r
- result = IsMsgForScalerMsgQ();\r
- break;\r
- case MSG_SENDER_DBUS:\r
- result = IsMsgForScalerDbus();\r
- break;\r
- case MSG_SENDER_INTERNAL:\r
- result = false;\r
- break;\r
- default:\r
- SERVER_ERR("undefined sender(%d)", m_sender);\r
- break;\r
- }\r
-\r
- return result;\r
-}\r
-\r
-bool CMessage::IsMsgFor(ResourceType rsc_type)\r
-{\r
- bool result = false;\r
-\r
- switch (rsc_type) {\r
- case ResourceType::VIDEO_SCALER:\r
- result = IsMsgForScaler();\r
- break;\r
- default:\r
- break;\r
- }\r
-\r
- return result;\r
-}\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <assert.h>
+#include <ri-api.h>
+#include <ri-module-api.h>
+#include <rms_debug.h>
+#include <CMessage.h>
+
+CMessage::CMessage(std::string name)
+{
+ m_sender = MSG_SENDER_INTERNAL;
+ m_msgq_req = NULL;
+ m_name = name;
+}
+
+CMessage::CMessage(rms_msg_request *req)
+{
+ assert(req);
+
+ m_msgq_req = (rms_msg_request*) calloc(1, sizeof(rms_msg_request));
+ assert(m_msgq_req);
+ memcpy(m_msgq_req, req, sizeof(rms_msg_request));
+
+ m_sender = MSG_SENDER_MSGQ;
+}
+
+CMessage::CMessage(GDBusMethodInvocation *invoc)
+{
+ assert(invoc);
+
+ m_invoc = invoc;
+ m_sender = MSG_SENDER_DBUS;
+ m_msgq_req = NULL;
+}
+
+CMessage::~CMessage(void)
+{
+ if (m_msgq_req)
+ free(m_msgq_req);
+}
+
+int CMessage::GetReqType(void)
+{
+ int req_type = RMS_REQUEST_MAX;
+ assert(m_msgq_req);
+
+ switch (m_sender) {
+ case MSG_SENDER_MSGQ:
+ req_type = m_msgq_req->type;
+ break;
+ case MSG_SENDER_DBUS:
+ case MSG_SENDER_INTERNAL:
+ break;
+ default:
+ SERVER_ERR("undefined sender(%d)", m_sender);
+ break;
+ }
+
+ return req_type;
+}
+
+bool CMessage::IsMsgForScalerDbus(void)
+{
+ std::string method_name = g_dbus_method_invocation_get_method_name(m_invoc);
+
+ if (!method_name.compare("FindDeviceId"))
+ return true;
+ if (!method_name.compare("SwapResources"))
+ return true;
+ if (!method_name.compare("GetScalerState"))
+ return true;
+ if (!method_name.compare("GetScalerHWID"))
+ return true;
+ if (!method_name.compare("RestoreResources"))
+ return true;
+
+ return false;
+}
+
+bool CMessage::IsMsgForScalerMsgQ(void)
+{
+ bool result = false;
+ switch (m_msgq_req->type) {
+ case RMS_REQUEST_ALLOCATE_RESOURCE:
+ for (int i = 0; i < m_msgq_req->request_num; i++) {
+ if (ri_is_video_scaler_category(m_msgq_req->resource[i]))
+ {
+ result = true;
+ break;
+ }
+ }
+ break;
+ case RMS_REQUEST_RELEASE_RESOURCES:
+ int category_type;
+ for (int i = 0; i < m_msgq_req->request_num; i++) {
+ ri_get_category_type_by_device_id(m_msgq_req->resource[i], &category_type);
+ if (ri_is_video_scaler_category(category_type))
+ {
+ result = true;
+ break;
+ }
+ }
+ break;
+ case RMS_REQUEST_UNREGISTER:
+ case RMS_REQUEST_REGISTER:
+ case RMS_REQUEST_QUERY:
+ case RMS_REQUEST_SET_PRIORITY:
+ case RMS_REQUEST_SET_APPID:
+ result = false;
+ break;
+ default:
+ SERVER_ERR("undefined req type(%d)", m_msgq_req->type);
+ break;
+ }
+
+ return result;
+}
+
+void CMessage::PrintInfo(void)
+{
+ switch (m_sender) {
+ case MSG_SENDER_MSGQ:
+ PrintMsgQ();
+ break;
+ case MSG_SENDER_DBUS:
+ PrintDbus();
+ break;
+ case MSG_SENDER_INTERNAL:
+ PrintInternal();
+ break;
+ default:
+ SERVER_ERR("undefined sender(%d)", m_sender);
+ break;
+ }
+}
+
+void CMessage::PrintDbus(void)
+{
+ SERVER_ERR("Sender:Dbus/%s", g_dbus_method_invocation_get_method_name(m_invoc));
+}
+
+void CMessage::PrintInternal(void)
+{
+ SERVER_ERR("Sender:Internal/%s", m_name.c_str());
+}
+
+void CMessage::PrintMsgQ(void)
+{
+ SERVER_ERR("Sender:MsgQ/type(%d)/cid(%d)/num(%d)", m_msgq_req->type, m_msgq_req->handle, m_msgq_req->request_num);
+}
+
+bool CMessage::IsUnlockMsg(void)
+{
+ if (m_sender != MSG_SENDER_INTERNAL)
+ return false;
+
+ return (!m_name.compare("NotifyUnlock"));
+}
+
+bool CMessage::IsMsgForScaler(void)
+{
+ bool result = false;
+
+ switch (m_sender) {
+ case MSG_SENDER_MSGQ:
+ result = IsMsgForScalerMsgQ();
+ break;
+ case MSG_SENDER_DBUS:
+ result = IsMsgForScalerDbus();
+ break;
+ case MSG_SENDER_INTERNAL:
+ result = false;
+ break;
+ default:
+ SERVER_ERR("undefined sender(%d)", m_sender);
+ break;
+ }
+
+ return result;
+}
+
+bool CMessage::IsMsgFor(ResourceType rsc_type)
+{
+ bool result = false;
+
+ switch (rsc_type) {
+ case ResourceType::VIDEO_SCALER:
+ result = IsMsgForScaler();
+ break;
+ default:
+ break;
+ }
+
+ return result;
+}
-/*\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 <sys/types.h>\r
-#include <sys/ipc.h>\r
-#include <sys/msg.h>\r
-#include <unistd.h>\r
-#include <errno.h>\r
-#include <trace.h>\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <assert.h>\r
-#include <gio/gio.h>\r
-\r
-#include <CMessage.h>\r
-#include <CMessageHandler.h>\r
-#include <CCallback.h>\r
-#include <CDebugUtils.h>\r
-#include <rms_debug.h>\r
-#include <CHandleManager.h>\r
-#include <CResourceManager.h>\r
-#include <CConsumerContainer.h>\r
-#include <CQueryHandler.h>\r
-#include <CAsyncQueue.h>\r
-#include <CCache.h>\r
-#include <CDbusHandler.h>\r
-\r
-#define RMS_HANLDE_COMMON 100 // common handle for the request rm_register() is not required\r
-#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))\r
-\r
-struct rms_msg_handler {\r
- const char *msg_name;\r
- CMessageHandler::MsgHandler handler;\r
-};\r
-\r
-CMessageHandler::CMessageHandler(CResourceManager *rsc_mgr)\r
-{\r
- assert(rsc_mgr);\r
-\r
- msgq_rx = new CMessageQueue(MSG_QUEUE_RX);\r
- msgq_tx = new CMessageQueue(MSG_QUEUE_TX);\r
- async_queue = new CAsyncQueue();\r
- async_pending_queue = new CAsyncQueue();\r
-\r
- m_rsc_mgr = rsc_mgr;\r
- m_query_h = new CQueryHandler(rsc_mgr);\r
- m_handle_mgr = new CHandleManager(rsc_mgr);\r
- m_lock_ctr = CLockController::GetInstance();\r
- m_lock_ctr->SetMsgQ(async_queue);\r
-\r
- CCallback::InitCallback();\r
- InitDbusHandlers();\r
- InitInternalMsgHandlers();\r
-}\r
-\r
-CMessageHandler::~CMessageHandler(void)\r
-{\r
-\r
-}\r
-\r
-void CMessageHandler::InitDbusHandlers(void)\r
-{\r
- struct rms_msg_handler dbus_handlers[] = {\r
- {"RegisterResource", &CMessageHandler::RegisterResource},\r
- {"GetResourceState", &CMessageHandler::GetResourceState},\r
- {"GetResourceList", &CMessageHandler::GetResourceList},\r
- {"GetRscCollectionState", &CMessageHandler::GetResourceCollectionState},\r
- {"FindDeviceId", &CMessageHandler::FindDeviceId},\r
- {"SwapResources", &CMessageHandler::SwapResources},\r
- {"GetScalerState", &CMessageHandler::GetScalerState},\r
- {"GetAppId", &CMessageHandler::GetAppId},\r
- {"GetActiveAudioOut", &CMessageHandler::GetActiveAudioOut},\r
- {"GetScalerHWID", &CMessageHandler::GetScalerHWID},\r
- {"RestoreResources", &CMessageHandler::RestoreResources},\r
- {"NotifyResourcePolicy", &CMessageHandler::NotifyResourcePolicy},\r
- {"NotifyAppZoneInfo", &CMessageHandler::NotifyAppZoneInfo}\r
- // Please add a new dbus message handler here\r
- };\r
-\r
- std::string msg_name;\r
- for (unsigned int i = 0; i < ARRAY_SIZE(dbus_handlers); i++) {\r
- msg_name.assign(dbus_handlers[i].msg_name);\r
- m_dbus_handlers.insert(std::pair<std::string, CMessageHandler::MsgHandler>(msg_name, dbus_handlers[i].handler));\r
- }\r
-}\r
-\r
-void CMessageHandler::InitInternalMsgHandlers(void)\r
-{\r
- struct rms_msg_handler internal_msg_handlers[] = {\r
- {"NotifyWatchdog", &CMessageHandler::NotifyWatchdog}\r
- // Please add a new internal message handler here\r
- };\r
-\r
- std::string msg_name;\r
- for (unsigned int i = 0; i < ARRAY_SIZE(internal_msg_handlers); i++) {\r
- msg_name.assign(internal_msg_handlers[i].msg_name);\r
- m_internal_msg_handlers.insert(std::pair<std::string, CMessageHandler::MsgHandler>(msg_name, internal_msg_handlers[i].handler));\r
- }\r
-}\r
-\r
-void CMessageHandler::m_ConstructRequestedDevice(rms_msg_request *request, rms_requests_device_s *requested_resource)\r
-{\r
- requested_resource->resources_num = request->request_num;\r
-\r
- for (int i = 0; i < requested_resource->resources_num; i++) {\r
- requested_resource->devices[i].device_id = request->resource[i];\r
- requested_resource->devices[i].requested_state = (rms_requests_resource_state_e) request->state[i];\r
- }\r
-}\r
-\r
-int CMessageHandler::Run(void)\r
-{\r
- if (g_thread_new("rms_msgq_thread", msgQThread, this) == NULL) {\r
- SERVER_ERR("failed to create rms_msgq thread");\r
- assert(0);\r
- return RMS_ERROR;\r
- }\r
-\r
- if (g_thread_new("rms_msg_thread", msgThread, this) == NULL) {\r
- SERVER_ERR("event loop thread create failed\n");\r
- assert(0);\r
- return RMS_ERROR;\r
- }\r
-\r
- m_dbus_h = new CDbusHandler(async_queue);\r
- return RMS_OK;\r
-}\r
-\r
-gpointer CMessageHandler::msgQThread(gpointer data)\r
-{\r
- assert(data);\r
-\r
- CMessageHandler *msg_handler = (CMessageHandler*) data;\r
- CAsyncQueue *asyncq = msg_handler->async_queue;\r
- CMessageQueue *msgq = msg_handler->msgq_rx;\r
- rms_msg_request req;\r
-\r
- while (1) {\r
- memset(&req, 0, sizeof(rms_msg_request));\r
-\r
- if (msgq->receive(&req, RMS_REQUEST_DATA_TYPE_ALL) != RMS_OK)\r
- continue;\r
-\r
- SERVER_DBG("push req type(%d)-pid(%d)-cid(%d)-len(%d)", req.type, req.pid, req.handle, asyncq->length());\r
-\r
- CMessage *msg = new CMessage(&req);\r
- asyncq->push(msg);\r
- }\r
-\r
- return NULL;\r
-}\r
-\r
-gpointer CMessageHandler::msgThread(gpointer data)\r
-{\r
- assert(data);\r
- SERVER_INFO("prepare to handle messages");\r
-\r
- CMessageHandler *msg_handler = (CMessageHandler*) data;\r
-\r
- while (1) {\r
- msg_handler->ProcessMessage();\r
- usleep(30000);\r
- }\r
-\r
- return NULL;\r
-}\r
-\r
-bool CMessageHandler::IsRegisteredHandle(int handle)\r
-{\r
- return (CConsumerContainer::getInstance()->findConsumer(handle) != NULL);\r
-}\r
-\r
-void CMessageHandler::SetRequesterInfo(rms_msg_request *request)\r
-{\r
- char *app_id = m_handle_mgr->GetAppID(request->handle);\r
- m_handle_mgr->GetPriority(request->handle, &request->main_priority, &request->sub_priority);\r
-\r
- snprintf(request->app_id, RMS_APPID_LENGTH, "%s", (app_id) ? app_id : "");\r
-\r
- SERVER_INFO("handle(%d)-app_id(%s)", request->handle, request->app_id);\r
-\r
- if (app_id)\r
- free(app_id);\r
-}\r
-\r
-\r
-void CMessageHandler::m_RegisterConsumer(rms_msg_request *request, rms_msg_response *response)\r
-{\r
- char cmd[RMS_NAME_BUF_SIZE] = {0,};\r
-\r
- int handle = m_handle_mgr->GetNewHandle(request->pid, request->main_priority, request->sub_priority, request->app_pid, request->app_id);\r
-\r
- response->result = (handle == RMS_HANDLE_NOT_AVAILABLE) ? RMS_ERROR : RMS_OK;\r
-\r
- m_ConstructResponse(response, request->data_type, RMS_RESPONSE_REGISTER, handle, request->pid);\r
-\r
- if (response->result == RMS_ERROR)\r
- return;\r
-\r
- if (m_rsc_mgr->RegisterConsumer(handle, request->pid, request->app_id, request->main_priority, request->sub_priority) != RMS_OK)\r
- SERVER_ERR("failed to add consumer to manager. handle[%d]", handle);\r
-\r
- rms_get_cmd_name(request->pid, cmd, sizeof(cmd));\r
-\r
- SERVER_INFO("newly assigned handle(%d) - pid(%d)-(%s)", response->handle, request->pid, cmd);\r
-}\r
-\r
-void CMessageHandler::m_UnregisterConsumer(rms_msg_request *request, rms_msg_response *response)\r
-{\r
- SERVER_INFO("request for unregister handle(%d)", request->handle);\r
-\r
- m_ConstructResponse(response, request->data_type, RMS_RESPONSE_UNREGISTER, request->handle, request->pid);\r
-\r
- if (!IsRegisteredHandle(request->handle)) {\r
- response->result = RMS_ERROR;\r
- return;\r
- }\r
-\r
- response->result = m_handle_mgr->RemoveHandle(request->handle, request->pid);\r
-\r
- if (response->result != RMS_OK)\r
- return;\r
-\r
- m_rsc_mgr->UnregisterConsumer(request->handle);\r
-}\r
-\r
-void CMessageHandler::m_FreeAllocatedDevice(rms_return_device_s *allocated_device)\r
-{\r
- if (allocated_device->device_ids) {\r
- free(allocated_device->device_ids);\r
- allocated_device->device_ids = NULL;\r
- }\r
-\r
- for (int i=0 ; i < allocated_device->resources_num; i++) {\r
- if (allocated_device->devices[i].device_path) {\r
- free((void*)allocated_device->devices[i].device_path);\r
- allocated_device->devices[i].device_path = NULL;\r
- }\r
- }\r
-\r
- if (allocated_device->devices) {\r
- free(allocated_device->devices);\r
- allocated_device->devices = NULL;\r
- }\r
-}\r
-\r
-void CMessageHandler::m_Free(consumer_reclaim_s *consumer_info)\r
-{\r
- if (!consumer_info)\r
- return;\r
-\r
- if (!consumer_info->consumer_info)\r
- return;\r
-\r
- for (int i = 0; i < consumer_info->ret_quantity; i++) {\r
- if (consumer_info->consumer_info[i].conflicted_resources != NULL)\r
- free(consumer_info->consumer_info[i].conflicted_resources);\r
- }\r
-\r
- free(consumer_info->consumer_info);\r
-}\r
-\r
-void CMessageHandler::m_AllocateResources(rms_msg_request *request, rms_msg_response *response)\r
-{\r
- trace_begin("RSC ALLOCATE START");\r
- trace_end();\r
-\r
- if (!IsRegisteredHandle(request->handle)) {\r
- m_ConstructResponse(response, request->data_type, RMS_RESPONSE_ALLOCATE_RESOURCE, request->handle, request->pid);\r
- response->result = RMS_ERROR;\r
- return;\r
- }\r
-\r
- int result = RMS_OK;\r
- bool need_response = true;\r
- rms_return_device_s allocated_device;\r
- memset(&allocated_device, 0, sizeof(rms_return_device_s));\r
-\r
- m_handle_mgr->ReclaimAllInvalidCustomer(request->pid);\r
-\r
- SetRequesterInfo(request);\r
-\r
- result = m_rsc_mgr->AllocateResources(request, &allocated_device);\r
-\r
- bool needReclaimResources = (result == RMS_ERROR_TAKE_RESOURCE_FROM_OTHER_CONSUMER);\r
-\r
- if (needReclaimResources) {\r
- consumer_reclaim_s consumers_reclaim;\r
- memset(&consumers_reclaim, 0, sizeof(consumers_reclaim));\r
- int zone_id = -1;\r
- if (m_rsc_mgr->FindReclaimableConsumers(request, &consumers_reclaim, &zone_id) == RMS_OK) {\r
- CResourceDB::getInstance()->AddReclaimResources(&consumers_reclaim);\r
- if (ReclaimResources(result, request->handle, zone_id, &consumers_reclaim, &need_response) == RMS_OK) {\r
- result = m_rsc_mgr->AllocateResources(request, &allocated_device);\r
- }\r
- CResourceDB::getInstance()->ClearReclaimResources();\r
- }\r
- m_Free(&consumers_reclaim);\r
- }\r
-\r
- m_ConstructResponse(response, request->data_type, RMS_RESPONSE_ALLOCATE_RESOURCE, request->handle, request->pid);\r
-\r
- response->result = result;\r
- response->error_type = (result == RMS_OK) ? RMS_ERR_TYPE_NONE : (rms_error_type_e)allocated_device.error_type;\r
- response->resource_num = allocated_device.resources_num;\r
-\r
- if (!need_response)\r
- response->error_type = RMS_ERR_TYPE_TERMINATED_PROCESS;\r
-\r
- for (int i = 0; i < response->resource_num; i++) {\r
- response->resource[i] = allocated_device.device_ids[i];\r
- }\r
-\r
- m_FreeAllocatedDevice(&allocated_device);\r
- CCache::getInstance()->Drop();\r
-\r
- trace_begin("RSC ALLOCATE END");\r
- trace_end();\r
-}\r
-\r
-void CMessageHandler::m_ReleaseResources(rms_msg_request *request, rms_msg_response *response)\r
-{\r
- SERVER_DBG("request for deallocation");\r
-\r
- m_ConstructResponse(response, request->data_type, RMS_RESPONSE_RELEASE_RESOURCES, request->handle, request->pid);\r
-\r
- if (!IsRegisteredHandle(request->handle)) {\r
- response->result = RMS_ERROR;\r
- return;\r
- }\r
-\r
- rms_requests_device_s requested_resource;\r
- memset(&requested_resource, 0, sizeof(rms_requests_device_s));\r
-\r
- m_ConstructRequestedDevice(request, &requested_resource);\r
-\r
- response->result = m_rsc_mgr->ReleaseResources(request->handle, &requested_resource);\r
-}\r
-\r
-void CMessageHandler::m_Query(rms_msg_request *request, rms_msg_response *response)\r
-{\r
- int answer = 0;\r
-\r
- m_ConstructResponse(response, request->data_type, RMS_RESPONSE_QUERY, request->handle, request->pid);\r
-\r
- m_handle_mgr->ReclaimAllInvalidCustomer(request->handle);\r
-\r
- response->result = m_query_h->GetAnswer(request, &answer);\r
- response->is_available = answer;\r
-\r
- SERVER_INFO("query on (%d), result(%d)", request->sub_type, answer);\r
-}\r
-\r
-void CMessageHandler::m_SetConsumerPriority(rms_msg_request *request, rms_msg_response *response)\r
-{\r
- SERVER_INFO("request for priority setting. priority(%d)", request->main_priority);\r
-\r
- m_ConstructResponse(response, request->data_type, RMS_RESPONSE_SET_PRIORITY, request->handle, request->pid);\r
-\r
- response->result = m_handle_mgr->SetPriority(request->handle, request->main_priority, request->sub_priority);\r
-}\r
-\r
-void CMessageHandler::m_SetAppID(rms_msg_request *request, rms_msg_response *response)\r
-{\r
- SERVER_INFO("request for appid setting. appid(%s)", request->app_id);\r
-\r
- m_ConstructResponse(response, request->data_type, RMS_RESPONSE_SET_APPID, request->handle, request->pid);\r
-\r
- int ret = m_handle_mgr->SetAppID(request->handle, request->app_id);\r
-\r
- if (ret != RMS_OK) {\r
- SERVER_ERR("cannot update appid. handle(%d). ret(%d)", request->handle, ret);\r
-\r
- response->result = RMS_ERROR;\r
- return;\r
- }\r
-\r
- response->result = m_rsc_mgr->SetAppId(request->handle, request->app_id);\r
-}\r
-\r
-CMessageHandler::msg_handler CMessageHandler::handlers[RMS_REQUEST_MAX] = {\r
- &CMessageHandler::m_RegisterConsumer,\r
- &CMessageHandler::m_UnregisterConsumer,\r
- &CMessageHandler::m_AllocateResources,\r
- &CMessageHandler::m_ReleaseResources,\r
- &CMessageHandler::m_Query,\r
- &CMessageHandler::m_SetConsumerPriority,\r
- &CMessageHandler::m_SetAppID,\r
-};\r
-\r
-void CMessageHandler::ProcessMsgQMessage(CMessage *msg)\r
-{\r
- if (!IsValidRequest(msg->GetReqType())) {\r
- SERVER_ERR("invalid req type(%d)", msg->GetReqType());\r
- return;\r
- }\r
-\r
- rms_msg_response resp;\r
- memset(&resp, 0, sizeof(rms_msg_response));\r
-\r
- rms_msg_request *req = msg->GetRequest();\r
- SERVER_INFO("req type(%d)-pid(%d)-cid(%d)-t(%lu)", req->type, req->pid, req->handle, req->time);\r
-\r
- (this->*handlers[req->type])(msg->GetRequest(), &resp);\r
-\r
- if (resp.error_type == RMS_ERR_TYPE_TERMINATED_PROCESS) {\r
- SERVER_ERR("skip to send a response (%d)", req->pid);\r
- return;\r
- }\r
-\r
- if (msgq_tx->send(&resp) != RMS_OK) {\r
- SERVER_ERR("failed to send response");\r
- }\r
-}\r
-\r
-GVariant *CMessageHandler::RegisterResource(GVariant *params)\r
-{\r
- char *dev_name;\r
- char *dev_node;\r
- int category;\r
- int sharable_count;\r
-\r
- g_variant_get(params, "(&ssii)", &dev_name, &dev_node, &category, &sharable_count);\r
-\r
- SERVER_INFO("dev_name(%s)/dev_node(%s)/category(%d)/sharable(%d)", dev_name, dev_node, category, sharable_count);\r
- return g_variant_new("(i)", RMS_OK);\r
-}\r
-\r
-GVariant *CMessageHandler::GetResourceState(GVariant *params)\r
-{\r
- int device_id;\r
- int state;\r
-\r
- g_variant_get(params, "(i)", &device_id);\r
-\r
- state = m_rsc_mgr->GetResourceState(device_id);\r
-\r
- SERVER_INFO("state (%d:%d)", device_id, state);\r
-\r
- return g_variant_new("(i)", state);\r
-}\r
-\r
-GVariant *CMessageHandler::FindDeviceId(GVariant *params)\r
-{\r
- int virtual_id;\r
- int real_id;\r
-\r
- g_variant_get(params, "(i)", &virtual_id);\r
-\r
- real_id = m_rsc_mgr->FindDeviceId(virtual_id);\r
-\r
- SERVER_INFO("real id (%d:%d)", virtual_id, real_id);\r
-\r
- return g_variant_new("(i)", real_id);\r
-}\r
-\r
-GVariant *CMessageHandler::GetScalerHWID(GVariant *params)\r
-{\r
- int zone_id;\r
- int hw_id;\r
-\r
- g_variant_get(params, "(i)", &zone_id);\r
-\r
- hw_id = m_rsc_mgr->GetScalerHWId(zone_id);\r
-\r
- SERVER_INFO("hw id (%d:%d)", zone_id, hw_id);\r
-\r
- return g_variant_new("(i)", hw_id);\r
-}\r
-\r
-GVariant *CMessageHandler::SwapResources(GVariant *params)\r
-{\r
- int device_id_a;\r
- int device_id_b;\r
- int result = 0;\r
-\r
- g_variant_get(params, "(ii)", &device_id_a, &device_id_b);\r
-\r
- result = m_rsc_mgr->SwapResources(device_id_a, device_id_b);\r
-\r
- SERVER_INFO("swap result (%d:%d) > (%d)", device_id_a, device_id_b, result);\r
-\r
- return g_variant_new("(i)", result);\r
-}\r
-\r
-GVariant *CMessageHandler::RestoreResources(GVariant *params)\r
-{\r
- int category_id;\r
- int result = 0;\r
-\r
- g_variant_get(params, "(i)", &category_id);\r
-\r
- result = m_rsc_mgr->RestoreResources(category_id);\r
-\r
- SERVER_INFO("restore result (%d) > (%d)", category_id, result);\r
-\r
- return g_variant_new("(i)", result);\r
-}\r
-\r
-GVariant *CMessageHandler::NotifyResourcePolicy(GVariant *params)\r
-{\r
- int policy;\r
- int result = 0;\r
-\r
- g_variant_get(params, "(i)", &policy);\r
-\r
- m_rsc_mgr->ResetZoneIds();\r
-\r
- SERVER_INFO("notify result (%d) > (%d)", policy, result);\r
- return g_variant_new("(i)", result);\r
-}\r
-\r
-GVariant *CMessageHandler::NotifyAppZoneInfo(GVariant *params)\r
-{\r
- char *app_id;\r
- int zone_id;\r
- int result = 0;\r
-\r
- g_variant_get(params, "(&si)", &app_id, &zone_id);\r
-\r
- if (!app_id) {\r
- result = -1;\r
- SERVER_INFO("invalid param (%s:%d) - result(%d)", "null", zone_id, result);\r
- return g_variant_new("(i)", result);\r
- }\r
-\r
- m_rsc_mgr->UpdateZoneIds(app_id, zone_id);\r
-\r
- SERVER_INFO("notify result (%s:%d) > (%d)", app_id, zone_id, result);\r
- return g_variant_new("(i)", result);\r
-}\r
-\r
-GVariant *CMessageHandler::GetResourceList(GVariant *params)\r
-{\r
- int category_id;\r
-\r
- g_variant_get(params, "(i)", &category_id);\r
-\r
- SERVER_DBG("category (%d)", category_id);\r
-\r
- GVariantBuilder builder;\r
- g_variant_builder_init(&builder, G_VARIANT_TYPE("(a(iissi))"));\r
-\r
- g_variant_builder_open(&builder, G_VARIANT_TYPE("a(iissi)"));\r
- m_rsc_mgr->GetResourceList(category_id, &builder);\r
- g_variant_builder_close(&builder);\r
-\r
- return g_variant_builder_end(&builder);\r
-}\r
-\r
-GVariant *CMessageHandler::GetScalerState(GVariant *params)\r
-{\r
- SERVER_INFO("GetScalerState");\r
-\r
- GVariantBuilder builder;\r
- g_variant_builder_init(&builder, G_VARIANT_TYPE("(a(iiiiis))"));\r
-\r
- g_variant_builder_open(&builder, G_VARIANT_TYPE("a(iiiiis)"));\r
- m_rsc_mgr->GetScalerState(&builder);\r
- g_variant_builder_close(&builder);\r
-\r
- return g_variant_builder_end(&builder);\r
-}\r
-\r
-GVariant *CMessageHandler::GetAppId(GVariant *params)\r
-{\r
- int result = 0;\r
- int handle;\r
- g_variant_get(params, "(i)", &handle);\r
-\r
- SERVER_INFO("GetAppId(%d)", handle);\r
-\r
- CConsumer *consumer = CConsumerContainer::getInstance()->findConsumer(handle);\r
- if (!consumer) {\r
- SERVER_ERR("consumer(%d) not found", handle);\r
- result = -1;\r
- return g_variant_new("(is)", result, "");\r
- }\r
-\r
- return g_variant_new("(is)", result, (consumer->GetAppID().empty()) ? consumer->GetCmdName().c_str() : consumer->GetAppID().c_str());\r
-}\r
-\r
-GVariant *CMessageHandler::GetResourceCollectionState(GVariant *params)\r
-{\r
- int collection;\r
-\r
- g_variant_get(params, "(i)", &collection);\r
-\r
- SERVER_INFO("collection (%d)", collection);\r
-\r
- GVariantBuilder builder;\r
- g_variant_builder_init(&builder, G_VARIANT_TYPE("(a(isiiis))"));\r
-\r
- g_variant_builder_open(&builder, G_VARIANT_TYPE("a(isiiis)"));\r
- m_rsc_mgr->GetResourceCollectionState(collection, &builder);\r
- g_variant_builder_close(&builder);\r
-\r
- return g_variant_builder_end(&builder);\r
-}\r
-\r
-GVariant *CMessageHandler::GetActiveAudioOut(GVariant *params)\r
-{\r
- int cid;\r
- int active_audio_out;\r
-\r
- g_variant_get(params, "(i)", &cid);\r
-\r
- active_audio_out = m_rsc_mgr->GetActiveAudioOut(cid);\r
- SERVER_INFO("active_audio_out(%d:%d)", cid, active_audio_out);\r
-\r
- return g_variant_new("(i)", active_audio_out);\r
-}\r
-\r
-void CMessageHandler::ProcessDbusMessage(CMessage *msg)\r
-{\r
- GDBusMethodInvocation *invoc = msg->GetMethodInvocation();\r
- std::string method_name(g_dbus_method_invocation_get_method_name(invoc));\r
-\r
- auto it = m_dbus_handlers.find(method_name);\r
- if (it == m_dbus_handlers.end()) {\r
- SERVER_ERR("handler is not found (%s)", method_name.c_str());\r
- return;\r
- }\r
-\r
- GVariant *params = g_dbus_method_invocation_get_parameters(invoc);\r
- GVariant *result = (this->*(it->second))(params);\r
-\r
- g_dbus_method_invocation_return_value(invoc, result);\r
-}\r
-\r
-void CMessageHandler::ProcessInternalMessage(CMessage *msg)\r
-{\r
- auto it = m_internal_msg_handlers.find(msg->GetName());\r
- if (it == m_internal_msg_handlers.end()) {\r
- SERVER_ERR("handler is not found (%s)", msg->GetName().c_str());\r
- return;\r
- }\r
-\r
- (this->*(it->second))(NULL);\r
-}\r
-\r
-void CMessageHandler::EmptyPendingQueue(void)\r
-{\r
- if (async_pending_queue->length() <= 0)\r
- return;\r
-\r
- SERVER_WARN("empty pending queue(%d)", async_pending_queue->length());\r
- async_queue->push(async_pending_queue);\r
-}\r
-\r
-void CMessageHandler::InsertPendingQueue(CMessage *msg)\r
-{\r
- SERVER_WARN("msg locked");\r
- msg->PrintInfo();\r
- async_pending_queue->push(msg);\r
-}\r
-\r
-int CMessageHandler::ProcessMessage(void)\r
-{\r
- CMessage *msg = (CMessage*) async_queue->pop();\r
- assert(msg);\r
-\r
- if ((m_lock_ctr->GetLockCount() > 0) && m_lock_ctr->IsLocked(msg)) {\r
- InsertPendingQueue(msg);\r
- return 0;\r
- }\r
-\r
- if (msg->IsUnlockMsg()) {\r
- EmptyPendingQueue();\r
- delete msg;\r
- return 0;\r
- }\r
-\r
- switch (msg->GetSender()) {\r
- case MSG_SENDER_MSGQ:\r
- ProcessMsgQMessage(msg);\r
- break;\r
- case MSG_SENDER_DBUS:\r
- ProcessDbusMessage(msg);\r
- break;\r
- case MSG_SENDER_INTERNAL:\r
- ProcessInternalMessage(msg);\r
- break;\r
- default:\r
- break;\r
- }\r
-\r
- delete msg;\r
-\r
- return 0;\r
-}\r
-\r
-bool CMessageHandler::IsAllResourcesReclaimed(rms_consumer_tobe_returned_s *consumer_info)\r
-{\r
- for (int idx = 0; idx < consumer_info->n_conflicted; idx++) {\r
- if (!m_rsc_mgr->IsReclaimed(consumer_info->conflicted_resources[idx].device_id, consumer_info->consumer_id)) {\r
- SERVER_WARN("IsReclaimed is failed");\r
- return false;\r
- }\r
- }\r
-\r
- SERVER_WARN("all conflicted resources are freed");\r
-\r
- return true;\r
-}\r
-\r
-void CMessageHandler::ProcessMessage(CAsyncQueue *queue, CMessage *msg, int cid_requester, int cid_releaser)\r
-{\r
- rms_msg_request *req = msg->GetRequest();\r
- rms_msg_response resp;\r
- int handle;\r
- char cmd[RMS_NAME_BUF_SIZE] = {0,};\r
-\r
- switch (req->type) {\r
- case RMS_REQUEST_RELEASE_RESOURCES:\r
-\r
- rms_requests_device_s requested_resource;\r
- memset(&requested_resource, 0, sizeof(rms_requests_device_s));\r
-\r
- m_ConstructResponse(&resp, req->data_type, RMS_RESPONSE_RELEASE_RESOURCES, req->handle, req->pid);\r
- m_ConstructRequestedDevice(req, &requested_resource);\r
-\r
- if ((resp.result = m_rsc_mgr->ReleaseResources(req->handle, &requested_resource)) != RMS_OK)\r
- SERVER_ERR("failed to release resources requested by (%d)", req->handle);\r
-\r
- SendResponse(&resp);\r
-\r
- break;\r
-\r
- case RMS_REQUEST_UNREGISTER:\r
-\r
- m_ConstructResponse(&resp, req->data_type, RMS_RESPONSE_UNREGISTER, req->handle, req->pid);\r
-\r
- SERVER_WARN("unregister requested by handle(%d)", req->handle);\r
-\r
- if (req->handle == cid_requester) {\r
- SERVER_WARN("unregister request from requester(%d), send to internal queue", req->handle);\r
-\r
- PushMessage(queue, msg);\r
- } else {\r
- if ((resp.result = m_handle_mgr->RemoveHandle(req->handle, req->pid)) == RMS_OK) {\r
- m_rsc_mgr->UnregisterConsumer(req->handle);\r
- }\r
-\r
- SendResponse(&resp);\r
- }\r
- break;\r
-\r
- case RMS_REQUEST_REGISTER:\r
- handle = m_handle_mgr->GetNewHandle(req->pid, req->main_priority, req->sub_priority, req->app_pid, req->app_id);\r
-\r
- resp.result = (handle == RMS_HANDLE_NOT_AVAILABLE) ? RMS_ERROR : RMS_OK;\r
- m_ConstructResponse(&resp, req->data_type, RMS_RESPONSE_REGISTER, handle, req->pid);\r
-\r
- if (resp.result == RMS_ERROR) {\r
- SendResponse(&resp);\r
- break;\r
- }\r
-\r
- if (m_rsc_mgr->RegisterConsumer(handle, req->pid, req->app_id, req->main_priority, req->sub_priority) != RMS_OK)\r
- SERVER_ERR("failed to add consumer to manager. handle[%d]", handle);\r
-\r
- rms_get_cmd_name(req->pid, cmd, sizeof(cmd));\r
-\r
- SERVER_INFO("newly assigned handle(%d) date type(%ld)- pid(%d)-(%s)", resp.handle, req->data_type, req->pid, cmd);\r
- SendResponse(&resp);\r
- break;\r
-\r
- default:\r
- SERVER_ERR("unexpected request(%d) by handle(%d)/pid(%d)", req->type, req->handle, req->pid);\r
-\r
- if (req->handle == cid_releaser) {\r
- m_ConstructResponse(&resp, req->data_type, (rms_response_type_e)req->type, req->handle, req->pid);\r
- resp.result = RMS_ERROR;\r
-\r
- SendResponse(&resp);\r
- } else {\r
- PushMessage(queue, msg);\r
- }\r
- break;\r
- }\r
-}\r
-\r
-int CMessageHandler::ProcessCallbackMessage(rms_consumer_tobe_returned_s *consumer_info, int requester_cid)\r
-{\r
- CMessage *msg = NULL;\r
- int result = RMS_OK;\r
- CAsyncQueue *queue = new CAsyncQueue();\r
-\r
- unsigned int timeout_ms = CCallback::GetTimeout();\r
-\r
- while (!IsAllResourcesReclaimed(consumer_info)) {\r
- msg = (CMessage*) async_queue->pop(timeout_ms);\r
-\r
- if (!msg) {\r
- SERVER_ERR("receive cb request timeout! CID[%d]/PID[%ld]", consumer_info->consumer_id, consumer_info->process_id);\r
- result = RMS_ERROR;\r
- goto out;\r
- }\r
-\r
- if (msg->GetSender() == MSG_SENDER_DBUS) {\r
- ProcessDbusMessage(msg);\r
- } else if (msg->GetSender() == MSG_SENDER_MSGQ) {\r
- SERVER_WARN("[MSG_SENDER_MSGQ] requester cid %d consumer id %d", requester_cid, consumer_info->consumer_id);\r
- ProcessMessage(queue, msg, requester_cid, consumer_info->consumer_id);\r
- } else {\r
- ProcessInternalMessage(msg);\r
- }\r
-\r
- delete msg;\r
- }\r
-\r
-out:\r
- async_queue->push_front(queue);\r
-\r
- delete queue;\r
-\r
- return result;\r
-}\r
-\r
-int *CMessageHandler::m_SerializeCallbackData(const rms_consumer_tobe_returned_s *consumer_info, int reason, int *data_size)\r
-{\r
- int num_conflicted_resources = consumer_info->n_conflicted;\r
-\r
- int *callback_data = (int*) calloc(num_conflicted_resources + 4, sizeof(int));\r
- assert(callback_data);\r
-\r
- callback_data[0] = CCallback::ConvertCallbackType(reason);\r
- callback_data[1] = consumer_info->consumer_id;\r
- callback_data[2] = consumer_info->process_id;\r
- callback_data[3] = num_conflicted_resources;\r
-\r
- for (int res = 0; res < num_conflicted_resources; res++) {\r
- callback_data[(res+4)] = consumer_info->conflicted_resources[res].virtual_id;\r
- SERVER_DBG("- virtual_id:%d ", consumer_info->conflicted_resources[res].virtual_id);\r
- }\r
-\r
- *data_size = (num_conflicted_resources + 4) * sizeof(int);\r
-\r
- return callback_data;\r
-}\r
-\r
-bool CMessageHandler::IsValidProcess(int pid)\r
-{\r
- return rm_is_valid_pid(pid);\r
-}\r
-\r
-bool CMessageHandler::IsValidRequest(int req_type)\r
-{\r
- return (req_type >= RMS_REQUEST_REGISTER && req_type < RMS_REQUEST_MAX);\r
-}\r
-\r
-int CMessageHandler::ReleaseInvalidProcessResources(int pid, int handle)\r
-{\r
- m_handle_mgr->RemoveHandle(handle, pid);\r
- CCallback::RemoveFIFOServerToClient(pid, handle);\r
-\r
- return RMS_OK;\r
-}\r
-\r
-void CMessageHandler::NotifyConflict(consumer_reclaim_s *conflict_info, int zone_id)\r
-{\r
- if (!conflict_info)\r
- return;\r
-\r
- int consumer_id = -1;\r
- int device_id = -1;\r
- int category_id = -1;\r
- int app_zone_id = -1;\r
- int n_consumer = conflict_info->ret_quantity;\r
- CConsumer *consumer = NULL;\r
-\r
- GError *error = NULL;\r
- GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);\r
-\r
- if (!connection) {\r
- SERVER_ERR("failed to get connection (%s)", (error) ? error->message : "unknown");\r
- goto out;\r
- }\r
-\r
- for (int i = 0; i < n_consumer; i++) {\r
- consumer_id = conflict_info->consumer_info[i].consumer_id;\r
- consumer = CConsumerContainer::getInstance()->findConsumer(consumer_id);\r
-\r
- for (int j = 0; j < conflict_info->consumer_info[i].n_conflicted; j++) {\r
- device_id = conflict_info->consumer_info[i].conflicted_resources[j].device_id;\r
- app_zone_id = m_rsc_mgr->GetZoneId(device_id);\r
- category_id = conflict_info->consumer_info[i].conflicted_resources[j].category_id;\r
- SERVER_INFO("send resource conflict (%d:%d:%d:%s:%d:%d)",\r
- category_id, device_id, consumer_id, (consumer->GetAppID().empty()) ? consumer->GetCmdName().c_str() : consumer->GetAppID().c_str(), app_zone_id, zone_id);\r
- if (!g_dbus_connection_emit_signal(connection,\r
- NULL,\r
- RM_DBUS_OBJ_PATH,\r
- RM_DBUS_INTERFACE_NAME,\r
- "RscConflicted",\r
- g_variant_new("(iiisii)", category_id, device_id, consumer_id,\r
- (consumer->GetAppID().empty()) ? consumer->GetCmdName().c_str() : consumer->GetAppID().c_str(), app_zone_id, zone_id),\r
- &error)) {\r
- SERVER_ERR("failed to send resource conflict (%d:%d:%d:%s)-%s", category_id, device_id, consumer_id,\r
- (consumer->GetAppID().empty()) ? consumer->GetCmdName().c_str():consumer->GetAppID().c_str(), (error) ? error->message : "unknown");\r
- }\r
- }\r
- }\r
-out:\r
- if (error)\r
- g_error_free(error);\r
-}\r
-\r
-int CMessageHandler::ReclaimResources(int reason, int requester_cid, int requester_zone_id, consumer_reclaim_s *conflict_info, bool *need_response)\r
-{\r
- int num_consumers = conflict_info->ret_quantity;\r
- int data_size = 0;\r
- int *callback_data = NULL;\r
- char cmd[RMS_NAME_BUF_SIZE] = {0,};\r
- int err = 0;\r
- int cid = 0;\r
- int pid = 0;\r
-\r
- SERVER_WARN("start to reclaim - retirable consumers : (%d)", num_consumers);\r
-\r
- if (num_consumers > 0)\r
- NotifyConflict(conflict_info, requester_zone_id);\r
-\r
- for (int i = 0; i < num_consumers; i++) {\r
- pid = (int) conflict_info->consumer_info[i].process_id;\r
- cid = conflict_info->consumer_info[i].consumer_id;\r
-\r
- if (!IsValidProcess(pid)) {\r
- SERVER_ERR("handle(%d)/pid(%d) terminated", cid, pid);\r
- m_rsc_mgr->ReleaseResourcesOfPid(pid);\r
- ReleaseInvalidProcessResources(pid, cid);\r
- continue;\r
- }\r
-\r
- SERVER_DBG("[%d]th cid[%d]/rscs[%d]", i+1, cid, conflict_info->consumer_info[i].n_conflicted);\r
-\r
- callback_data = m_SerializeCallbackData(&conflict_info->consumer_info[i], reason, &data_size);\r
-\r
- if (CCallback::SendCallbackMessage(cid, pid, (void*) callback_data, data_size, &err) != RMS_OK) {\r
- if (err == ENXIO) { //ENXIO No such device or address\r
- SERVER_ERR("Process cannot get callback (CID:%d)/(PID:%d)", cid, pid);\r
- m_rsc_mgr->ReleaseResourcesOfPid(pid);\r
- ReleaseInvalidProcessResources(pid, cid);\r
- free(callback_data);\r
- continue;\r
- }\r
-\r
- if (err == ENOENT && !IsRegisteredHandle(cid)) {\r
- SERVER_ERR("already unregistred (%d)", cid);\r
- free(callback_data);\r
- continue;\r
- }\r
-\r
- SERVER_ERR("failed to send callback message to (CID:%d)/(PID:%d), errno(%d)", cid, pid, err);\r
- free(callback_data);\r
- return RMS_ERROR;\r
- }\r
-\r
- SERVER_WARN("[%d]th callback message sent to CID[%d]/PID[%d]/RSCS[%d]", i+1, cid, pid, conflict_info->consumer_info[i].n_conflicted);\r
-\r
- if (ProcessCallbackMessage(&conflict_info->consumer_info[i], requester_cid) != RMS_OK) {\r
- if (!IsValidProcess(pid)) {\r
- SERVER_ERR("handle(%d)/pid(%d) terminated", cid, pid);\r
- m_rsc_mgr->ReleaseResourcesOfPid(pid);\r
- ReleaseInvalidProcessResources(pid, cid);\r
- free(callback_data);\r
-\r
- if (!IsRegisteredHandle(requester_cid)) {\r
- SERVER_ERR("requester(%d:%d) terminated as well", pid, requester_cid);\r
- *need_response = false;\r
- return RMS_ERROR;\r
- }\r
- continue;\r
- }\r
-\r
- rms_get_cmd_name(pid, cmd, sizeof(cmd));\r
- SERVER_ERR("failed to process callback request from : (%s) /(CID:%d)/(PID:%d)", cmd, cid, pid);\r
-\r
- rms_display_timeout_error_popup(RMS_ALARM_NO_DEALLOCATION, conflict_info->consumer_info[i]);\r
- int ret = rms_report_emergency(cid, pid, RMS_EMERGENCY_CONSUMER_NOT_RESPONDING);\r
-\r
- SERVER_ERR("release resources of cosumer(%d) forcely", pid);\r
- m_rsc_mgr->UnregisterConsumer(cid);\r
- m_handle_mgr->RemoveHandle(cid, pid);\r
-\r
- free(callback_data);\r
- return ret;\r
- }\r
-\r
- free(callback_data);\r
- }\r
-\r
- return RMS_OK;\r
-}\r
-\r
-int CMessageHandler::SendResponse(rms_msg_response *response)\r
-{\r
- return msgq_tx->send(response);\r
-}\r
-\r
-int CMessageHandler::PushMessage(CAsyncQueue *queue, CMessage *msg)\r
-{\r
- CMessage *msg_copy = new CMessage(msg->GetRequest());\r
- rms_msg_request *req = msg->GetRequest();\r
- SERVER_INFO("push_front msg type(%d)-pid(%d)-cid(%d)", req->type, req->pid, req->handle);\r
-\r
- queue->push_front(msg_copy);\r
-\r
- return RMS_OK;\r
-}\r
-\r
-void CMessageHandler::m_ConstructResponse(rms_msg_response *response, int data_type, rms_response_type_e msg_type, int handle, int pid)\r
-{\r
- assert(response);\r
-\r
- response->data_type = data_type;\r
- response->type = msg_type;\r
- response->handle = handle;\r
- response->pid = pid;\r
-}\r
-\r
-void CMessageHandler::NotifyWatchdog(void)\r
-{\r
- if (!async_queue)\r
- return;\r
-\r
- SERVER_INFO("push watchdog msg");\r
- async_queue->push(new CMessage("NotifyWatchdog"));\r
-}\r
-\r
-GVariant *CMessageHandler::NotifyWatchdog(GVariant *params)\r
-{\r
- SERVER_INFO("send watchdog notify completed");\r
- return NULL;\r
-}\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <unistd.h>
+#include <errno.h>
+#include <trace.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <gio/gio.h>
+
+#include <CMessage.h>
+#include <CMessageHandler.h>
+#include <CCallback.h>
+#include <CDebugUtils.h>
+#include <rms_debug.h>
+#include <CHandleManager.h>
+#include <CResourceManager.h>
+#include <CConsumerContainer.h>
+#include <CQueryHandler.h>
+#include <CAsyncQueue.h>
+#include <CCache.h>
+#include <CDbusHandler.h>
+
+#define RMS_HANLDE_COMMON 100 // common handle for the request rm_register() is not required
+#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
+
+struct rms_msg_handler {
+ const char *msg_name;
+ CMessageHandler::MsgHandler handler;
+};
+
+CMessageHandler::CMessageHandler(CResourceManager *rsc_mgr)
+{
+ assert(rsc_mgr);
+
+ msgq_rx = new CMessageQueue(MSG_QUEUE_RX);
+ msgq_tx = new CMessageQueue(MSG_QUEUE_TX);
+ async_queue = new CAsyncQueue();
+ async_pending_queue = new CAsyncQueue();
+
+ m_rsc_mgr = rsc_mgr;
+ m_query_h = new CQueryHandler(rsc_mgr);
+ m_handle_mgr = new CHandleManager(rsc_mgr);
+ m_lock_ctr = CLockController::GetInstance();
+ m_lock_ctr->SetMsgQ(async_queue);
+
+ CCallback::InitCallback();
+ InitDbusHandlers();
+ InitInternalMsgHandlers();
+}
+
+CMessageHandler::~CMessageHandler(void)
+{
+
+}
+
+void CMessageHandler::InitDbusHandlers(void)
+{
+ struct rms_msg_handler dbus_handlers[] = {
+ {"RegisterResource", &CMessageHandler::RegisterResource},
+ {"GetResourceState", &CMessageHandler::GetResourceState},
+ {"GetResourceList", &CMessageHandler::GetResourceList},
+ {"GetRscCollectionState", &CMessageHandler::GetResourceCollectionState},
+ {"FindDeviceId", &CMessageHandler::FindDeviceId},
+ {"SwapResources", &CMessageHandler::SwapResources},
+ {"GetScalerState", &CMessageHandler::GetScalerState},
+ {"GetAppId", &CMessageHandler::GetAppId},
+ {"GetActiveAudioOut", &CMessageHandler::GetActiveAudioOut},
+ {"GetScalerHWID", &CMessageHandler::GetScalerHWID},
+ {"RestoreResources", &CMessageHandler::RestoreResources},
+ {"NotifyResourcePolicy", &CMessageHandler::NotifyResourcePolicy},
+ {"NotifyAppZoneInfo", &CMessageHandler::NotifyAppZoneInfo}
+ // Please add a new dbus message handler here
+ };
+
+ std::string msg_name;
+ for (unsigned int i = 0; i < ARRAY_SIZE(dbus_handlers); i++) {
+ msg_name.assign(dbus_handlers[i].msg_name);
+ m_dbus_handlers.insert(std::pair<std::string, CMessageHandler::MsgHandler>(msg_name, dbus_handlers[i].handler));
+ }
+}
+
+void CMessageHandler::InitInternalMsgHandlers(void)
+{
+ struct rms_msg_handler internal_msg_handlers[] = {
+ {"NotifyWatchdog", &CMessageHandler::NotifyWatchdog}
+ // Please add a new internal message handler here
+ };
+
+ std::string msg_name;
+ for (unsigned int i = 0; i < ARRAY_SIZE(internal_msg_handlers); i++) {
+ msg_name.assign(internal_msg_handlers[i].msg_name);
+ m_internal_msg_handlers.insert(std::pair<std::string, CMessageHandler::MsgHandler>(msg_name, internal_msg_handlers[i].handler));
+ }
+}
+
+void CMessageHandler::m_ConstructRequestedDevice(rms_msg_request *request, rms_requests_device_s *requested_resource)
+{
+ requested_resource->resources_num = request->request_num;
+
+ for (int i = 0; i < requested_resource->resources_num; i++) {
+ requested_resource->devices[i].device_id = request->resource[i];
+ requested_resource->devices[i].requested_state = (rms_requests_resource_state_e) request->state[i];
+ }
+}
+
+int CMessageHandler::Run(void)
+{
+ if (g_thread_new("rms_msgq_thread", msgQThread, this) == NULL) {
+ 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");
+ assert(0);
+ return RMS_ERROR;
+ }
+
+ m_dbus_h = new CDbusHandler(async_queue);
+ return RMS_OK;
+}
+
+gpointer CMessageHandler::msgQThread(gpointer data)
+{
+ assert(data);
+
+ CMessageHandler *msg_handler = (CMessageHandler*) data;
+ CAsyncQueue *asyncq = msg_handler->async_queue;
+ CMessageQueue *msgq = msg_handler->msgq_rx;
+ rms_msg_request req;
+
+ while (1) {
+ memset(&req, 0, sizeof(rms_msg_request));
+
+ if (msgq->receive(&req, RMS_REQUEST_DATA_TYPE_ALL) != RMS_OK)
+ continue;
+
+ SERVER_DBG("push req type(%d)-pid(%d)-cid(%d)-len(%d)", req.type, req.pid, req.handle, asyncq->length());
+
+ CMessage *msg = new CMessage(&req);
+ asyncq->push(msg);
+ }
+
+ return NULL;
+}
+
+gpointer CMessageHandler::msgThread(gpointer data)
+{
+ assert(data);
+ SERVER_INFO("prepare to handle messages");
+
+ CMessageHandler *msg_handler = (CMessageHandler*) data;
+
+ while (1) {
+ msg_handler->ProcessMessage();
+ usleep(30000);
+ }
+
+ return NULL;
+}
+
+bool CMessageHandler::IsRegisteredHandle(int handle)
+{
+ return (CConsumerContainer::getInstance()->findConsumer(handle) != NULL);
+}
+
+void CMessageHandler::SetRequesterInfo(rms_msg_request *request)
+{
+ char *app_id = m_handle_mgr->GetAppID(request->handle);
+ m_handle_mgr->GetPriority(request->handle, &request->main_priority, &request->sub_priority);
+
+ snprintf(request->app_id, RMS_APPID_LENGTH, "%s", (app_id) ? app_id : "");
+
+ SERVER_INFO("handle(%d)-app_id(%s)", request->handle, request->app_id);
+
+ if (app_id)
+ free(app_id);
+}
+
+
+void CMessageHandler::m_RegisterConsumer(rms_msg_request *request, rms_msg_response *response)
+{
+ char cmd[RMS_NAME_BUF_SIZE] = {0,};
+
+ int handle = m_handle_mgr->GetNewHandle(request->pid, request->main_priority, request->sub_priority, request->app_pid, request->app_id);
+
+ response->result = (handle == RMS_HANDLE_NOT_AVAILABLE) ? RMS_ERROR : RMS_OK;
+
+ m_ConstructResponse(response, request->data_type, RMS_RESPONSE_REGISTER, handle, request->pid);
+
+ if (response->result == RMS_ERROR)
+ return;
+
+ if (m_rsc_mgr->RegisterConsumer(handle, request->pid, request->app_id, request->main_priority, request->sub_priority) != RMS_OK)
+ SERVER_ERR("failed to add consumer to manager. handle[%d]", handle);
+
+ rms_get_cmd_name(request->pid, cmd, sizeof(cmd));
+
+ SERVER_INFO("newly assigned handle(%d) - pid(%d)-(%s)", response->handle, request->pid, cmd);
+}
+
+void CMessageHandler::m_UnregisterConsumer(rms_msg_request *request, rms_msg_response *response)
+{
+ SERVER_INFO("request for unregister handle(%d)", request->handle);
+
+ m_ConstructResponse(response, request->data_type, RMS_RESPONSE_UNREGISTER, request->handle, request->pid);
+
+ if (!IsRegisteredHandle(request->handle)) {
+ response->result = RMS_ERROR;
+ return;
+ }
+
+ response->result = m_handle_mgr->RemoveHandle(request->handle, request->pid);
+
+ if (response->result != RMS_OK)
+ return;
+
+ m_rsc_mgr->UnregisterConsumer(request->handle);
+}
+
+void CMessageHandler::m_FreeAllocatedDevice(rms_return_device_s *allocated_device)
+{
+ if (allocated_device->device_ids) {
+ free(allocated_device->device_ids);
+ allocated_device->device_ids = NULL;
+ }
+
+ for (int i=0 ; i < allocated_device->resources_num; i++) {
+ if (allocated_device->devices[i].device_path) {
+ free((void*)allocated_device->devices[i].device_path);
+ allocated_device->devices[i].device_path = NULL;
+ }
+ }
+
+ if (allocated_device->devices) {
+ free(allocated_device->devices);
+ allocated_device->devices = NULL;
+ }
+}
+
+void CMessageHandler::m_Free(consumer_reclaim_s *consumer_info)
+{
+ if (!consumer_info)
+ return;
+
+ if (!consumer_info->consumer_info)
+ return;
+
+ for (int i = 0; i < consumer_info->ret_quantity; i++) {
+ if (consumer_info->consumer_info[i].conflicted_resources != NULL)
+ free(consumer_info->consumer_info[i].conflicted_resources);
+ }
+
+ free(consumer_info->consumer_info);
+}
+
+void CMessageHandler::m_AllocateResources(rms_msg_request *request, rms_msg_response *response)
+{
+ trace_begin("RSC ALLOCATE START");
+ trace_end();
+
+ if (!IsRegisteredHandle(request->handle)) {
+ m_ConstructResponse(response, request->data_type, RMS_RESPONSE_ALLOCATE_RESOURCE, request->handle, request->pid);
+ response->result = RMS_ERROR;
+ return;
+ }
+
+ int result = RMS_OK;
+ bool need_response = true;
+ rms_return_device_s allocated_device;
+ memset(&allocated_device, 0, sizeof(rms_return_device_s));
+
+ m_handle_mgr->ReclaimAllInvalidCustomer(request->pid);
+
+ SetRequesterInfo(request);
+
+ result = m_rsc_mgr->AllocateResources(request, &allocated_device);
+
+ bool needReclaimResources = (result == RMS_ERROR_TAKE_RESOURCE_FROM_OTHER_CONSUMER);
+
+ if (needReclaimResources) {
+ consumer_reclaim_s consumers_reclaim;
+ memset(&consumers_reclaim, 0, sizeof(consumers_reclaim));
+ int zone_id = -1;
+ if (m_rsc_mgr->FindReclaimableConsumers(request, &consumers_reclaim, &zone_id) == RMS_OK) {
+ CResourceDB::getInstance()->AddReclaimResources(&consumers_reclaim);
+ if (ReclaimResources(result, request->handle, zone_id, &consumers_reclaim, &need_response) == RMS_OK) {
+ result = m_rsc_mgr->AllocateResources(request, &allocated_device);
+ }
+ CResourceDB::getInstance()->ClearReclaimResources();
+ }
+ m_Free(&consumers_reclaim);
+ }
+
+ m_ConstructResponse(response, request->data_type, RMS_RESPONSE_ALLOCATE_RESOURCE, request->handle, request->pid);
+
+ response->result = result;
+ response->error_type = (result == RMS_OK) ? RMS_ERR_TYPE_NONE : (rms_error_type_e)allocated_device.error_type;
+ response->resource_num = allocated_device.resources_num;
+
+ if (!need_response)
+ response->error_type = RMS_ERR_TYPE_TERMINATED_PROCESS;
+
+ for (int i = 0; i < response->resource_num; i++) {
+ response->resource[i] = allocated_device.device_ids[i];
+ }
+
+ m_FreeAllocatedDevice(&allocated_device);
+ CCache::getInstance()->Drop();
+
+ trace_begin("RSC ALLOCATE END");
+ trace_end();
+}
+
+void CMessageHandler::m_ReleaseResources(rms_msg_request *request, rms_msg_response *response)
+{
+ SERVER_DBG("request for deallocation");
+
+ m_ConstructResponse(response, request->data_type, RMS_RESPONSE_RELEASE_RESOURCES, request->handle, request->pid);
+
+ if (!IsRegisteredHandle(request->handle)) {
+ response->result = RMS_ERROR;
+ return;
+ }
+
+ rms_requests_device_s requested_resource;
+ memset(&requested_resource, 0, sizeof(rms_requests_device_s));
+
+ m_ConstructRequestedDevice(request, &requested_resource);
+
+ response->result = m_rsc_mgr->ReleaseResources(request->handle, &requested_resource);
+}
+
+void CMessageHandler::m_Query(rms_msg_request *request, rms_msg_response *response)
+{
+ int answer = 0;
+
+ m_ConstructResponse(response, request->data_type, RMS_RESPONSE_QUERY, request->handle, request->pid);
+
+ m_handle_mgr->ReclaimAllInvalidCustomer(request->handle);
+
+ response->result = m_query_h->GetAnswer(request, &answer);
+ response->is_available = answer;
+
+ SERVER_INFO("query on (%d), result(%d)", request->sub_type, answer);
+}
+
+void CMessageHandler::m_SetConsumerPriority(rms_msg_request *request, rms_msg_response *response)
+{
+ SERVER_INFO("request for priority setting. priority(%d)", request->main_priority);
+
+ m_ConstructResponse(response, request->data_type, RMS_RESPONSE_SET_PRIORITY, request->handle, request->pid);
+
+ response->result = m_handle_mgr->SetPriority(request->handle, request->main_priority, request->sub_priority);
+}
+
+void CMessageHandler::m_SetAppID(rms_msg_request *request, rms_msg_response *response)
+{
+ SERVER_INFO("request for appid setting. appid(%s)", request->app_id);
+
+ m_ConstructResponse(response, request->data_type, RMS_RESPONSE_SET_APPID, request->handle, request->pid);
+
+ int ret = m_handle_mgr->SetAppID(request->handle, request->app_id);
+
+ if (ret != RMS_OK) {
+ SERVER_ERR("cannot update appid. handle(%d). ret(%d)", request->handle, ret);
+
+ response->result = RMS_ERROR;
+ return;
+ }
+
+ response->result = m_rsc_mgr->SetAppId(request->handle, request->app_id);
+}
+
+CMessageHandler::msg_handler CMessageHandler::handlers[RMS_REQUEST_MAX] = {
+ &CMessageHandler::m_RegisterConsumer,
+ &CMessageHandler::m_UnregisterConsumer,
+ &CMessageHandler::m_AllocateResources,
+ &CMessageHandler::m_ReleaseResources,
+ &CMessageHandler::m_Query,
+ &CMessageHandler::m_SetConsumerPriority,
+ &CMessageHandler::m_SetAppID,
+};
+
+void CMessageHandler::ProcessMsgQMessage(CMessage *msg)
+{
+ if (!IsValidRequest(msg->GetReqType())) {
+ SERVER_ERR("invalid req type(%d)", msg->GetReqType());
+ return;
+ }
+
+ rms_msg_response resp;
+ memset(&resp, 0, sizeof(rms_msg_response));
+
+ rms_msg_request *req = msg->GetRequest();
+ SERVER_INFO("req type(%d)-pid(%d)-cid(%d)-t(%lu)", req->type, req->pid, req->handle, req->time);
+
+ (this->*handlers[req->type])(msg->GetRequest(), &resp);
+
+ if (resp.error_type == RMS_ERR_TYPE_TERMINATED_PROCESS) {
+ SERVER_ERR("skip to send a response (%d)", req->pid);
+ return;
+ }
+
+ if (msgq_tx->send(&resp) != RMS_OK) {
+ SERVER_ERR("failed to send response");
+ }
+}
+
+GVariant *CMessageHandler::RegisterResource(GVariant *params)
+{
+ char *dev_name;
+ char *dev_node;
+ int category;
+ int sharable_count;
+
+ g_variant_get(params, "(&ssii)", &dev_name, &dev_node, &category, &sharable_count);
+
+ SERVER_INFO("dev_name(%s)/dev_node(%s)/category(%d)/sharable(%d)", dev_name, dev_node, category, sharable_count);
+ return g_variant_new("(i)", RMS_OK);
+}
+
+GVariant *CMessageHandler::GetResourceState(GVariant *params)
+{
+ int device_id;
+ int state;
+
+ g_variant_get(params, "(i)", &device_id);
+
+ state = m_rsc_mgr->GetResourceState(device_id);
+
+ SERVER_INFO("state (%d:%d)", device_id, state);
+
+ return g_variant_new("(i)", state);
+}
+
+GVariant *CMessageHandler::FindDeviceId(GVariant *params)
+{
+ int virtual_id;
+ int real_id;
+
+ g_variant_get(params, "(i)", &virtual_id);
+
+ real_id = m_rsc_mgr->FindDeviceId(virtual_id);
+
+ SERVER_INFO("real id (%d:%d)", virtual_id, real_id);
+
+ return g_variant_new("(i)", real_id);
+}
+
+GVariant *CMessageHandler::GetScalerHWID(GVariant *params)
+{
+ int zone_id;
+ int hw_id;
+
+ g_variant_get(params, "(i)", &zone_id);
+
+ hw_id = m_rsc_mgr->GetScalerHWId(zone_id);
+
+ SERVER_INFO("hw id (%d:%d)", zone_id, hw_id);
+
+ return g_variant_new("(i)", hw_id);
+}
+
+GVariant *CMessageHandler::SwapResources(GVariant *params)
+{
+ int device_id_a;
+ int device_id_b;
+ int result = 0;
+
+ g_variant_get(params, "(ii)", &device_id_a, &device_id_b);
+
+ result = m_rsc_mgr->SwapResources(device_id_a, device_id_b);
+
+ SERVER_INFO("swap result (%d:%d) > (%d)", device_id_a, device_id_b, result);
+
+ return g_variant_new("(i)", result);
+}
+
+GVariant *CMessageHandler::RestoreResources(GVariant *params)
+{
+ int category_id;
+ int result = 0;
+
+ g_variant_get(params, "(i)", &category_id);
+
+ result = m_rsc_mgr->RestoreResources(category_id);
+
+ SERVER_INFO("restore result (%d) > (%d)", category_id, result);
+
+ return g_variant_new("(i)", result);
+}
+
+GVariant *CMessageHandler::NotifyResourcePolicy(GVariant *params)
+{
+ int policy;
+ int result = 0;
+
+ g_variant_get(params, "(i)", &policy);
+
+ m_rsc_mgr->ResetZoneIds();
+
+ SERVER_INFO("notify result (%d) > (%d)", policy, result);
+ return g_variant_new("(i)", result);
+}
+
+GVariant *CMessageHandler::NotifyAppZoneInfo(GVariant *params)
+{
+ char *app_id;
+ int zone_id;
+ int result = 0;
+
+ g_variant_get(params, "(&si)", &app_id, &zone_id);
+
+ if (!app_id) {
+ result = -1;
+ SERVER_INFO("invalid param (%s:%d) - result(%d)", "null", zone_id, result);
+ return g_variant_new("(i)", result);
+ }
+
+ m_rsc_mgr->UpdateZoneIds(app_id, zone_id);
+
+ SERVER_INFO("notify result (%s:%d) > (%d)", app_id, zone_id, result);
+ return g_variant_new("(i)", result);
+}
+
+GVariant *CMessageHandler::GetResourceList(GVariant *params)
+{
+ int category_id;
+
+ g_variant_get(params, "(i)", &category_id);
+
+ SERVER_DBG("category (%d)", category_id);
+
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("(a(iissi))"));
+
+ g_variant_builder_open(&builder, G_VARIANT_TYPE("a(iissi)"));
+ m_rsc_mgr->GetResourceList(category_id, &builder);
+ g_variant_builder_close(&builder);
+
+ return g_variant_builder_end(&builder);
+}
+
+GVariant *CMessageHandler::GetScalerState(GVariant *params)
+{
+ SERVER_INFO("GetScalerState");
+
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("(a(iiiiis))"));
+
+ g_variant_builder_open(&builder, G_VARIANT_TYPE("a(iiiiis)"));
+ m_rsc_mgr->GetScalerState(&builder);
+ g_variant_builder_close(&builder);
+
+ return g_variant_builder_end(&builder);
+}
+
+GVariant *CMessageHandler::GetAppId(GVariant *params)
+{
+ int result = 0;
+ int handle;
+ g_variant_get(params, "(i)", &handle);
+
+ SERVER_INFO("GetAppId(%d)", handle);
+
+ CConsumer *consumer = CConsumerContainer::getInstance()->findConsumer(handle);
+ if (!consumer) {
+ SERVER_ERR("consumer(%d) not found", handle);
+ result = -1;
+ return g_variant_new("(is)", result, "");
+ }
+
+ return g_variant_new("(is)", result, (consumer->GetAppID().empty()) ? consumer->GetCmdName().c_str() : consumer->GetAppID().c_str());
+}
+
+GVariant *CMessageHandler::GetResourceCollectionState(GVariant *params)
+{
+ int collection;
+
+ g_variant_get(params, "(i)", &collection);
+
+ SERVER_INFO("collection (%d)", collection);
+
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("(a(isiiis))"));
+
+ g_variant_builder_open(&builder, G_VARIANT_TYPE("a(isiiis)"));
+ m_rsc_mgr->GetResourceCollectionState(collection, &builder);
+ g_variant_builder_close(&builder);
+
+ return g_variant_builder_end(&builder);
+}
+
+GVariant *CMessageHandler::GetActiveAudioOut(GVariant *params)
+{
+ int cid;
+ int active_audio_out;
+
+ g_variant_get(params, "(i)", &cid);
+
+ active_audio_out = m_rsc_mgr->GetActiveAudioOut(cid);
+ SERVER_INFO("active_audio_out(%d:%d)", cid, active_audio_out);
+
+ return g_variant_new("(i)", active_audio_out);
+}
+
+void CMessageHandler::ProcessDbusMessage(CMessage *msg)
+{
+ GDBusMethodInvocation *invoc = msg->GetMethodInvocation();
+ std::string method_name(g_dbus_method_invocation_get_method_name(invoc));
+
+ auto it = m_dbus_handlers.find(method_name);
+ if (it == m_dbus_handlers.end()) {
+ SERVER_ERR("handler is not found (%s)", method_name.c_str());
+ return;
+ }
+
+ GVariant *params = g_dbus_method_invocation_get_parameters(invoc);
+ GVariant *result = (this->*(it->second))(params);
+
+ g_dbus_method_invocation_return_value(invoc, result);
+}
+
+void CMessageHandler::ProcessInternalMessage(CMessage *msg)
+{
+ auto it = m_internal_msg_handlers.find(msg->GetName());
+ if (it == m_internal_msg_handlers.end()) {
+ SERVER_ERR("handler is not found (%s)", msg->GetName().c_str());
+ return;
+ }
+
+ (this->*(it->second))(NULL);
+}
+
+void CMessageHandler::EmptyPendingQueue(void)
+{
+ if (async_pending_queue->length() <= 0)
+ return;
+
+ SERVER_WARN("empty pending queue(%d)", async_pending_queue->length());
+ async_queue->push(async_pending_queue);
+}
+
+void CMessageHandler::InsertPendingQueue(CMessage *msg)
+{
+ SERVER_WARN("msg locked");
+ msg->PrintInfo();
+ async_pending_queue->push(msg);
+}
+
+int CMessageHandler::ProcessMessage(void)
+{
+ CMessage *msg = (CMessage*) async_queue->pop();
+ assert(msg);
+
+ if ((m_lock_ctr->GetLockCount() > 0) && m_lock_ctr->IsLocked(msg)) {
+ InsertPendingQueue(msg);
+ return 0;
+ }
+
+ if (msg->IsUnlockMsg()) {
+ EmptyPendingQueue();
+ delete msg;
+ return 0;
+ }
+
+ switch (msg->GetSender()) {
+ case MSG_SENDER_MSGQ:
+ ProcessMsgQMessage(msg);
+ break;
+ case MSG_SENDER_DBUS:
+ ProcessDbusMessage(msg);
+ break;
+ case MSG_SENDER_INTERNAL:
+ ProcessInternalMessage(msg);
+ break;
+ default:
+ break;
+ }
+
+ delete msg;
+
+ return 0;
+}
+
+bool CMessageHandler::IsAllResourcesReclaimed(rms_consumer_tobe_returned_s *consumer_info)
+{
+ for (int idx = 0; idx < consumer_info->n_conflicted; idx++) {
+ if (!m_rsc_mgr->IsReclaimed(consumer_info->conflicted_resources[idx].device_id, consumer_info->consumer_id)) {
+ SERVER_WARN("IsReclaimed is failed");
+ return false;
+ }
+ }
+
+ SERVER_WARN("all conflicted resources are freed");
+
+ return true;
+}
+
+void CMessageHandler::ProcessMessage(CAsyncQueue *queue, CMessage *msg, int cid_requester, int cid_releaser)
+{
+ rms_msg_request *req = msg->GetRequest();
+ rms_msg_response resp;
+ int handle;
+ char cmd[RMS_NAME_BUF_SIZE] = {0,};
+
+ switch (req->type) {
+ case RMS_REQUEST_RELEASE_RESOURCES:
+
+ rms_requests_device_s requested_resource;
+ memset(&requested_resource, 0, sizeof(rms_requests_device_s));
+
+ m_ConstructResponse(&resp, req->data_type, RMS_RESPONSE_RELEASE_RESOURCES, req->handle, req->pid);
+ m_ConstructRequestedDevice(req, &requested_resource);
+
+ if ((resp.result = m_rsc_mgr->ReleaseResources(req->handle, &requested_resource)) != RMS_OK)
+ SERVER_ERR("failed to release resources requested by (%d)", req->handle);
+
+ SendResponse(&resp);
+
+ break;
+
+ case RMS_REQUEST_UNREGISTER:
+
+ m_ConstructResponse(&resp, req->data_type, RMS_RESPONSE_UNREGISTER, req->handle, req->pid);
+
+ SERVER_WARN("unregister requested by handle(%d)", req->handle);
+
+ if (req->handle == cid_requester) {
+ SERVER_WARN("unregister request from requester(%d), send to internal queue", req->handle);
+
+ PushMessage(queue, msg);
+ } else {
+ if ((resp.result = m_handle_mgr->RemoveHandle(req->handle, req->pid)) == RMS_OK) {
+ m_rsc_mgr->UnregisterConsumer(req->handle);
+ }
+
+ SendResponse(&resp);
+ }
+ break;
+
+ case RMS_REQUEST_REGISTER:
+ handle = m_handle_mgr->GetNewHandle(req->pid, req->main_priority, req->sub_priority, req->app_pid, req->app_id);
+
+ resp.result = (handle == RMS_HANDLE_NOT_AVAILABLE) ? RMS_ERROR : RMS_OK;
+ m_ConstructResponse(&resp, req->data_type, RMS_RESPONSE_REGISTER, handle, req->pid);
+
+ if (resp.result == RMS_ERROR) {
+ SendResponse(&resp);
+ break;
+ }
+
+ if (m_rsc_mgr->RegisterConsumer(handle, req->pid, req->app_id, req->main_priority, req->sub_priority) != RMS_OK)
+ SERVER_ERR("failed to add consumer to manager. handle[%d]", handle);
+
+ rms_get_cmd_name(req->pid, cmd, sizeof(cmd));
+
+ SERVER_INFO("newly assigned handle(%d) date type(%ld)- pid(%d)-(%s)", resp.handle, req->data_type, req->pid, cmd);
+ SendResponse(&resp);
+ break;
+
+ default:
+ SERVER_ERR("unexpected request(%d) by handle(%d)/pid(%d)", req->type, req->handle, req->pid);
+
+ if (req->handle == cid_releaser) {
+ m_ConstructResponse(&resp, req->data_type, (rms_response_type_e)req->type, req->handle, req->pid);
+ resp.result = RMS_ERROR;
+
+ SendResponse(&resp);
+ } else {
+ PushMessage(queue, msg);
+ }
+ break;
+ }
+}
+
+int CMessageHandler::ProcessCallbackMessage(rms_consumer_tobe_returned_s *consumer_info, int requester_cid)
+{
+ CMessage *msg = NULL;
+ int result = RMS_OK;
+ CAsyncQueue *queue = new CAsyncQueue();
+
+ unsigned int timeout_ms = CCallback::GetTimeout();
+
+ while (!IsAllResourcesReclaimed(consumer_info)) {
+ msg = (CMessage*) async_queue->pop(timeout_ms);
+
+ if (!msg) {
+ SERVER_ERR("receive cb request timeout! CID[%d]/PID[%ld]", consumer_info->consumer_id, consumer_info->process_id);
+ result = RMS_ERROR;
+ goto out;
+ }
+
+ if (msg->GetSender() == MSG_SENDER_DBUS) {
+ ProcessDbusMessage(msg);
+ } else if (msg->GetSender() == MSG_SENDER_MSGQ) {
+ SERVER_WARN("[MSG_SENDER_MSGQ] requester cid %d consumer id %d", requester_cid, consumer_info->consumer_id);
+ ProcessMessage(queue, msg, requester_cid, consumer_info->consumer_id);
+ } else {
+ ProcessInternalMessage(msg);
+ }
+
+ delete msg;
+ }
+
+out:
+ async_queue->push_front(queue);
+
+ delete queue;
+
+ return result;
+}
+
+int *CMessageHandler::m_SerializeCallbackData(const rms_consumer_tobe_returned_s *consumer_info, int reason, int *data_size)
+{
+ int num_conflicted_resources = consumer_info->n_conflicted;
+
+ int *callback_data = (int*) calloc(num_conflicted_resources + 4, sizeof(int));
+ assert(callback_data);
+
+ callback_data[0] = CCallback::ConvertCallbackType(reason);
+ callback_data[1] = consumer_info->consumer_id;
+ callback_data[2] = consumer_info->process_id;
+ callback_data[3] = num_conflicted_resources;
+
+ for (int res = 0; res < num_conflicted_resources; res++) {
+ callback_data[(res+4)] = consumer_info->conflicted_resources[res].virtual_id;
+ SERVER_DBG("- virtual_id:%d ", consumer_info->conflicted_resources[res].virtual_id);
+ }
+
+ *data_size = (num_conflicted_resources + 4) * sizeof(int);
+
+ return callback_data;
+}
+
+bool CMessageHandler::IsValidProcess(int pid)
+{
+ return rm_is_valid_pid(pid);
+}
+
+bool CMessageHandler::IsValidRequest(int req_type)
+{
+ return (req_type >= RMS_REQUEST_REGISTER && req_type < RMS_REQUEST_MAX);
+}
+
+int CMessageHandler::ReleaseInvalidProcessResources(int pid, int handle)
+{
+ m_handle_mgr->RemoveHandle(handle, pid);
+ CCallback::RemoveFIFOServerToClient(pid, handle);
+
+ return RMS_OK;
+}
+
+void CMessageHandler::NotifyConflict(consumer_reclaim_s *conflict_info, int zone_id)
+{
+ if (!conflict_info)
+ return;
+
+ int consumer_id = -1;
+ int device_id = -1;
+ int category_id = -1;
+ int app_zone_id = -1;
+ int n_consumer = conflict_info->ret_quantity;
+ CConsumer *consumer = NULL;
+
+ GError *error = NULL;
+ GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+
+ if (!connection) {
+ SERVER_ERR("failed to get connection (%s)", (error) ? error->message : "unknown");
+ goto out;
+ }
+
+ for (int i = 0; i < n_consumer; i++) {
+ consumer_id = conflict_info->consumer_info[i].consumer_id;
+ consumer = CConsumerContainer::getInstance()->findConsumer(consumer_id);
+
+ 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);
+ category_id = conflict_info->consumer_info[i].conflicted_resources[j].category_id;
+ SERVER_INFO("send resource conflict (%d:%d:%d:%s:%d:%d)",
+ category_id, device_id, consumer_id, (consumer->GetAppID().empty()) ? consumer->GetCmdName().c_str() : consumer->GetAppID().c_str(), app_zone_id, zone_id);
+ if (!g_dbus_connection_emit_signal(connection,
+ NULL,
+ RM_DBUS_OBJ_PATH,
+ RM_DBUS_INTERFACE_NAME,
+ "RscConflicted",
+ g_variant_new("(iiisii)", category_id, device_id, consumer_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");
+ }
+ }
+ }
+out:
+ if (error)
+ g_error_free(error);
+}
+
+int CMessageHandler::ReclaimResources(int reason, int requester_cid, int requester_zone_id, consumer_reclaim_s *conflict_info, bool *need_response)
+{
+ int num_consumers = conflict_info->ret_quantity;
+ int data_size = 0;
+ int *callback_data = NULL;
+ char cmd[RMS_NAME_BUF_SIZE] = {0,};
+ int err = 0;
+ int cid = 0;
+ int pid = 0;
+
+ SERVER_WARN("start to reclaim - retirable consumers : (%d)", num_consumers);
+
+ if (num_consumers > 0)
+ NotifyConflict(conflict_info, requester_zone_id);
+
+ for (int i = 0; i < num_consumers; i++) {
+ pid = (int) conflict_info->consumer_info[i].process_id;
+ cid = conflict_info->consumer_info[i].consumer_id;
+
+ if (!IsValidProcess(pid)) {
+ SERVER_ERR("handle(%d)/pid(%d) terminated", cid, pid);
+ m_rsc_mgr->ReleaseResourcesOfPid(pid);
+ ReleaseInvalidProcessResources(pid, cid);
+ continue;
+ }
+
+ SERVER_DBG("[%d]th cid[%d]/rscs[%d]", i+1, cid, conflict_info->consumer_info[i].n_conflicted);
+
+ callback_data = m_SerializeCallbackData(&conflict_info->consumer_info[i], reason, &data_size);
+
+ if (CCallback::SendCallbackMessage(cid, pid, (void*) callback_data, data_size, &err) != RMS_OK) {
+ if (err == ENXIO) { //ENXIO No such device or address
+ SERVER_ERR("Process cannot get callback (CID:%d)/(PID:%d)", cid, pid);
+ m_rsc_mgr->ReleaseResourcesOfPid(pid);
+ ReleaseInvalidProcessResources(pid, cid);
+ free(callback_data);
+ continue;
+ }
+
+ if (err == ENOENT && !IsRegisteredHandle(cid)) {
+ SERVER_ERR("already unregistred (%d)", cid);
+ free(callback_data);
+ continue;
+ }
+
+ SERVER_ERR("failed to send callback message to (CID:%d)/(PID:%d), errno(%d)", cid, pid, err);
+ free(callback_data);
+ return RMS_ERROR;
+ }
+
+ SERVER_WARN("[%d]th callback message sent to CID[%d]/PID[%d]/RSCS[%d]", i+1, cid, pid, conflict_info->consumer_info[i].n_conflicted);
+
+ if (ProcessCallbackMessage(&conflict_info->consumer_info[i], requester_cid) != RMS_OK) {
+ if (!IsValidProcess(pid)) {
+ SERVER_ERR("handle(%d)/pid(%d) terminated", cid, pid);
+ m_rsc_mgr->ReleaseResourcesOfPid(pid);
+ ReleaseInvalidProcessResources(pid, cid);
+ free(callback_data);
+
+ if (!IsRegisteredHandle(requester_cid)) {
+ SERVER_ERR("requester(%d:%d) terminated as well", pid, requester_cid);
+ *need_response = false;
+ return RMS_ERROR;
+ }
+ continue;
+ }
+
+ rms_get_cmd_name(pid, cmd, sizeof(cmd));
+ SERVER_ERR("failed to process callback request from : (%s) /(CID:%d)/(PID:%d)", cmd, cid, pid);
+
+ rms_display_timeout_error_popup(RMS_ALARM_NO_DEALLOCATION, conflict_info->consumer_info[i]);
+ int ret = rms_report_emergency(cid, pid, RMS_EMERGENCY_CONSUMER_NOT_RESPONDING);
+
+ SERVER_ERR("release resources of cosumer(%d) forcely", pid);
+ m_rsc_mgr->UnregisterConsumer(cid);
+ m_handle_mgr->RemoveHandle(cid, pid);
+
+ free(callback_data);
+ return ret;
+ }
+
+ free(callback_data);
+ }
+
+ return RMS_OK;
+}
+
+int CMessageHandler::SendResponse(rms_msg_response *response)
+{
+ return msgq_tx->send(response);
+}
+
+int CMessageHandler::PushMessage(CAsyncQueue *queue, CMessage *msg)
+{
+ CMessage *msg_copy = new CMessage(msg->GetRequest());
+ rms_msg_request *req = msg->GetRequest();
+ SERVER_INFO("push_front msg type(%d)-pid(%d)-cid(%d)", req->type, req->pid, req->handle);
+
+ queue->push_front(msg_copy);
+
+ return RMS_OK;
+}
+
+void CMessageHandler::m_ConstructResponse(rms_msg_response *response, int data_type, rms_response_type_e msg_type, int handle, int pid)
+{
+ assert(response);
+
+ response->data_type = data_type;
+ response->type = msg_type;
+ response->handle = handle;
+ response->pid = pid;
+}
+
+void CMessageHandler::NotifyWatchdog(void)
+{
+ if (!async_queue)
+ return;
+
+ SERVER_INFO("push watchdog msg");
+ async_queue->push(new CMessage("NotifyWatchdog"));
+}
+
+GVariant *CMessageHandler::NotifyWatchdog(GVariant *params)
+{
+ SERVER_INFO("send watchdog notify completed");
+ return 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 <assert.h>\r
-#include <errno.h>\r
-#include <sys/types.h>\r
-#include <sys/ipc.h>\r
-#include <sys/msg.h>\r
-#include <unistd.h>\r
-\r
-#include <rms_debug.h>\r
-#include <CMessageQueue.h>\r
-\r
-CMessageQueue::CMessageQueue(msgq_type_e type)\r
-{\r
- msgq_type = type;\r
-\r
- if (init() != RMS_OK) {\r
- SERVER_ERR("failed to initialize message queue(%d)", type);\r
- assert(0 && "failed to initialize message queue");\r
- }\r
-}\r
-\r
-CMessageQueue::~CMessageQueue(void)\r
-{\r
-}\r
-\r
-int CMessageQueue::init(void)\r
-{\r
- int key = getKey(msgq_type);\r
-\r
- msgq_id = msgget((key_t) key, 0666 | IPC_CREAT);\r
- if (msgq_id == -1) {\r
- SERVER_ERR("failed to create a message queue (%d), errno(%d)", key, errno);\r
- return RMS_ERROR;\r
- }\r
-\r
- struct msqid_ds queue_stat;\r
- long prev_size = 0;\r
-\r
- if (msgctl(msgq_id, IPC_STAT, &queue_stat) != 0) {\r
- SERVER_ERR("failed to get queue info (%d:%d), errno(%d)", key, msgq_id, errno);\r
- goto out;\r
- }\r
-\r
- prev_size = queue_stat.msg_qbytes;\r
- queue_stat.msg_qbytes = msgq_size;\r
-\r
- if (msgctl(msgq_id, IPC_SET, &queue_stat) != 0) {\r
- SERVER_ERR("failed to set queue info (%d:%d), errno(%d)", key, msgq_id, errno);\r
- goto out;\r
- }\r
-\r
- SERVER_INFO("msgq(%d:%d) size changed (%ld) -> (%ld)", key, msgq_id, prev_size, msgq_size);\r
-\r
-out:\r
- return RMS_OK;\r
-}\r
-\r
-int CMessageQueue::send(rms_msg_response *response)\r
-{\r
- int retry = 0;\r
-\r
- while (msgsnd(msgq_id, (void*) response, sizeof(rms_msg_response) - sizeof(long), 0) == -1) {\r
- SERVER_ERR("failed to send response message (%d), retry(%d) - type(%d)/cid(%d)", errno, retry, response->type, response->handle);\r
-\r
- if (errno == EIDRM) { // errno 43 : identifier removed\r
- SERVER_ERR("msgid removed from system");\r
- if (recover() != RMS_OK)\r
- return RMS_ERROR;\r
- } else if ((errno == EINVAL) && (response->data_type > 0)) {\r
- SERVER_ERR("msgid might be removed from system");\r
- if (recover() != RMS_OK) {\r
- return RMS_ERROR;\r
- }\r
- }\r
-\r
- if (retry >= 5) { //timeout\r
- return RMS_ERROR;\r
- }\r
-\r
- usleep(20*1000); // 20ms\r
- retry++;\r
- }\r
-\r
- return RMS_OK;\r
-\r
-}\r
-\r
-int CMessageQueue::receive(rms_msg_request *request, int msg_type)\r
-{\r
- int ret = -1;\r
- ret = msgrcv(msgq_id, (void*) request, sizeof(rms_msg_request) - sizeof(long), msg_type, 0);\r
-\r
- if (ret == -1) {\r
- SERVER_ERR("failed to receive msg(%d:%d). errno(%d)", msgq_type, msgq_id, errno);\r
-\r
- if (errno == EIDRM) { // errno 43 : identifier removed\r
- SERVER_ERR("WARNING! msgq(%d:%d) removed from system", msgq_type, msgq_id);\r
- recover();\r
- }\r
-\r
- return RMS_ERROR;\r
- }\r
-\r
- return RMS_OK;\r
-}\r
-\r
-int CMessageQueue::recover(void)\r
-{\r
- int key = getKey(msgq_type);\r
-\r
- msgq_id = msgget((key_t) key, 0666 | IPC_CREAT);\r
-\r
- if (msgq_id == -1) {\r
- SERVER_ERR("failed to get new msgq_id, key(%d), errno(%d)", key, errno);\r
- return RMS_ERROR;\r
- }\r
-\r
- SERVER_ERR("message queue recovered - (%d:%d)", key, msgq_id);\r
- return RMS_OK;\r
-}\r
-\r
-int CMessageQueue::getKey(msgq_type_e type)\r
-{\r
- return (type == MSG_QUEUE_RX) ? key_rx : key_tx;\r
-}\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <unistd.h>
+
+#include <rms_debug.h>
+#include <CMessageQueue.h>
+
+CMessageQueue::CMessageQueue(msgq_type_e type)
+{
+ msgq_type = type;
+
+ if (init() != RMS_OK) {
+ SERVER_ERR("failed to initialize message queue(%d)", type);
+ assert(0 && "failed to initialize message queue");
+ }
+}
+
+CMessageQueue::~CMessageQueue(void)
+{
+}
+
+int CMessageQueue::init(void)
+{
+ int key = getKey(msgq_type);
+
+ msgq_id = msgget((key_t) key, 0666 | IPC_CREAT);
+ if (msgq_id == -1) {
+ SERVER_ERR("failed to create a message queue (%d), errno(%d)", key, errno);
+ return RMS_ERROR;
+ }
+
+ struct msqid_ds queue_stat;
+ long prev_size = 0;
+
+ if (msgctl(msgq_id, IPC_STAT, &queue_stat) != 0) {
+ SERVER_ERR("failed to get queue info (%d:%d), errno(%d)", key, msgq_id, errno);
+ goto out;
+ }
+
+ prev_size = queue_stat.msg_qbytes;
+ queue_stat.msg_qbytes = msgq_size;
+
+ if (msgctl(msgq_id, IPC_SET, &queue_stat) != 0) {
+ SERVER_ERR("failed to set queue info (%d:%d), errno(%d)", key, msgq_id, errno);
+ goto out;
+ }
+
+ SERVER_INFO("msgq(%d:%d) size changed (%ld) -> (%ld)", key, msgq_id, prev_size, msgq_size);
+
+out:
+ return RMS_OK;
+}
+
+int CMessageQueue::send(rms_msg_response *response)
+{
+ int retry = 0;
+
+ while (msgsnd(msgq_id, (void*) response, sizeof(rms_msg_response) - sizeof(long), 0) == -1) {
+ SERVER_ERR("failed to send response message (%d), retry(%d) - type(%d)/cid(%d)", errno, retry, response->type, response->handle);
+
+ if (errno == EIDRM) { // errno 43 : identifier removed
+ SERVER_ERR("msgid removed from system");
+ if (recover() != RMS_OK)
+ return RMS_ERROR;
+ } else if ((errno == EINVAL) && (response->data_type > 0)) {
+ SERVER_ERR("msgid might be removed from system");
+ if (recover() != RMS_OK) {
+ return RMS_ERROR;
+ }
+ }
+
+ if (retry >= 5) { //timeout
+ return RMS_ERROR;
+ }
+
+ usleep(20*1000); // 20ms
+ retry++;
+ }
+
+ return RMS_OK;
+
+}
+
+int CMessageQueue::receive(rms_msg_request *request, int msg_type)
+{
+ int ret = -1;
+ ret = msgrcv(msgq_id, (void*) request, sizeof(rms_msg_request) - sizeof(long), msg_type, 0);
+
+ if (ret == -1) {
+ SERVER_ERR("failed to receive msg(%d:%d). errno(%d)", msgq_type, msgq_id, errno);
+
+ if (errno == EIDRM) { // errno 43 : identifier removed
+ SERVER_ERR("WARNING! msgq(%d:%d) removed from system", msgq_type, msgq_id);
+ recover();
+ }
+
+ return RMS_ERROR;
+ }
+
+ return RMS_OK;
+}
+
+int CMessageQueue::recover(void)
+{
+ int key = getKey(msgq_type);
+
+ msgq_id = msgget((key_t) key, 0666 | IPC_CREAT);
+
+ if (msgq_id == -1) {
+ SERVER_ERR("failed to get new msgq_id, key(%d), errno(%d)", key, errno);
+ return RMS_ERROR;
+ }
+
+ SERVER_ERR("message queue recovered - (%d:%d)", key, msgq_id);
+ return RMS_OK;
+}
+
+int CMessageQueue::getKey(msgq_type_e type)
+{
+ return (type == MSG_QUEUE_RX) ? key_rx : key_tx;
+}
-/*\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 <stdlib.h>\r
-#include <assert.h>\r
-#include <glib.h>\r
-\r
-#include <rms_debug.h>\r
-#include <CDebugUtils.h>\r
-#include <CQueryHandler.h>\r
-\r
-CQueryHandler::CQueryHandler(CResourceManager *rsc_mgr)\r
-{\r
- assert(rsc_mgr);\r
- m_rsc_mgr = rsc_mgr;\r
-}\r
-\r
-CQueryHandler::~CQueryHandler(void)\r
-{\r
-}\r
-\r
-int CQueryHandler::GetAnswer(rms_msg_request *request, int *answer_out)\r
-{\r
- int result = RMS_OK;\r
- int answer = 0;\r
- char process_name[RMS_NAME_BUF_SIZE] = {0,};\r
-\r
- switch (request->sub_type) {\r
- case RMS_QUERY_ALLOCATION:\r
- result = m_rsc_mgr->IsCategoryAvailableToUse(request, &answer);\r
- *answer_out = answer;\r
- break;\r
- case RMS_QUERY_TERMINATE:\r
- rms_get_cmd_name(request->pid, process_name, RMS_NAME_BUF_SIZE);\r
- result = RMS_OK;\r
- *answer_out = process_htable_contains(process_name);\r
- break;\r
- case RMS_QUERY_ACTIVE_DECS:\r
- *answer_out = m_rsc_mgr->GetActiveDecoderNum();\r
- result = RMS_OK;\r
- break;\r
- default:\r
- SERVER_ERR("not defined query type (%d)", request->sub_type);\r
- break;\r
- }\r
-\r
- return result;\r
-}\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <assert.h>
+#include <glib.h>
+
+#include <rms_debug.h>
+#include <CDebugUtils.h>
+#include <CQueryHandler.h>
+
+CQueryHandler::CQueryHandler(CResourceManager *rsc_mgr)
+{
+ assert(rsc_mgr);
+ m_rsc_mgr = rsc_mgr;
+}
+
+CQueryHandler::~CQueryHandler(void)
+{
+}
+
+int CQueryHandler::GetAnswer(rms_msg_request *request, int *answer_out)
+{
+ int result = RMS_OK;
+ int answer = 0;
+ char process_name[RMS_NAME_BUF_SIZE] = {0,};
+
+ switch (request->sub_type) {
+ case RMS_QUERY_ALLOCATION:
+ result = m_rsc_mgr->IsCategoryAvailableToUse(request, &answer);
+ *answer_out = answer;
+ break;
+ case RMS_QUERY_TERMINATE:
+ rms_get_cmd_name(request->pid, process_name, RMS_NAME_BUF_SIZE);
+ result = RMS_OK;
+ *answer_out = process_htable_contains(process_name);
+ break;
+ case RMS_QUERY_ACTIVE_DECS:
+ *answer_out = m_rsc_mgr->GetActiveDecoderNum();
+ result = RMS_OK;
+ break;
+ default:
+ SERVER_ERR("not defined query type (%d)", request->sub_type);
+ break;
+ }
+
+ return result;
+}
-/*\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
-\r
-#include <rms_debug.h>\r
-#include "CSysInfo.h"\r
-#include "CRequester.h"\r
-#include "CRequest.h"\r
-\r
-CRequest::CRequest(CRequester *requester)\r
-:m_requester(requester)\r
-{\r
- m_device_id = 0;\r
- m_category_id = 0;\r
- m_category_option = 0;\r
- m_category = RMS_CATEGORY_NONE;\r
- m_result = RMS_ERROR;\r
- m_candidate_device = RMS_DEVICE_NONE;\r
- m_allocated_device = RMS_DEVICE_NONE;\r
- m_virtual_device = RMS_DEVICE_NONE;\r
-}\r
-\r
-CRequest::~CRequest()\r
-{\r
-}\r
-\r
-CRequester *CRequest::getRequester(void)\r
-{\r
- return m_requester;\r
-}\r
-\r
-int CRequest::ToMultiviewZoneId(int category_option)\r
-{\r
- const int ZONE_INFO = 0x1E00000;\r
- int zone_id = ((category_option & ZONE_INFO) >> 21);\r
- return zone_id;\r
-}\r
-\r
-void CRequest::SetCategory(int category_id, int category_option)\r
-{\r
- m_category_id = category_id;\r
- m_category_option = category_option;\r
- m_category = ToResourceCategory(category_id, category_option);\r
- m_mixing_mode = ToMixingMode(category_id, category_option);\r
- m_mv_zone_id = ToMultiviewZoneId(category_option);\r
-}\r
-\r
-void CRequest::SetState(int req_state)\r
-{\r
- m_state = (rms_requests_resource_state_e) req_state;\r
-}\r
-\r
-void CRequest::SetResult(rms_return_code_e req_result)\r
-{\r
- m_result = req_result;\r
-}\r
-\r
-rms_return_code_e CRequest::GetResult(void)\r
-{\r
- return m_result;\r
-}\r
-\r
-rms_rsc_category_e CRequest::GetCategory(void)\r
-{\r
- return m_category;\r
-}\r
-\r
-bool CRequest::IsMainDeviceRequest(void)\r
-{\r
- if (m_state == RMS_STATE_EXCLUSIVE_AUTO)\r
- return false;\r
-\r
- SERVER_INFO("m_category_id(%d), option(%d)", m_category_id, m_category_option);\r
-\r
- if (IsSupportedCategory(m_category_option)) {\r
- if ((m_category_option & RMS_DEVICE_OPT_MAIN) || (m_category_option & RMS_FORCE_TO_MAIN))\r
- return true;\r
- }\r
-\r
- if ((m_category_id == RMS_CATEGORY_VIDEO_DECODER) && (m_category_option != RMS_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED)) {\r
- return (m_category_option & RMS_DEVICE_OPT_MAIN);\r
- }\r
-\r
- if (m_category_id == RMS_CATEGORY_AUDIO_DECODER) {\r
- if (m_category_option == RMS_CATEGORY_AUDIO_DECODER_NOT_SUPPORTED)\r
- return false;\r
- if (m_category_option == RMS_DEVICE_OPT_NONE)\r
- return true;\r
-\r
- return (m_category_option & RMS_DEVICE_OPT_MAIN);\r
- }\r
-\r
- if (m_category_id == RMS_CATEGORY_MJPEG_DECODER)\r
- return (m_category_option & RMS_DEVICE_OPT_MAIN);\r
-\r
- if (m_category == RMS_CATEGORY_SCALER_MULTIVIEW)\r
- return (m_category_option & RMS_DEVICE_OPT_MAIN);\r
-\r
- return false;\r
-}\r
-\r
-bool CRequest::IsAIDeviceRequest(void)\r
-{\r
- if (m_state == RMS_STATE_EXCLUSIVE_AUTO)\r
- return false;\r
-\r
- if ((m_category_id == RMS_CATEGORY_VIDEO_DECODER) && (m_category_option != RMS_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED))\r
- return (m_category_option & RMS_VIDEO_DEC_OPT_AI);\r
-\r
- return false;\r
-}\r
-\r
-bool CRequest::IsSubDeviceRequest(void)\r
-{\r
- if (m_state == RMS_STATE_EXCLUSIVE_AUTO)\r
- return false;\r
-\r
- //SERVER_DBG("m_category_id(%d), option(%d)", m_category_id, m_category_option);\r
-\r
- if (IsSupportedCategory(m_category_option)) {\r
- if ((m_category_option & RMS_DEVICE_OPT_SUB) || (m_category_option & RMS_FORCE_TO_SUB))\r
- return true;\r
- }\r
-\r
- if ((m_category_id == RMS_CATEGORY_VIDEO_DECODER_SUB) && (m_category_option != RMS_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED))\r
- return (m_category_option & RMS_DEVICE_OPT_SUB);\r
-\r
- if (m_category_id == RMS_CATEGORY_AUDIO_DECODER_SUB) {\r
- if (m_category_option == RMS_CATEGORY_AUDIO_DECODER_NOT_SUPPORTED)\r
- return false;\r
- if (m_category_option == RMS_DEVICE_OPT_NONE)\r
- return true;\r
-\r
- return (m_category_option & RMS_DEVICE_OPT_SUB);\r
- }\r
-\r
- if (m_category_id == RMS_CATEGORY_MJPEG_DECODER)\r
- return (m_category_option & RMS_DEVICE_OPT_SUB);\r
-\r
- if (m_category == RMS_CATEGORY_SCALER_MULTIVIEW)\r
- return (m_category_option & RMS_DEVICE_OPT_SUB);\r
-\r
- return false;\r
-}\r
-\r
-rms_rsc_category_e CRequest::ToVideoDecoderCategory(int category, int category_option, bool force_main, bool force_sub)\r
-{\r
- rms_rsc_category_e result = RMS_CATEGORY_NONE;\r
-\r
- if (category_option == RMS_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED) {\r
- result = RMS_CATEGORY_NONE;\r
- } else if ((category_option > RMS_CATEGORY_VIDEO_DECODER_OPTION) && (category_option < RMS_CATEGORY_VIDEO_DECODER_OPTION_MAX)) {\r
- result = (rms_rsc_category_e) category_option;\r
- } else {\r
- if (category == RMS_CATEGORY_VIDEO_DECODER) {\r
- result = (rms_rsc_category_e) ((force_sub) ? RMS_CATEGORY_VIDEO_DECODER_SUB : category);\r
- } else if (category == RMS_CATEGORY_VIDEO_DECODER_SUB) {\r
- result = (rms_rsc_category_e) ((force_main) ? (rms_rsc_category_e) RMS_CATEGORY_VIDEO_DECODER : category);\r
- } else {\r
- result = (rms_rsc_category_e) category;\r
- }\r
- }\r
-\r
- return result;\r
-}\r
-\r
-rms_rsc_category_e CRequest::ToImageDecoderCategory(int category, int category_option)\r
-{\r
- rms_rsc_category_e result = RMS_CATEGORY_NONE;\r
-\r
- SERVER_INFO("category(%d)/category_option(%d)", category, category_option);\r
-\r
- if (category_option == RMS_CATEGORY_IMAGE_DECODER_NOT_SUPPORTED) {\r
- result = RMS_CATEGORY_NONE;\r
- } else if ((category_option > RMS_CATEGORY_HEIC_DECODER_OPTION) && (category_option < RMS_CATEGORY_HEIC_DECODER_OPTION_MAX)) {\r
- result = (rms_rsc_category_e) category_option;\r
- } else if ((category_option > RMS_CATEGORY_JPEG_DECODER_OPTION) && (category_option < RMS_CATEGORY_JPEG_DECODER_OPTION_MAX)) {\r
- result = (rms_rsc_category_e) category_option;\r
- } else {\r
- result = (rms_rsc_category_e) category;\r
- }\r
-\r
- return result;\r
-}\r
-\r
-rms_rsc_category_e CRequest::ToJpegDecoderCategory(int category, int category_option)\r
-{\r
- rms_rsc_category_e result = RMS_CATEGORY_NONE;\r
-\r
- SERVER_INFO("category(%d)/category_option(%d)", category, category_option);\r
-\r
- if (category_option == RMS_CATEGORY_JPEG_DECODER_NOT_SUPPORTED) {\r
- result = RMS_CATEGORY_NONE;\r
- } else if ((category_option > RMS_CATEGORY_JPEG_DECODER_OPTION) && (category_option < RMS_CATEGORY_JPEG_DECODER_OPTION_MAX)) {\r
- result = (rms_rsc_category_e) category_option;\r
- } else {\r
- result = (rms_rsc_category_e) category;\r
- }\r
-\r
- return result;\r
-}\r
-\r
-rms_rsc_category_e CRequest::ToMJpegDecoderCategory(int category, int category_option)\r
-{\r
- rms_rsc_category_e result = RMS_CATEGORY_NONE;\r
-\r
- if (category_option == RMS_CATEGORY_MJPEG_DECODER_NOT_SUPPORTED) {\r
- result = RMS_CATEGORY_NONE;\r
- } else if ((category_option > RMS_CATEGORY_MJPEG_DECODER_OPTION) && (category_option < RMS_CATEGORY_MJPEG_DECODER_OPTION_MAX)) {\r
- result = (rms_rsc_category_e) category_option;\r
- } else {\r
- result = (rms_rsc_category_e)category;\r
- }\r
-\r
- return result;\r
-}\r
-\r
-rms_rsc_category_e CRequest::ToAudioDecoderCategory(int category, int category_option, bool force_main, bool force_sub)\r
-{\r
- rms_rsc_category_e result = RMS_CATEGORY_NONE;\r
- bool support_mixing = CSysInfo::GetInstance()->IsAudioMixingSupported();\r
-\r
- if (category_option == RMS_CATEGORY_AUDIO_DECODER_NOT_SUPPORTED) {\r
- result = RMS_CATEGORY_NONE;\r
- } else if (category_option == RMS_CATEGORY_NOT_PERMITTED) {\r
- result = RMS_CATEGORY_NOT_PERMITTED;\r
- } else if (support_mixing && (category_option > RMS_CATEGORY_AUDIO_DECODER_OPTION && category_option < RMS_CATEGORY_AUDIO_DECODER_OPTION_MAX)) {\r
- result = (rms_rsc_category_e) category_option;\r
- } else {\r
- if (category == RMS_CATEGORY_AUDIO_DECODER) {\r
- result = (rms_rsc_category_e) ((force_sub) ? RMS_CATEGORY_AUDIO_DECODER_SUB : category);\r
- } else if (category == RMS_CATEGORY_AUDIO_DECODER_SUB) {\r
- result = (rms_rsc_category_e) ((force_main) ? RMS_CATEGORY_AUDIO_DECODER : category);\r
- } else {\r
- result = (rms_rsc_category_e) category;\r
- }\r
- }\r
-\r
- return result;\r
-}\r
-\r
-rms_rsc_category_e CRequest::ToScalerCategory(int category, int category_option, bool force_main, bool force_sub)\r
-{\r
- if (category_option == RMS_CATEGORY_NOT_PERMITTED)\r
- return (rms_rsc_category_e) category_option;\r
-\r
- if (force_sub)\r
- return RMS_CATEGORY_SCALER_SUB;\r
-\r
- if (force_main)\r
- return RMS_CATEGORY_SCALER;\r
-\r
- if (category > RMS_CATEGORY_SCALER_OPTION && category < RMS_CATEGORY_SCALER_OPTION_MAX)\r
- return (rms_rsc_category_e) category_option;\r
-\r
- if (category_option > RMS_CATEGORY_SCALER_OPTION && category_option < RMS_CATEGORY_SCALER_OPTION_MAX)\r
- return (rms_rsc_category_e) category_option;\r
-\r
- return (rms_rsc_category_e) category;\r
-}\r
-\r
-rms_rsc_category_e CRequest::ToAudioOutCategory(int category, int category_option, bool force_main, bool force_sub)\r
-{\r
- if (category_option == RMS_CATEGORY_NOT_PERMITTED)\r
- return (rms_rsc_category_e) category_option;\r
-\r
- if (force_sub)\r
- return RMS_CATEGORY_AUDIO_SUB_OUT;\r
-\r
- if (force_main)\r
- return RMS_CATEGORY_AUDIO_MAIN_OUT;\r
-\r
- return (rms_rsc_category_e) category;\r
-}\r
-\r
-bool CRequest::IsSupportedCategory(int category_option)\r
-{\r
- bool result = true;\r
-\r
- switch (category_option) {\r
- case RMS_CATEGORY_IMAGE_DECODER_NOT_SUPPORTED:\r
- case RMS_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED:\r
- case RMS_CATEGORY_JPEG_DECODER_NOT_SUPPORTED:\r
- case RMS_CATEGORY_MJPEG_DECODER_NOT_SUPPORTED:\r
- case RMS_CATEGORY_NOT_PERMITTED:\r
- result = false;\r
- break;\r
- default:\r
- result = true;\r
- break;\r
- }\r
-\r
- return result;\r
-}\r
-\r
-int CRequest::UnmaskMainSubOptions(int category_option)\r
-{\r
- int result = category_option;\r
-\r
- result = (result & ~RMS_DEVICE_OPT_MAIN);\r
- result = (result & ~RMS_DEVICE_OPT_SUB);\r
-\r
- return result;\r
-}\r
-\r
-int CRequest::UnmaskMixingOptions(int category_option)\r
-{\r
- int result = category_option;\r
-\r
- result = (result & ~RMS_MIXING_OPT_DEFAULT);\r
- result = (result & ~RMS_MIXING_OPT_MULTIVIEW);\r
- result = (result & ~RMS_MIXING_OPT_INTERACTION_SOUND);\r
-\r
- return result;\r
-}\r
-\r
-int CRequest::UnmaskForceOptions(int category_option)\r
-{\r
- int result = category_option;\r
-\r
- result = (result & ~RMS_FORCE_TO_MAIN);\r
- result = (result & ~RMS_FORCE_TO_SUB);\r
-\r
- return result;\r
-}\r
-\r
-int CRequest::UnmaskMVZoneInfo(int category_option)\r
-{\r
- const int ZONE_INFO = 0x1E00000;\r
-\r
- return (category_option & ~ZONE_INFO);\r
-}\r
-\r
-rms_rsc_category_e CRequest::ToResourceCategory(int category, int category_option)\r
-{\r
- rms_rsc_category_e result = RMS_CATEGORY_NONE;\r
- bool supported = IsSupportedCategory(category_option);\r
- bool force_main = false;\r
- bool force_sub = false;\r
-\r
- if (supported) {\r
- force_main = (category_option & RMS_FORCE_TO_MAIN);\r
- force_sub = (category_option & RMS_FORCE_TO_SUB);\r
- category_option = UnmaskMainSubOptions(category_option);\r
- }\r
-\r
- switch (category) {\r
- case RMS_CATEGORY_VIDEO_DECODER:\r
- case RMS_CATEGORY_VIDEO_DECODER_SUB:\r
- if (supported) {\r
- category_option = UnmaskMVZoneInfo(category_option);\r
- category_option = (category_option & ~RMS_VIDEO_DEC_OPT_AI);\r
- category_option = UnmaskForceOptions(category_option);\r
- }\r
- result = ToVideoDecoderCategory(category, category_option, force_main, force_sub);\r
- break;\r
- case RMS_CATEGORY_JPEG_DECODER:\r
- result = ToJpegDecoderCategory(category, category_option);\r
- break;\r
- case RMS_CATEGORY_MJPEG_DECODER:\r
- if (supported)\r
- category_option = UnmaskMVZoneInfo(category_option);\r
-\r
- result = ToMJpegDecoderCategory(category, category_option);\r
- break;\r
- case RMS_CATEGORY_IMAGE_DECODER:\r
- result = ToImageDecoderCategory(category, category_option);\r
- break;\r
- case RMS_CATEGORY_AUDIO_DECODER:\r
- case RMS_CATEGORY_AUDIO_DECODER_SUB:\r
- if (supported) {\r
- category_option = UnmaskMixingOptions(category_option);\r
- category_option = UnmaskForceOptions(category_option);\r
- }\r
-\r
- result = ToAudioDecoderCategory(category, category_option, force_main, force_sub);\r
- break;\r
- case RMS_CATEGORY_SCALER:\r
- case RMS_CATEGORY_SCALER_SUB:\r
- if (supported)\r
- category_option = UnmaskMVZoneInfo(category_option);\r
-\r
- result = ToScalerCategory(category, category_option, force_main, force_sub);\r
- break;\r
- case RMS_CATEGORY_AUDIO_MAIN_OUT:\r
- case RMS_CATEGORY_AUDIO_SUB_OUT:\r
- result = ToAudioOutCategory(category, category_option, force_main, force_sub);\r
- break;\r
- default:\r
- result = (rms_rsc_category_e) category;\r
- break;\r
- }\r
-\r
- return result;\r
-}\r
-\r
-rms_mixing_mode_e CRequest::ToMixingMode(int category, int category_option)\r
-{\r
- if (category != RMS_CATEGORY_AUDIO_DECODER && category != RMS_CATEGORY_AUDIO_DECODER_SUB)\r
- return RMS_MIXING_MODE_DEFAULT;\r
-\r
- if (category_option & RMS_MIXING_OPT_MULTIVIEW)\r
- return RMS_MIXING_MODE_MULTIVIEW;\r
-\r
- if (category_option & RMS_MIXING_OPT_INTERACTION_SOUND)\r
- return RMS_MIXING_MODE_INTERACTION_SOUND;\r
-\r
- return RMS_MIXING_MODE_DEFAULT;\r
-}\r
-\r
-void CRequest::PrintResult(void)\r
-{\r
- SERVER_WARN("result (%d) - con(%d:%s) / cat(%d) / req(%d:%d) / devId(%d) / vId(%d) / rsn(%d)",\r
- m_result,\r
- m_requester->getHandle(),\r
- m_requester->getAppId().empty() ? m_requester->GetCmdName().c_str() : m_requester->getAppId().c_str(),\r
- m_category, m_category_id, m_category_option, m_allocated_device, m_virtual_device, m_reason);\r
-}\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+
+#include <rms_debug.h>
+#include "CSysInfo.h"
+#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;
+}
+
+int CRequest::ToMultiviewZoneId(int category_option)
+{
+ const int ZONE_INFO = 0x1E00000;
+ int zone_id = ((category_option & ZONE_INFO) >> 21);
+ return zone_id;
+}
+
+void CRequest::SetCategory(int category_id, int category_option)
+{
+ m_category_id = category_id;
+ m_category_option = category_option;
+ m_category = ToResourceCategory(category_id, category_option);
+ m_mixing_mode = ToMixingMode(category_id, category_option);
+ m_mv_zone_id = ToMultiviewZoneId(category_option);
+}
+
+void CRequest::SetState(int req_state)
+{
+ m_state = (rms_requests_resource_state_e) req_state;
+}
+
+void CRequest::SetResult(rms_return_code_e req_result)
+{
+ m_result = req_result;
+}
+
+rms_return_code_e CRequest::GetResult(void)
+{
+ return m_result;
+}
+
+rms_rsc_category_e CRequest::GetCategory(void)
+{
+ return m_category;
+}
+
+bool CRequest::IsMainDeviceRequest(void)
+{
+ if (m_state == RMS_STATE_EXCLUSIVE_AUTO)
+ return false;
+
+ SERVER_INFO("m_category_id(%d), option(%d)", m_category_id, m_category_option);
+
+ if (IsSupportedCategory(m_category_option)) {
+ if ((m_category_option & RMS_DEVICE_OPT_MAIN) || (m_category_option & RMS_FORCE_TO_MAIN))
+ return true;
+ }
+
+ if ((m_category_id == RMS_CATEGORY_VIDEO_DECODER) && (m_category_option != RMS_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED)) {
+ return (m_category_option & RMS_DEVICE_OPT_MAIN);
+ }
+
+ if (m_category_id == RMS_CATEGORY_AUDIO_DECODER) {
+ if (m_category_option == RMS_CATEGORY_AUDIO_DECODER_NOT_SUPPORTED)
+ return false;
+ if (m_category_option == RMS_DEVICE_OPT_NONE)
+ return true;
+
+ return (m_category_option & RMS_DEVICE_OPT_MAIN);
+ }
+
+ if (m_category_id == RMS_CATEGORY_MJPEG_DECODER)
+ return (m_category_option & RMS_DEVICE_OPT_MAIN);
+
+ if (m_category == RMS_CATEGORY_SCALER_MULTIVIEW)
+ return (m_category_option & RMS_DEVICE_OPT_MAIN);
+
+ return false;
+}
+
+bool CRequest::IsAIDeviceRequest(void)
+{
+ if (m_state == RMS_STATE_EXCLUSIVE_AUTO)
+ return false;
+
+ if ((m_category_id == RMS_CATEGORY_VIDEO_DECODER) && (m_category_option != RMS_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED))
+ return (m_category_option & RMS_VIDEO_DEC_OPT_AI);
+
+ return false;
+}
+
+bool CRequest::IsSubDeviceRequest(void)
+{
+ if (m_state == RMS_STATE_EXCLUSIVE_AUTO)
+ return false;
+
+ //SERVER_DBG("m_category_id(%d), option(%d)", m_category_id, m_category_option);
+
+ if (IsSupportedCategory(m_category_option)) {
+ if ((m_category_option & RMS_DEVICE_OPT_SUB) || (m_category_option & RMS_FORCE_TO_SUB))
+ return true;
+ }
+
+ if ((m_category_id == RMS_CATEGORY_VIDEO_DECODER_SUB) && (m_category_option != RMS_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED))
+ return (m_category_option & RMS_DEVICE_OPT_SUB);
+
+ if (m_category_id == RMS_CATEGORY_AUDIO_DECODER_SUB) {
+ if (m_category_option == RMS_CATEGORY_AUDIO_DECODER_NOT_SUPPORTED)
+ return false;
+ if (m_category_option == RMS_DEVICE_OPT_NONE)
+ return true;
+
+ return (m_category_option & RMS_DEVICE_OPT_SUB);
+ }
+
+ if (m_category_id == RMS_CATEGORY_MJPEG_DECODER)
+ return (m_category_option & RMS_DEVICE_OPT_SUB);
+
+ if (m_category == RMS_CATEGORY_SCALER_MULTIVIEW)
+ return (m_category_option & RMS_DEVICE_OPT_SUB);
+
+ return false;
+}
+
+rms_rsc_category_e CRequest::ToVideoDecoderCategory(int category, int category_option, bool force_main, bool force_sub)
+{
+ rms_rsc_category_e result = RMS_CATEGORY_NONE;
+
+ if (category_option == RMS_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED) {
+ result = RMS_CATEGORY_NONE;
+ } else if ((category_option > RMS_CATEGORY_VIDEO_DECODER_OPTION) && (category_option < RMS_CATEGORY_VIDEO_DECODER_OPTION_MAX)) {
+ result = (rms_rsc_category_e) category_option;
+ } else {
+ if (category == RMS_CATEGORY_VIDEO_DECODER) {
+ result = (rms_rsc_category_e) ((force_sub) ? RMS_CATEGORY_VIDEO_DECODER_SUB : category);
+ } else if (category == RMS_CATEGORY_VIDEO_DECODER_SUB) {
+ result = (rms_rsc_category_e) ((force_main) ? (rms_rsc_category_e) RMS_CATEGORY_VIDEO_DECODER : category);
+ } else {
+ result = (rms_rsc_category_e) category;
+ }
+ }
+
+ return result;
+}
+
+rms_rsc_category_e CRequest::ToImageDecoderCategory(int category, int category_option)
+{
+ rms_rsc_category_e result = RMS_CATEGORY_NONE;
+
+ SERVER_INFO("category(%d)/category_option(%d)", category, category_option);
+
+ if (category_option == RMS_CATEGORY_IMAGE_DECODER_NOT_SUPPORTED) {
+ result = RMS_CATEGORY_NONE;
+ } else if ((category_option > RMS_CATEGORY_HEIC_DECODER_OPTION) && (category_option < RMS_CATEGORY_HEIC_DECODER_OPTION_MAX)) {
+ result = (rms_rsc_category_e) category_option;
+ } else if ((category_option > RMS_CATEGORY_JPEG_DECODER_OPTION) && (category_option < RMS_CATEGORY_JPEG_DECODER_OPTION_MAX)) {
+ result = (rms_rsc_category_e) category_option;
+ } else {
+ result = (rms_rsc_category_e) category;
+ }
+
+ return result;
+}
+
+rms_rsc_category_e CRequest::ToJpegDecoderCategory(int category, int category_option)
+{
+ rms_rsc_category_e result = RMS_CATEGORY_NONE;
+
+ SERVER_INFO("category(%d)/category_option(%d)", category, category_option);
+
+ if (category_option == RMS_CATEGORY_JPEG_DECODER_NOT_SUPPORTED) {
+ result = RMS_CATEGORY_NONE;
+ } else if ((category_option > RMS_CATEGORY_JPEG_DECODER_OPTION) && (category_option < RMS_CATEGORY_JPEG_DECODER_OPTION_MAX)) {
+ result = (rms_rsc_category_e) category_option;
+ } else {
+ result = (rms_rsc_category_e) category;
+ }
+
+ return result;
+}
+
+rms_rsc_category_e CRequest::ToMJpegDecoderCategory(int category, int category_option)
+{
+ rms_rsc_category_e result = RMS_CATEGORY_NONE;
+
+ if (category_option == RMS_CATEGORY_MJPEG_DECODER_NOT_SUPPORTED) {
+ result = RMS_CATEGORY_NONE;
+ } else if ((category_option > RMS_CATEGORY_MJPEG_DECODER_OPTION) && (category_option < RMS_CATEGORY_MJPEG_DECODER_OPTION_MAX)) {
+ result = (rms_rsc_category_e) category_option;
+ } else {
+ result = (rms_rsc_category_e)category;
+ }
+
+ return result;
+}
+
+rms_rsc_category_e CRequest::ToAudioDecoderCategory(int category, int category_option, bool force_main, bool force_sub)
+{
+ rms_rsc_category_e result = RMS_CATEGORY_NONE;
+ bool support_mixing = CSysInfo::GetInstance()->IsAudioMixingSupported();
+
+ if (category_option == RMS_CATEGORY_AUDIO_DECODER_NOT_SUPPORTED) {
+ result = RMS_CATEGORY_NONE;
+ } else if (category_option == RMS_CATEGORY_NOT_PERMITTED) {
+ result = RMS_CATEGORY_NOT_PERMITTED;
+ } else if (support_mixing && (category_option > RMS_CATEGORY_AUDIO_DECODER_OPTION && category_option < RMS_CATEGORY_AUDIO_DECODER_OPTION_MAX)) {
+ result = (rms_rsc_category_e) category_option;
+ } else {
+ if (category == RMS_CATEGORY_AUDIO_DECODER) {
+ result = (rms_rsc_category_e) ((force_sub) ? RMS_CATEGORY_AUDIO_DECODER_SUB : category);
+ } else if (category == RMS_CATEGORY_AUDIO_DECODER_SUB) {
+ result = (rms_rsc_category_e) ((force_main) ? RMS_CATEGORY_AUDIO_DECODER : category);
+ } else {
+ result = (rms_rsc_category_e) category;
+ }
+ }
+
+ return result;
+}
+
+rms_rsc_category_e CRequest::ToScalerCategory(int category, int category_option, bool force_main, bool force_sub)
+{
+ if (category_option == RMS_CATEGORY_NOT_PERMITTED)
+ return (rms_rsc_category_e) category_option;
+
+ if (force_sub)
+ return RMS_CATEGORY_SCALER_SUB;
+
+ if (force_main)
+ return RMS_CATEGORY_SCALER;
+
+ if (category > RMS_CATEGORY_SCALER_OPTION && category < RMS_CATEGORY_SCALER_OPTION_MAX)
+ return (rms_rsc_category_e) category_option;
+
+ if (category_option > RMS_CATEGORY_SCALER_OPTION && category_option < RMS_CATEGORY_SCALER_OPTION_MAX)
+ return (rms_rsc_category_e) category_option;
+
+ return (rms_rsc_category_e) category;
+}
+
+rms_rsc_category_e CRequest::ToAudioOutCategory(int category, int category_option, bool force_main, bool force_sub)
+{
+ if (category_option == RMS_CATEGORY_NOT_PERMITTED)
+ return (rms_rsc_category_e) category_option;
+
+ if (force_sub)
+ return RMS_CATEGORY_AUDIO_SUB_OUT;
+
+ if (force_main)
+ return RMS_CATEGORY_AUDIO_MAIN_OUT;
+
+ return (rms_rsc_category_e) category;
+}
+
+bool CRequest::IsSupportedCategory(int category_option)
+{
+ bool result = true;
+
+ switch (category_option) {
+ case RMS_CATEGORY_IMAGE_DECODER_NOT_SUPPORTED:
+ case RMS_CATEGORY_VIDEO_DECODER_NOT_SUPPORTED:
+ case RMS_CATEGORY_JPEG_DECODER_NOT_SUPPORTED:
+ case RMS_CATEGORY_MJPEG_DECODER_NOT_SUPPORTED:
+ case RMS_CATEGORY_NOT_PERMITTED:
+ result = false;
+ break;
+ default:
+ result = true;
+ break;
+ }
+
+ return result;
+}
+
+int CRequest::UnmaskMainSubOptions(int category_option)
+{
+ int result = category_option;
+
+ result = (result & ~RMS_DEVICE_OPT_MAIN);
+ result = (result & ~RMS_DEVICE_OPT_SUB);
+
+ return result;
+}
+
+int CRequest::UnmaskMixingOptions(int category_option)
+{
+ int result = category_option;
+
+ result = (result & ~RMS_MIXING_OPT_DEFAULT);
+ result = (result & ~RMS_MIXING_OPT_MULTIVIEW);
+ result = (result & ~RMS_MIXING_OPT_INTERACTION_SOUND);
+
+ return result;
+}
+
+int CRequest::UnmaskForceOptions(int category_option)
+{
+ int result = category_option;
+
+ result = (result & ~RMS_FORCE_TO_MAIN);
+ result = (result & ~RMS_FORCE_TO_SUB);
+
+ return result;
+}
+
+int CRequest::UnmaskMVZoneInfo(int category_option)
+{
+ const int ZONE_INFO = 0x1E00000;
+
+ return (category_option & ~ZONE_INFO);
+}
+
+rms_rsc_category_e CRequest::ToResourceCategory(int category, int category_option)
+{
+ rms_rsc_category_e result = RMS_CATEGORY_NONE;
+ bool supported = IsSupportedCategory(category_option);
+ bool force_main = false;
+ bool force_sub = false;
+
+ if (supported) {
+ force_main = (category_option & RMS_FORCE_TO_MAIN);
+ force_sub = (category_option & RMS_FORCE_TO_SUB);
+ category_option = UnmaskMainSubOptions(category_option);
+ }
+
+ switch (category) {
+ case RMS_CATEGORY_VIDEO_DECODER:
+ case RMS_CATEGORY_VIDEO_DECODER_SUB:
+ if (supported) {
+ category_option = UnmaskMVZoneInfo(category_option);
+ category_option = (category_option & ~RMS_VIDEO_DEC_OPT_AI);
+ category_option = UnmaskForceOptions(category_option);
+ }
+ result = ToVideoDecoderCategory(category, category_option, force_main, force_sub);
+ break;
+ case RMS_CATEGORY_JPEG_DECODER:
+ result = ToJpegDecoderCategory(category, category_option);
+ break;
+ case RMS_CATEGORY_MJPEG_DECODER:
+ if (supported)
+ category_option = UnmaskMVZoneInfo(category_option);
+
+ result = ToMJpegDecoderCategory(category, category_option);
+ break;
+ case RMS_CATEGORY_IMAGE_DECODER:
+ result = ToImageDecoderCategory(category, category_option);
+ break;
+ case RMS_CATEGORY_AUDIO_DECODER:
+ case RMS_CATEGORY_AUDIO_DECODER_SUB:
+ if (supported) {
+ category_option = UnmaskMixingOptions(category_option);
+ category_option = UnmaskForceOptions(category_option);
+ }
+
+ result = ToAudioDecoderCategory(category, category_option, force_main, force_sub);
+ break;
+ case RMS_CATEGORY_SCALER:
+ case RMS_CATEGORY_SCALER_SUB:
+ if (supported)
+ category_option = UnmaskMVZoneInfo(category_option);
+
+ result = ToScalerCategory(category, category_option, force_main, force_sub);
+ break;
+ case RMS_CATEGORY_AUDIO_MAIN_OUT:
+ case RMS_CATEGORY_AUDIO_SUB_OUT:
+ result = ToAudioOutCategory(category, category_option, force_main, force_sub);
+ break;
+ default:
+ result = (rms_rsc_category_e) category;
+ break;
+ }
+
+ return result;
+}
+
+rms_mixing_mode_e CRequest::ToMixingMode(int category, int 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)
+ return RMS_MIXING_MODE_INTERACTION_SOUND;
+
+ return RMS_MIXING_MODE_DEFAULT;
+}
+
+void CRequest::PrintResult(void)
+{
+ SERVER_WARN("result (%d) - con(%d:%s) / cat(%d) / req(%d:%d) / devId(%d) / vId(%d) / rsn(%d)",
+ m_result,
+ m_requester->getHandle(),
+ m_requester->getAppId().empty() ? m_requester->GetCmdName().c_str() : m_requester->getAppId().c_str(),
+ m_category, m_category_id, m_category_option, m_allocated_device, m_virtual_device, m_reason);
+}
-/*\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 "CDebugUtils.h"\r
-#include "CRequester.h"\r
-\r
-CRequester::CRequester()\r
-{\r
- m_handle = 0;\r
- m_pid = 0;\r
- m_main_priority = 0;\r
- m_sub_priority = 0;\r
- m_app_id.assign("");\r
-}\r
-\r
-CRequester::CRequester(rms_msg_request *req)\r
-{\r
- m_handle = req->handle;\r
- m_pid = req->pid;\r
- m_main_priority = req->main_priority;\r
- m_sub_priority = req->sub_priority;\r
- m_app_id.assign(req->app_id);\r
- SetCmdName(req->pid);\r
-}\r
-\r
-CRequester::~CRequester()\r
-{\r
-}\r
-\r
-void CRequester::SetCmdName(int pid)\r
-{\r
- char cmd_name[512] = {0, };\r
- std::string delimiter = "/";\r
-\r
- rms_get_cmd_name(pid, cmd_name, 512);\r
- m_cmd_name.assign(cmd_name);\r
- m_cmd_name = m_cmd_name.substr(m_cmd_name.find_last_of(delimiter) + 1, m_cmd_name.length());\r
-}\r
-\r
-int CRequester::getHandle(void)\r
-{\r
- return m_handle;\r
-}\r
-\r
-int CRequester::getPid(void)\r
-{\r
- return m_pid;\r
-}\r
-\r
-int CRequester::getMainPriority(void)\r
-{\r
- return m_main_priority;\r
-}\r
-\r
-int CRequester::getSubPriority(void)\r
-{\r
- return m_sub_priority;\r
-}\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "CDebugUtils.h"
+#include "CRequester.h"
+
+CRequester::CRequester()
+{
+ m_handle = 0;
+ m_pid = 0;
+ m_main_priority = 0;
+ m_sub_priority = 0;
+ m_app_id.assign("");
+}
+
+CRequester::CRequester(rms_msg_request *req)
+{
+ m_handle = req->handle;
+ m_pid = req->pid;
+ m_main_priority = req->main_priority;
+ m_sub_priority = req->sub_priority;
+ m_app_id.assign(req->app_id);
+ SetCmdName(req->pid);
+}
+
+CRequester::~CRequester()
+{
+}
+
+void CRequester::SetCmdName(int pid)
+{
+ char cmd_name[512] = {0, };
+ std::string delimiter = "/";
+
+ rms_get_cmd_name(pid, cmd_name, 512);
+ m_cmd_name.assign(cmd_name);
+ m_cmd_name = m_cmd_name.substr(m_cmd_name.find_last_of(delimiter) + 1, m_cmd_name.length());
+}
+
+int CRequester::getHandle(void)
+{
+ return m_handle;
+}
+
+int CRequester::getPid(void)
+{
+ return m_pid;
+}
+
+int CRequester::getMainPriority(void)
+{
+ return m_main_priority;
+}
+
+int CRequester::getSubPriority(void)
+{
+ return m_sub_priority;
+}
-/*\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 <glib.h>\r
-#include <vconf.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <iostream>\r
-#include <assert.h>\r
-#include <trace.h>\r
-#include <dlfcn.h>\r
-\r
-#include <CResourceService.h>\r
-#include <CDebugUtils.h>\r
-#include <rms_debug.h>\r
-#include <rms_type.h>\r
-#include <CMessageHandler.h>\r
-#include <CResourceManager.h>\r
-\r
-#define RM_SERVER_SMART_DEADLOCK_WATCHDOG_TIME_90_SEC 90\r
-#define RM_SERVER_WATCHDOG_TIME_10000_MSEC 10000\r
-#define RM_SERVER_INVALID_TABLE_TIME_30000_MSEC 30000\r
-\r
-int CResourceService::Init(GMainLoop *main_loop)\r
-{\r
- CResourceManager *rsc_mgr = new CResourceManager();\r
- if (rsc_mgr->RegisterResources() != RMS_OK) {\r
- SERVER_ERR("RegisterResources is failed");\r
- g_timeout_add(RM_SERVER_INVALID_TABLE_TIME_30000_MSEC, InvalidResourceTableMsgCallback, NULL);\r
- return RMS_ERROR;\r
- }\r
-\r
- m_msg_h = new CMessageHandler(rsc_mgr);\r
- if (m_msg_h->Run() != RMS_OK) {\r
- SERVER_ERR("RUN failed");\r
- return RMS_ERROR;\r
- }\r
-\r
- SERVER_INFO("Done");\r
- return RMS_OK;\r
-}\r
-\r
-int CResourceService::IsFirstLaunch(void)\r
-{\r
- const char *vconf_key = "memory/rsc_mgr/is_launched_before";\r
- int is_launched_before = 0;\r
-\r
- if (vconf_get_int(vconf_key, &is_launched_before) != 0)\r
- SERVER_ERR("Failed to get %s", vconf_key);\r
-\r
- if (is_launched_before == 1) {\r
- SERVER_ERR("!!!!! Resource Manager 2nd Launch !!!!!");\r
- return 0;\r
- }\r
-\r
- if (vconf_set_int(vconf_key, 1) != 0)\r
- SERVER_ERR("Failed to set %s", vconf_key);\r
-\r
- return 1;\r
-}\r
-\r
-void CResourceService::RequestColdPowerOff(void)\r
-{\r
- const char *vconf_request_cold_poweroff = "memory/boot/cold_poweroff_request_pkg";\r
-\r
- if (vconf_set_str(vconf_request_cold_poweroff, "resource-manager") != 0) {\r
- SERVER_ERR("Failed to set %s", vconf_request_cold_poweroff);\r
- }\r
-}\r
-\r
-void CResourceService::CreateWatchDogTimer(void)\r
-{\r
-}\r
-\r
-void CResourceService::SetVIPProcess(void)\r
-{\r
- void *handle;\r
- void (*vip_func)(void);\r
-\r
- handle = dlopen("/lib/libproc-stat.so.5", RTLD_LAZY);\r
-\r
- if (!handle) {\r
- SERVER_ERR("failed to open libproc-stat.so (%s)", dlerror());\r
- return;\r
- }\r
-\r
- *(void**)&vip_func = dlsym(handle, "proc_stat_set_vip_process");\r
-\r
- if (!vip_func) {\r
- SERVER_ERR("failed to find proc_stat_set_vip_process");\r
- dlclose(handle);\r
- return;\r
- }\r
-\r
- SERVER_INFO("set vip process");\r
- vip_func();\r
- dlclose(handle);\r
-}\r
-\r
-gboolean CResourceService::WatchDogCallback(gpointer data)\r
-{\r
- return G_SOURCE_CONTINUE;\r
-}\r
-\r
-gboolean CResourceService::InvalidResourceTableMsgCallback(gpointer data)\r
-{\r
- SERVER_ERR("resource table not loaded!");\r
- rms_print_model_info();\r
- return G_SOURCE_CONTINUE;\r
-}\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <vconf.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <iostream>
+#include <assert.h>
+#include <trace.h>
+#include <dlfcn.h>
+
+#include <CResourceService.h>
+#include <CDebugUtils.h>
+#include <rms_debug.h>
+#include <rms_type.h>
+#include <CMessageHandler.h>
+#include <CResourceManager.h>
+
+#define RM_SERVER_SMART_DEADLOCK_WATCHDOG_TIME_90_SEC 90
+#define RM_SERVER_WATCHDOG_TIME_10000_MSEC 10000
+#define RM_SERVER_INVALID_TABLE_TIME_30000_MSEC 30000
+
+int CResourceService::Init(GMainLoop *main_loop)
+{
+ CResourceManager *rsc_mgr = new CResourceManager();
+ if (rsc_mgr->RegisterResources() != RMS_OK) {
+ SERVER_ERR("RegisterResources is failed");
+ g_timeout_add(RM_SERVER_INVALID_TABLE_TIME_30000_MSEC, InvalidResourceTableMsgCallback, NULL);
+ return RMS_ERROR;
+ }
+
+ m_msg_h = new CMessageHandler(rsc_mgr);
+ if (m_msg_h->Run() != RMS_OK) {
+ SERVER_ERR("RUN failed");
+ return RMS_ERROR;
+ }
+
+ SERVER_INFO("Done");
+ return RMS_OK;
+}
+
+int CResourceService::IsFirstLaunch(void)
+{
+ const char *vconf_key = "memory/rsc_mgr/is_launched_before";
+ int is_launched_before = 0;
+
+ if (vconf_get_int(vconf_key, &is_launched_before) != 0)
+ SERVER_ERR("Failed to get %s", vconf_key);
+
+ if (is_launched_before == 1) {
+ SERVER_ERR("!!!!! Resource Manager 2nd Launch !!!!!");
+ return 0;
+ }
+
+ if (vconf_set_int(vconf_key, 1) != 0)
+ SERVER_ERR("Failed to set %s", vconf_key);
+
+ return 1;
+}
+
+void CResourceService::RequestColdPowerOff(void)
+{
+ const char *vconf_request_cold_poweroff = "memory/boot/cold_poweroff_request_pkg";
+
+ if (vconf_set_str(vconf_request_cold_poweroff, "resource-manager") != 0) {
+ SERVER_ERR("Failed to set %s", vconf_request_cold_poweroff);
+ }
+}
+
+void CResourceService::CreateWatchDogTimer(void)
+{
+}
+
+void CResourceService::SetVIPProcess(void)
+{
+ void *handle;
+ void (*vip_func)(void);
+
+ handle = dlopen("/lib/libproc-stat.so.5", RTLD_LAZY);
+
+ if (!handle) {
+ SERVER_ERR("failed to open libproc-stat.so (%s)", dlerror());
+ return;
+ }
+
+ *(void**)&vip_func = dlsym(handle, "proc_stat_set_vip_process");
+
+ if (!vip_func) {
+ SERVER_ERR("failed to find proc_stat_set_vip_process");
+ dlclose(handle);
+ return;
+ }
+
+ SERVER_INFO("set vip process");
+ vip_func();
+ dlclose(handle);
+}
+
+gboolean CResourceService::WatchDogCallback(gpointer data)
+{
+ return G_SOURCE_CONTINUE;
+}
+
+gboolean CResourceService::InvalidResourceTableMsgCallback(gpointer data)
+{
+ SERVER_ERR("resource table not loaded!");
+ rms_print_model_info();
+ return G_SOURCE_CONTINUE;
+}
-/*\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 <stdlib.h>\r
-#include <iostream>\r
-#include <assert.h>\r
-#include <system_info.h>\r
-#include <rms_debug.h>\r
-#include <CSysInfo.h>\r
-\r
-CSysInfo *CSysInfo::m_instance = NULL;\r
-\r
-CSysInfo *CSysInfo::GetInstance(void)\r
-{\r
- if (!m_instance) {\r
- m_instance = new(std::nothrow) CSysInfo;\r
- assert(m_instance);\r
- }\r
-\r
- return m_instance;\r
-}\r
-\r
-bool CSysInfo::IsAudioMixingSupported(void)\r
-{\r
- static bool init = false;\r
- bool supported = false;\r
-\r
- if (init)\r
- return m_support_audio_mixing;\r
-\r
- if (system_info_get_custom_bool("com.samsung/featureconf/multiview.dualsound", &supported) != SYSTEM_INFO_ERROR_NONE) {\r
- SERVER_ERR("failed to get com.samsung/featureconf/multiview.dualsound");\r
- return m_support_audio_mixing;\r
- }\r
-\r
- m_support_audio_mixing = supported;\r
- init = true;\r
- SERVER_INFO("multiview.dualsound (%d)", supported);\r
- return m_support_audio_mixing;\r
-}\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <iostream>
+#include <assert.h>
+#include <system_info.h>
+#include <rms_debug.h>
+#include <CSysInfo.h>
+
+CSysInfo *CSysInfo::m_instance = NULL;
+
+CSysInfo *CSysInfo::GetInstance(void)
+{
+ if (!m_instance) {
+ m_instance = new(std::nothrow) CSysInfo;
+ assert(m_instance);
+ }
+
+ return m_instance;
+}
+
+bool CSysInfo::IsAudioMixingSupported(void)
+{
+ static bool init = false;
+ bool supported = false;
+
+ if (init)
+ return m_support_audio_mixing;
+
+ if (system_info_get_custom_bool("com.samsung/featureconf/multiview.dualsound", &supported) != SYSTEM_INFO_ERROR_NONE) {
+ SERVER_ERR("failed to get com.samsung/featureconf/multiview.dualsound");
+ return m_support_audio_mixing;
+ }
+
+ m_support_audio_mixing = supported;
+ init = true;
+ SERVER_INFO("multiview.dualsound (%d)", supported);
+ return m_support_audio_mixing;
+}
-/*\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 <sys/types.h>\r
-#include <sys/ipc.h>\r
-#include <sys/msg.h>\r
-#include <errno.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <sys/stat.h>\r
-#include <unistd.h>\r
-#include <rms_debug.h>\r
-#include <rms_type.h>\r
-#include <unistd.h>\r
-\r
-#define RM_MSGQ_KEY_TX 8212\r
-#define RM_MSGQ_KEY_RX 8211\r
-\r
-static int _is_symlink_file(const char *path)\r
-{\r
- struct stat st;\r
- if (lstat(path, &st) == -1) {\r
- SERVER_ERR("stat error. file path(%s)", path);\r
- return 0;\r
- }\r
-\r
- return (S_ISLNK(st.st_mode)) ? 1 : 0;\r
-}\r
-\r
-static int _is_realpath(const char *path)\r
-{\r
- char *rms_realpath = NULL;\r
- int len_path = 0;\r
- int len_realpath = 0;\r
- int result = 1;\r
-\r
- rms_realpath = realpath(path, NULL);\r
-\r
- if (!rms_realpath) {\r
- SERVER_INFO("realpath(%s) is null(%d)", path, errno);\r
- return 0;\r
- }\r
-\r
- len_path = strlen(path);\r
- len_realpath = strlen(rms_realpath);\r
-\r
- if (len_path != len_realpath) {\r
- SERVER_ERR("length mismatch(%d:%d)", len_path, len_realpath);\r
- result = 0;\r
- goto out;\r
- }\r
-\r
- if (strncmp(path, rms_realpath, len_path)) {\r
- SERVER_ERR("path mismatch(%s:%s)", path, rms_realpath);\r
- result = 0;\r
- goto out;\r
- }\r
-\r
-out:\r
- free(rms_realpath);\r
-\r
- return result;\r
-}\r
-\r
-int main()\r
-{\r
- int msgq_tx = -1, msgq_rx = -1;\r
- msgq_tx = msgget((key_t)RM_MSGQ_KEY_TX, 0666 | IPC_CREAT);\r
- msgq_rx = msgget((key_t)RM_MSGQ_KEY_RX, 0666 | IPC_CREAT);\r
-\r
- if ((msgq_tx == -1) || (msgq_rx == -1)) {\r
- SERVER_ERR("NEW MSGQ_CREATE failed to get msgq_id - msgq_tx(%d), msgq_rx(%d)", msgq_tx, msgq_rx);\r
- return -1;\r
- }\r
-\r
- SERVER_INFO("msgq_tx (%d), msgq_rx(%d)", msgq_tx, msgq_rx);\r
-\r
- FILE *fp = NULL;\r
- const char *flag_path = "/run/rsc_mgr_ready";\r
-\r
- fp = fopen(flag_path,"w");\r
-\r
- if (!fp) {\r
- SERVER_ERR("NEW_MSGQ_CREATE Failed to create message queue(%s) errno(%d)", flag_path, errno);\r
- return -1;\r
- }\r
-\r
- if (!_is_realpath(flag_path)) {\r
- SERVER_ERR("%s is not realpath", flag_path);\r
- fclose(fp);\r
- return -1;\r
- }\r
-\r
- if (_is_symlink_file(flag_path)) {\r
- SERVER_ERR("%s is symbolic link file", flag_path);\r
- fclose(fp);\r
- return -1;\r
- }\r
-\r
- SERVER_INFO("NEW_MSGQ_CREATE resource manager message queue(%s) created", flag_path);\r
-\r
- fflush(fp);\r
- fsync(fileno(fp));\r
- fclose(fp);\r
- return 0;\r
-}\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <rms_debug.h>
+#include <rms_type.h>
+#include <unistd.h>
+
+#define RM_MSGQ_KEY_TX 8212
+#define RM_MSGQ_KEY_RX 8211
+
+static int _is_symlink_file(const char *path)
+{
+ struct stat st;
+ if (lstat(path, &st) == -1) {
+ SERVER_ERR("stat error. file path(%s)", path);
+ return 0;
+ }
+
+ return (S_ISLNK(st.st_mode)) ? 1 : 0;
+}
+
+static int _is_realpath(const char *path)
+{
+ char *rms_realpath = NULL;
+ int len_path = 0;
+ int len_realpath = 0;
+ int result = 1;
+
+ rms_realpath = realpath(path, NULL);
+
+ if (!rms_realpath) {
+ SERVER_INFO("realpath(%s) is null(%d)", path, errno);
+ return 0;
+ }
+
+ len_path = strlen(path);
+ len_realpath = strlen(rms_realpath);
+
+ if (len_path != len_realpath) {
+ SERVER_ERR("length mismatch(%d:%d)", len_path, len_realpath);
+ result = 0;
+ goto out;
+ }
+
+ if (strncmp(path, rms_realpath, len_path)) {
+ SERVER_ERR("path mismatch(%s:%s)", path, rms_realpath);
+ result = 0;
+ goto out;
+ }
+
+out:
+ free(rms_realpath);
+
+ return result;
+}
+
+int main()
+{
+ int msgq_tx = -1, msgq_rx = -1;
+ msgq_tx = msgget((key_t)RM_MSGQ_KEY_TX, 0666 | IPC_CREAT);
+ msgq_rx = msgget((key_t)RM_MSGQ_KEY_RX, 0666 | IPC_CREAT);
+
+ if ((msgq_tx == -1) || (msgq_rx == -1)) {
+ SERVER_ERR("NEW MSGQ_CREATE failed to get msgq_id - msgq_tx(%d), msgq_rx(%d)", msgq_tx, msgq_rx);
+ return -1;
+ }
+
+ SERVER_INFO("msgq_tx (%d), msgq_rx(%d)", msgq_tx, msgq_rx);
+
+ FILE *fp = NULL;
+ const char *flag_path = "/run/rsc_mgr_ready";
+
+ fp = fopen(flag_path,"w");
+
+ if (!fp) {
+ SERVER_ERR("NEW_MSGQ_CREATE Failed to create message queue(%s) errno(%d)", flag_path, errno);
+ return -1;
+ }
+
+ if (!_is_realpath(flag_path)) {
+ SERVER_ERR("%s is not realpath", flag_path);
+ fclose(fp);
+ return -1;
+ }
+
+ if (_is_symlink_file(flag_path)) {
+ SERVER_ERR("%s is symbolic link file", flag_path);
+ fclose(fp);
+ return -1;
+ }
+
+ SERVER_INFO("NEW_MSGQ_CREATE resource manager message queue(%s) created", flag_path);
+
+ fflush(fp);
+ fsync(fileno(fp));
+ fclose(fp);
+ return 0;
+}
-/*\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 <trace.h>\r
-#include <rms_debug.h>\r
-#include <CResourceService.h>\r
-\r
-#include <iostream>\r
-\r
-int main(void)\r
-{\r
- SERVER_INFO("RscMgr server main loop\n");\r
- trace_begin("[RSC_MGR] main start");\r
- trace_end();\r
-\r
- GMainLoop *main_loop;\r
- main_loop = g_main_loop_new(NULL, FALSE);\r
-\r
- if (!main_loop) {\r
- SERVER_ERR("failed to create a main loop\n");\r
- return 0;\r
- }\r
-\r
- CResourceService *service = new(std::nothrow) CResourceService;\r
- service->Init(main_loop);\r
-\r
- g_main_loop_ref(main_loop);\r
- g_main_loop_run(main_loop);\r
-\r
- return 0;\r
-}\r
+/*
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <trace.h>
+#include <rms_debug.h>
+#include <CResourceService.h>
+
+#include <iostream>
+
+int main(void)
+{
+ SERVER_INFO("RscMgr server main loop\n");
+ trace_begin("[RSC_MGR] main start");
+ trace_end();
+
+ 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;
+ }
+
+ CResourceService *service = new(std::nothrow) CResourceService;
+ service->Init(main_loop);
+
+ g_main_loop_ref(main_loop);
+ g_main_loop_run(main_loop);
+
+ return 0;
+}