Skip to content
Draft
Show file tree
Hide file tree
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 @@ -141,7 +141,7 @@ internal byte[] WaveFormat
{
get
{
WAVEFORMATEX wfx = new();
WAVEFORMATEX wfx = default;
wfx.wFormatTag = (short)EncodingFormat;
wfx.nChannels = (short)ChannelCount;
wfx.nSamplesPerSec = SamplesPerSecond;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal SpAudioStreamWrapper(Stream stream, SpeechAudioFormatInfo audioFormat)

if (audioFormat != null)
{
WAVEFORMATEX wfx = new();
WAVEFORMATEX wfx = default;
wfx.wFormatTag = (short)audioFormat.EncodingFormat;
wfx.nChannels = (short)audioFormat.ChannelCount;
wfx.nSamplesPerSec = audioFormat.SamplesPerSecond;
Expand Down Expand Up @@ -78,7 +78,7 @@ internal void GetStreamOffsets(Stream stream)
{
BinaryReader br = new(stream);
// Read the riff Header
RIFFHDR riff = new();
RIFFHDR riff = default;

riff._id = br.ReadUInt32();
riff._len = br.ReadInt32();
Expand All @@ -89,7 +89,7 @@ internal void GetStreamOffsets(Stream stream)
throw new FormatException();
}

BLOCKHDR block = new();
BLOCKHDR block = default;
block._id = br.ReadUInt32();
block._len = br.ReadInt32();

Expand All @@ -112,7 +112,7 @@ internal void GetStreamOffsets(Stream stream)

while (true)
{
DATAHDR dataHdr = new();
DATAHDR dataHdr = default;

// check for the end of file (+8 for the 2 DWORD)
if (stream.Position + 8 >= stream.Length)
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/System.Speech/src/Internal/SrgsCompiler/Arc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ internal static int CompareContentForKey(Arc arc1, Arc arc2)

internal float Serialize(StreamMarshaler streamBuffer, bool isLast, uint arcIndex)
{
CfgArc A = new();
CfgArc A = default;

A.LastArc = isLast;
A.HasSemanticTag = SemanticTagCount > 0;
Expand Down Expand Up @@ -223,7 +223,7 @@ internal float Serialize(StreamMarshaler streamBuffer, bool isLast, uint arcInde

internal static float SerializeExtraEpsilonWithTag(StreamMarshaler streamBuffer, Arc arc, bool isLast, uint arcIndex)
{
CfgArc A = new();
CfgArc A = default;

A.LastArc = isLast;
A.HasSemanticTag = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ internal void Commit(StreamMarshaler streamBuffer)
//
// Write a dummy 0 index state entry
//
CfgArc dummyArc = new();
CfgArc dummyArc = default;

System.Diagnostics.Debug.Assert(streamBuffer.Stream.Position - startStreamPosition == header.pArcs);
streamBuffer.WriteStream(dummyArc);
Expand Down Expand Up @@ -817,7 +817,7 @@ internal void InitFromBinaryGrammar(StreamMarshaler streamHelper)
//
Arc[] apArcTable = new Arc[header.arcs.Length];
bool fLastArcNull = true;
CfgArc pLastArc = new();
CfgArc pLastArc = default;
State currentState = null;
SortedDictionary<int, Rule>.Enumerator ieFirstArcs = ruleFirstArcs.GetEnumerator();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ internal static CfgHeader ConvertCfgHeader(StreamMarshaler streamHelper, bool in
// Because in 64-bit code, pointers != sizeof(ULONG) we copy each member explicitly.
//

CfgHeader header = new();
CfgHeader header = default;
header.FormatId = cfgSerializedHeader.FormatId;
header.GrammarGUID = cfgSerializedHeader.GrammarGUID;
header.langId = cfgSerializedHeader.LangID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal ScriptRef(string rule, string sMethod, RuleMethodScript method)

internal void Serialize(StringBlob symbols, StreamMarshaler streamBuffer)
{
CfgScriptRef script = new();
CfgScriptRef script = default;

// Get the symbol id for the rule
script._idRule = symbols.Find(_rule);
Expand Down
12 changes: 6 additions & 6 deletions src/libraries/System.Speech/src/Internal/Synthesis/AudioBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ internal void PlayWaveFile(AudioData audio)
// Fake a header for ALaw and ULaw
if (!string.IsNullOrEmpty(audio._mimeType))
{
WAVEFORMATEX wfx = new();
WAVEFORMATEX wfx = default;

wfx.nChannels = 1;
wfx.nSamplesPerSec = 8000;
Expand Down Expand Up @@ -164,7 +164,7 @@ internal void PlayWaveFile(AudioData audio)
{
while (true)
{
DATAHDR dataHdr = new();
DATAHDR dataHdr = default;

// check for the end of file (+8 for the 2 DWORD)
if (audio._stream.Position + 8 >= audio._stream.Length)
Expand Down Expand Up @@ -208,7 +208,7 @@ internal void PlayWaveFile(AudioData audio)
internal static byte[] GetWaveFormat(BinaryReader br)
{
// Read the riff Header
RIFFHDR riff = new();
RIFFHDR riff = default;

riff._id = br.ReadUInt32();
riff._len = br.ReadInt32();
Expand All @@ -219,7 +219,7 @@ internal static byte[] GetWaveFormat(BinaryReader br)
return null;
}

BLOCKHDR block = new();
BLOCKHDR block = default;
block._id = br.ReadUInt32();
block._len = br.ReadInt32();

Expand Down Expand Up @@ -392,7 +392,7 @@ internal static WAVEFORMATEX ToWaveHeader(byte[] waveHeader)
{
GCHandle gc = GCHandle.Alloc(waveHeader, GCHandleType.Pinned);
IntPtr ptr = gc.AddrOfPinnedObject();
WAVEFORMATEX wfx = new();
WAVEFORMATEX wfx = default;
wfx.wFormatTag = Marshal.ReadInt16(ptr);
wfx.nChannels = Marshal.ReadInt16(ptr, 2);
wfx.nSamplesPerSec = Marshal.ReadInt32(ptr, 4);
Expand Down Expand Up @@ -444,7 +444,7 @@ internal static WAVEFORMATEX Default
{
get
{
WAVEFORMATEX wfx = new();
WAVEFORMATEX wfx = default;
wfx.wFormatTag = 1;
wfx.nChannels = 1;
wfx.nSamplesPerSec = 22050;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ internal static int GetDevicedId(string name)
internal static Interop.WinMM.MMSYSERR GetDeviceName(int deviceId, [MarshalAs(UnmanagedType.LPWStr)] out string prodName)
{
prodName = string.Empty;
Interop.WinMM.WAVEOUTCAPS caps = new();
Interop.WinMM.WAVEOUTCAPS caps = default;

Interop.WinMM.MMSYSERR result = Interop.WinMM.waveOutGetDevCaps((IntPtr)deviceId, ref caps, Marshal.SizeOf<Interop.WinMM.WAVEOUTCAPS>());
if (result != Interop.WinMM.MMSYSERR.NOERROR)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal AudioFileOut(Stream stream, SpeechAudioFormatInfo formatInfo, bool head
_startStreamPosition = _stream.Position;
_hasHeader = headerInfo;

_wfxOut = new WAVEFORMATEX();
_wfxOut = default;
// if we have a formatInfo object, format conversion may be necessary
if (formatInfo != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ internal static bool ToSapi(List<TextFragment> ssmlFrags, ref GCHandle sapiFragL
SPVTEXTFRAG sapiFrag = new();

// start with the text fragment
sapiFrag.gcNext = fFirst ? new GCHandle() : sapiFragLast;
sapiFrag.gcNext = fFirst ? default : sapiFragLast;
sapiFrag.pNext = fFirst ? IntPtr.Zero : sapiFragLast.AddrOfPinnedObject();
sapiFrag.gcText = GCHandle.Alloc(textFragment.TextToSpeak, GCHandleType.Pinned);
sapiFrag.pTextStart = sapiFrag.gcText.AddrOfPinnedObject();
sapiFrag.ulTextSrcOffset = textFragment.TextOffset;
sapiFrag.ulTextLen = textFragment.TextLength;

// State
SPVSTATE sapiState = new();
SPVSTATE sapiState = default;
FragmentState ssmlState = textFragment.State;
sapiState.eAction = (SPVACTIONS)ssmlState.Action;
sapiState.LangID = (short)ssmlState.LangId;
Expand Down Expand Up @@ -72,7 +72,7 @@ internal static bool ToSapi(List<TextFragment> ssmlFrags, ref GCHandle sapiFragL
}
else
{
sapiFrag.gcPhoneme = new GCHandle();
sapiFrag.gcPhoneme = default;
sapiState.pPhoneIds = IntPtr.Zero;
}

Expand Down
38 changes: 19 additions & 19 deletions src/libraries/System.Speech/src/Internal/Synthesis/SSmlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal static void Parse(XmlReader reader, ISsmlParser engine, object voice)
/// </summary>
private static void ProcessSpeakElement(XmlReader reader, ISsmlParser engine, object voice)
{
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;
ssmlAttributes._voice = voice;
ssmlAttributes._age = VoiceAge.NotSet;
ssmlAttributes._gender = VoiceGender.NotSet;
Expand Down Expand Up @@ -217,7 +217,7 @@ private static void ProcessSpeakElement(XmlReader reader, ISsmlParser engine, ob
private static void ProcessElement(XmlReader reader, ISsmlParser engine, string sElement, SsmlElement possibleElements, SsmlAttributes ssmAttributesParent, bool fIgnore, List<SsmlXmlAttribute> extraAttributes)
{
// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;

// This is equivalent to a memcpy
ssmlAttributes = ssmAttributesParent;
Expand Down Expand Up @@ -296,7 +296,7 @@ private static void ParseAudio(XmlReader reader, ISsmlParser engine, SsmlElement
string sElement = ValidateElement(element, SsmlElement.Audio, reader.Name);

// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;
List<SsmlXmlAttribute> extraAttributes = null;

// This is equivalent to a memcpy
Expand Down Expand Up @@ -357,7 +357,7 @@ private static void ParseBreak(XmlReader reader, ISsmlParser engine, SsmlElement
string sElement = ValidateElement(element, SsmlElement.Break, reader.Name);

// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;
List<SsmlXmlAttribute> extraAttributes = null;

// This is equivalent to a memcpy
Expand Down Expand Up @@ -432,7 +432,7 @@ private static void ParseDesc(XmlReader reader, ISsmlParser engine, SsmlElement
string sElement = ValidateElement(element, SsmlElement.Desc, reader.Name);

// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;
List<SsmlXmlAttribute> extraAttributes = null;

// This is equivalent to a memcpy
Expand Down Expand Up @@ -488,7 +488,7 @@ private static void ParseEmphasis(XmlReader reader, ISsmlParser engine, SsmlElem
string sElement = ValidateElement(element, SsmlElement.Emphasis, reader.Name);

// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;
List<SsmlXmlAttribute> extraAttributes = null;

// This is equivalent to a memcpy
Expand Down Expand Up @@ -548,7 +548,7 @@ private static void ParseMark(XmlReader reader, ISsmlParser engine, SsmlElement
string sElement = ValidateElement(element, SsmlElement.Mark, reader.Name);

// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;
List<SsmlXmlAttribute> extraAttributes = null;

// This is equivalent to a memcpy
Expand Down Expand Up @@ -645,7 +645,7 @@ private static void ParseSentence(XmlReader reader, ISsmlParser engine, SsmlElem
private static void ParseTextBlock(XmlReader reader, ISsmlParser engine, bool isParagraph, string sElement, SsmlAttributes ssmAttributesParent, bool fIgnore)
{
// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;
List<SsmlXmlAttribute> extraAttributes = null;

// This is equivalent to a memcpy
Expand Down Expand Up @@ -713,7 +713,7 @@ private static void ParsePhoneme(XmlReader reader, ISsmlParser engine, SsmlEleme
string sElement = ValidateElement(element, SsmlElement.Phoneme, reader.Name);

// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;
List<SsmlXmlAttribute> extraAttributes = null;

// This is equivalent to a memcpy
Expand Down Expand Up @@ -835,7 +835,7 @@ private static void ParseProsody(XmlReader reader, ISsmlParser engine, SsmlEleme
string sElement = ValidateElement(element, SsmlElement.Prosody, reader.Name);

// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;
List<SsmlXmlAttribute> extraAttributes = null;

// This is equivalent to a memcpy
Expand Down Expand Up @@ -918,7 +918,7 @@ private static void ParseSayAs(XmlReader reader, ISsmlParser engine, SsmlElement
string sElement = ValidateElement(element, SsmlElement.SayAs, reader.Name);

// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;
List<SsmlXmlAttribute> extraAttributes = null;

// This is equivalent to a memcpy
Expand Down Expand Up @@ -987,7 +987,7 @@ private static void ParseSub(XmlReader reader, ISsmlParser engine, SsmlElement e
string sElement = ValidateElement(element, SsmlElement.Sub, reader.Name);

// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;
List<SsmlXmlAttribute> extraAttributes = null;

// This is equivalent to a memcpy
Expand Down Expand Up @@ -1050,7 +1050,7 @@ private static void ParseVoice(XmlReader reader, ISsmlParser engine, SsmlElement
}

// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;

// This is equivalent to a memcpy
ssmlAttributes = ssmAttributesParent;
Expand Down Expand Up @@ -1219,7 +1219,7 @@ private static void ParseLexicon(XmlReader reader, ISsmlParser engine, SsmlEleme
string sElement = ValidateElement(element, SsmlElement.Lexicon, reader.Name);

// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;
List<SsmlXmlAttribute> extraAttributes = null;

// This is equivalent to a memcpy
Expand Down Expand Up @@ -1288,7 +1288,7 @@ private static void ParsePromptEngine0(XmlReader reader, ISsmlParser engine, Ssm
string sElement = ValidateElement(elementAllowed, element, reader.Name);

// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;

// This is equivalent to a memcpy
ssmlAttributes = ssmAttributesParent;
Expand Down Expand Up @@ -1322,7 +1322,7 @@ private static string ParsePromptEngine1(XmlReader reader, ISsmlParser engine, S
string sElement = ValidateElement(elementAllowed, element, reader.Name);

// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;

// This is equivalent to a memcpy
ssmlAttributes = ssmAttributesParent;
Expand Down Expand Up @@ -1381,7 +1381,7 @@ private static void ParseDatabase(XmlReader reader, ISsmlParser engine, SsmlElem
string sElement = ValidateElement(element, SsmlElement.PromptEngineDatabase, reader.Name);

// Make a local copy of the ssmlAttribute
SsmlAttributes ssmlAttributes = new();
SsmlAttributes ssmlAttributes = default;

// This is equivalent to a memcpy
ssmlAttributes = ssmAttributesParent;
Expand Down Expand Up @@ -1539,8 +1539,8 @@ private static ContourPoint[] ParseContour(string contour)
int comma = NextChar(achContour, start, ',', true, out percent);
int parenthesis = NextChar(achContour, comma, ')', true, out ignored);

ProsodyNumber timePosition = new();
ProsodyNumber target = new();
ProsodyNumber timePosition = default;
ProsodyNumber target = default;

// Parse the 2 numbers
if (!percent || !TryParseNumber(contour.Substring(start, comma - (start + 1)), ref timePosition) || timePosition.SsmlAttributeId == ProsodyNumber.AbsoluteNumber)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ internal override IntPtr GetOutputFormat(IntPtr preferredFormat)
{
// Initialize TTS Engine
Guid formatId = SAPIGuids.SPDFID_WaveFormatEx;
Guid guidNull = new();
Guid guidNull = default;
IntPtr coMem = IntPtr.Zero;

_sapiEngine.GetOutputFormat(ref formatId, preferredFormat, out guidNull, out coMem);
Expand All @@ -149,7 +149,7 @@ internal override void Speak(List<TextFragment> frags, byte[] wfx)
try
{
IntPtr waveFormat = gc.AddrOfPinnedObject();
GCHandle spvTextFragment = new();
GCHandle spvTextFragment = default;

if (ConvertTextFrag.ToSapi(frags, ref spvTextFragment))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ internal byte[] WaveFormat(byte[] targetWaveFormat)
if (_waveFormat == null || !Array.Equals(targetWaveFormat, _waveFormat))
{
IntPtr waveFormat = IntPtr.Zero;
GCHandle targetFormat = new();
GCHandle targetFormat = default;

if (targetWaveFormat != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ private void ThreadProc()
//--- Make sure we have a voice defined by now
if (!paramSpeak._isXml)
{
FragmentState fragmentState = new();
FragmentState fragmentState = default;
fragmentState.Action = TtsEngineAction.Speak;
fragmentState.Prosody = new Prosody();
TextFragment textFragment = new(fragmentState, paramSpeak._textToSpeak);
Expand Down
Loading
Loading