Author: abock
Date: 2005-11-23 17:51:39 -0500 (Wed, 23 Nov 2005)
New Revision: 53424
Modified:
trunk/entagged-sharp/ChangeLog
trunk/entagged-sharp/src/Asf/AsfFileReader.cs
trunk/entagged-sharp/src/Asf/Util/AsfTagReader.cs
Log:
2005-11-23 Aaron Bockover <[EMAIL PROTECTED]>
* src/Asf/Util/AsfTagReader.cs (ReadFixedSizeUTF16Str): Optimize the
reader by reducing number of byte array copies, fixed an index out of
range exception, instantiate a static readonly UnicodeEncoding object,
and use UnicodeEncoding.GetString() to perform the encoding
* src/Asf/AsfFileReader.cs: Added audio/x-ms-wma SupportedMimeType
Modified: trunk/entagged-sharp/ChangeLog
===================================================================
--- trunk/entagged-sharp/ChangeLog 2005-11-23 22:45:10 UTC (rev 53423)
+++ trunk/entagged-sharp/ChangeLog 2005-11-23 22:51:39 UTC (rev 53424)
@@ -1,5 +1,14 @@
2005-11-23 Aaron Bockover <[EMAIL PROTECTED]>
+ * src/Asf/Util/AsfTagReader.cs (ReadFixedSizeUTF16Str): Optimize the
+ reader by reducing number of byte array copies, fixed an index out of
+ range exception, instantiate a static readonly UnicodeEncoding object,
+ and use UnicodeEncoding.GetString() to perform the encoding
+
+ * src/Asf/AsfFileReader.cs: Added audio/x-ms-wma SupportedMimeType
+
+2005-11-23 Aaron Bockover <[EMAIL PROTECTED]>
+
* src/Asf/*: Added ASF/WMA parser by Christian Laireiter
* src/Makefile.am: Added build rules for src/Asf/*
Modified: trunk/entagged-sharp/src/Asf/AsfFileReader.cs
===================================================================
--- trunk/entagged-sharp/src/Asf/AsfFileReader.cs 2005-11-23 22:45:10 UTC
(rev 53423)
+++ trunk/entagged-sharp/src/Asf/AsfFileReader.cs 2005-11-23 22:51:39 UTC
(rev 53424)
@@ -36,6 +36,7 @@
// of the first audio stream is extracted.
[SupportedMimeType ("entagged/wma")]
+ [SupportedMimeType ("audio/x-ms-wma")]
public sealed class AsfFileReader : AudioFileReader
{
private static readonly AsfInfoReader infoReader = new AsfInfoReader();
Modified: trunk/entagged-sharp/src/Asf/Util/AsfTagReader.cs
===================================================================
--- trunk/entagged-sharp/src/Asf/Util/AsfTagReader.cs 2005-11-23 22:45:10 UTC
(rev 53423)
+++ trunk/entagged-sharp/src/Asf/Util/AsfTagReader.cs 2005-11-23 22:51:39 UTC
(rev 53424)
@@ -163,22 +163,21 @@
}
return result;
}
+
+ private static readonly UnicodeEncoding Utf16Encoding = new
UnicodeEncoding();
- private static String ReadFixedSizeUTF16Str(BinaryReader reader, int
strLen)
+ private static String ReadFixedSizeUTF16Str(BinaryReader reader, int
length)
{
- UnicodeEncoding encoding = new UnicodeEncoding();
- byte[] strBytes = new byte[strLen];
- reader.Read (strBytes,0,strBytes.Length);
- if (strBytes[strBytes.Length-1] == 0 &&
strBytes[strBytes.Length-2] == 0) {
- byte[] copy = new byte[strBytes.Length-2];
- Array.Copy (strBytes,0,copy,0,copy.Length);
- strBytes = copy;
+ byte [] bytes = new byte[length];
+ reader.Read(bytes, 0, bytes.Length);
+
+ if(bytes.Length - 2 >= 0 && bytes[bytes.Length - 1] == 0 &&
bytes[bytes.Length - 2] == 0) {
+ byte [] copy = new byte[bytes.Length - 2];
+ Array.Copy(bytes, 0, copy, 0, copy.Length);
+ bytes = copy;
}
- char[] chars = new
char[encoding.GetCharCount(strBytes,0,strBytes.Length)];
- encoding.GetChars (strBytes,0,strBytes.Length,chars,0);
- // TODO The optional zero termination must be recognized to
construct the string.
- return new string (chars);
+
+ return Utf16Encoding.GetString(bytes, 0, bytes.Length);
}
}
-
}
\ No newline at end of file
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches