[vlc-commits] [Git][videolan/vlc][master] 2 commits: mmdevice: clear pending status on selection error

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Jul 30 08:09:53 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
a1808eb8 by Anthony La at 2026-07-30T07:45:11+00:00
mmdevice: clear pending status on selection error

No device request is made when ToWide() fails, so the worker cannot
clear DEVICE_PENDING. Mark the acquisition as failed before returning.
- - - - -
db483e2b by Anthony La at 2026-07-30T07:45:11+00:00
mmdevice: wait for pending device acquisition in Start

MMSessionMainloop() marks the device as pending before MMSession() releases the old device. Start() can run while the lock is dropped for cleanup and still see the invalid device.

Wait until the acquisition is done before using sys->dev. Broadcast the completion since DeviceRequestLocked() and Start() may both be waiting.
- - - - -


1 changed file:

- modules/audio_output/mmdevice.c


Changes:

=====================================
modules/audio_output/mmdevice.c
=====================================
@@ -756,7 +756,10 @@ static int DeviceSelectLocked(audio_output_t *aout, const char *id)
     wchar_t *previous = atomic_exchange(&sys->device_name, selected_device_name);
     free(previous);
     if (unlikely(selected_device_name == NULL && new_string))
+    {
+        sys->device_status = DEVICE_ACQUISITION_FAILED;
         return -1;
+    }
 
     return DeviceRequestLocked(aout);
 }
@@ -942,7 +945,7 @@ static HRESULT MMSession(audio_output_t *aout, IMMDeviceEnumerator *it)
         }
     }
 
-    vlc_cond_signal(&sys->ready);
+    vlc_cond_broadcast(&sys->ready);
     vlc_sem_post(&sys->init_passed);
 
     if (FAILED(hr))
@@ -1219,6 +1222,9 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
     EnterMTA();
     vlc_mutex_lock(&sys->lock);
 
+    while (sys->device_status == DEVICE_PENDING)
+        vlc_cond_wait(&sys->ready, &sys->lock);
+
     if ((atomic_exchange(&sys->default_device_changed, false) && DeviceRestartLocked(aout) != 0)
       || sys->dev == NULL)
     {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/77fc1594e2d3804f6e4ca06ea27736fb2acadae0...db483e2ba82f2302697f87c6273061331e6775bf

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/77fc1594e2d3804f6e4ca06ea27736fb2acadae0...db483e2ba82f2302697f87c6273061331e6775bf
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list