138 lines
No EOL
4 KiB
C#
138 lines
No EOL
4 KiB
C#
using JD.Audio.Annotations;
|
|
using JD.Core.Collections;
|
|
using JD.Remoting;
|
|
using System.ComponentModel;
|
|
|
|
namespace ConductorDebugger.Source.Brick
|
|
{
|
|
public enum BrickState
|
|
{
|
|
NotCreated = 0,
|
|
Preparing,
|
|
Ready,
|
|
Started,
|
|
Discarding,
|
|
Seeking
|
|
}
|
|
|
|
/// <summary>
|
|
/// Visual representation of a Conductor Brick
|
|
/// </summary>
|
|
public class BrickModel : Observable
|
|
{
|
|
private readonly BeatUnit _absoluteStartBeat;
|
|
private readonly BeatUnit _localStartBeat;
|
|
private readonly BeatUnit _duration;
|
|
private readonly BeatUnit _prefetchDuration = new BeatUnit(8);
|
|
private readonly string _name;
|
|
private readonly string _type;
|
|
private readonly BrickState _brickState;
|
|
|
|
[DisplayName("Brick Name")]
|
|
[Browsable(true)]
|
|
[ReadOnly(true)]
|
|
public string Name
|
|
{
|
|
get { return _name; }
|
|
}
|
|
|
|
[DisplayName("Brick Type")]
|
|
[Browsable(true)]
|
|
[ReadOnly(true)]
|
|
public string Type
|
|
{
|
|
get { return _type; }
|
|
}
|
|
|
|
[DisplayName("Absolute Start Beat")]
|
|
[Browsable(true)]
|
|
[ReadOnly(true)]
|
|
public BeatUnit AbsoluteStartBeat
|
|
{
|
|
get { return _absoluteStartBeat; }
|
|
}
|
|
|
|
[DisplayName("Local Start Beat")]
|
|
[Browsable(true)]
|
|
[ReadOnly(true)]
|
|
public BeatUnit LocalStartBeat
|
|
{
|
|
get { return _localStartBeat; }
|
|
}
|
|
|
|
[DisplayName("Duration")]
|
|
[Browsable(true)]
|
|
[ReadOnly(true)]
|
|
public BeatUnit Duration
|
|
{
|
|
get { return _duration; }
|
|
}
|
|
|
|
[DisplayName("Prefetch Duration")]
|
|
[Browsable(true)]
|
|
[ReadOnly(true)]
|
|
public BeatUnit PrefetchDuration
|
|
{
|
|
get { return _prefetchDuration; }
|
|
}
|
|
|
|
[DisplayName("Brick State")]
|
|
[Browsable(true)]
|
|
[ReadOnly(true)]
|
|
public BrickState BrickState
|
|
{
|
|
get { return _brickState; }
|
|
}
|
|
|
|
public BrickModel(IBlob blob)
|
|
{
|
|
blob.Extract(out _type);
|
|
|
|
blob.Extract(out _name);
|
|
|
|
int absoluteStartBeat;
|
|
blob.Extract(out absoluteStartBeat);
|
|
_absoluteStartBeat = new BeatUnit(absoluteStartBeat);
|
|
|
|
int localStartBeat;
|
|
blob.Extract(out localStartBeat);
|
|
_localStartBeat = new BeatUnit(localStartBeat);
|
|
|
|
int duration;
|
|
blob.Extract(out duration);
|
|
_duration = new BeatUnit(duration);
|
|
|
|
int prefetchDuration;
|
|
blob.Extract(out prefetchDuration);
|
|
_prefetchDuration = new BeatUnit(prefetchDuration);
|
|
|
|
blob.ExtractEnum(out _brickState);
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
var model = obj as BrickModel;
|
|
return model != null && Equals(model);
|
|
}
|
|
|
|
protected bool Equals(BrickModel other)
|
|
{
|
|
return _absoluteStartBeat.Equals(other._absoluteStartBeat) && _localStartBeat.Equals(other._localStartBeat) && _duration.Equals(other._duration) && _prefetchDuration.Equals(other._prefetchDuration) && string.Equals(_name, other._name) && string.Equals(_type, other._type) && _brickState == other._brickState;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
unchecked
|
|
{
|
|
int hashCode = _absoluteStartBeat.GetHashCode();
|
|
hashCode = (hashCode * 397) ^ _localStartBeat.GetHashCode();
|
|
hashCode = (hashCode * 397) ^ _duration.GetHashCode();
|
|
hashCode = (hashCode * 397) ^ _prefetchDuration.GetHashCode();
|
|
hashCode = (hashCode * 397) ^ (_name != null ? _name.GetHashCode() : 0);
|
|
hashCode = (hashCode * 397) ^ (_type != null ? _type.GetHashCode() : 0);
|
|
hashCode = (hashCode * 397) ^ (int)_brickState;
|
|
return hashCode;
|
|
}
|
|
}
|
|
}
|
|
} |