Commit caaddf3
committed
Defer UMS device-list updates to the main thread
libusbhsfs's populate callback runs on its USB-event thread. The
previous code mutated context.filesystems / cur_fs directly from
that thread, racing with main-thread reads from UI code.
Stash the new device list under a mutex; have the main loops
(menu_loop, video_loop) drain and apply pending changes once per
frame so context.filesystems stays single-threaded for readers.
Also handle USB unplug during playback: when the filesystem
hosting the currently-playing file disappears, async-stop mpv
and break out of video_loop with EIO so the user falls back to
the menu cleanly. (Note: this does not eliminate crashes when
mpv's demuxer thread is mid-read at the moment of physical
removal -- that race is inside libusbhsfs and would require
upstream changes to fix.)1 parent 79a3eb2 commit caaddf3
1 file changed
Lines changed: 36 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
137 | 140 | | |
138 | 141 | | |
139 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
140 | 149 | | |
141 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
142 | 163 | | |
143 | 164 | | |
144 | 165 | | |
| |||
187 | 208 | | |
188 | 209 | | |
189 | 210 | | |
| 211 | + | |
| 212 | + | |
190 | 213 | | |
191 | 214 | | |
192 | 215 | | |
| |||
283 | 306 | | |
284 | 307 | | |
285 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
286 | 321 | | |
287 | 322 | | |
288 | 323 | | |
| |||
0 commit comments