MCPcopy Create free account
hub / github.com/SFML/SFML / seekCallback

Function seekCallback

src/SFML/Audio/SoundFileReaderMp3.cpp:55–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55drmp3_bool32 seekCallback(void* userData, int offset, drmp3_seek_origin origin)
56{
57 auto* stream = static_cast<sf::InputStream*>(userData);
58
59 if (origin == DRMP3_SEEK_CUR)
60 {
61 auto currentPosition = stream->tell();
62
63 if (!currentPosition.has_value())
64 return false;
65
66 offset = static_cast<int>(currentPosition.value()) + offset;
67 }
68 else if (origin == DRMP3_SEEK_END)
69 {
70 auto currentSize = stream->getSize();
71
72 if (!currentSize.has_value())
73 return false;
74
75 offset = static_cast<int>(currentSize.value()) + offset;
76 }
77
78 const std::optional position = stream->seek(static_cast<std::size_t>(offset));
79 return position.has_value();
80}
81
82drmp3_bool32 tellCallback(void* userData, drmp3_int64* pCursor)
83{

Callers

nothing calls this directly

Calls 3

tellMethod · 0.45
getSizeMethod · 0.45
seekMethod · 0.45

Tested by

no test coverage detected