diff options
| author | 2018-01-24 22:38:19 -0500 | |
|---|---|---|
| committer | 2018-01-24 22:38:19 -0500 | |
| commit | de177f66926a5170c1ad0621085494d27de8e2d4 (patch) | |
| tree | ae56efe8654d3aa3a5e75ec04bd9dfdcc06023a9 /src/core | |
| parent | ResponseBuilder: Use a bit field for customizing instead of always_move_handles. (diff) | |
| download | yuzu-de177f66926a5170c1ad0621085494d27de8e2d4.tar.gz yuzu-de177f66926a5170c1ad0621085494d27de8e2d4.tar.xz yuzu-de177f66926a5170c1ad0621085494d27de8e2d4.zip | |
audout_u: Various cleanups.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/service/audio/audout_u.cpp | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 3a0f8f362..f56ba2ea1 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp | |||
| @@ -23,7 +23,7 @@ constexpr u64 audio_ticks{static_cast<u64>(BASE_CLOCK_RATE / 500)}; | |||
| 23 | 23 | ||
| 24 | class IAudioOut final : public ServiceFramework<IAudioOut> { | 24 | class IAudioOut final : public ServiceFramework<IAudioOut> { |
| 25 | public: | 25 | public: |
| 26 | IAudioOut() : ServiceFramework("IAudioOut"), audio_out_state(Stopped) { | 26 | IAudioOut() : ServiceFramework("IAudioOut"), audio_out_state(AudioState::Stopped) { |
| 27 | static const FunctionInfo functions[] = { | 27 | static const FunctionInfo functions[] = { |
| 28 | {0x0, nullptr, "GetAudioOutState"}, | 28 | {0x0, nullptr, "GetAudioOutState"}, |
| 29 | {0x1, &IAudioOut::StartAudioOut, "StartAudioOut"}, | 29 | {0x1, &IAudioOut::StartAudioOut, "StartAudioOut"}, |
| @@ -58,8 +58,8 @@ private: | |||
| 58 | void StartAudioOut(Kernel::HLERequestContext& ctx) { | 58 | void StartAudioOut(Kernel::HLERequestContext& ctx) { |
| 59 | LOG_WARNING(Service_Audio, "(STUBBED) called"); | 59 | LOG_WARNING(Service_Audio, "(STUBBED) called"); |
| 60 | 60 | ||
| 61 | // start audio | 61 | // Start audio |
| 62 | audio_out_state = Started; | 62 | audio_out_state = AudioState::Started; |
| 63 | 63 | ||
| 64 | IPC::ResponseBuilder rb{ctx, 2}; | 64 | IPC::ResponseBuilder rb{ctx, 2}; |
| 65 | rb.Push(RESULT_SUCCESS); | 65 | rb.Push(RESULT_SUCCESS); |
| @@ -68,8 +68,8 @@ private: | |||
| 68 | void StopAudioOut(Kernel::HLERequestContext& ctx) { | 68 | void StopAudioOut(Kernel::HLERequestContext& ctx) { |
| 69 | LOG_WARNING(Service_Audio, "(STUBBED) called"); | 69 | LOG_WARNING(Service_Audio, "(STUBBED) called"); |
| 70 | 70 | ||
| 71 | // stop audio | 71 | // Stop audio |
| 72 | audio_out_state = Stopped; | 72 | audio_out_state = AudioState::Stopped; |
| 73 | 73 | ||
| 74 | queue_keys.clear(); | 74 | queue_keys.clear(); |
| 75 | 75 | ||
| @@ -89,8 +89,7 @@ private: | |||
| 89 | LOG_WARNING(Service_Audio, "(STUBBED) called"); | 89 | LOG_WARNING(Service_Audio, "(STUBBED) called"); |
| 90 | IPC::RequestParser rp{ctx}; | 90 | IPC::RequestParser rp{ctx}; |
| 91 | 91 | ||
| 92 | u64 key = rp.Pop<u64>(); | 92 | const u64 key{rp.Pop<u64>()}; |
| 93 | |||
| 94 | queue_keys.insert(queue_keys.begin(), key); | 93 | queue_keys.insert(queue_keys.begin(), key); |
| 95 | 94 | ||
| 96 | IPC::ResponseBuilder rb{ctx, 2}; | 95 | IPC::ResponseBuilder rb{ctx, 2}; |
| @@ -102,11 +101,10 @@ private: | |||
| 102 | 101 | ||
| 103 | const auto& buffer = ctx.BufferDescriptorB()[0]; | 102 | const auto& buffer = ctx.BufferDescriptorB()[0]; |
| 104 | 103 | ||
| 105 | // TODO(st4rk): this is how libtransistor currently implements the | 104 | // TODO(st4rk): This is how libtransistor currently implements the |
| 106 | // GetReleasedAudioOutBuffer, it should return the key (a VAddr) to the APP and this address | 105 | // GetReleasedAudioOutBuffer, it should return the key (a VAddr) to the app and this address |
| 107 | // is used to know which buffer should be filled with data and send again to the service | 106 | // is used to know which buffer should be filled with data and send again to the service |
| 108 | // through AppendAudioOutBuffer. Check if this is the proper way to do it. | 107 | // through AppendAudioOutBuffer. Check if this is the proper way to do it. |
| 109 | |||
| 110 | u64 key{0}; | 108 | u64 key{0}; |
| 111 | 109 | ||
| 112 | if (queue_keys.size()) { | 110 | if (queue_keys.size()) { |
| @@ -124,8 +122,7 @@ private: | |||
| 124 | } | 122 | } |
| 125 | 123 | ||
| 126 | void UpdateAudioBuffersCallback() { | 124 | void UpdateAudioBuffersCallback() { |
| 127 | 125 | if (audio_out_state != AudioState::Started) { | |
| 128 | if (audio_out_state != Started) { | ||
| 129 | return; | 126 | return; |
| 130 | } | 127 | } |
| 131 | 128 | ||
| @@ -136,7 +133,7 @@ private: | |||
| 136 | buffer_event->Signal(); | 133 | buffer_event->Signal(); |
| 137 | } | 134 | } |
| 138 | 135 | ||
| 139 | enum AudioState : u32 { | 136 | enum class AudioState : u32 { |
| 140 | Started, | 137 | Started, |
| 141 | Stopped, | 138 | Stopped, |
| 142 | }; | 139 | }; |
| @@ -148,10 +145,10 @@ private: | |||
| 148 | /// This is the evend handle used to check if the audio buffer was released | 145 | /// This is the evend handle used to check if the audio buffer was released |
| 149 | Kernel::SharedPtr<Kernel::Event> buffer_event; | 146 | Kernel::SharedPtr<Kernel::Event> buffer_event; |
| 150 | 147 | ||
| 151 | /// (st4rk): this is just a temporary workaround for the future implementation. Libtransistor | 148 | /// (st4rk): This is just a temporary workaround for the future implementation. Libtransistor |
| 152 | /// uses the key as an address in the App, so we need to return when the | 149 | /// uses the key as an address in the App, so we need to return when the |
| 153 | /// GetReleasedAudioOutBuffer_1 is called, otherwise we'll run in problems, because | 150 | /// GetReleasedAudioOutBuffer_1 is called, otherwise we'll run in problems, because |
| 154 | /// libtransistor uses the key returned as an pointer; | 151 | /// libtransistor uses the key returned as an pointer. |
| 155 | std::vector<u64> queue_keys; | 152 | std::vector<u64> queue_keys; |
| 156 | 153 | ||
| 157 | AudioState audio_out_state; | 154 | AudioState audio_out_state; |
| @@ -169,11 +166,9 @@ void AudOutU::ListAudioOuts(Kernel::HLERequestContext& ctx) { | |||
| 169 | IPC::ResponseBuilder rb = rp.MakeBuilder(3, 0, 0); | 166 | IPC::ResponseBuilder rb = rp.MakeBuilder(3, 0, 0); |
| 170 | 167 | ||
| 171 | rb.Push(RESULT_SUCCESS); | 168 | rb.Push(RESULT_SUCCESS); |
| 172 | // TODO(st4rk): we're currently returning only one audio interface | 169 | // TODO(st4rk): We're currently returning only one audio interface (stringlist size). However, |
| 173 | // (stringlist size) | 170 | // it's highly possible to have more than one interface (despite that libtransistor requires |
| 174 | // however, it's highly possible to have more than one interface (despite that | 171 | // only one). |
| 175 | // libtransistor | ||
| 176 | // requires only one). | ||
| 177 | rb.Push<u32>(1); | 172 | rb.Push<u32>(1); |
| 178 | } | 173 | } |
| 179 | 174 | ||
| @@ -184,20 +179,13 @@ void AudOutU::OpenAudioOut(Kernel::HLERequestContext& ctx) { | |||
| 184 | audio_out_interface = std::make_shared<IAudioOut>(); | 179 | audio_out_interface = std::make_shared<IAudioOut>(); |
| 185 | } | 180 | } |
| 186 | 181 | ||
| 187 | auto sessions = Kernel::ServerSession::CreateSessionPair(audio_out_interface->GetServiceName()); | ||
| 188 | auto server = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions); | ||
| 189 | auto client = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions); | ||
| 190 | audio_out_interface->ClientConnected(server); | ||
| 191 | LOG_DEBUG(Service, "called, initialized IAudioOut -> session=%u", client->GetObjectId()); | ||
| 192 | IPC::ResponseBuilder rb{ctx, 6, 0, 1}; | 182 | IPC::ResponseBuilder rb{ctx, 6, 0, 1}; |
| 193 | |||
| 194 | rb.Push(RESULT_SUCCESS); | 183 | rb.Push(RESULT_SUCCESS); |
| 195 | rb.Push<u32>(sample_rate); | 184 | rb.Push<u32>(sample_rate); |
| 196 | rb.Push<u32>(audio_channels); | 185 | rb.Push<u32>(audio_channels); |
| 197 | rb.Push<u32>(static_cast<u32>(PcmFormat::Int16)); | 186 | rb.Push<u32>(static_cast<u32>(PcmFormat::Int16)); |
| 198 | // this field is unknown | 187 | rb.Push<u32>(0); // This field is unknown |
| 199 | rb.Push<u32>(0); | 188 | rb.PushIpcInterface<Audio::IAudioOut>(audio_out_interface); |
| 200 | rb.PushMoveObjects(std::move(client)); | ||
| 201 | } | 189 | } |
| 202 | 190 | ||
| 203 | AudOutU::AudOutU() : ServiceFramework("audout:u") { | 191 | AudOutU::AudOutU() : ServiceFramework("audout:u") { |