summaryrefslogtreecommitdiff
path: root/src/audio_core
diff options
context:
space:
mode:
authorGravatar Liam2023-12-18 09:22:20 -0500
committerGravatar Liam2023-12-18 17:27:32 -0500
commita7731abb72e80c26d5af771d17233652435a0c7d (patch)
tree6bbfbd090638d3647aea9db93c945e88792eca45 /src/audio_core
parentoboe_sink: set low latency performance mode (diff)
downloadyuzu-a7731abb72e80c26d5af771d17233652435a0c7d.tar.gz
yuzu-a7731abb72e80c26d5af771d17233652435a0c7d.tar.xz
yuzu-a7731abb72e80c26d5af771d17233652435a0c7d.zip
oboe_sink: specify additional required parameters
Diffstat (limited to 'src/audio_core')
-rw-r--r--src/audio_core/sink/oboe_sink.cpp40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/audio_core/sink/oboe_sink.cpp b/src/audio_core/sink/oboe_sink.cpp
index 8143b0db6..e61841172 100644
--- a/src/audio_core/sink/oboe_sink.cpp
+++ b/src/audio_core/sink/oboe_sink.cpp
@@ -29,7 +29,7 @@ public:
29 } 29 }
30 30
31 ~OboeSinkStream() override { 31 ~OboeSinkStream() override {
32 LOG_DEBUG(Audio_Sink, "Destructing Oboe stream {}", name); 32 LOG_INFO(Audio_Sink, "Destroyed Oboe stream");
33 } 33 }
34 34
35 void Finalize() override { 35 void Finalize() override {
@@ -66,12 +66,7 @@ public:
66 std::shared_ptr<oboe::AudioStream> temp_stream; 66 std::shared_ptr<oboe::AudioStream> temp_stream;
67 oboe::AudioStreamBuilder builder; 67 oboe::AudioStreamBuilder builder;
68 68
69 const auto result = builder.setDirection(direction) 69 const auto result = ConfigureBuilder(builder, direction)->openStream(temp_stream);
70 ->setPerformanceMode(oboe::PerformanceMode::LowLatency)
71 ->setSampleRate(TargetSampleRate)
72 ->setFormat(oboe::AudioFormat::I16)
73 ->setFormatConversionAllowed(true)
74 ->openStream(temp_stream);
75 ASSERT(result == oboe::Result::OK); 70 ASSERT(result == oboe::Result::OK);
76 71
77 return temp_stream->getChannelCount() >= 6 ? 6 : 2; 72 return temp_stream->getChannelCount() >= 6 ? 6 : 2;
@@ -106,6 +101,20 @@ protected:
106 } 101 }
107 102
108private: 103private:
104 static oboe::AudioStreamBuilder* ConfigureBuilder(oboe::AudioStreamBuilder& builder,
105 oboe::Direction direction) {
106 // TODO: investigate callback delay issues when using AAudio
107 return builder.setPerformanceMode(oboe::PerformanceMode::LowLatency)
108 ->setAudioApi(oboe::AudioApi::OpenSLES)
109 ->setDirection(direction)
110 ->setSampleRate(TargetSampleRate)
111 ->setSampleRateConversionQuality(oboe::SampleRateConversionQuality::High)
112 ->setFormat(oboe::AudioFormat::I16)
113 ->setFormatConversionAllowed(true)
114 ->setUsage(oboe::Usage::Game)
115 ->setBufferCapacityInFrames(TargetSampleCount * 2);
116 }
117
109 bool OpenStream() { 118 bool OpenStream() {
110 const auto direction = [&]() { 119 const auto direction = [&]() {
111 switch (type) { 120 switch (type) {
@@ -136,13 +145,10 @@ private:
136 }(); 145 }();
137 146
138 oboe::AudioStreamBuilder builder; 147 oboe::AudioStreamBuilder builder;
139 const auto result = builder.setDirection(direction) 148 const auto result = ConfigureBuilder(builder, direction)
140 ->setPerformanceMode(oboe::PerformanceMode::LowLatency)
141 ->setSampleRate(TargetSampleRate)
142 ->setChannelCount(expected_channels) 149 ->setChannelCount(expected_channels)
143 ->setChannelMask(expected_mask) 150 ->setChannelMask(expected_mask)
144 ->setFormat(oboe::AudioFormat::I16) 151 ->setChannelConversionAllowed(true)
145 ->setFormatConversionAllowed(true)
146 ->setDataCallback(this) 152 ->setDataCallback(this)
147 ->setErrorCallback(this) 153 ->setErrorCallback(this)
148 ->openStream(m_stream); 154 ->openStream(m_stream);
@@ -153,8 +159,16 @@ private:
153 bool SetStreamProperties() { 159 bool SetStreamProperties() {
154 ASSERT(m_stream); 160 ASSERT(m_stream);
155 161
162 m_stream->setBufferSizeInFrames(TargetSampleCount * 2);
156 device_channels = m_stream->getChannelCount(); 163 device_channels = m_stream->getChannelCount();
157 LOG_INFO(Audio_Sink, "Opened Oboe stream with {} channels", device_channels); 164
165 const auto sample_rate = m_stream->getSampleRate();
166 const auto buffer_capacity = m_stream->getBufferCapacityInFrames();
167 const auto stream_backend =
168 m_stream->getAudioApi() == oboe::AudioApi::AAudio ? "AAudio" : "OpenSLES";
169
170 LOG_INFO(Audio_Sink, "Opened Oboe {} stream with {} channels sample rate {} capacity {}",
171 stream_backend, device_channels, sample_rate, buffer_capacity);
158 172
159 return true; 173 return true;
160 } 174 }