| 430 | } |
| 431 | |
| 432 | void 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 | |
| 461 | void FCEUI_AviEnd() |
| 462 | { |
no test coverage detected