* @brief Builds the frame index from the sample cache populated during observer-based data reading. */
| 907 | * @brief Builds the frame index from the sample cache populated during observer-based data reading. |
| 908 | */ |
| 909 | void 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 |