diff options
Diffstat (limited to 'src/audio_core')
| -rw-r--r-- | src/audio_core/renderer/audio_device.cpp | 14 | ||||
| -rw-r--r-- | src/audio_core/renderer/audio_device.h | 6 |
2 files changed, 8 insertions, 12 deletions
diff --git a/src/audio_core/renderer/audio_device.cpp b/src/audio_core/renderer/audio_device.cpp index 2d9bf82bb..5be5594f6 100644 --- a/src/audio_core/renderer/audio_device.cpp +++ b/src/audio_core/renderer/audio_device.cpp | |||
| @@ -36,8 +36,7 @@ AudioDevice::AudioDevice(Core::System& system, const u64 applet_resource_user_id | |||
| 36 | : output_sink{system.AudioCore().GetOutputSink()}, | 36 | : output_sink{system.AudioCore().GetOutputSink()}, |
| 37 | applet_resource_user_id{applet_resource_user_id_}, user_revision{revision} {} | 37 | applet_resource_user_id{applet_resource_user_id_}, user_revision{revision} {} |
| 38 | 38 | ||
| 39 | u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer, | 39 | u32 AudioDevice::ListAudioDeviceName(std::span<AudioDeviceName> out_buffer) const { |
| 40 | const size_t max_count) const { | ||
| 41 | std::span<const AudioDeviceName> names{}; | 40 | std::span<const AudioDeviceName> names{}; |
| 42 | 41 | ||
| 43 | if (CheckFeatureSupported(SupportTags::AudioUsbDeviceOutput, user_revision)) { | 42 | if (CheckFeatureSupported(SupportTags::AudioUsbDeviceOutput, user_revision)) { |
| @@ -46,19 +45,18 @@ u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer, | |||
| 46 | names = device_names; | 45 | names = device_names; |
| 47 | } | 46 | } |
| 48 | 47 | ||
| 49 | const u32 out_count{static_cast<u32>(std::min(max_count, names.size()))}; | 48 | const u32 out_count{static_cast<u32>(std::min(out_buffer.size(), names.size()))}; |
| 50 | for (u32 i = 0; i < out_count; i++) { | 49 | for (u32 i = 0; i < out_count; i++) { |
| 51 | out_buffer.push_back(names[i]); | 50 | out_buffer[i] = names[i]; |
| 52 | } | 51 | } |
| 53 | return out_count; | 52 | return out_count; |
| 54 | } | 53 | } |
| 55 | 54 | ||
| 56 | u32 AudioDevice::ListAudioOutputDeviceName(std::vector<AudioDeviceName>& out_buffer, | 55 | u32 AudioDevice::ListAudioOutputDeviceName(std::span<AudioDeviceName> out_buffer) const { |
| 57 | const size_t max_count) const { | 56 | const u32 out_count{static_cast<u32>(std::min(out_buffer.size(), output_device_names.size()))}; |
| 58 | const u32 out_count{static_cast<u32>(std::min(max_count, output_device_names.size()))}; | ||
| 59 | 57 | ||
| 60 | for (u32 i = 0; i < out_count; i++) { | 58 | for (u32 i = 0; i < out_count; i++) { |
| 61 | out_buffer.push_back(output_device_names[i]); | 59 | out_buffer[i] = output_device_names[i]; |
| 62 | } | 60 | } |
| 63 | return out_count; | 61 | return out_count; |
| 64 | } | 62 | } |
diff --git a/src/audio_core/renderer/audio_device.h b/src/audio_core/renderer/audio_device.h index ca4040add..4242dad30 100644 --- a/src/audio_core/renderer/audio_device.h +++ b/src/audio_core/renderer/audio_device.h | |||
| @@ -36,20 +36,18 @@ public: | |||
| 36 | * Get a list of the available output devices. | 36 | * Get a list of the available output devices. |
| 37 | * | 37 | * |
| 38 | * @param out_buffer - Output buffer to write the available device names. | 38 | * @param out_buffer - Output buffer to write the available device names. |
| 39 | * @param max_count - Maximum number of devices to write (count of out_buffer). | ||
| 40 | * @return Number of device names written. | 39 | * @return Number of device names written. |
| 41 | */ | 40 | */ |
| 42 | u32 ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer, size_t max_count) const; | 41 | u32 ListAudioDeviceName(std::span<AudioDeviceName> out_buffer) const; |
| 43 | 42 | ||
| 44 | /** | 43 | /** |
| 45 | * Get a list of the available output devices. | 44 | * Get a list of the available output devices. |
| 46 | * Different to above somehow... | 45 | * Different to above somehow... |
| 47 | * | 46 | * |
| 48 | * @param out_buffer - Output buffer to write the available device names. | 47 | * @param out_buffer - Output buffer to write the available device names. |
| 49 | * @param max_count - Maximum number of devices to write (count of out_buffer). | ||
| 50 | * @return Number of device names written. | 48 | * @return Number of device names written. |
| 51 | */ | 49 | */ |
| 52 | u32 ListAudioOutputDeviceName(std::vector<AudioDeviceName>& out_buffer, size_t max_count) const; | 50 | u32 ListAudioOutputDeviceName(std::span<AudioDeviceName> out_buffer) const; |
| 53 | 51 | ||
| 54 | /** | 52 | /** |
| 55 | * Set the volume of all streams in the backend sink. | 53 | * Set the volume of all streams in the backend sink. |