Calling obs_frontend_set_preview_program_mode() directly from a thread that is not the main OBS UI thread will lead to undefined behaviour, so we have to use this helper function instead - copied from obs-websocket plugin
| 27 | // is not the main OBS UI thread will lead to undefined behaviour, so we have |
| 28 | // to use this helper function instead - copied from obs-websocket plugin |
| 29 | static void enableStudioMode(bool enable) |
| 30 | { |
| 31 | if (obs_frontend_preview_program_mode_active() != enable) { |
| 32 | obs_queue_task( |
| 33 | OBS_TASK_UI, |
| 34 | [](void *param) { |
| 35 | auto studioModeEnabled = (bool *)param; |
| 36 | obs_frontend_set_preview_program_mode( |
| 37 | *studioModeEnabled); |
| 38 | }, |
| 39 | &enable, true); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | bool MacroActionSudioMode::PerformAction() |
| 44 | { |