@@ -150,6 +150,12 @@ namespace display_device {
150150 session_t::clear_vdd_state () {
151151 current_vdd_client_id.clear ();
152152 last_vdd_setting.clear ();
153+ // 恢复原始的 output_name,避免下一个会话使用已销毁的 VDD 设备 ID
154+ if (!original_output_name.empty ()) {
155+ config::video.output_name = original_output_name;
156+ original_output_name.clear ();
157+ BOOST_LOG (debug) << " 已恢复原始 output_name: " << config::video.output_name ;
158+ }
153159 }
154160
155161 void
@@ -182,17 +188,12 @@ namespace display_device {
182188 }
183189
184190 /* *
185- * @brief Wait for VDD device to initialize and be fully ready .
191+ * @brief Wait for VDD device to be available (active or inactive) .
186192 * @param device_zako Output parameter for the device ID.
187193 * @param max_attempts Maximum number of retry attempts.
188194 * @param initial_delay Initial delay between retries.
189195 * @param max_delay Maximum delay between retries.
190- * @return true if device was found and is ready, false otherwise.
191- *
192- * This function checks multiple conditions to ensure the VDD device is fully ready:
193- * 1. Device can be found by friendly name
194- * 2. Device is in the active device list
195- * 3. Device has a valid source mode (can be queried for display configuration)
196+ * @return true if device was found (active or inactive), false otherwise.
196197 */
197198 bool
198199 wait_for_vdd_device (std::string &device_zako, int max_attempts,
@@ -202,26 +203,19 @@ namespace display_device {
202203 [&device_zako]() {
203204 device_zako = display_device::find_device_by_friendlyname (ZAKO_NAME);
204205 if (device_zako.empty ()) {
206+ BOOST_LOG (debug) << " VDD device not found by friendly name" ;
205207 return false ;
206208 }
207209
208- const auto display_data = w_utils::query_display_config (w_utils::ACTIVE_ONLY_DEVICES);
209- if (!display_data) {
210- return false ;
211- }
212-
213- const auto path = w_utils::get_active_path (device_zako, display_data->paths );
214- if (!path) {
215- return false ;
216- }
217-
218- const auto source_index = w_utils::get_source_index (*path, display_data->modes );
219- return source_index && w_utils::get_source_mode (source_index, display_data->modes );
210+ // Device found by friendly name - that's all we need
211+ // It can be activated later during display configuration
212+ BOOST_LOG (debug) << " VDD device found: " << device_zako;
213+ return true ;
220214 },
221215 { .max_attempts = max_attempts,
222216 .initial_delay = initial_delay,
223217 .max_delay = max_delay,
224- .context = " 等待VDD设备初始化并完全就绪 " });
218+ .context = " Waiting for VDD device availability " });
225219 }
226220
227221 /* *
@@ -388,7 +382,7 @@ namespace display_device {
388382 if (device_zako.empty ()) {
389383 BOOST_LOG (info) << " 创建虚拟显示器..." ;
390384 vdd_utils::create_vdd_monitor (current_client_id, hdr_brightness, physical_size);
391- std::this_thread::sleep_for (233ms );
385+ std::this_thread::sleep_for (500ms );
392386 }
393387
394388 // Wait for device to be ready
@@ -408,6 +402,11 @@ namespace display_device {
408402 return ;
409403 }
410404
405+ if (original_output_name.empty ()) {
406+ original_output_name = config::video.output_name ;
407+ BOOST_LOG (debug) << " 保存原始 output_name: " << original_output_name;
408+ }
409+
411410 // Update configuration and state
412411 config.device_id = device_zako;
413412 config::video.output_name = device_zako;
0 commit comments