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

Method flushBlocks

src/SFML/Audio/SoundFileWriterOgg.cpp:233–263  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

231
232////////////////////////////////////////////////////////////
233void SoundFileWriterOgg::flushBlocks()
234{
235 // Let the library divide uncompressed data into blocks, and process them
236 vorbis_block block;
237 vorbis_block_init(&m_state, &block);
238 while (vorbis_analysis_blockout(&m_state, &block) == 1)
239 {
240 // Let the automatic bitrate management do its job
241 vorbis_analysis(&block, nullptr);
242 vorbis_bitrate_addblock(&block);
243
244 // Get new packets from the bitrate management engine
245 ogg_packet packet;
246 while (vorbis_bitrate_flushpacket(&m_state, &packet))
247 {
248 // Write the packet to the ogg stream
249 ogg_stream_packetin(&m_ogg, &packet);
250
251 // If the stream produced new pages, write them to the output file
252 ogg_page page;
253 while (ogg_stream_flush(&m_ogg, &page) > 0)
254 {
255 m_file.write(reinterpret_cast<const char*>(page.header), page.header_len);
256 m_file.write(reinterpret_cast<const char*>(page.body), page.body_len);
257 }
258 }
259 }
260
261 // Clear the allocated block
262 vorbis_block_clear(&block);
263}
264
265
266////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected