Serialize MIC service
This commit is contained in:
		
							
								
								
									
										4
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								TODO
									
									
									
									
									
								
							| @@ -86,8 +86,8 @@ | ||||
|         ✔ HID @done(19-12-30 14:46) | ||||
|         ✔ HTTP @done(19-12-30 15:18) | ||||
|         ✔ IR @done(19-12-30 16:06) | ||||
|         ☐ LDR_RO | ||||
|         ☐ MIC | ||||
|         ✔ LDR_RO @done(19-12-30 16:25) | ||||
|         ✔ MIC @done(19-12-30 16:53) | ||||
|         ☐ MVD | ||||
|         ☐ NDM | ||||
|         ☐ NEWS | ||||
|   | ||||
| @@ -3,6 +3,7 @@ | ||||
| // Refer to the license.txt file included. | ||||
|  | ||||
| #include "common/alignment.h" | ||||
| #include "common/archives.h" | ||||
| #include "common/common_types.h" | ||||
| #include "common/logging/log.h" | ||||
| #include "core/arm/arm_interface.h" | ||||
| @@ -12,6 +13,9 @@ | ||||
| #include "core/hle/service/ldr_ro/cro_helper.h" | ||||
| #include "core/hle/service/ldr_ro/ldr_ro.h" | ||||
|  | ||||
| SERVICE_CONSTRUCT_IMPL(Service::LDR::RO) | ||||
| SERIALIZE_EXPORT_IMPL(Service::LDR::RO) | ||||
|  | ||||
| namespace Service::LDR { | ||||
|  | ||||
| static const ResultCode ERROR_ALREADY_INITIALIZED = // 0xD9612FF9 | ||||
|   | ||||
| @@ -14,6 +14,13 @@ namespace Service::LDR { | ||||
|  | ||||
| struct ClientSlot : public Kernel::SessionRequestHandler::SessionDataBase { | ||||
|     VAddr loaded_crs = 0; ///< the virtual address of the static module | ||||
|  | ||||
| private: | ||||
|     template <class Archive> | ||||
|     void serialize(Archive& ar, const unsigned int) { | ||||
|         ar& loaded_crs; | ||||
|     } | ||||
|     friend class boost::serialization::access; | ||||
| }; | ||||
|  | ||||
| class RO final : public ServiceFramework<RO, ClientSlot> { | ||||
| @@ -151,8 +158,19 @@ private: | ||||
|     void Shutdown(Kernel::HLERequestContext& self); | ||||
|  | ||||
|     Core::System& system; | ||||
|  | ||||
| private: | ||||
|     template <class Archive> | ||||
|     void serialize(Archive& ar, const unsigned int) { | ||||
|         ar& boost::serialization::base_object<Kernel::SessionRequestHandler>(*this); | ||||
|     } | ||||
|     friend class boost::serialization::access; | ||||
| }; | ||||
|  | ||||
| void InstallInterfaces(Core::System& system); | ||||
|  | ||||
| } // namespace Service::LDR | ||||
|  | ||||
| SERVICE_CONSTRUCT(Service::LDR::RO) | ||||
| BOOST_CLASS_EXPORT_KEY(Service::LDR::RO) | ||||
| BOOST_CLASS_EXPORT_KEY(Service::LDR::ClientSlot) | ||||
|   | ||||
| @@ -5,6 +5,7 @@ | ||||
| #ifdef HAVE_CUBEB | ||||
| #include "audio_core/cubeb_input.h" | ||||
| #endif | ||||
| #include "common/archives.h" | ||||
| #include "common/logging/log.h" | ||||
| #include "core/core.h" | ||||
| #include "core/frontend/mic.h" | ||||
| @@ -17,8 +18,17 @@ | ||||
| #include "core/hle/service/mic_u.h" | ||||
| #include "core/settings.h" | ||||
|  | ||||
| SERVICE_CONSTRUCT_IMPL(Service::MIC::MIC_U) | ||||
| SERIALIZE_EXPORT_IMPL(Service::MIC::MIC_U) | ||||
|  | ||||
| namespace Service::MIC { | ||||
|  | ||||
| template <class Archive> | ||||
| void MIC_U::serialize(Archive& ar, const unsigned int) { | ||||
|     ar&* impl.get(); | ||||
| } | ||||
| SERIALIZE_IMPL(MIC_U) | ||||
|  | ||||
| /// Microphone audio encodings. | ||||
| enum class Encoding : u8 { | ||||
|     PCM8 = 0,        ///< Unsigned 8-bit PCM. | ||||
| @@ -59,6 +69,7 @@ constexpr u64 GetBufferUpdateRate(SampleRate sample_rate) { | ||||
|  | ||||
| // Variables holding the current mic buffer writing state | ||||
| struct State { | ||||
|     std::shared_ptr<Kernel::SharedMemory> memory_ref = nullptr; | ||||
|     u8* sharedmem_buffer = nullptr; | ||||
|     u32 sharedmem_size = 0; | ||||
|     std::size_t size = 0; | ||||
| @@ -95,6 +106,20 @@ struct State { | ||||
|         std::memcpy(sharedmem_buffer + (sharedmem_size - sizeof(u32)), reinterpret_cast<u8*>(&off), | ||||
|                     sizeof(u32)); | ||||
|     } | ||||
|  | ||||
| private: | ||||
|     template <class Archive> | ||||
|     void serialize(Archive& ar, const unsigned int) { | ||||
|         ar& sharedmem_size; | ||||
|         ar& size; | ||||
|         ar& offset; | ||||
|         ar& initial_offset; | ||||
|         ar& looped_buffer; | ||||
|         ar& sample_size; | ||||
|         ar& sample_rate; | ||||
|         sharedmem_buffer = memory_ref ? memory_ref->GetPointer() : nullptr; | ||||
|     } | ||||
|     friend class boost::serialization::access; | ||||
| }; | ||||
|  | ||||
| struct MIC_U::Impl { | ||||
| @@ -363,6 +388,21 @@ struct MIC_U::Impl { | ||||
|     std::unique_ptr<Frontend::Mic::Interface> mic; | ||||
|     Core::Timing& timing; | ||||
|     State state{}; | ||||
|  | ||||
| private: | ||||
|     template <class Archive> | ||||
|     void serialize(Archive& ar, const unsigned int) { | ||||
|         ar& change_mic_impl_requested; | ||||
|         ar& buffer_full_event; | ||||
|         // buffer_write_event set in constructor | ||||
|         ar& shared_memory; | ||||
|         ar& client_version; | ||||
|         ar& allow_shell_closed; | ||||
|         ar& clamp; | ||||
|         // mic interface set in constructor | ||||
|         ar& state; | ||||
|     } | ||||
|     friend class boost::serialization::access; | ||||
| }; | ||||
|  | ||||
| void MIC_U::MapSharedMem(Kernel::HLERequestContext& ctx) { | ||||
|   | ||||
| @@ -190,6 +190,10 @@ private: | ||||
|  | ||||
|     struct Impl; | ||||
|     std::unique_ptr<Impl> impl; | ||||
|  | ||||
|     template <class Archive> | ||||
|     void serialize(Archive& ar, const unsigned int); | ||||
|     friend class boost::serialization::access; | ||||
| }; | ||||
|  | ||||
| void ReloadMic(Core::System& system); | ||||
| @@ -197,3 +201,6 @@ void ReloadMic(Core::System& system); | ||||
| void InstallInterfaces(Core::System& system); | ||||
|  | ||||
| } // namespace Service::MIC | ||||
|  | ||||
| SERVICE_CONSTRUCT(Service::MIC::MIC_U) | ||||
| BOOST_CLASS_EXPORT_KEY(Service::MIC::MIC_U) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Hamish Milne
					Hamish Milne