summaryrefslogtreecommitdiffstats
path: root/src/audio_core/sink/sink_stream.h
diff options
context:
space:
mode:
authorBilly Laws <blaws05@gmail.com>2023-03-18 21:52:02 +0100
committerBilly Laws <blaws05@gmail.com>2023-03-26 23:48:57 +0200
commitd8fc3f403b62e2b3d67ec08791fdc66847ddb4ac (patch)
tree7a5e37809980a7c4988df5845e6daf161d7e859f /src/audio_core/sink/sink_stream.h
parentMerge pull request #9994 from liamwhite/integer-constant (diff)
downloadyuzu-d8fc3f403b62e2b3d67ec08791fdc66847ddb4ac.tar
yuzu-d8fc3f403b62e2b3d67ec08791fdc66847ddb4ac.tar.gz
yuzu-d8fc3f403b62e2b3d67ec08791fdc66847ddb4ac.tar.bz2
yuzu-d8fc3f403b62e2b3d67ec08791fdc66847ddb4ac.tar.lz
yuzu-d8fc3f403b62e2b3d67ec08791fdc66847ddb4ac.tar.xz
yuzu-d8fc3f403b62e2b3d67ec08791fdc66847ddb4ac.tar.zst
yuzu-d8fc3f403b62e2b3d67ec08791fdc66847ddb4ac.zip
Diffstat (limited to '')
-rw-r--r--src/audio_core/sink/sink_stream.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/audio_core/sink/sink_stream.h b/src/audio_core/sink/sink_stream.h
index 5fea72ab7..2340c936c 100644
--- a/src/audio_core/sink/sink_stream.h
+++ b/src/audio_core/sink/sink_stream.h
@@ -5,6 +5,7 @@
#include <array>
#include <atomic>
+#include <chrono>
#include <memory>
#include <mutex>
#include <span>
@@ -14,6 +15,7 @@
#include "common/common_types.h"
#include "common/reader_writer_queue.h"
#include "common/ring_buffer.h"
+#include "common/thread.h"
namespace Core {
class System;
@@ -210,6 +212,13 @@ public:
*/
void Unstall();
+ /**
+ * Get the total number of samples expected to have been played by this stream.
+ *
+ * @return The number of samples.
+ */
+ u64 GetExpectedPlayedSampleCount();
+
protected:
/// Core system
Core::System& system;
@@ -237,6 +246,14 @@ private:
std::atomic<u32> queued_buffers{};
/// The ring size for audio out buffers (usually 4, rarely 2 or 8)
u32 max_queue_size{};
+ /// Locks access to sample count tracking info
+ std::mutex sample_count_lock;
+ /// Minimum number of total samples that have been played since the last callback
+ u64 min_played_sample_count{};
+ /// Maximum number of total samples that can be played since the last callback
+ u64 max_played_sample_count{};
+ /// The time the two above tracking variables were last written to
+ std::chrono::microseconds last_sample_count_update_time{};
/// Set by the audio render/in/out system which uses this stream
f32 system_volume{1.0f};
/// Set via IAudioDevice service calls