Added crude debug pipes

This commit is contained in:
Joshua Askharoun
2021-04-27 11:48:43 -05:00
parent 1b199adc28
commit 5d7546edaf
9 changed files with 134 additions and 36 deletions
+10
View File
@@ -70,6 +70,16 @@ namespace Microsoft.Zune.Shell
{
break;
}
case "debug":
try
{
Application.IsDebug = bool.Parse(commandLineArgument.Value);
break;
}
catch (FormatException ex)
{
break;
}
default:
hashtable[commandLineArgument.Name] = commandLineArgument.Value;
break;
+2
View File
@@ -133,6 +133,8 @@ namespace Microsoft.Iris
get => DllResources.StaticDllResourcesOnly;
}
public static bool IsDebug { get; set; }
public static void Initialize()
{
if (IsInitialized)
+57
View File
@@ -5,6 +5,8 @@
// Assembly location: C:\Program Files\Zune\UIX.dll
using System;
using System.IO;
using System.IO.Pipes;
using System.Threading;
namespace Microsoft.Iris.Queues
@@ -14,6 +16,9 @@ namespace Microsoft.Iris.Queues
private static Interconnect s_interconnect = new Interconnect();
[ThreadStatic]
private static Dispatcher s_threadDispatcher;
private static NamedPipeClientStream _debugPipe;
private static BinaryWriter _debugPipeWriter;
private static BinaryReader _debugPipeReader;
private Thread _owningThread;
private uint _enterCount;
private Feeder _feeder;
@@ -66,7 +71,10 @@ namespace Microsoft.Iris.Queues
{
QueueItem nextItem = queue.GetNextItem();
if (nextItem != null)
{
SendDebugMessage(nextItem.ToDebugPacketString());
nextItem.Dispatch();
}
else
break;
}
@@ -132,5 +140,54 @@ namespace Microsoft.Iris.Queues
}
return flag;
}
private static NamedPipeClientStream DebugPipe
{
get
{
if (_debugPipe == null && Application.IsDebug)
{
_debugPipe = new NamedPipeClientStream(System.Reflection.Assembly.GetExecutingAssembly().FullName);
_debugPipe.Connect();
}
return _debugPipe;
}
}
private static BinaryWriter DebugPipeWriter
{
get
{
if (_debugPipe != null && _debugPipeWriter == null)
_debugPipeWriter = new BinaryWriter(DebugPipe);
return _debugPipeWriter;
}
}
private static BinaryReader DebugPipeReader
{
get
{
if (_debugPipe != null && _debugPipeReader == null)
_debugPipeReader = new BinaryReader(DebugPipe);
return _debugPipeReader;
}
}
/// <summary>
/// Sends a message via <see cref="debugPipe"/>
/// </summary>
/// <param name="message"></param>
public static void SendDebugMessage(string message)
{
if (Application.IsDebug && DebugPipe.IsConnected && DebugPipe.CanWrite)
{
DebugPipe.WriteByte(0x01);
byte[] buffer = System.Text.Encoding.Unicode.GetBytes(message);
DebugPipe.Write(BitConverter.GetBytes(buffer.Length), 0, sizeof(int));
DebugPipe.Write(buffer, 0, buffer.Length);
DebugPipe.Flush();
}
}
}
}
+2
View File
@@ -20,6 +20,8 @@ namespace Microsoft.Iris.Queues
public override string ToString() => GetType().Name;
public virtual string ToDebugPacketString() => ToString();
internal class Chain
{
public virtual void Dispose()
@@ -158,6 +158,36 @@ namespace Microsoft.Iris.Session
UIDispatcher.Post(thread, priority, queueItem);
}
public override string ToDebugPacketString()
{
string packetString = string.Empty; ;
switch (_callType)
{
case CallType.Simple:
var simpleCallback = (SimpleCallback)_target;
packetString = simpleCallback.Target.ToString() + "." + simpleCallback.Method.Name;
break;
case CallType.OneParam:
var deferredHandler = (DeferredHandler)_target;
string targetStr = deferredHandler.Target?.ToString();
if (!string.IsNullOrEmpty(targetStr))
packetString += targetStr + ".";
packetString += $"{deferredHandler.Method.Name}({_param})";
break;
case CallType.Event:
var eventHandler = (EventHandler)_target;
packetString = $"{eventHandler.Target}.{eventHandler.Method.Name}({_param}, {_args})";
break;
case CallType.RenderItem:
var deferredInvokeItem = (IDeferredInvokeItem)_param;
packetString = deferredInvokeItem.ToString();
break;
default:
throw new InvalidOperationException();
}
return packetString;
}
private enum CallType
{
None,
+1 -1
View File
@@ -190,7 +190,7 @@ namespace Microsoft.Iris.ViewItems
char ch1 = value[value.Length - 1];
char ch2 = value[value.Length - 2];
if (ch1 == ' ' && ch2 != ' ')
_content += (string)(object)ch1;
_content += ch1;
}
else
_content = value;
+14 -17
View File
@@ -36,34 +36,31 @@ namespace ZuneUI
private long _duration;
private static long[] c_podcastVideoLengths = new long[3]
{
0L,
3000000000L,
6000000000L
0L,
3000000000L,
6000000000L
};
private static long[] c_podcastVideoMarkPlayedAtEOFMinus = new long[3]
{
300000000L,
600000000L,
1200000000L
300000000L,
600000000L,
1200000000L
};
public LibraryPlaybackTrack(
int mediaId,
MediaType mediaType,
ContainerPlayMarker containerPlayMarker)
public LibraryPlaybackTrack(int mediaId, MediaType mediaType, ContainerPlayMarker containerPlayMarker)
{
this._mediaId = mediaId;
this._mediaType = mediaType;
this._listType = PlaylistManager.MediaTypeToListType(mediaType);
this._containerPlayMarker = containerPlayMarker;
ThreadPool.QueueUserWorkItem(args =>
{
this._isInCollection = PlaylistManager.IsInCollection(this._mediaId, this._mediaType);
Application.DeferredInvoke(delegate
{
this.RatingChanged.Invoke();
}, null);
}, null);
{
this._isInCollection = PlaylistManager.IsInCollection(this._mediaId, this._mediaType);
Application.DeferredInvoke(delegate
{
this.RatingChanged.Invoke();
}, null);
}, null);
}
public int MediaId => this._mediaId;
+5 -5
View File
@@ -707,7 +707,7 @@ namespace ZuneUI
int[] columnIndexes = new int[1] { atom };
object[] fieldValues = new object[1]
{
defaultValue
defaultValue
};
ZuneLibrary.GetFieldValues(mediaId, listType, 1, columnIndexes, fieldValues, Instance.QueryContext);
return (T)fieldValues[0];
@@ -744,10 +744,10 @@ namespace ZuneUI
int[] columnIndexes = new int[4] { 177, 451, 344, 440 };
object[] fieldValues = new object[4]
{
MediaType.Undefined,
Guid.Empty,
string.Empty,
VideoDefinition.Unknown
MediaType.Undefined,
Guid.Empty,
string.Empty,
VideoDefinition.Unknown
};
ZuneLibrary.GetFieldValues(dbMediaId, EListType.eVideoList, columnIndexes.Length, columnIndexes, fieldValues, Instance.QueryContext);
type = (MediaType)fieldValues[0];
+13 -13
View File
@@ -1898,50 +1898,50 @@ namespace ZuneUI
private void UpdatePropertiesAndCommands()
{
bool flag1 = this._playerState == PlayerState.Playing;
bool isPlaying = this._playerState == PlayerState.Playing;
ArrayListDataSet arrayListDataSet;
bool flag2;
bool isPlaylist;
bool flag3;
PlaybackTrack playbackTrack;
int num;
bool flag4;
bool supportsShuffle;
if (this._playlistCurrent != null)
{
arrayListDataSet = this._playlistCurrent.TrackList;
flag2 = true;
isPlaylist = true;
flag3 = this.IsCurrentPlaylistContextCompatible(this._pagePlaybackContext);
playbackTrack = this._playlistCurrent.CurrentTrack;
num = this._playlistCurrent.ListIndexOfCurrentTrack;
flag4 = this._playlistCurrent.QuickMixSession == null;
supportsShuffle = this._playlistCurrent.QuickMixSession == null;
}
else
{
flag2 = false;
isPlaylist = false;
arrayListDataSet = null;
flag3 = true;
playbackTrack = null;
num = -1;
this.PlayingVideo = false;
flag4 = true;
supportsShuffle = true;
}
if (arrayListDataSet != this._currentPlaylist)
{
this._currentPlaylist = arrayListDataSet;
this.FirePropertyChanged("CurrentPlaylist");
}
if (flag2 != this._hasPlaylist)
if (isPlaylist != this._hasPlaylist)
{
this._hasPlaylist = flag2;
this._hasPlaylist = isPlaylist;
this.FirePropertyChanged("HasPlaylist");
}
if (flag4 != this._playlistSupportsShuffle)
if (supportsShuffle != this._playlistSupportsShuffle)
{
this._playlistSupportsShuffle = flag4;
this._playlistSupportsShuffle = supportsShuffle;
this.FirePropertyChanged("PlaylistSupportsShuffle");
}
if (flag1 != this._isPlaying)
if (isPlaying != this._isPlaying)
{
this._isPlaying = flag1;
this._isPlaying = isPlaying;
this.FirePropertyChanged("Playing");
if (this._isPlaying)
{