pmanko / MXPTiny

Transport stream recorder for H.264 streaming devices by Blackmagic Design
GNU General Public License v3.0
1 stars 0 forks source link

Pipes missing messages #12

Open philliha opened 7 years ago

philliha commented 7 years ago

Very occasionally the pipes miss messages. I believe this is because of the ways the pipes connect after receiving a message. In my pipeclient I have a timeout on the initial connect but none after that one:

private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
      {
          string log = "";
          if (Settings.Default.selLogger == "My Computer")
              log = ".";
          else
              log = Settings.Default.selLogger;
          using (var client = new NamedPipeClientStream(log, System.Environment.MachineName + anglePort.ToString(), PipeDirection.In))
          {
              Console.Write("Attempting to connect to pipe...");
             // client.Connect();
              try
              {
                  client.Connect(2000);
              }
              catch (TimeoutException)
              {
                  return;
              }
              Console.WriteLine("Connected to pipe.");
              using (StreamReader sr = new StreamReader(client))
              {
                  string temp;
                  while (true)
                  {
                      while ((temp = sr.ReadLine()) != null)
                      {
                          Console.WriteLine("Received from server: {0}", temp);
                          if (temp.StartsWith("P"))
                          {
                              filePath = temp.Substring(1);
                              backgroundWorker1.ReportProgress(0);
                          }
                          if (temp.StartsWith("stop"))
                          {
                              backgroundWorker1.ReportProgress(1);
                          }
                          if (temp.StartsWith("halt"))
                          {
                              return;
                          }
                          client.Connect();
                      }
                  }
              }
          }
      }

I think if we mirror this functionality we'll be all set.

philliha commented 7 years ago

Occasionally missing the first clip is still happening, very sporadically. No sort of sequence to it, Joe was doing the same test every time and it happened 2 out of 30ish. Works fine after the first missed clip, you can continue to capture. Seems like it only every happens on the first clip as Joe logged 50 in a row with no issue. Will test further this afternoon.

pmanko commented 7 years ago

@philliha yeah, that's what I was noticing too - which is why I was trying to do the first clip before the loop. I might go back to that, especially since you've said that logger switching will require a restart.