/////////////////////////////////////////////////////// Entry point of application \return Application exit code ///////////////////////////////////////////////////////
| 19 | /// |
| 20 | //////////////////////////////////////////////////////////// |
| 21 | int main() |
| 22 | { |
| 23 | // List the available playback devices |
| 24 | auto devices = sf::PlaybackDevice::getAvailableDevices(); |
| 25 | |
| 26 | if (devices.empty()) |
| 27 | { |
| 28 | std::cout << "No playback devices available\n"; |
| 29 | return EXIT_FAILURE; |
| 30 | } |
| 31 | |
| 32 | std::cout << "Available playback devices:\n\n"; |
| 33 | |
| 34 | for (auto i = 0u; i < devices.size(); ++i) |
| 35 | std::cout << i << ": " << devices[i] << '\n'; |
| 36 | |
| 37 | std::cout << '\n'; |
| 38 | |
| 39 | // Output the default device name if one is available |
| 40 | const auto defaultDevice = sf::PlaybackDevice::getDefaultDevice(); |
| 41 | |
| 42 | if (defaultDevice) |
| 43 | std::cout << "Default device: " << *defaultDevice << '\n'; |
| 44 | |
| 45 | std::cout << std::endl; |
| 46 | |
| 47 | std::size_t deviceIndex = 0; |
| 48 | |
| 49 | // Choose the playback device |
| 50 | if (devices.size() > 1) |
| 51 | { |
| 52 | deviceIndex = devices.size(); |
| 53 | std::cout << "Please choose the playback device to use [0-" << devices.size() - 1 << "]: "; |
| 54 | do |
| 55 | { |
| 56 | std::cin >> deviceIndex; |
| 57 | std::cin.ignore(10'000, '\n'); |
| 58 | } while (deviceIndex >= devices.size()); |
| 59 | } |
| 60 | |
| 61 | // Check if we can and whether the user wants to enable automatic stream routing |
| 62 | bool automaticStreamRouting = false; |
| 63 | |
| 64 | if (devices[deviceIndex] == defaultDevice) |
| 65 | { |
| 66 | char answer{}; |
| 67 | std::cout << "Activate automatic stream routing? (Y/N): "; |
| 68 | do |
| 69 | { |
| 70 | std::cin >> answer; |
| 71 | std::cin.ignore(10'000, '\n'); |
| 72 | } while (answer != 'Y' && answer != 'y' && answer != 'N' && answer != 'n'); |
| 73 | automaticStreamRouting = (answer == 'Y') || (answer == 'y'); |
| 74 | } |
| 75 | |
| 76 | // Check if we should manually reroute to the default device or the null device |
| 77 | bool rerouteToNull = false; |
| 78 |
nothing calls this directly
no test coverage detected