From: jae915 Date: Wed, 29 May 2024 00:00:23 +0000 (+0900) Subject: change appid acquisition method due to AMD latency X-Git-Tag: accepted/tizen/unified/20240603.160955^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6db5ef5ea89f6754a294c953348007595fc4bc1c;p=platform%2Fcore%2Fmultimedia%2Flibmm-camcorder.git change appid acquisition method due to AMD latency Change-Id: Ie2b4b1c1f49e4c041e507c6896834e970797d780 --- diff --git a/src/mm_camcorder_rm.c b/src/mm_camcorder_rm.c index b3e1d12..cdb3696 100644 --- a/src/mm_camcorder_rm.c +++ b/src/mm_camcorder_rm.c @@ -31,6 +31,8 @@ #include "mm_camcorder_rm.h" #include "mm_camcorder_internal.h" +#define PROCESS_NAME_PATH_MAX 200 + static rm_cb_result __mmcamcorder_rm_callback(int handle, rm_callback_type event_src, rm_device_request_s *info, void* cb_data) { @@ -64,6 +66,60 @@ static rm_cb_result __mmcamcorder_rm_callback(int handle, rm_callback_type event return cb_res; } +void _mmcamcorder_get_appid_bypid(int pid, char *name, size_t size) +{ + FILE *cmdline; + char buf[PROCESS_NAME_PATH_MAX]; + int length; + unsigned int buf_pos = 0; + unsigned int ret_pos = 0; + char *read = NULL; + + + mmf_return_if_fail(name); + + if (size > 0u) { + name[0] = 0; + } + + length = snprintf(buf, sizeof(buf), "/proc/%d/cmdline", (int)pid); + if (length >= (int)sizeof(buf)) + return; + + cmdline = fopen(buf, "r"); + if (NULL == cmdline) { + MMCAM_LOG_ERROR("File[%s] open failed", buf); + return; + } + + read = fgets(buf, sizeof(buf), cmdline); + fclose(cmdline); + + if (NULL == read) { + MMCAM_LOG_ERROR("File read failed"); + return; + } + + for (buf_pos = 0; buf_pos < sizeof(buf); buf_pos++) { + switch(buf[buf_pos]) { + case '\0': + name[ret_pos] = '\0'; + return; + case '/': + ret_pos = 0; + break; + default: + if (ret_pos < size) + name[ret_pos] = buf[buf_pos]; + + ret_pos++; + break; + } + } + +} + + int _mmcamcorder_rm_create(MMHandleType handle) { int ret = RM_OK; @@ -77,7 +133,7 @@ int _mmcamcorder_rm_create(MMHandleType handle) mm_camcorder_get_attributes(handle, NULL, MMCAM_CLIENT_PID, &hcamcorder->rci.app_pid, NULL); - aul_app_get_appid_bypid(hcamcorder->rci.app_pid, hcamcorder->rci.app_id, sizeof(hcamcorder->rci.app_id)); + _mmcamcorder_get_appid_bypid(hcamcorder->rci.app_pid, hcamcorder->rci.app_id, sizeof(hcamcorder->rci.app_id)); /* RM register */ /* NULL should be passed for the rci parameter if the application does not have "visibility" */