|
|
|
|
@ -31,7 +31,7 @@ void process(void*);
|
|
|
|
|
|
|
|
|
|
/* Вызывается под lock; резервирование делает отказ команды наблюдаемым до изменения состояния. */ |
|
|
|
|
bool schedule() { |
|
|
|
|
if (!bridge.inst || !uasync_is_running(bridge.inst->ua)) { |
|
|
|
|
if (!bridge.inst) { |
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "desktop stream command rejected: core unavailable"); return false; |
|
|
|
|
} |
|
|
|
|
if (bridge.pending) return true; |
|
|
|
|
@ -150,6 +150,11 @@ bool gui_stream_attach(UTUN_INSTANCE* inst) {
|
|
|
|
|
} |
|
|
|
|
bridge.inst = inst; bridge.output.clear(); bridge.bytes = 0; |
|
|
|
|
stream_set_event_callback(inst, mediaEvent, nullptr); |
|
|
|
|
if (bridge.watchPending) { |
|
|
|
|
bridge.watchPending = false; |
|
|
|
|
if (stream_watch_sources(inst, bridge.watch) != STREAM_OK) |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "desktop initial source watch failed group=%llx", (unsigned long long)bridge.watch); |
|
|
|
|
} |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_STREAM, "desktop stream bridge attached"); return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -167,6 +172,10 @@ void gui_stream_detach(UTUN_INSTANCE* inst) {
|
|
|
|
|
|
|
|
|
|
bool gui_stream_watch(uint64_t group) { |
|
|
|
|
std::lock_guard<std::mutex> guard(bridge.lock); |
|
|
|
|
if (!bridge.inst) { |
|
|
|
|
bridge.watch = group; bridge.watchPending = true; |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_STREAM, "desktop source watch queued until attach group=%llx", (unsigned long long)group); return true; |
|
|
|
|
} |
|
|
|
|
if (!schedule()) return false; |
|
|
|
|
bridge.watch = group; bridge.watchPending = true; return true; |
|
|
|
|
} |
|
|
|
|
|