MCPcopy Create free account
hub / github.com/TASEmulators/fceux / FCEUI_AviSoundUpdate

Function FCEUI_AviSoundUpdate

src/drivers/win/aviout.cpp:432–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432void FCEUI_AviSoundUpdate(void* soundData, int soundLen)
433{
434 if(!avi_file || !avi_file->valid || !avi_file->sound_added)
435 return;
436
437 const int audioSegmentSize = avi_audiosegment_size(avi_file);
438 const int samplesPerSegment = audioSegmentSize / avi_file->wave_format.nBlockAlign;
439 const int soundSize = soundLen * avi_file->wave_format.nBlockAlign;
440 int nBytes = soundSize;
441 while (avi_file->audio_buffer_pos + nBytes > audioSegmentSize) {
442 const int bytesToTransfer = audioSegmentSize - avi_file->audio_buffer_pos;
443 memcpy(&avi_file->audio_buffer[avi_file->audio_buffer_pos], &((u8*)soundData)[soundSize - nBytes], bytesToTransfer);
444 nBytes -= bytesToTransfer;
445
446 if(FAILED(AVIStreamWrite(avi_file->compressed_streams[AUDIO_STREAM],
447 avi_file->sound_samples, samplesPerSegment,
448 avi_file->audio_buffer, audioSegmentSize, 0, NULL, &avi_file->ByteBuffer)))
449 {
450 avi_file->valid = 0;
451 return;
452 }
453 avi_file->sound_samples += samplesPerSegment;
454 avi_file->tBytes += avi_file->ByteBuffer;
455 avi_file->audio_buffer_pos = 0;
456 }
457 memcpy(&avi_file->audio_buffer[avi_file->audio_buffer_pos], &((u8*)soundData)[soundSize - nBytes], nBytes);
458 avi_file->audio_buffer_pos += nBytes;
459}
460
461void FCEUI_AviEnd()
462{

Callers 1

FCEU_WriteWaveDataFunction · 0.85

Calls 1

avi_audiosegment_sizeFunction · 0.85

Tested by

no test coverage detected