mirror of
				https://git.zaroz.cloud/nintendo-back-up/yuzu/yuzu-mainline.git
				synced 2025-03-21 01:53:15 +00:00 
			
		
		
		
	Audio: Correct buffer release for host timing.
This commit is contained in:
		
							parent
							
								
									7fd7d05838
								
							
						
					
					
						commit
						e3d561fb84
					
				| @ -66,6 +66,15 @@ s64 Stream::GetBufferReleaseNS(const Buffer& buffer) const { | ||||
|     return ns.count(); | ||||
| } | ||||
| 
 | ||||
| s64 Stream::GetBufferReleaseNSHostTiming(const Buffer& buffer) const { | ||||
|     const std::size_t num_samples{buffer.GetSamples().size() / GetNumChannels()}; | ||||
|     /// DSP signals before playing the last sample, in HLE we emulate this in this way
 | ||||
|     s64 base_samples = std::max<s64>(static_cast<s64>(num_samples) - 1, 0); | ||||
|     const auto ns = | ||||
|         std::chrono::nanoseconds((static_cast<u64>(base_samples) * 1000000000ULL) / sample_rate); | ||||
|     return ns.count(); | ||||
| } | ||||
| 
 | ||||
| static void VolumeAdjustSamples(std::vector<s16>& samples, float game_volume) { | ||||
|     const float volume{std::clamp(Settings::Volume() - (1.0f - game_volume), 0.0f, 1.0f)}; | ||||
| 
 | ||||
| @ -105,7 +114,11 @@ void Stream::PlayNextBuffer() { | ||||
| 
 | ||||
|     sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples()); | ||||
| 
 | ||||
|     if (core_timing.IsHostTiming()) { | ||||
|         core_timing.ScheduleEvent(GetBufferReleaseNSHostTiming(*active_buffer), release_event, {}); | ||||
|     } else { | ||||
|         core_timing.ScheduleEvent(GetBufferReleaseNS(*active_buffer), release_event, {}); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void Stream::ReleaseActiveBuffer() { | ||||
|  | ||||
| @ -98,6 +98,9 @@ private: | ||||
|     /// Gets the number of core cycles when the specified buffer will be released
 | ||||
|     s64 GetBufferReleaseNS(const Buffer& buffer) const; | ||||
| 
 | ||||
|     /// Gets the number of core cycles when the specified buffer will be released
 | ||||
|     s64 GetBufferReleaseNSHostTiming(const Buffer& buffer) const; | ||||
| 
 | ||||
|     u32 sample_rate;                  ///< Sample rate of the stream
 | ||||
|     Format format;                    ///< Format of the stream
 | ||||
|     float game_volume = 1.0f;         ///< The volume the game currently has set
 | ||||
|  | ||||
| @ -72,6 +72,11 @@ public: | ||||
|         this->is_multicore = is_multicore; | ||||
|     } | ||||
| 
 | ||||
|     /// Check if it's using host timing.
 | ||||
|     bool IsHostTiming() const { | ||||
|         return is_multicore; | ||||
|     } | ||||
| 
 | ||||
|     /// Pauses/Unpauses the execution of the timer thread.
 | ||||
|     void Pause(bool is_paused); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Fernando Sahmkow
						Fernando Sahmkow