Serialize MIC service

This commit is contained in:
Hamish Milne 2019-12-30 16:53:57 +00:00 committed by zhupengfei
parent e3c0211b74
commit 01ec2e8a67
5 changed files with 71 additions and 2 deletions

4
TODO
View File

@ -86,8 +86,8 @@
✔ HID @done(19-12-30 14:46) ✔ HID @done(19-12-30 14:46)
✔ HTTP @done(19-12-30 15:18) ✔ HTTP @done(19-12-30 15:18)
✔ IR @done(19-12-30 16:06) ✔ IR @done(19-12-30 16:06)
☐ LDR_RO ✔ LDR_RO @done(19-12-30 16:25)
☐ MIC ✔ MIC @done(19-12-30 16:53)
☐ MVD ☐ MVD
☐ NDM ☐ NDM
☐ NEWS ☐ NEWS

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/alignment.h" #include "common/alignment.h"
#include "common/archives.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/arm/arm_interface.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/cro_helper.h"
#include "core/hle/service/ldr_ro/ldr_ro.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 { namespace Service::LDR {
static const ResultCode ERROR_ALREADY_INITIALIZED = // 0xD9612FF9 static const ResultCode ERROR_ALREADY_INITIALIZED = // 0xD9612FF9

View File

@ -14,6 +14,13 @@ namespace Service::LDR {
struct ClientSlot : public Kernel::SessionRequestHandler::SessionDataBase { struct ClientSlot : public Kernel::SessionRequestHandler::SessionDataBase {
VAddr loaded_crs = 0; ///< the virtual address of the static module 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> { class RO final : public ServiceFramework<RO, ClientSlot> {
@ -151,8 +158,19 @@ private:
void Shutdown(Kernel::HLERequestContext& self); void Shutdown(Kernel::HLERequestContext& self);
Core::System& system; 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); void InstallInterfaces(Core::System& system);
} // namespace Service::LDR } // namespace Service::LDR
SERVICE_CONSTRUCT(Service::LDR::RO)
BOOST_CLASS_EXPORT_KEY(Service::LDR::RO)
BOOST_CLASS_EXPORT_KEY(Service::LDR::ClientSlot)

View File

@ -5,6 +5,7 @@
#ifdef HAVE_CUBEB #ifdef HAVE_CUBEB
#include "audio_core/cubeb_input.h" #include "audio_core/cubeb_input.h"
#endif #endif
#include "common/archives.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/core.h" #include "core/core.h"
#include "core/frontend/mic.h" #include "core/frontend/mic.h"
@ -17,8 +18,17 @@
#include "core/hle/service/mic_u.h" #include "core/hle/service/mic_u.h"
#include "core/settings.h" #include "core/settings.h"
SERVICE_CONSTRUCT_IMPL(Service::MIC::MIC_U)
SERIALIZE_EXPORT_IMPL(Service::MIC::MIC_U)
namespace Service::MIC { 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. /// Microphone audio encodings.
enum class Encoding : u8 { enum class Encoding : u8 {
PCM8 = 0, ///< Unsigned 8-bit PCM. PCM8 = 0, ///< Unsigned 8-bit PCM.
@ -59,6 +69,7 @@ constexpr u64 GetBufferUpdateRate(SampleRate sample_rate) {
// Variables holding the current mic buffer writing state // Variables holding the current mic buffer writing state
struct State { struct State {
std::shared_ptr<Kernel::SharedMemory> memory_ref = nullptr;
u8* sharedmem_buffer = nullptr; u8* sharedmem_buffer = nullptr;
u32 sharedmem_size = 0; u32 sharedmem_size = 0;
std::size_t 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), std::memcpy(sharedmem_buffer + (sharedmem_size - sizeof(u32)), reinterpret_cast<u8*>(&off),
sizeof(u32)); 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 { struct MIC_U::Impl {
@ -363,6 +388,21 @@ struct MIC_U::Impl {
std::unique_ptr<Frontend::Mic::Interface> mic; std::unique_ptr<Frontend::Mic::Interface> mic;
Core::Timing& timing; Core::Timing& timing;
State state{}; 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) { void MIC_U::MapSharedMem(Kernel::HLERequestContext& ctx) {

View File

@ -190,6 +190,10 @@ private:
struct Impl; struct Impl;
std::unique_ptr<Impl> 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); void ReloadMic(Core::System& system);
@ -197,3 +201,6 @@ void ReloadMic(Core::System& system);
void InstallInterfaces(Core::System& system); void InstallInterfaces(Core::System& system);
} // namespace Service::MIC } // namespace Service::MIC
SERVICE_CONSTRUCT(Service::MIC::MIC_U)
BOOST_CLASS_EXPORT_KEY(Service::MIC::MIC_U)