Skip to content

Commit

Permalink
feat: Add waiting mechanism when ReadyForMoreMediaData is false
Browse files Browse the repository at this point in the history
  • Loading branch information
yuto-trd committed Jun 24, 2024
1 parent 3022d32 commit b9ea235
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Beutl.Extensions.AVFoundation/Encoding/AVFWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,15 @@ private static CMBlockBuffer CreateCMBlockBufferWithMemoryBlock(uint length, Int

public override bool AddAudio(IPcm sound)
{
if (!_audioInput.ReadyForMoreMediaData)
int count = 0;
while (!_audioInput.ReadyForMoreMediaData)
{
return false;
Thread.Sleep(10);
count++;
if (count > 100)
{
return false;
}
}

var sourceFormat = AudioStreamBasicDescription.CreateLinearPCM(sound.SampleRate, (uint)sound.NumChannels);
Expand Down

0 comments on commit b9ea235

Please sign in to comment.