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

◆ create_writer() [1/2]

std::shared_ptr< SoundFileWriter > MayaFlux::IO::IOManager::create_writer ( const std::string &  filepath,
uint32_t  channels,
uint32_t  sample_rate = 48000,
AVCodecID  codec_id = AV_CODEC_ID_NONE 
)

Construct an open SoundFileWriter the caller drives manually.

Allocates, opens, and returns a writer ready to accept write() calls. IOManager does not track this writer; the caller is responsible for calling close() when done.

Parameters
filepathOutput file path. Extension determines container format.
channelsNumber of channels in all submitted data.
sample_ratePCM sample rate in Hz.
codec_idEncoder override; AV_CODEC_ID_NONE = container default.
Returns
Open SoundFileWriter, or nullptr if open() failed.

Definition at line 331 of file IOManager.cpp.

335{
336 auto writer = std::make_shared<SoundFileWriter>();
337 if (!writer->open(filepath, channels, sample_rate, codec_id)) {
339 "create_writer: open failed for '{}': {}", filepath, writer->last_error());
340 return nullptr;
341 }
342
343 {
344 std::lock_guard lock(m_save_tasks_mutex);
345 m_writers.push_back(writer);
346 }
347 return writer;
348}
#define MF_ERROR(comp, ctx,...)
std::mutex m_save_tasks_mutex
std::vector< std::shared_ptr< SoundFileWriter > > m_writers
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.

References MayaFlux::Journal::FileIO, MayaFlux::Journal::IO, m_save_tasks_mutex, m_writers, and MF_ERROR.