diff --git a/osd/util/Render_Rockchip.c b/osd/util/Render_Rockchip.c index e18ac50..960474a 100644 --- a/osd/util/Render_Rockchip.c +++ b/osd/util/Render_Rockchip.c @@ -35,14 +35,22 @@ typedef struct { extern int AHI_TiltY; int Init_x86(uint16_t *width, uint16_t *height) { // Create shared memory region - const char *shm_name = "msposd"; // Name of the shared memory region - - // Open the shared memory segment - int shm_fd = shm_open(shm_name, O_RDWR, 0666); - if (shm_fd == -1) { - perror("Failed to open shared memory"); - return -1; + int shm_fd = -1; + + // Wait until the shared memory segment exists + while (shm_fd == -1) { + shm_fd = shm_open(shm_name, O_RDWR, 0666); + if (shm_fd == -1) { + if (errno == ENOENT) { + printf("Shared memory '%s' does not exist. Waiting...\n", shm_name); + sleep(1); // Wait for 1 second before trying again + continue; + } else { + perror("Failed to open shared memory"); + return -1; + } + } } // Map just the header to read width and height