diff options
author | Chris Robinson <[email protected]> | 2020-03-30 15:37:41 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-03-30 15:37:41 -0700 |
commit | f2ddf971df5cbbd112e0d677b0ea5bd6368051dc (patch) | |
tree | 8142af1d3cde52f61c30d88951aeff00cb3f2b39 /alc | |
parent | 167bdce48d1656569cf63448fc2328800288c38f (diff) |
Return the enumerated device names from the backend
Rather than using an out parameter.
Diffstat (limited to 'alc')
34 files changed, 192 insertions, 144 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 691b9274..0851305a 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1217,18 +1217,28 @@ void ProbeAllDevicesList() DO_INITCONFIG(); std::lock_guard<std::recursive_mutex> _{ListLock}; - alcAllDevicesList.clear(); - if(PlaybackFactory) - PlaybackFactory->probe(DevProbe::Playback, &alcAllDevicesList); + if(!PlaybackFactory) + decltype(alcAllDevicesList){}.swap(alcAllDevicesList); + else + { + std::string names{PlaybackFactory->probe(DevProbe::Playback)}; + if(names.empty()) names += '\0'; + names.swap(alcAllDevicesList); + } } void ProbeCaptureDeviceList() { DO_INITCONFIG(); std::lock_guard<std::recursive_mutex> _{ListLock}; - alcCaptureDeviceList.clear(); - if(CaptureFactory) - CaptureFactory->probe(DevProbe::Capture, &alcCaptureDeviceList); + if(!CaptureFactory) + decltype(alcCaptureDeviceList){}.swap(alcCaptureDeviceList); + else + { + std::string names{CaptureFactory->probe(DevProbe::Capture)}; + if(names.empty()) names += '\0'; + names.swap(alcCaptureDeviceList); + } } } // namespace diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp index bfeec1b8..f132cb72 100644 --- a/alc/backends/alsa.cpp +++ b/alc/backends/alsa.cpp @@ -1229,27 +1229,31 @@ bool AlsaBackendFactory::init() bool AlsaBackendFactory::querySupport(BackendType type) { return (type == BackendType::Playback || type == BackendType::Capture); } -void AlsaBackendFactory::probe(DevProbe type, std::string *outnames) +std::string AlsaBackendFactory::probe(DevProbe type) { - auto add_device = [outnames](const DevMap &entry) -> void + std::string outnames; + + auto add_device = [&outnames](const DevMap &entry) -> void { /* +1 to also append the null char (to ensure a null-separated list and * double-null terminated list). */ - outnames->append(entry.name.c_str(), entry.name.length()+1); + outnames.append(entry.name.c_str(), entry.name.length()+1); }; switch(type) { - case DevProbe::Playback: - PlaybackDevices = probe_devices(SND_PCM_STREAM_PLAYBACK); - std::for_each(PlaybackDevices.cbegin(), PlaybackDevices.cend(), add_device); - break; + case DevProbe::Playback: + PlaybackDevices = probe_devices(SND_PCM_STREAM_PLAYBACK); + std::for_each(PlaybackDevices.cbegin(), PlaybackDevices.cend(), add_device); + break; - case DevProbe::Capture: - CaptureDevices = probe_devices(SND_PCM_STREAM_CAPTURE); - std::for_each(CaptureDevices.cbegin(), CaptureDevices.cend(), add_device); - break; + case DevProbe::Capture: + CaptureDevices = probe_devices(SND_PCM_STREAM_CAPTURE); + std::for_each(CaptureDevices.cbegin(), CaptureDevices.cend(), add_device); + break; } + + return outnames; } BackendPtr AlsaBackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/alsa.h b/alc/backends/alsa.h index fb9de006..e1c50444 100644 --- a/alc/backends/alsa.h +++ b/alc/backends/alsa.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/base.h b/alc/backends/base.h index 6f0c773d..764fb3f4 100644 --- a/alc/backends/base.h +++ b/alc/backends/base.h @@ -66,7 +66,7 @@ struct BackendFactory { virtual bool querySupport(BackendType type) = 0; - virtual void probe(DevProbe type, std::string *outnames) = 0; + virtual std::string probe(DevProbe type) = 0; virtual BackendPtr createBackend(ALCdevice *device, BackendType type) = 0; diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp index 5570b716..56520641 100644 --- a/alc/backends/coreaudio.cpp +++ b/alc/backends/coreaudio.cpp @@ -637,16 +637,18 @@ bool CoreAudioBackendFactory::init() { return true; } bool CoreAudioBackendFactory::querySupport(BackendType type) { return type == BackendType::Playback || type == BackendType::Capture; } -void CoreAudioBackendFactory::probe(DevProbe type, std::string *outnames) +std::string CoreAudioBackendFactory::probe(DevProbe type) { + std::string outnames; switch(type) { - case DevProbe::Playback: - case DevProbe::Capture: - /* Includes null char. */ - outnames->append(ca_device, sizeof(ca_device)); - break; + case DevProbe::Playback: + case DevProbe::Capture: + /* Includes null char. */ + outnames.append(ca_device, sizeof(ca_device)); + break; } + return outnames; } BackendPtr CoreAudioBackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/coreaudio.h b/alc/backends/coreaudio.h index 37b9ebe5..212db92b 100644 --- a/alc/backends/coreaudio.h +++ b/alc/backends/coreaudio.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp index 83b10116..abe36e57 100644 --- a/alc/backends/dsound.cpp +++ b/alc/backends/dsound.cpp @@ -869,14 +869,15 @@ bool DSoundBackendFactory::init() bool DSoundBackendFactory::querySupport(BackendType type) { return (type == BackendType::Playback || type == BackendType::Capture); } -void DSoundBackendFactory::probe(DevProbe type, std::string *outnames) +std::string DSoundBackendFactory::probe(DevProbe type) { - auto add_device = [outnames](const DevMap &entry) -> void + std::string outnames; + auto add_device = [&outnames](const DevMap &entry) -> void { /* +1 to also append the null char (to ensure a null-separated list and * double-null terminated list). */ - outnames->append(entry.name.c_str(), entry.name.length()+1); + outnames.append(entry.name.c_str(), entry.name.length()+1); }; /* Initialize COM to prevent name truncation */ @@ -884,24 +885,26 @@ void DSoundBackendFactory::probe(DevProbe type, std::string *outnames) HRESULT hrcom{CoInitialize(nullptr)}; switch(type) { - case DevProbe::Playback: - PlaybackDevices.clear(); - hr = DirectSoundEnumerateW(DSoundEnumDevices, &PlaybackDevices); - if(FAILED(hr)) - ERR("Error enumerating DirectSound playback devices (0x%lx)!\n", hr); - std::for_each(PlaybackDevices.cbegin(), PlaybackDevices.cend(), add_device); - break; + case DevProbe::Playback: + PlaybackDevices.clear(); + hr = DirectSoundEnumerateW(DSoundEnumDevices, &PlaybackDevices); + if(FAILED(hr)) + ERR("Error enumerating DirectSound playback devices (0x%lx)!\n", hr); + std::for_each(PlaybackDevices.cbegin(), PlaybackDevices.cend(), add_device); + break; - case DevProbe::Capture: - CaptureDevices.clear(); - hr = DirectSoundCaptureEnumerateW(DSoundEnumDevices, &CaptureDevices); - if(FAILED(hr)) - ERR("Error enumerating DirectSound capture devices (0x%lx)!\n", hr); - std::for_each(CaptureDevices.cbegin(), CaptureDevices.cend(), add_device); - break; + case DevProbe::Capture: + CaptureDevices.clear(); + hr = DirectSoundCaptureEnumerateW(DSoundEnumDevices, &CaptureDevices); + if(FAILED(hr)) + ERR("Error enumerating DirectSound capture devices (0x%lx)!\n", hr); + std::for_each(CaptureDevices.cbegin(), CaptureDevices.cend(), add_device); + break; } if(SUCCEEDED(hrcom)) CoUninitialize(); + + return outnames; } BackendPtr DSoundBackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/dsound.h b/alc/backends/dsound.h index 6bef0bfc..d1948198 100644 --- a/alc/backends/dsound.h +++ b/alc/backends/dsound.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp index 0cad064d..f784fed9 100644 --- a/alc/backends/jack.cpp +++ b/alc/backends/jack.cpp @@ -504,18 +504,19 @@ bool JackBackendFactory::init() bool JackBackendFactory::querySupport(BackendType type) { return (type == BackendType::Playback); } -void JackBackendFactory::probe(DevProbe type, std::string *outnames) +std::string JackBackendFactory::probe(DevProbe type) { + std::string outnames; switch(type) { - case DevProbe::Playback: - /* Includes null char. */ - outnames->append(jackDevice, sizeof(jackDevice)); - break; - - case DevProbe::Capture: - break; + case DevProbe::Playback: + /* Includes null char. */ + outnames.append(jackDevice, sizeof(jackDevice)); + break; + case DevProbe::Capture: + break; } + return outnames; } BackendPtr JackBackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/jack.h b/alc/backends/jack.h index 10beebfb..793d6f8e 100644 --- a/alc/backends/jack.h +++ b/alc/backends/jack.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/loopback.cpp b/alc/backends/loopback.cpp index 511061f3..44ac68d1 100644 --- a/alc/backends/loopback.cpp +++ b/alc/backends/loopback.cpp @@ -66,8 +66,8 @@ bool LoopbackBackendFactory::init() bool LoopbackBackendFactory::querySupport(BackendType) { return true; } -void LoopbackBackendFactory::probe(DevProbe, std::string*) -{ } +std::string LoopbackBackendFactory::probe(DevProbe) +{ return std::string{}; } BackendPtr LoopbackBackendFactory::createBackend(ALCdevice *device, BackendType) { return BackendPtr{new LoopbackBackend{device}}; } diff --git a/alc/backends/loopback.h b/alc/backends/loopback.h index 09c085b8..df4929e6 100644 --- a/alc/backends/loopback.h +++ b/alc/backends/loopback.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/null.cpp b/alc/backends/null.cpp index 4cdebf57..1b90a1ee 100644 --- a/alc/backends/null.cpp +++ b/alc/backends/null.cpp @@ -154,17 +154,19 @@ bool NullBackendFactory::init() bool NullBackendFactory::querySupport(BackendType type) { return (type == BackendType::Playback); } -void NullBackendFactory::probe(DevProbe type, std::string *outnames) +std::string NullBackendFactory::probe(DevProbe type) { + std::string outnames; switch(type) { - case DevProbe::Playback: - /* Includes null char. */ - outnames->append(nullDevice, sizeof(nullDevice)); - break; - case DevProbe::Capture: - break; + case DevProbe::Playback: + /* Includes null char. */ + outnames.append(nullDevice, sizeof(nullDevice)); + break; + case DevProbe::Capture: + break; } + return outnames; } BackendPtr NullBackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/null.h b/alc/backends/null.h index f19d5b4d..1d714349 100644 --- a/alc/backends/null.h +++ b/alc/backends/null.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/opensl.cpp b/alc/backends/opensl.cpp index b1355061..d9ee47eb 100644 --- a/alc/backends/opensl.cpp +++ b/alc/backends/opensl.cpp @@ -939,16 +939,18 @@ bool OSLBackendFactory::init() { return true; } bool OSLBackendFactory::querySupport(BackendType type) { return (type == BackendType::Playback || type == BackendType::Capture); } -void OSLBackendFactory::probe(DevProbe type, std::string *outnames) +std::string OSLBackendFactory::probe(DevProbe type) { + std::string outnames; switch(type) { - case DevProbe::Playback: - case DevProbe::Capture: - /* Includes null char. */ - outnames->append(opensl_device, sizeof(opensl_device)); - break; + case DevProbe::Playback: + case DevProbe::Capture: + /* Includes null char. */ + outnames.append(opensl_device, sizeof(opensl_device)); + break; } + return outnames; } BackendPtr OSLBackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/opensl.h b/alc/backends/opensl.h index 809aa339..4309293b 100644 --- a/alc/backends/opensl.h +++ b/alc/backends/opensl.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/oss.cpp b/alc/backends/oss.cpp index a24744c2..ef3ca556 100644 --- a/alc/backends/oss.cpp +++ b/alc/backends/oss.cpp @@ -670,32 +670,36 @@ bool OSSBackendFactory::init() bool OSSBackendFactory::querySupport(BackendType type) { return (type == BackendType::Playback || type == BackendType::Capture); } -void OSSBackendFactory::probe(DevProbe type, std::string *outnames) +std::string OSSBackendFactory::probe(DevProbe type) { - auto add_device = [outnames](const DevMap &entry) -> void + std::string outnames; + + auto add_device = [&outnames](const DevMap &entry) -> void { struct stat buf; if(stat(entry.device_name.c_str(), &buf) == 0) { /* Includes null char. */ - outnames->append(entry.name.c_str(), entry.name.length()+1); + outnames.append(entry.name.c_str(), entry.name.length()+1); } }; switch(type) { - case DevProbe::Playback: - PlaybackDevices.clear(); - ALCossListPopulate(&PlaybackDevices, DSP_CAP_OUTPUT); - std::for_each(PlaybackDevices.cbegin(), PlaybackDevices.cend(), add_device); - break; + case DevProbe::Playback: + PlaybackDevices.clear(); + ALCossListPopulate(&PlaybackDevices, DSP_CAP_OUTPUT); + std::for_each(PlaybackDevices.cbegin(), PlaybackDevices.cend(), add_device); + break; - case DevProbe::Capture: - CaptureDevices.clear(); - ALCossListPopulate(&CaptureDevices, DSP_CAP_INPUT); - std::for_each(CaptureDevices.cbegin(), CaptureDevices.cend(), add_device); - break; + case DevProbe::Capture: + CaptureDevices.clear(); + ALCossListPopulate(&CaptureDevices, DSP_CAP_INPUT); + std::for_each(CaptureDevices.cbegin(), CaptureDevices.cend(), add_device); + break; } + + return outnames; } BackendPtr OSSBackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/oss.h b/alc/backends/oss.h index 9e63d7b6..4305dc78 100644 --- a/alc/backends/oss.h +++ b/alc/backends/oss.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/portaudio.cpp b/alc/backends/portaudio.cpp index 96eb1af4..7696e4f6 100644 --- a/alc/backends/portaudio.cpp +++ b/alc/backends/portaudio.cpp @@ -419,16 +419,18 @@ bool PortBackendFactory::init() bool PortBackendFactory::querySupport(BackendType type) { return (type == BackendType::Playback || type == BackendType::Capture); } -void PortBackendFactory::probe(DevProbe type, std::string *outnames) +std::string PortBackendFactory::probe(DevProbe type) { + std::string outnames; switch(type) { - case DevProbe::Playback: - case DevProbe::Capture: - /* Includes null char. */ - outnames->append(pa_device, sizeof(pa_device)); - break; + case DevProbe::Playback: + case DevProbe::Capture: + /* Includes null char. */ + outnames.append(pa_device, sizeof(pa_device)); + break; } + return outnames; } BackendPtr PortBackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/portaudio.h b/alc/backends/portaudio.h index 082e9020..d88d78e1 100644 --- a/alc/backends/portaudio.h +++ b/alc/backends/portaudio.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp index e40204f5..102e3915 100644 --- a/alc/backends/pulseaudio.cpp +++ b/alc/backends/pulseaudio.cpp @@ -1501,14 +1501,16 @@ bool PulseBackendFactory::init() bool PulseBackendFactory::querySupport(BackendType type) { return type == BackendType::Playback || type == BackendType::Capture; } -void PulseBackendFactory::probe(DevProbe type, std::string *outnames) +std::string PulseBackendFactory::probe(DevProbe type) { - auto add_device = [outnames](const DevMap &entry) -> void + std::string outnames; + + auto add_device = [&outnames](const DevMap &entry) -> void { /* +1 to also append the null char (to ensure a null-separated list and * double-null terminated list). */ - outnames->append(entry.name.c_str(), entry.name.length()+1); + outnames.append(entry.name.c_str(), entry.name.length()+1); }; switch(type) @@ -1523,6 +1525,8 @@ void PulseBackendFactory::probe(DevProbe type, std::string *outnames) std::for_each(CaptureDevices.cbegin(), CaptureDevices.cend(), add_device); break; } + + return outnames; } BackendPtr PulseBackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/pulseaudio.h b/alc/backends/pulseaudio.h index 40f3e305..575eecc1 100644 --- a/alc/backends/pulseaudio.h +++ b/alc/backends/pulseaudio.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/sdl2.cpp b/alc/backends/sdl2.cpp index af3081f1..e894e6a6 100644 --- a/alc/backends/sdl2.cpp +++ b/alc/backends/sdl2.cpp @@ -193,22 +193,25 @@ bool SDL2BackendFactory::init() bool SDL2BackendFactory::querySupport(BackendType type) { return type == BackendType::Playback; } -void SDL2BackendFactory::probe(DevProbe type, std::string *outnames) +std::string SDL2BackendFactory::probe(DevProbe type) { + std::string outnames; + if(type != DevProbe::Playback) - return; + return outnames; int num_devices{SDL_GetNumAudioDevices(SDL_FALSE)}; /* Includes null char. */ - outnames->append(defaultDeviceName, sizeof(defaultDeviceName)); + outnames.append(defaultDeviceName, sizeof(defaultDeviceName)); for(int i{0};i < num_devices;++i) { std::string name{DEVNAME_PREFIX}; name += SDL_GetAudioDeviceName(i, SDL_FALSE); if(!name.empty()) - outnames->append(name.c_str(), name.length()+1); + outnames.append(name.c_str(), name.length()+1); } + return outnames; } BackendPtr SDL2BackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/sdl2.h b/alc/backends/sdl2.h index 041d47ee..3c6d09bc 100644 --- a/alc/backends/sdl2.h +++ b/alc/backends/sdl2.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/sndio.cpp b/alc/backends/sndio.cpp index 5b95a8f0..e9f11791 100644 --- a/alc/backends/sndio.cpp +++ b/alc/backends/sndio.cpp @@ -452,16 +452,18 @@ bool SndIOBackendFactory::init() bool SndIOBackendFactory::querySupport(BackendType type) { return (type == BackendType::Playback || type == BackendType::Capture); } -void SndIOBackendFactory::probe(DevProbe type, std::string *outnames) +std::string SndIOBackendFactory::probe(DevProbe type) { + std::string outnames; switch(type) { - case DevProbe::Playback: - case DevProbe::Capture: - /* Includes null char. */ - outnames->append(sndio_device, sizeof(sndio_device)); - break; + case DevProbe::Playback: + case DevProbe::Capture: + /* Includes null char. */ + outnames.append(sndio_device, sizeof(sndio_device)); + break; } + return outnames; } BackendPtr SndIOBackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/sndio.h b/alc/backends/sndio.h index 1ed63d5e..5928ebd9 100644 --- a/alc/backends/sndio.h +++ b/alc/backends/sndio.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/solaris.cpp b/alc/backends/solaris.cpp index 93ab64cb..a6f1c3f0 100644 --- a/alc/backends/solaris.cpp +++ b/alc/backends/solaris.cpp @@ -270,21 +270,23 @@ bool SolarisBackendFactory::init() bool SolarisBackendFactory::querySupport(BackendType type) { return type == BackendType::Playback; } -void SolarisBackendFactory::probe(DevProbe type, std::string *outnames) +std::string SolarisBackendFactory::probe(DevProbe type) { + std::string outnames; switch(type) { - case DevProbe::Playback: - { - struct stat buf; - if(stat(solaris_driver.c_str(), &buf) == 0) - outnames->append(solaris_device, sizeof(solaris_device)); - } - break; + case DevProbe::Playback: + { + struct stat buf; + if(stat(solaris_driver.c_str(), &buf) == 0) + outnames.append(solaris_device, sizeof(solaris_device)); + } + break; - case DevProbe::Capture: - break; + case DevProbe::Capture: + break; } + return outnames; } BackendPtr SolarisBackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/solaris.h b/alc/backends/solaris.h index 98b10593..14ace580 100644 --- a/alc/backends/solaris.h +++ b/alc/backends/solaris.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp index fc48d492..74c3afbe 100644 --- a/alc/backends/wasapi.cpp +++ b/alc/backends/wasapi.cpp @@ -1744,14 +1744,15 @@ bool WasapiBackendFactory::init() bool WasapiBackendFactory::querySupport(BackendType type) { return type == BackendType::Playback || type == BackendType::Capture; } -void WasapiBackendFactory::probe(DevProbe type, std::string *outnames) +std::string WasapiBackendFactory::probe(DevProbe type) { - auto add_device = [outnames](const DevMap &entry) -> void + std::string outnames; + auto add_device = [&outnames](const DevMap &entry) -> void { /* +1 to also append the null char (to ensure a null-separated list and * double-null terminated list). */ - outnames->append(entry.name.c_str(), entry.name.length()+1); + outnames.append(entry.name.c_str(), entry.name.length()+1); }; switch(type) @@ -1766,6 +1767,8 @@ void WasapiBackendFactory::probe(DevProbe type, std::string *outnames) std::for_each(CaptureDevices.cbegin(), CaptureDevices.cend(), add_device); break; } + + return outnames; } BackendPtr WasapiBackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/wasapi.h b/alc/backends/wasapi.h index 067dd259..ef718a6f 100644 --- a/alc/backends/wasapi.h +++ b/alc/backends/wasapi.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/wave.cpp b/alc/backends/wave.cpp index f4fa2b70..2c4c4412 100644 --- a/alc/backends/wave.cpp +++ b/alc/backends/wave.cpp @@ -373,17 +373,19 @@ bool WaveBackendFactory::init() bool WaveBackendFactory::querySupport(BackendType type) { return type == BackendType::Playback; } -void WaveBackendFactory::probe(DevProbe type, std::string *outnames) +std::string WaveBackendFactory::probe(DevProbe type) { + std::string outnames; switch(type) { - case DevProbe::Playback: - /* Includes null char. */ - outnames->append(waveDevice, sizeof(waveDevice)); - break; - case DevProbe::Capture: - break; + case DevProbe::Playback: + /* Includes null char. */ + outnames.append(waveDevice, sizeof(waveDevice)); + break; + case DevProbe::Capture: + break; } + return outnames; } BackendPtr WaveBackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/wave.h b/alc/backends/wave.h index b9b62d7f..637d082c 100644 --- a/alc/backends/wave.h +++ b/alc/backends/wave.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; diff --git a/alc/backends/winmm.cpp b/alc/backends/winmm.cpp index a2437496..cd63352f 100644 --- a/alc/backends/winmm.cpp +++ b/alc/backends/winmm.cpp @@ -590,28 +590,30 @@ bool WinMMBackendFactory::init() bool WinMMBackendFactory::querySupport(BackendType type) { return type == BackendType::Playback || type == BackendType::Capture; } -void WinMMBackendFactory::probe(DevProbe type, std::string *outnames) +std::string WinMMBackendFactory::probe(DevProbe type) { - auto add_device = [outnames](const std::string &dname) -> void + std::string outnames; + auto add_device = [&outnames](const std::string &dname) -> void { /* +1 to also append the null char (to ensure a null-separated list and * double-null terminated list). */ if(!dname.empty()) - outnames->append(dname.c_str(), dname.length()+1); + outnames.append(dname.c_str(), dname.length()+1); }; switch(type) { - case DevProbe::Playback: - ProbePlaybackDevices(); - std::for_each(PlaybackDevices.cbegin(), PlaybackDevices.cend(), add_device); - break; - - case DevProbe::Capture: - ProbeCaptureDevices(); - std::for_each(CaptureDevices.cbegin(), CaptureDevices.cend(), add_device); - break; + case DevProbe::Playback: + ProbePlaybackDevices(); + std::for_each(PlaybackDevices.cbegin(), PlaybackDevices.cend(), add_device); + break; + + case DevProbe::Capture: + ProbeCaptureDevices(); + std::for_each(CaptureDevices.cbegin(), CaptureDevices.cend(), add_device); + break; } + return outnames; } BackendPtr WinMMBackendFactory::createBackend(ALCdevice *device, BackendType type) diff --git a/alc/backends/winmm.h b/alc/backends/winmm.h index e357ec19..28b66e98 100644 --- a/alc/backends/winmm.h +++ b/alc/backends/winmm.h @@ -9,7 +9,7 @@ public: bool querySupport(BackendType type) override; - void probe(DevProbe type, std::string *outnames) override; + std::string probe(DevProbe type) override; BackendPtr createBackend(ALCdevice *device, BackendType type) override; |