fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 Amlogic Corporation. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
fei.deng | dd910ef | 2024-06-07 10:25:30 +0800 | [diff] [blame] | 16 | #include <fcntl.h> |
| 17 | #include <string.h> |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 18 | #include "wayland_plugin.h" |
| 19 | #include "wayland_display.h" |
| 20 | #include "Logger.h" |
| 21 | #include "Times.h" |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 22 | #include "ErrorCode.h" |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 23 | |
| 24 | #define TAG "rlib:wayland_plugin" |
| 25 | |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 26 | WaylandPlugin::WaylandPlugin(int logCatgory) |
| 27 | : mRenderLock("renderlock"), |
| 28 | mLogCategory(logCatgory) |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 29 | { |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 30 | mDisplay = new WaylandDisplay(this, logCatgory); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 31 | mQueue = new Tls::Queue(); |
| 32 | mPaused = false; |
| 33 | mImmediatelyOutput = false; |
| 34 | } |
| 35 | |
| 36 | WaylandPlugin::~WaylandPlugin() |
| 37 | { |
| 38 | if (mDisplay) { |
| 39 | delete mDisplay; |
| 40 | } |
| 41 | if (mQueue) { |
| 42 | mQueue->flush(); |
| 43 | delete mQueue; |
| 44 | mQueue = NULL; |
| 45 | } |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 46 | TRACE(mLogCategory,"desconstruct"); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | void WaylandPlugin::init() |
| 50 | { |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 51 | INFO(mLogCategory,"\n--------------------------------\n" |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 52 | "plugin : weston\n" |
| 53 | "ARCH : %s\n" |
| 54 | "branch name : %s\n" |
| 55 | "git version : %s\n" |
| 56 | "change id : %s \n" |
| 57 | "ID : %s \n" |
| 58 | "last changed: %s\n" |
| 59 | "build-time : %s\n" |
| 60 | "build-name : %s\n" |
| 61 | "--------------------------------\n", |
| 62 | #if defined(__aarch64__) |
| 63 | "arm64", |
| 64 | #else |
| 65 | "arm", |
| 66 | #endif |
| 67 | BRANCH_NAME, |
| 68 | GIT_VERSION, |
| 69 | COMMIT_CHANGEID, |
| 70 | COMMIT_PD, |
| 71 | LAST_CHANGED, |
| 72 | BUILD_TIME, |
| 73 | BUILD_NAME |
| 74 | ); |
| 75 | } |
| 76 | |
| 77 | void WaylandPlugin::release() |
| 78 | { |
| 79 | } |
| 80 | |
| 81 | void WaylandPlugin::setCallback(void *userData, PluginCallback *callback) |
| 82 | { |
| 83 | mUserData = userData; |
| 84 | mCallback = callback; |
| 85 | } |
| 86 | |
| 87 | int WaylandPlugin::openDisplay() |
| 88 | { |
| 89 | int ret; |
| 90 | |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 91 | Tls::Mutex::Autolock _l(mRenderLock); |
| 92 | DEBUG(mLogCategory,"openDisplay"); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 93 | ret = mDisplay->openDisplay(); |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 94 | if (ret != NO_ERROR) { |
| 95 | ERROR(mLogCategory,"Error open display"); |
| 96 | return ret; |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 97 | } |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 98 | DEBUG(mLogCategory,"openDisplay end"); |
| 99 | return ret; |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | int WaylandPlugin::openWindow() |
| 103 | { |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 104 | Tls::Mutex::Autolock _l(mRenderLock); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 105 | /* if weston can't support pts feature, |
| 106 | * we should create a post buffer thread to |
| 107 | * send buffer by mono time |
| 108 | */ |
fei.deng | 640c3c9 | 2024-04-12 08:31:19 +0000 | [diff] [blame] | 109 | WaylandDisplay::AmlConfigAPIList *amlconfig = mDisplay->getAmlConfigAPIList(); |
| 110 | if (!amlconfig->enableSetPts) { |
fei.deng | dd910ef | 2024-06-07 10:25:30 +0800 | [diff] [blame] | 111 | DEBUG(mLogCategory,"run frame post thread"); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 112 | setThreadPriority(50); |
| 113 | run("waylandPostThread"); |
| 114 | } |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 115 | return NO_ERROR; |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | int WaylandPlugin::prepareFrame(RenderBuffer *buffer) |
| 119 | { |
| 120 | mDisplay->prepareFrameBuffer(buffer); |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 121 | return NO_ERROR; |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | int WaylandPlugin::displayFrame(RenderBuffer *buffer, int64_t displayTime) |
| 125 | { |
| 126 | /* if weston can't support pts feature, |
| 127 | * push buffer to queue, the buffer will send to |
| 128 | * weston in post thread |
| 129 | */ |
fei.deng | 640c3c9 | 2024-04-12 08:31:19 +0000 | [diff] [blame] | 130 | WaylandDisplay::AmlConfigAPIList *amlconfig = mDisplay->getAmlConfigAPIList(); |
| 131 | if (!amlconfig->enableSetPts) { |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 132 | buffer->time = displayTime; |
| 133 | mQueue->push(buffer); |
fei.deng | dd910ef | 2024-06-07 10:25:30 +0800 | [diff] [blame] | 134 | DEBUG(mLogCategory,"queue size:%d,pts:%lld us",mQueue->getCnt(),buffer->pts/1000); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 135 | } else { |
| 136 | mDisplay->displayFrameBuffer(buffer, displayTime); |
| 137 | } |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 138 | return NO_ERROR; |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | void WaylandPlugin::queueFlushCallback(void *userdata,void *data) |
| 142 | { |
| 143 | WaylandPlugin* plugin = static_cast<WaylandPlugin *>(userdata); |
| 144 | plugin->handleFrameDropped((RenderBuffer *)data); |
| 145 | plugin->handleBufferRelease((RenderBuffer *)data); |
| 146 | } |
| 147 | |
| 148 | int WaylandPlugin::flush() |
| 149 | { |
| 150 | RenderBuffer *entity; |
| 151 | mQueue->flushAndCallback(this, WaylandPlugin::queueFlushCallback); |
| 152 | mDisplay->flushBuffers(); |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 153 | return NO_ERROR; |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | int WaylandPlugin::pause() |
| 157 | { |
| 158 | mPaused = true; |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 159 | return NO_ERROR; |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 160 | } |
| 161 | int WaylandPlugin::resume() |
| 162 | { |
| 163 | mPaused = false; |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 164 | return NO_ERROR; |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | int WaylandPlugin::closeDisplay() |
| 168 | { |
| 169 | RenderBuffer *entity; |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 170 | Tls::Mutex::Autolock _l(mRenderLock); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 171 | mDisplay->closeDisplay(); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 172 | |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 173 | return NO_ERROR; |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | int WaylandPlugin::closeWindow() |
| 177 | { |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 178 | Tls::Mutex::Autolock _l(mRenderLock); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 179 | if (isRunning()) { |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 180 | DEBUG(mLogCategory,"stop frame post thread"); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 181 | requestExitAndWait(); |
| 182 | } |
fei.deng | dd910ef | 2024-06-07 10:25:30 +0800 | [diff] [blame] | 183 | mQueue->flushAndCallback(this, WaylandPlugin::queueFlushCallback); |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 184 | return NO_ERROR; |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | |
| 188 | int WaylandPlugin::getValue(PluginKey key, void *value) |
| 189 | { |
| 190 | switch (key) { |
| 191 | case PLUGIN_KEY_SELECT_DISPLAY_OUTPUT: { |
| 192 | *(int *)(value) = mDisplay->getDisplayOutput(); |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 193 | TRACE(mLogCategory,"get select display output:%d",*(int *)value); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 194 | } break; |
fei.deng | f1f5fc3 | 2023-12-06 06:22:20 +0000 | [diff] [blame] | 195 | case PLUGIN_KEY_CURRENT_OUTPUT: { |
| 196 | *(int *)(value) = mDisplay->getCurrentOutputCrtcIndex(); |
| 197 | //DEBUG(mLogCategory,"get current crtc output index:%d",*(int *)value); |
| 198 | } break; |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 199 | } |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 200 | return NO_ERROR; |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | int WaylandPlugin::setValue(PluginKey key, void *value) |
| 204 | { |
| 205 | switch (key) { |
| 206 | case PLUGIN_KEY_WINDOW_SIZE: { |
| 207 | RenderRect* rect = static_cast<RenderRect*>(value); |
| 208 | if (mDisplay) { |
| 209 | mDisplay->setWindowSize(rect->x, rect->y, rect->w, rect->h); |
| 210 | } |
| 211 | } break; |
| 212 | case PLUGIN_KEY_FRAME_SIZE: { |
| 213 | RenderFrameSize * frameSize = static_cast<RenderFrameSize * >(value); |
| 214 | if (mDisplay) { |
| 215 | mDisplay->setFrameSize(frameSize->width, frameSize->height); |
| 216 | } |
| 217 | } break; |
| 218 | case PLUGIN_KEY_VIDEO_FORMAT: { |
| 219 | int videoFormat = *(int *)(value); |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 220 | DEBUG(mLogCategory,"Set video format :%d",videoFormat); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 221 | mDisplay->setVideoBufferFormat((RenderVideoFormat)videoFormat); |
| 222 | } break; |
| 223 | case PLUGIN_KEY_SELECT_DISPLAY_OUTPUT: { |
| 224 | int outputIndex = *(int *)(value); |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 225 | DEBUG(mLogCategory,"Set select display output :%d",outputIndex); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 226 | mDisplay->setDisplayOutput(outputIndex); |
| 227 | } break; |
| 228 | case PLUGIN_KEY_VIDEO_PIP: { |
| 229 | int pip = *(int *) (value); |
| 230 | pip = pip > 0? 1: 0; |
| 231 | mDisplay->setPip(pip); |
| 232 | } break; |
| 233 | case PLUGIN_KEY_IMMEDIATELY_OUTPUT: { |
| 234 | bool mImmediatelyOutput = (*(int *)(value)) > 0? true: false; |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 235 | DEBUG(mLogCategory, "Set immediately output:%d",mImmediatelyOutput); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 236 | } break; |
fei.deng | 640c3c9 | 2024-04-12 08:31:19 +0000 | [diff] [blame] | 237 | case PLUGIN_KEY_KEEP_LAST_FRAME: { |
| 238 | int keep = *(int *) (value); |
| 239 | DEBUG(mLogCategory, "Set keep last frame:%d",keep); |
| 240 | mDisplay->setKeepLastFrame(keep); |
| 241 | } break; |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 242 | } |
| 243 | return 0; |
| 244 | } |
| 245 | |
| 246 | void WaylandPlugin::handleBufferRelease(RenderBuffer *buffer) |
| 247 | { |
| 248 | if (mCallback) { |
| 249 | mCallback->doBufferReleaseCallback(mUserData, (void *)buffer); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | void WaylandPlugin::handleFrameDisplayed(RenderBuffer *buffer) |
| 254 | { |
| 255 | if (mCallback) { |
| 256 | mCallback->doBufferDisplayedCallback(mUserData, (void *)buffer); |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | void WaylandPlugin::handleFrameDropped(RenderBuffer *buffer) |
| 261 | { |
| 262 | if (mCallback) { |
| 263 | mCallback->doBufferDropedCallback(mUserData, (void *)buffer); |
| 264 | } |
| 265 | } |
| 266 | |
fei.deng | 3287c08 | 2024-04-23 09:29:22 +0000 | [diff] [blame] | 267 | void WaylandPlugin::handleMsgNotify(int type, void *detail) |
| 268 | { |
| 269 | if (mCallback) { |
| 270 | mCallback->doMsgCallback(mUserData, type, detail); |
| 271 | } |
| 272 | } |
| 273 | |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 274 | void WaylandPlugin::readyToRun() |
| 275 | { |
| 276 | } |
| 277 | |
| 278 | bool WaylandPlugin::threadLoop() |
| 279 | { |
| 280 | RenderBuffer *curFrameEntity = NULL; |
| 281 | RenderBuffer *expiredFrameEntity = NULL; |
| 282 | int64_t nowMonotime = Tls::Times::getSystemTimeUs(); |
| 283 | |
| 284 | //if queue is empty or paused, loop next |
| 285 | if (mQueue->isEmpty() || mPaused) { |
| 286 | goto tag_next; |
| 287 | } |
| 288 | |
fei.deng | 1cfb275 | 2023-10-26 08:01:25 +0000 | [diff] [blame] | 289 | //if weston has no wl_outout,it means weston can't display frames |
| 290 | //so we should display buffer to display to drop buffers |
| 291 | if (mDisplay->getWlOutput() == NULL) { |
| 292 | mQueue->pop((void **)&expiredFrameEntity); |
| 293 | goto tag_post; |
| 294 | } |
| 295 | |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 296 | //if weston obtains a buffer rendering,we can't send buffer to weston |
| 297 | if (mDisplay->isRedrawingPending()) { |
| 298 | goto tag_next; |
| 299 | } |
| 300 | |
| 301 | //we output video frame asap |
| 302 | if (mImmediatelyOutput) { |
| 303 | //pop the peeked frame |
| 304 | mQueue->pop((void **)&expiredFrameEntity); |
| 305 | goto tag_post; |
| 306 | } |
| 307 | |
| 308 | while (mQueue->peek((void **)&curFrameEntity, 0) == Q_OK) |
| 309 | { |
| 310 | //no frame expired,loop next |
| 311 | if (nowMonotime < curFrameEntity->time) { |
| 312 | break; |
| 313 | } |
| 314 | |
| 315 | //pop the peeked frame |
| 316 | mQueue->pop((void **)&curFrameEntity); |
| 317 | |
| 318 | //drop last expired frame,got a new expired frame |
| 319 | if (expiredFrameEntity) { |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 320 | WARNING(mLogCategory,"drop,now:%lld,display:%lld(pts:%lld ms),n-d:%lld ms", |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 321 | nowMonotime,expiredFrameEntity->time,expiredFrameEntity->pts/1000000, |
| 322 | (nowMonotime - expiredFrameEntity->time)/1000); |
| 323 | handleFrameDropped(expiredFrameEntity); |
| 324 | handleBufferRelease(expiredFrameEntity); |
| 325 | expiredFrameEntity = NULL; |
| 326 | } |
| 327 | |
| 328 | expiredFrameEntity = curFrameEntity; |
| 329 | } |
| 330 | |
| 331 | tag_post: |
| 332 | if (!expiredFrameEntity) { |
| 333 | //TRACE(mLogCategory,"no frame expire"); |
| 334 | goto tag_next; |
| 335 | } |
| 336 | |
| 337 | if (mDisplay) { |
fei.deng | dd910ef | 2024-06-07 10:25:30 +0800 | [diff] [blame] | 338 | TRACE(mLogCategory,"post,now:%lld,display:%lld(pts:%lld ms),n-d::%lld ms, size:%d", |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 339 | nowMonotime,expiredFrameEntity->time,expiredFrameEntity->pts/1000000, |
fei.deng | dd910ef | 2024-06-07 10:25:30 +0800 | [diff] [blame] | 340 | (nowMonotime - expiredFrameEntity->time)/1000,mQueue->getCnt()); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 341 | mDisplay->displayFrameBuffer(expiredFrameEntity, expiredFrameEntity->time); |
| 342 | } |
| 343 | |
| 344 | tag_next: |
| 345 | usleep(4*1000); |
| 346 | return true; |
| 347 | } |
| 348 | |
| 349 | void *makePluginInstance(int id) |
| 350 | { |
fei.deng | dd910ef | 2024-06-07 10:25:30 +0800 | [diff] [blame] | 351 | int fd= -1; |
| 352 | const char *levelPath = "/run/rlib_plugin_level"; |
| 353 | |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 354 | int category =Logger_init(id); |
fei.deng | c467785 | 2023-10-09 07:21:04 +0000 | [diff] [blame] | 355 | char *env = getenv("VIDEO_RENDER_PLUGIN_LOG_LEVEL"); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 356 | if (env) { |
| 357 | int level = atoi(env); |
| 358 | Logger_set_level(level); |
fei.deng | dd910ef | 2024-06-07 10:25:30 +0800 | [diff] [blame] | 359 | INFO(category,"env set VIDEO_RENDER_PLUGIN_LOG_LEVEL=%d",level); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 360 | } |
fei.deng | dd910ef | 2024-06-07 10:25:30 +0800 | [diff] [blame] | 361 | |
| 362 | //get log level from /run/rlib_plugin_level |
| 363 | fd= open(levelPath, O_RDONLY|O_CLOEXEC); |
| 364 | if ( fd >= 0 ) |
| 365 | { |
| 366 | char valstr[64]; |
| 367 | uint32_t val= 0; |
| 368 | int nRead; |
| 369 | |
| 370 | memset(valstr, 0, sizeof(valstr)); |
| 371 | nRead = read(fd, valstr, sizeof(valstr) - 1); |
| 372 | valstr[strlen(valstr)] = '\0'; |
| 373 | if (sscanf(valstr, "%u", &val) > 0) |
| 374 | { |
| 375 | Logger_set_level(val); |
| 376 | INFO(category,"set VIDEO_RENDER_LOG_LEVEL=%d",val); |
| 377 | } |
| 378 | close(fd); |
| 379 | fd = -1; |
| 380 | } |
| 381 | Logger_set_level(4); |
| 382 | |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 383 | WaylandPlugin *pluginInstance = new WaylandPlugin(category); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 384 | return static_cast<void *>(pluginInstance); |
| 385 | } |
| 386 | |
| 387 | void destroyPluginInstance(void * plugin) |
| 388 | { |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 389 | int category; |
| 390 | |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 391 | WaylandPlugin *pluginInstance = static_cast<WaylandPlugin *>(plugin); |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 392 | category = pluginInstance->getLogCategory(); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 393 | delete pluginInstance; |
fei.deng | b9a1a57 | 2023-09-13 01:33:57 +0000 | [diff] [blame] | 394 | Logger_exit(category); |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 395 | } |