| 491 | } |
| 492 | |
| 493 | void UsbInterface::startControlThread(void) |
| 494 | { |
| 495 | if (mCtrlThreadValid) { |
| 496 | return; |
| 497 | } |
| 498 | |
| 499 | mCtrlRunning.store(true); |
| 500 | // Same priority and core hint as the server worker. It spends virtually |
| 501 | // all of its life parked in eventWait, so it costs nothing to keep. |
| 502 | if (R_SUCCEEDED(threadCreate(&mCtrlThread, controlThreadEntry, this, nullptr, 0x4000, 0x2C, -2)) && R_SUCCEEDED(threadStart(&mCtrlThread))) { |
| 503 | mCtrlThreadValid = true; |
| 504 | } |
| 505 | else { |
| 506 | mCtrlRunning.store(false); |
| 507 | Logging::error("Failed to start the MTP control-request thread; hosts will re-enumerate the device instead of recovering from an error."); |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | void UsbInterface::stopControlThread(void) |
| 512 | { |