MCPcopy Create free account
hub / github.com/AbyssEngine/AbyssEngineOld / getSample

Method getSample

src/Abyss/Streams/AudioStream.cpp:179–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179int16_t Abyss::Streams::AudioStream::getSample() {
180 std::lock_guard lock(_mutex);
181
182 if (_isPaused || (!_isPlaying && _ringBuffer.available() == 0))
183 return 0;
184
185 if (_ringBuffer.available() == 0 && _isPlaying)
186 update();
187
188 if (!_isPlaying && _ringBuffer.available() == 0)
189 return 0;
190
191 uint8_t data[2];
192 _ringBuffer.readData(std::span(data, 2));
193 return static_cast<int16_t>(static_cast<uint16_t>(data[0] & 0xFF) | static_cast<uint16_t>(data[1]) << 8);
194}
195
196void Abyss::Streams::AudioStream::setLoop(const bool loop) {
197 std::lock_guard lock(_mutex);

Callers

nothing calls this directly

Calls 2

availableMethod · 0.80
readDataMethod · 0.80

Tested by

no test coverage detected