forked from xamarin/xamarin-macios
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AVFoundation] Obsolete AVSpeechSynthesizer.WriteUtteranceAsync. Fixes …
…xamarin#20338. The callback may be called multiple times, which means the async version won't work correctly. So obsolete and hide the Async binding for now, and remove in XAMCORE_5_0. References: * https://discord.com/channels/732297728826277939/732297808148824115/1219903715939582022 * https://developer.apple.com/documentation/avfaudio/avspeechsynthesizer/3141659-writeutterance?language=objc Fixes xamarin#20338.
- Loading branch information
1 parent
bb775d0
commit dcb828e
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Runtime.Versioning; | ||
using System.Threading.Tasks; | ||
|
||
using ObjCRuntime; | ||
|
||
#nullable enable | ||
|
||
namespace AVFoundation { | ||
|
||
public partial class AVSpeechSynthesizer { | ||
#if !XAMCORE_5_0 | ||
#if NET | ||
[SupportedOSPlatform ("tvos13.0")] | ||
[SupportedOSPlatform ("ios13.0")] | ||
[SupportedOSPlatform ("maccatalyst")] | ||
[SupportedOSPlatform ("macos")] | ||
#endif | ||
[BindingImpl (BindingImplOptions.Optimizable)] | ||
[Obsolete ("Do not use this API, it doesn't work correctly. Use the non-Async version (WriteUtterance) instead.")] | ||
[EditorBrowsable (EditorBrowsableState.Never)] | ||
public unsafe virtual Task<AVAudioBuffer> WriteUtteranceAsync (AVSpeechUtterance utterance) | ||
{ | ||
var tcs = new TaskCompletionSource<AVAudioBuffer> (); | ||
WriteUtterance(utterance, (obj_) => { | ||
tcs.SetResult (obj_!); | ||
}); | ||
return tcs.Task; | ||
} | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters