MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / buildFrameIndexFromCache

Method buildFrameIndexFromCache

app/src/MDF4/Player.cpp:909–940  ·  view source on GitHub ↗

* @brief Builds the frame index from the sample cache populated during observer-based data reading. */

Source from the content-addressed store, hash-verified

907 * @brief Builds the frame index from the sample cache populated during observer-based data reading.
908 */
909void MDF4::Player::buildFrameIndexFromCache()
910{
911 if (m_sampleCache.empty())
912 return;
913
914 uint64_t sampleIndex = 0;
915 m_frameIndex.reserve(m_sampleCache.size());
916
917 for (const auto& cachePair : m_sampleCache) {
918 FrameIndex frameIdx;
919
920 if (m_isSerialStudioFile && !m_timestampCache.empty()) {
921 auto timeIt = m_timestampCache.find(cachePair.first);
922 if (timeIt != m_timestampCache.end())
923 frameIdx.timestamp = timeIt->second;
924 else
925 frameIdx.timestamp = static_cast<double>(sampleIndex) * 0.001;
926 } else {
927 frameIdx.timestamp = static_cast<double>(sampleIndex) * 0.001;
928 }
929
930 frameIdx.recordIndex = cachePair.first;
931 frameIdx.channelGroup = nullptr;
932
933 m_frameIndex.push_back(frameIdx);
934 ++sampleIndex;
935 }
936
937 std::sort(m_frameIndex.begin(), m_frameIndex.end(), [](const FrameIndex& a, const FrameIndex& b) {
938 return a.recordIndex < b.recordIndex;
939 });
940}
941
942//--------------------------------------------------------------------------------------------------
943// Frame transmission helpers

Callers

nothing calls this directly

Calls 5

sortFunction · 0.85
emptyMethod · 0.80
findMethod · 0.80
beginMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected