///////////////////////////////////////////////////////
| 287 | |
| 288 | //////////////////////////////////////////////////////////// |
| 289 | std::optional<std::uint64_t> Music::onLoop() |
| 290 | { |
| 291 | // Called by underlying SoundStream so we can determine where to loop. |
| 292 | const std::lock_guard lock(m_impl->mutex); |
| 293 | const std::uint64_t currentOffset = m_impl->file.getSampleOffset(); |
| 294 | |
| 295 | if (isLooping() && (m_impl->loopSpan.length != 0) && |
| 296 | (currentOffset == m_impl->loopSpan.offset + m_impl->loopSpan.length)) |
| 297 | { |
| 298 | // Looping is enabled, and either we're at the loop end, or we're at the EOF |
| 299 | // when it's equivalent to the loop end (loop end takes priority). Send us to loop begin |
| 300 | m_impl->file.seek(m_impl->loopSpan.offset); |
| 301 | return m_impl->file.getSampleOffset(); |
| 302 | } |
| 303 | |
| 304 | if (isLooping() && (currentOffset >= m_impl->file.getSampleCount())) |
| 305 | { |
| 306 | // If we're at the EOF, reset to 0 |
| 307 | m_impl->file.seek(0); |
| 308 | return 0; |
| 309 | } |
| 310 | |
| 311 | return std::nullopt; |
| 312 | } |
| 313 | |
| 314 | |
| 315 | //////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected