MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ read_frames()

std::vector< Kakshya::DataVariant > MayaFlux::IO::SoundFileReader::read_frames ( uint64_t  num_frames,
uint64_t  offset = 0 
)

Read a specific number of frames from the file.

Parameters
num_framesNumber of frames to read.
offsetFrame offset from beginning.
Returns
DataVariant containing std::vector<double>.

Definition at line 515 of file SoundFileReader.cpp.

516{
517 std::shared_lock<std::shared_mutex> lock(m_context_mutex);
518
519 if (!m_context || !m_context->is_valid()) {
520 set_error("File not open");
521 return {};
522 }
523
524 auto ctx = m_context;
525
526 if (offset != m_current_frame_position.load()) {
527 lock.unlock();
528 std::unique_lock<std::shared_mutex> write_lock(m_context_mutex);
529
530 if (!m_context || !m_context->is_valid()) {
531 set_error("File closed during operation");
532 return {};
533 }
534
535 ctx = m_context;
536 if (!seek_internal(ctx, offset)) {
537 return {};
538 }
539
540 write_lock.unlock();
541 lock.lock();
542
543 if (!m_context || !m_context->is_valid()) {
544 set_error("File closed during operation");
545 return {};
546 }
547
548 ctx = m_context;
549 }
550
551 return decode_frames(ctx, num_frames, offset);
552}
std::vector< Kakshya::DataVariant > decode_frames(std::shared_ptr< FFmpegContext > ctx, uint64_t num_frames, uint64_t offset)
Decode a specific number of frames from the file.
bool seek_internal(std::shared_ptr< FFmpegContext > &ctx, uint64_t frame_position)
Internal seek implementation.
void set_error(const std::string &error) const
Set the last error message.
std::atomic< uint64_t > m_current_frame_position
Current frame position for reading.
std::shared_ptr< FFmpegContext > m_context

References decode_frames(), m_context, m_context_mutex, m_current_frame_position, seek_internal(), and set_error().

Referenced by read_all(), and read_region().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: