AudioCore: Use nanoseconds instead of cycles for buffer time.
This commit is contained in:
parent
dc58058203
commit
6bf137a0e8
|
@ -59,11 +59,11 @@ Stream::State Stream::GetState() const {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
s64 Stream::GetBufferReleaseCycles(const Buffer& buffer) const {
|
s64 Stream::GetBufferReleaseNS(const Buffer& buffer) const {
|
||||||
const std::size_t num_samples{buffer.GetSamples().size() / GetNumChannels()};
|
const std::size_t num_samples{buffer.GetSamples().size() / GetNumChannels()};
|
||||||
const auto us =
|
const auto ns =
|
||||||
std::chrono::microseconds((static_cast<u64>(num_samples) * 1000000) / sample_rate);
|
std::chrono::nanoseconds((static_cast<u64>(num_samples) * 1000000000ULL) / sample_rate);
|
||||||
return Core::Timing::usToCycles(us);
|
return ns.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void VolumeAdjustSamples(std::vector<s16>& samples, float game_volume) {
|
static void VolumeAdjustSamples(std::vector<s16>& samples, float game_volume) {
|
||||||
|
@ -105,7 +105,7 @@ void Stream::PlayNextBuffer() {
|
||||||
|
|
||||||
sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples());
|
sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples());
|
||||||
|
|
||||||
core_timing.ScheduleEvent(GetBufferReleaseCycles(*active_buffer), release_event, {});
|
core_timing.ScheduleEvent(GetBufferReleaseNS(*active_buffer), release_event, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stream::ReleaseActiveBuffer() {
|
void Stream::ReleaseActiveBuffer() {
|
||||||
|
|
|
@ -96,7 +96,7 @@ private:
|
||||||
void ReleaseActiveBuffer();
|
void ReleaseActiveBuffer();
|
||||||
|
|
||||||
/// Gets the number of core cycles when the specified buffer will be released
|
/// Gets the number of core cycles when the specified buffer will be released
|
||||||
s64 GetBufferReleaseCycles(const Buffer& buffer) const;
|
s64 GetBufferReleaseNS(const Buffer& buffer) const;
|
||||||
|
|
||||||
u32 sample_rate; ///< Sample rate of the stream
|
u32 sample_rate; ///< Sample rate of the stream
|
||||||
Format format; ///< Format of the stream
|
Format format; ///< Format of the stream
|
||||||
|
|
Loading…
Reference in New Issue