Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ public async ValueTask<string> StopAndExportAsync(double? seconds = default, str
_temporalController.Pause();
}

await Task.WhenAll(_videoPipeline.CompleteAsync().AsTask(), _audioPipeline.CompleteAsync().AsTask());

try
{
await Task.WhenAll(_videoPipeline.CompleteAsync().AsTask(), _audioPipeline.CompleteAsync().AsTask());

State = SessionState.Exporting;

// Generate output path if not provided
Expand Down Expand Up @@ -307,12 +307,22 @@ async ValueTask MuxAudioAsync()
throw exception;
}

var video = MuxVideoAsync();
var audio = MuxAudioAsync();

await audio;
await video;
// Always observe both tasks even if one of them fails, so that the muxer is not
// disposed (by the caller) while the other task is still using it.
var video = MuxVideoAsync().AsTask();
var audio = MuxAudioAsync().AsTask();

var whenAll = Task.WhenAll(video, audio);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

212行目ではWhenAll内でAsTaskしているのに、こちらは外でAsTaskしているのには何か理由がある?

try
{
await whenAll.ConfigureAwait(false);
}
catch (Exception) when (whenAll.Exception is { } aggregate && aggregate.InnerExceptions.Count > 1)
{
// Awaiting Task.WhenAll rethrows only the first exception;
// rethrow the AggregateException so that all failures are propagated.
throw aggregate;
}

await muxer.CompleteAsync();
}
Expand Down