This commit is contained in:
parent
0792524222
commit
fe6f2c2ec8
3 changed files with 98 additions and 49 deletions
|
|
@ -362,8 +362,12 @@ namespace DMX2
|
|||
courante = null;
|
||||
if (tickThread != null) {
|
||||
running = false;
|
||||
tickThread.Join(50);
|
||||
tickThread.Abort();
|
||||
tickThread.Join (50);
|
||||
tickThread.Abort ();
|
||||
}
|
||||
foreach (var seq in sequenceurs) {
|
||||
IDisposable idis = seq as IDisposable;
|
||||
if(idis!=null) idis.Dispose();
|
||||
}
|
||||
foreach(var driver in Drivers)
|
||||
driver.Dispose();
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ namespace DMX2
|
|||
SequenceurSon sequenceur;
|
||||
|
||||
public bool updateflag=true;
|
||||
bool updating=false;
|
||||
|
||||
bool ff=false;
|
||||
bool rw=false;
|
||||
|
|
@ -122,11 +123,11 @@ namespace DMX2
|
|||
#region implemented abstract members of DMX2.SequenceurUI
|
||||
public override void Update (bool full)
|
||||
{
|
||||
updating=true;
|
||||
if (full||updateflag ) {
|
||||
listFiles.QueueDraw();
|
||||
SelectionneLigne();
|
||||
UpdListFiles();
|
||||
|
||||
// listFiles.QueueDraw();
|
||||
SelectionneLigne();
|
||||
}
|
||||
updateflag=false;
|
||||
sclVolume.Value = sequenceur.Volume;
|
||||
|
|
@ -138,7 +139,10 @@ namespace DMX2
|
|||
if (rw) sequenceur.PlayTime += TimeSpan.FromSeconds(-1);
|
||||
|
||||
timeLabel.LabelProp = string.Format ("<small>elap.</small>{0:mm\\:ss\\.fff}\n<small>rem. </small>{1:mm\\:ss\\.fff}",cur,dur-cur);
|
||||
titleLabel.LabelProp = sequenceur.State;
|
||||
|
||||
pbCur.Fraction = (dur == TimeSpan.Zero)?0:(cur.TotalMilliseconds/dur.TotalMilliseconds);
|
||||
updating=false;
|
||||
}
|
||||
|
||||
int IndexSelection()
|
||||
|
|
@ -254,6 +258,7 @@ namespace DMX2
|
|||
|
||||
protected void OnListFilesCursorChanged (object sender, EventArgs e)
|
||||
{
|
||||
if(updating)return;
|
||||
TreeViewColumn col;
|
||||
TreePath path;
|
||||
listFiles.GetCursor (out path, out col);
|
||||
|
|
|
|||
|
|
@ -26,16 +26,8 @@ using System.Xml;
|
|||
namespace DMX2
|
||||
{
|
||||
|
||||
// TODO : Sauvegarde et chargement
|
||||
|
||||
public class SequenceurSon : Sequenceur
|
||||
public class SequenceurSon : Sequenceur, IDisposable
|
||||
{
|
||||
~SequenceurSon()
|
||||
{
|
||||
if(element!=null)
|
||||
Stop();
|
||||
element=null;
|
||||
}
|
||||
|
||||
SeqSonUI ui=null;
|
||||
|
||||
|
|
@ -57,7 +49,11 @@ namespace DMX2
|
|||
int fadeVStart;
|
||||
int fadeVEnd;
|
||||
|
||||
TimeSpan duration = TimeSpan.Zero;
|
||||
|
||||
Gst.Element element = null;
|
||||
Gst.State state,pending;
|
||||
Gst.StateChangeReturn scret;
|
||||
|
||||
public ReadOnlyCollection<string> Files {
|
||||
get {
|
||||
|
|
@ -107,28 +103,23 @@ namespace DMX2
|
|||
}
|
||||
set{
|
||||
if(element==null) return;
|
||||
if(element.CurrentState != Gst.State.Paused && element.CurrentState != Gst.State.Playing){
|
||||
taskQueue.Enqueue(delegate(){
|
||||
PlayTime = value;
|
||||
});
|
||||
return;
|
||||
}
|
||||
long pos = (long)(value.TotalMilliseconds) * 1000000;
|
||||
element.Seek (Gst.Format.Time,Gst.SeekFlags.Flush|Gst.SeekFlags.Accurate,pos);
|
||||
QueueTask(delegate(){
|
||||
//Console.WriteLine("Seek");
|
||||
long pos = (long)(value.TotalMilliseconds) * 1000000;
|
||||
element.Seek (Gst.Format.Time,Gst.SeekFlags.Flush|Gst.SeekFlags.Accurate,pos);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
TimeSpan duration = TimeSpan.Zero;
|
||||
|
||||
public TimeSpan Duration {
|
||||
get {
|
||||
if(element==null) return TimeSpan.Zero;
|
||||
//if(duration == TimeSpan.Zero) {
|
||||
Gst.Format format = Gst.Format.Time ;
|
||||
long dur;
|
||||
element.QueryDuration(ref format, out dur);
|
||||
duration = TimeSpan.FromMilliseconds(dur/1000000);
|
||||
//}
|
||||
if(duration == TimeSpan.Zero)
|
||||
{
|
||||
Gst.Format fmt = Gst.Format.Time; long dur;
|
||||
element.QueryDuration(ref fmt,out dur);
|
||||
return TimeSpan.FromMilliseconds(dur/1000000);
|
||||
}
|
||||
return duration;
|
||||
}
|
||||
}
|
||||
|
|
@ -141,10 +132,10 @@ namespace DMX2
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LoadFile (int pos)
|
||||
{
|
||||
//Console.WriteLine("LoadFile");
|
||||
|
||||
curfile = files[pos];
|
||||
Stop();
|
||||
|
||||
|
|
@ -161,20 +152,18 @@ namespace DMX2
|
|||
public void Play ()
|
||||
{
|
||||
if(element == null)return;
|
||||
if(element.CurrentState != Gst.State.Paused && element.CurrentState != Gst.State.Playing){
|
||||
taskQueue.Enqueue(delegate(){
|
||||
Play();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
element.SetState(Gst.State.Playing);
|
||||
QueueTask(delegate(){
|
||||
//Console.WriteLine("Play");
|
||||
element.SetState(Gst.State.Playing);
|
||||
});
|
||||
}
|
||||
|
||||
public void Pause ()
|
||||
{
|
||||
if(element == null)return;
|
||||
element.SetState(Gst.State.Paused);
|
||||
QueueTask(delegate(){
|
||||
element.SetState(Gst.State.Paused);
|
||||
});
|
||||
}
|
||||
|
||||
public void Stop ()
|
||||
|
|
@ -221,15 +210,54 @@ namespace DMX2
|
|||
return 0;
|
||||
}
|
||||
|
||||
public string State {
|
||||
get {
|
||||
if(element == null) return "Stopped";
|
||||
UpdateState();
|
||||
if(pending == Gst.State.VoidPending){
|
||||
return state.ToString();
|
||||
}
|
||||
if(scret == Gst.StateChangeReturn.Async)
|
||||
return string.Format("{0}=>{1}", state,pending);
|
||||
return string.Format("{0}=>{1} : {2}",state,pending,scret);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateState ()
|
||||
{
|
||||
scret = element.GetState (out state, out pending, 0UL);
|
||||
}
|
||||
|
||||
bool CheckAsync ()
|
||||
{
|
||||
if (element == null) return false;
|
||||
UpdateState ();
|
||||
return (scret != Gst.StateChangeReturn.Async);
|
||||
}
|
||||
|
||||
void QueueTask (Task t)
|
||||
{
|
||||
if (CheckAsync ()) {
|
||||
//Console.WriteLine("Sync");
|
||||
t();
|
||||
return;
|
||||
}
|
||||
//Console.WriteLine("Queue");
|
||||
taskQueue.Enqueue(t);
|
||||
}
|
||||
|
||||
public override void Tick (TimeSpan time)
|
||||
{
|
||||
if (element != null && taskQueue.Count>0) {
|
||||
if (element.CurrentState == Gst.State.Paused || element.CurrentState == Gst.State.Playing)
|
||||
if (taskQueue.Count>0 && CheckAsync()){
|
||||
//Console.WriteLine(State);
|
||||
Task task;
|
||||
if(taskQueue.TryDequeue(out task))
|
||||
{
|
||||
Task t;
|
||||
if(taskQueue.TryDequeue(out t)) t();
|
||||
//Console.WriteLine("ASync");
|
||||
task();
|
||||
}
|
||||
}
|
||||
|
||||
if (fading != TimeSpan.Zero) {
|
||||
fading-=time;
|
||||
if(fading<=TimeSpan.Zero){
|
||||
|
|
@ -294,6 +322,7 @@ namespace DMX2
|
|||
|
||||
public override void Command (string command)
|
||||
{
|
||||
//Console.WriteLine("Command");
|
||||
lock (this) {
|
||||
var cmd = regexCommand1.Match (command);
|
||||
|
||||
|
|
@ -330,9 +359,10 @@ namespace DMX2
|
|||
fadeVEnd = (int)vol;
|
||||
}
|
||||
else{
|
||||
Volume = vol;
|
||||
if (ui != null)
|
||||
ui.updateflag = true;
|
||||
fading = TimeSpan.Zero;
|
||||
Volume = vol;
|
||||
if (ui != null)
|
||||
ui.updateflag = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -423,6 +453,16 @@ namespace DMX2
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region IDisposable implementation
|
||||
void IDisposable.Dispose ()
|
||||
{
|
||||
if(element==null)return;
|
||||
element.SetState(Gst.State.Null);
|
||||
element.Dispose();
|
||||
element=null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue