mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	Address review comments
This commit is contained in:
		
							parent
							
								
									c669aa8d55
								
							
						
					
					
						commit
						5f532c2560
					
				
					 11 changed files with 119 additions and 135 deletions
				
			
		|  | @ -1,4 +1,4 @@ | |||
| // Copyright 2018 Citra Emulator Project
 | ||||
| // Copyright 2019 Citra Emulator Project
 | ||||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
|  | @ -12,39 +12,28 @@ constexpr std::array<u8, 32> NOISE_SAMPLE_8_BIT = { | |||
|     0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF5, 0xFF, 0xFF, 0xFF, 0xFF, 0x8E, 0xFF, | ||||
|     0xF4, 0xE1, 0xBF, 0x9A, 0x71, 0x58, 0x5B, 0x5F, 0x62, 0xC2, 0x25, 0x05, 0x01, 0x01, 0x01, 0x01}; | ||||
| 
 | ||||
| constexpr std::array<u8, 512> NOISE_SAMPLE_16_BIT = { | ||||
| constexpr std::array<u8, 32> NOISE_SAMPLE_16_BIT = { | ||||
|     0x64, 0x61, 0x74, 0x61, 0x56, 0xD7, 0x00, 0x00, 0x48, 0xF7, 0x86, 0x05, 0x77, 0x1A, 0xF4, 0x1F, | ||||
|     0x28, 0x0F, 0x6B, 0xEB, 0x1C, 0xC0, 0xCB, 0x9D, 0x46, 0x90, 0xDF, 0x98, 0xEA, 0xAE, 0xB5, 0xC4, | ||||
|     0x9D, 0xCE, 0xB6, 0xC9, 0xDF, 0xBD, 0x82, 0xBA, 0x83, 0xCD, 0x57, 0xF9, 0x96, 0x30, 0x2C, 0x5B, | ||||
|     0x29, 0x64, 0xD3, 0x46, 0x0D, 0x12, 0x3E, 0xDE, 0x00, 0xBD, 0x74, 0xAE, 0xF0, 0xA4, 0x91, 0x93, | ||||
|     0x02, 0x80, 0x00, 0x80, 0x03, 0x80, 0x6F, 0xAA, 0x8E, 0xE8, 0xEE, 0x1A, 0x2B, 0x2C, 0xC6, 0x18, | ||||
|     0xF8, 0xED, 0xC2, 0xBE, 0x00, 0x99, 0xC1, 0x82, 0x00, 0x80, 0xA6, 0x8A, 0x37, 0xA8, 0x6B, 0xCE, | ||||
|     0x20, 0xEF, 0xD0, 0xFD, 0x68, 0xF9, 0x50, 0xEF, 0x89, 0xF2, 0xDE, 0x0C, 0x24, 0x36, 0xDB, 0x58, | ||||
|     0xB2, 0x61, 0xD5, 0x4C, 0x0B, 0x27, 0x6D, 0x02, 0xDC, 0xE8, 0x13, 0xD8, 0x2F, 0xC9, 0x07, 0xBC, | ||||
|     0xAB, 0xBA, 0x70, 0xD1, 0xDE, 0x01, 0xF2, 0x3C, 0x64, 0x6A, 0xFF, 0x78, 0x47, 0x6B, 0x26, 0x56, | ||||
|     0x9B, 0x51, 0xF3, 0x65, 0xFF, 0x7F, 0xFF, 0x7F, 0x88, 0x6B, 0x46, 0x24, 0xBF, 0xD8, 0x8C, 0xB4, | ||||
|     0xD9, 0xCF, 0x77, 0x1C, 0x43, 0x6B, 0xFE, 0x7F, 0x15, 0x64, 0xA6, 0x13, 0x03, 0xCE, 0x51, 0xBF, | ||||
|     0xC7, 0xEB, 0xCB, 0x2E, 0x6C, 0x58, 0xA7, 0x51, 0x40, 0x2A, 0x24, 0x06, 0x45, 0xFB, 0xD3, 0xFE, | ||||
|     0x51, 0xF2, 0x1E, 0xC5, 0x79, 0x8A, 0x00, 0x80, 0x94, 0x8E, 0x7A, 0xDE, 0x83, 0x29, 0x8E, 0x3C, | ||||
|     0x4B, 0x0F, 0xD8, 0xCB, 0x41, 0xAB, 0xC1, 0xC5, 0xC6, 0xFE, 0x0F, 0x1F, 0x92, 0x05, 0x4B, 0xC4, | ||||
|     0xDC, 0x8F, 0xE1, 0x90, 0xE3, 0xC0, 0xDB, 0xF1, 0xCC, 0xF8, 0xC8, 0xD4, 0x2A, 0xAF, 0xB7, 0xB5, | ||||
|     0x7F, 0xF0, 0xB2, 0x39, 0xD4, 0x5C, 0xD6, 0x41, 0x69, 0xFD, 0xEA, 0xBB, 0x57, 0x9B, 0x59, 0x98, | ||||
|     0x8E, 0x9B, 0x8A, 0x97, 0x54, 0x98, 0xE6, 0xB5, 0x25, 0xF8, 0x77, 0x48, 0xFF, 0x7F, 0xFF, 0x7F, | ||||
|     0x49, 0x6B, 0xB4, 0x4B, 0xE9, 0x45, 0xE3, 0x57, 0x60, 0x64, 0x8C, 0x4D, 0x69, 0x10, 0x10, 0xCA, | ||||
|     0x13, 0xA4, 0xC5, 0xB7, 0xE4, 0xFD, 0x7C, 0x54, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F, 0xE0, 0x52, | ||||
|     0x5E, 0x22, 0x31, 0x0B, 0xB5, 0x12, 0xB1, 0x2E, 0xA7, 0x4D, 0x17, 0x61, 0x46, 0x65, 0xA5, 0x5F, | ||||
|     0x5C, 0x57, 0xB6, 0x4C, 0x3B, 0x38, 0xFD, 0x11, 0x70, 0xDC, 0x2A, 0xA8, 0xB9, 0x8C, 0xEA, 0x98, | ||||
|     0x07, 0xC6, 0xDF, 0xF7, 0x2D, 0x0C, 0xEC, 0xF0, 0xA8, 0xB2, 0x02, 0x80, 0x00, 0x80, 0xBA, 0x8A, | ||||
|     0x0E, 0xCB, 0x54, 0xF7, 0x2B, 0xEE, 0x4C, 0xB9, 0x48, 0x89, 0x8F, 0x90, 0x0E, 0xD8, 0x83, 0x32, | ||||
|     0xC5, 0x5C, 0x54, 0x34, 0x86, 0xD6, 0x78, 0x8C, 0x88, 0x90, 0x87, 0xDE, 0x75, 0x37, 0x55, 0x56, | ||||
|     0xF1, 0x28, 0xF0, 0xDA, 0xE2, 0xAB, 0xE6, 0xB6, 0xD6, 0xDF, 0x4D, 0xF4, 0xCF, 0xDE, 0x3E, 0xBA, | ||||
|     0xC6, 0xB3, 0x81, 0xDA, 0xFE, 0x0D, 0xE9, 0x1D, 0xCE, 0xFB, 0x59, 0xCD, 0x57, 0xCA, 0x77, 0x06, | ||||
|     0x63, 0x5A, 0xFE, 0x7F, 0x49, 0x63, 0x7F, 0x14, 0x0E, 0xDB, 0x2A, 0xE5, 0x3B, 0x27, 0xFF, 0x69, | ||||
|     0x0A, 0x7C, 0xC5, 0x56, 0x65, 0x19, 0xEC, 0xE5, 0x0E, 0xC6, 0xA6, 0xB0, 0x09, 0xA2, 0x06, 0xA8, | ||||
|     0xC7, 0xD1, 0xE9, 0x15, 0xD5, 0x4E, 0xBB, 0x56, 0x85, 0x2A, 0x25, 0xF0, 0x78, 0xD6, 0x70, 0xEB, | ||||
|     0xF2, 0x0F, 0xE1, 0x15, 0x66, 0xEC, 0xC7, 0xB0, 0xE7, 0x93, 0x9D, 0xAD, 0xD1, 0xE6, 0xD3, 0x0D, | ||||
|     0xAC, 0x00, 0xB2, 0xC7, 0x5D, 0x8B, 0x00, 0x80, 0xA1, 0x88, 0x14, 0xBE, 0xDF, 0xFB, 0xCF, 0x32, | ||||
|     0xD8, 0x5B, 0x0F, 0x6F, 0x6C, 0x62, 0xD9, 0x33, 0x76, 0xF3, 0xD6, 0xBF, 0x41, 0xB3, 0x5C, 0xD1}; | ||||
|     0x28, 0x0F, 0x6B, 0xEB, 0x1C, 0xC0, 0xCB, 0x9D, 0x46, 0x90, 0xDF, 0x98, 0xEA, 0xAE, 0xB5, 0xC4}; | ||||
| 
 | ||||
| Interface::~Interface() = default; | ||||
| 
 | ||||
| void NullMic::StartSampling(const Parameters& params) { | ||||
|     parameters = params; | ||||
|     is_sampling = true; | ||||
| } | ||||
| 
 | ||||
| void NullMic::StopSampling() { | ||||
|     is_sampling = false; | ||||
| } | ||||
| 
 | ||||
| void NullMic::AdjustSampleRate(u32 sample_rate) { | ||||
|     parameters.sample_rate = sample_rate; | ||||
| } | ||||
| 
 | ||||
| Samples NullMic::Read() { | ||||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| StaticMic::StaticMic() | ||||
|     : CACHE_8_BIT{NOISE_SAMPLE_8_BIT.begin(), NOISE_SAMPLE_8_BIT.end()}, | ||||
|  | @ -52,7 +41,7 @@ StaticMic::StaticMic() | |||
| 
 | ||||
| StaticMic::~StaticMic() = default; | ||||
| 
 | ||||
| void StaticMic::StartSampling(Parameters params) { | ||||
| void StaticMic::StartSampling(const Parameters& params) { | ||||
|     sample_rate = params.sample_rate; | ||||
|     sample_size = params.sample_size; | ||||
| 
 | ||||
|  | @ -70,17 +59,4 @@ Samples StaticMic::Read() { | |||
|     return (sample_size == 8) ? CACHE_8_BIT : CACHE_16_BIT; | ||||
| } | ||||
| 
 | ||||
| static std::shared_ptr<Mic::Interface> current_mic; | ||||
| 
 | ||||
| void RegisterMic(std::shared_ptr<Mic::Interface> mic) { | ||||
|     current_mic = mic; | ||||
| } | ||||
| 
 | ||||
| std::shared_ptr<Mic::Interface> GetCurrentMic() { | ||||
|     if (!current_mic) { | ||||
|         current_mic = std::make_shared<Mic::NullMic>(); | ||||
|     } | ||||
|     return current_mic; | ||||
| } | ||||
| 
 | ||||
| } // namespace Frontend::Mic
 | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| // Copyright 2018 Citra Emulator Project
 | ||||
| // Copyright 2019 Citra Emulator Project
 | ||||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
|  | @ -17,7 +17,6 @@ enum class Signedness : u8 { | |||
| }; | ||||
| 
 | ||||
| using Samples = std::vector<u8>; | ||||
| using SampleQueue = Common::SPSCQueue<Samples>; | ||||
| 
 | ||||
| struct Parameters { | ||||
|     Signedness sign; | ||||
|  | @ -32,17 +31,19 @@ class Interface { | |||
| public: | ||||
|     Interface() = default; | ||||
| 
 | ||||
|     virtual ~Interface() = default; | ||||
|     virtual ~Interface(); | ||||
| 
 | ||||
|     /// Starts the microphone. Called by Core
 | ||||
|     virtual void StartSampling(Parameters params) = 0; | ||||
|     virtual void StartSampling(const Parameters& params) = 0; | ||||
| 
 | ||||
|     /// Stops the microphone. Called by Core
 | ||||
|     virtual void StopSampling() = 0; | ||||
| 
 | ||||
|     /// Called from the actual event timing read back. The frontend impl is responsible for wrapping
 | ||||
|     /// up any data and returning them to the core so the core can write them to the sharedmem. If
 | ||||
|     /// theres nothing to return just return an empty vector
 | ||||
|     /**
 | ||||
|      * Called from the actual event timing at a constant period under a given sample rate. | ||||
|      * When sampling is enabled this function is expected to return a buffer of 16 samples in ideal | ||||
|      * conditions, but can be lax if the data is coming in from another source like a real mic. | ||||
|      */ | ||||
|     virtual Samples Read() = 0; | ||||
| 
 | ||||
|     /// Adjusts the Parameters. Implementations should update the parameters field in addition to
 | ||||
|  | @ -70,7 +71,7 @@ public: | |||
|         return is_sampling; | ||||
|     } | ||||
| 
 | ||||
|     Parameters GetParameters() const { | ||||
|     const Parameters& GetParameters() const { | ||||
|         return parameters; | ||||
|     } | ||||
| 
 | ||||
|  | @ -83,22 +84,13 @@ protected: | |||
| 
 | ||||
| class NullMic final : public Interface { | ||||
| public: | ||||
|     void StartSampling(Parameters params) override { | ||||
|         parameters = params; | ||||
|         is_sampling = true; | ||||
|     } | ||||
|     void StartSampling(const Parameters& params) override; | ||||
| 
 | ||||
|     void StopSampling() override { | ||||
|         is_sampling = false; | ||||
|     } | ||||
|     void StopSampling() override; | ||||
| 
 | ||||
|     void AdjustSampleRate(u32 sample_rate) override { | ||||
|         parameters.sample_rate = sample_rate; | ||||
|     } | ||||
|     void AdjustSampleRate(u32 sample_rate) override; | ||||
| 
 | ||||
|     Samples Read() override { | ||||
|         return {}; | ||||
|     } | ||||
|     Samples Read() override; | ||||
| }; | ||||
| 
 | ||||
| class StaticMic final : public Interface { | ||||
|  | @ -106,7 +98,7 @@ public: | |||
|     StaticMic(); | ||||
|     ~StaticMic() override; | ||||
| 
 | ||||
|     void StartSampling(Parameters params) override; | ||||
|     void StartSampling(const Parameters& params) override; | ||||
|     void StopSampling() override; | ||||
|     void AdjustSampleRate(u32 sample_rate) override; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue