diff options
| author | 2018-11-21 14:39:16 -0500 | |
|---|---|---|
| committer | 2018-11-22 00:53:39 -0500 | |
| commit | 5a6dc4d0412ca8fe99efaacf3d71cd057b8813a9 (patch) | |
| tree | 73af0a2b005cf0872dcc90b28f2e54e6a831398f /src | |
| parent | Merge pull request #1754 from ReinUsesLisp/zero-register (diff) | |
| download | yuzu-5a6dc4d0412ca8fe99efaacf3d71cd057b8813a9.tar.gz yuzu-5a6dc4d0412ca8fe99efaacf3d71cd057b8813a9.tar.xz yuzu-5a6dc4d0412ca8fe99efaacf3d71cd057b8813a9.zip | |
audout_u: Add support for multiple IAudioOut streams.
- Used by Undertale.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/audio/audout_u.cpp | 28 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audout_u.h | 3 |
2 files changed, 22 insertions, 9 deletions
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index ff1edefbb..23e1f1165 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp | |||
| @@ -44,8 +44,10 @@ enum class AudioState : u32 { | |||
| 44 | 44 | ||
| 45 | class IAudioOut final : public ServiceFramework<IAudioOut> { | 45 | class IAudioOut final : public ServiceFramework<IAudioOut> { |
| 46 | public: | 46 | public: |
| 47 | IAudioOut(AudoutParams audio_params, AudioCore::AudioOut& audio_core) | 47 | IAudioOut(AudoutParams audio_params, AudioCore::AudioOut& audio_core, std::string&& device_name, |
| 48 | : ServiceFramework("IAudioOut"), audio_core(audio_core), audio_params(audio_params) { | 48 | std::string&& unique_name) |
| 49 | : ServiceFramework("IAudioOut"), audio_core(audio_core), audio_params(audio_params), | ||
| 50 | device_name(std::move(device_name)) { | ||
| 49 | 51 | ||
| 50 | static const FunctionInfo functions[] = { | 52 | static const FunctionInfo functions[] = { |
| 51 | {0, &IAudioOut::GetAudioOutState, "GetAudioOutState"}, | 53 | {0, &IAudioOut::GetAudioOutState, "GetAudioOutState"}, |
| @@ -69,7 +71,7 @@ public: | |||
| 69 | Kernel::Event::Create(kernel, Kernel::ResetType::Sticky, "IAudioOutBufferReleased"); | 71 | Kernel::Event::Create(kernel, Kernel::ResetType::Sticky, "IAudioOutBufferReleased"); |
| 70 | 72 | ||
| 71 | stream = audio_core.OpenStream(audio_params.sample_rate, audio_params.channel_count, | 73 | stream = audio_core.OpenStream(audio_params.sample_rate, audio_params.channel_count, |
| 72 | "IAudioOut", [=]() { buffer_event->Signal(); }); | 74 | std::move(unique_name), [=]() { buffer_event->Signal(); }); |
| 73 | } | 75 | } |
| 74 | 76 | ||
| 75 | private: | 77 | private: |
| @@ -177,6 +179,7 @@ private: | |||
| 177 | 179 | ||
| 178 | AudioCore::AudioOut& audio_core; | 180 | AudioCore::AudioOut& audio_core; |
| 179 | AudioCore::StreamPtr stream; | 181 | AudioCore::StreamPtr stream; |
| 182 | std::string device_name; | ||
| 180 | 183 | ||
| 181 | AudoutParams audio_params{}; | 184 | AudoutParams audio_params{}; |
| 182 | 185 | ||
| @@ -199,7 +202,15 @@ void AudOutU::ListAudioOutsImpl(Kernel::HLERequestContext& ctx) { | |||
| 199 | void AudOutU::OpenAudioOutImpl(Kernel::HLERequestContext& ctx) { | 202 | void AudOutU::OpenAudioOutImpl(Kernel::HLERequestContext& ctx) { |
| 200 | LOG_DEBUG(Service_Audio, "called"); | 203 | LOG_DEBUG(Service_Audio, "called"); |
| 201 | 204 | ||
| 202 | ctx.WriteBuffer(DefaultDevice); | 205 | const auto device_name_data{ctx.ReadBuffer()}; |
| 206 | std::string device_name; | ||
| 207 | if (device_name_data[0] != '\0') { | ||
| 208 | device_name.assign(device_name_data.begin(), device_name_data.end()); | ||
| 209 | } else { | ||
| 210 | device_name.assign(DefaultDevice.begin(), DefaultDevice.end()); | ||
| 211 | } | ||
| 212 | ctx.WriteBuffer(device_name); | ||
| 213 | |||
| 203 | IPC::RequestParser rp{ctx}; | 214 | IPC::RequestParser rp{ctx}; |
| 204 | auto params{rp.PopRaw<AudoutParams>()}; | 215 | auto params{rp.PopRaw<AudoutParams>()}; |
| 205 | if (params.channel_count <= 2) { | 216 | if (params.channel_count <= 2) { |
| @@ -212,10 +223,9 @@ void AudOutU::OpenAudioOutImpl(Kernel::HLERequestContext& ctx) { | |||
| 212 | params.sample_rate = DefaultSampleRate; | 223 | params.sample_rate = DefaultSampleRate; |
| 213 | } | 224 | } |
| 214 | 225 | ||
| 215 | // TODO(bunnei): Support more than one IAudioOut interface. When we add this, ListAudioOutsImpl | 226 | std::string unique_name{fmt::format("{}-{}", device_name, audio_out_interfaces.size())}; |
| 216 | // will likely need to be updated as well. | 227 | auto audio_out_interface = std::make_shared<IAudioOut>( |
| 217 | ASSERT_MSG(!audio_out_interface, "Unimplemented"); | 228 | params, *audio_core, std::move(device_name), std::move(unique_name)); |
| 218 | audio_out_interface = std::make_shared<IAudioOut>(params, *audio_core); | ||
| 219 | 229 | ||
| 220 | IPC::ResponseBuilder rb{ctx, 6, 0, 1}; | 230 | IPC::ResponseBuilder rb{ctx, 6, 0, 1}; |
| 221 | rb.Push(RESULT_SUCCESS); | 231 | rb.Push(RESULT_SUCCESS); |
| @@ -224,6 +234,8 @@ void AudOutU::OpenAudioOutImpl(Kernel::HLERequestContext& ctx) { | |||
| 224 | rb.Push<u32>(static_cast<u32>(AudioCore::Codec::PcmFormat::Int16)); | 234 | rb.Push<u32>(static_cast<u32>(AudioCore::Codec::PcmFormat::Int16)); |
| 225 | rb.Push<u32>(static_cast<u32>(AudioState::Stopped)); | 235 | rb.Push<u32>(static_cast<u32>(AudioState::Stopped)); |
| 226 | rb.PushIpcInterface<Audio::IAudioOut>(audio_out_interface); | 236 | rb.PushIpcInterface<Audio::IAudioOut>(audio_out_interface); |
| 237 | |||
| 238 | audio_out_interfaces.push_back(std::move(audio_out_interface)); | ||
| 227 | } | 239 | } |
| 228 | 240 | ||
| 229 | AudOutU::AudOutU() : ServiceFramework("audout:u") { | 241 | AudOutU::AudOutU() : ServiceFramework("audout:u") { |
diff --git a/src/core/hle/service/audio/audout_u.h b/src/core/hle/service/audio/audout_u.h index dcaf64708..aed4c43b2 100644 --- a/src/core/hle/service/audio/audout_u.h +++ b/src/core/hle/service/audio/audout_u.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <vector> | ||
| 7 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 8 | 9 | ||
| 9 | namespace AudioCore { | 10 | namespace AudioCore { |
| @@ -24,7 +25,7 @@ public: | |||
| 24 | ~AudOutU() override; | 25 | ~AudOutU() override; |
| 25 | 26 | ||
| 26 | private: | 27 | private: |
| 27 | std::shared_ptr<IAudioOut> audio_out_interface; | 28 | std::vector<std::shared_ptr<IAudioOut>> audio_out_interfaces; |
| 28 | std::unique_ptr<AudioCore::AudioOut> audio_core; | 29 | std::unique_ptr<AudioCore::AudioOut> audio_core; |
| 29 | 30 | ||
| 30 | void ListAudioOutsImpl(Kernel::HLERequestContext& ctx); | 31 | void ListAudioOutsImpl(Kernel::HLERequestContext& ctx); |