Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Fixes hang waiting for cancelled TextToSpeech #1895

Merged
merged 2 commits into from
Jan 18, 2022
Merged
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
3 changes: 2 additions & 1 deletion Xamarin.Essentials/TextToSpeech/TextToSpeech.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ public async Task SpeakAsync(string text, int max, SpeechOptions options, Cancel
if (tcsUtterances?.Task != null)
await tcsUtterances.Task;

tcsUtterances = new TaskCompletionSource<bool>();

if (cancelToken != null)
{
cancelToken.Register(() =>
Expand Down Expand Up @@ -150,7 +152,6 @@ public async Task SpeakAsync(string text, int max, SpeechOptions options, Cancel
var parts = text.SplitSpeak(max);

numExpectedUtterances = parts.Count;
tcsUtterances = new TaskCompletionSource<bool>();

var guid = Guid.NewGuid().ToString();

Expand Down