Skip to content

Commit

Permalink
v.1.3.7.4, 2014-03-09, 16:36:03
Browse files Browse the repository at this point in the history
+ All soundcards and config in crash reports (except password)
= Failed to report active soundcards when no mic connected
  • Loading branch information
9001 committed Oct 12, 2015
1 parent 1976212 commit 19276fc
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 80 deletions.
31 changes: 9 additions & 22 deletions Loopstream/Exceptional.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,24 +281,10 @@ public Variables()

internal GeneralInfo(SerializableException serializableException, Exception exception)
{
this.config = LSSettings.singleton;
if (this.config == null)
{
this.config = new LSSettings();
this.config.host = "nullsettings";
}
if (this.exception == null) this.exception = new SerializableException();
this.config.serverPresets = new List<LSSettings.LSServerPreset>();
this.config.pass = "(redacted)";

this.devs = this.config.devs;
if (this.devs == null)
{
this.devs = new LSDevice[0];
}

this.exception = serializableException;

if (this.exception == null) this.exception = new SerializableException();

HostApplicationVersion = System.Windows.Forms.Application.ProductVersion;

this.CLRVersion = Environment.Version.ToString();
Expand Down Expand Up @@ -374,10 +360,6 @@ internal GeneralInfo(SerializableException serializableException, Exception exce

public SerializableException exception { get; set; }

public LSSettings config { get; set; }

public LSDevice[] devs { get; set; }

//public Variables vars { get; set; }

public string moar { get; set; }
Expand All @@ -386,11 +368,16 @@ internal GeneralInfo(SerializableException serializableException, Exception exce

public override string ToString()
{
var serializer = new XmlSerializer(this.GetType());
return GeneralInfo.ser(this);
}

public static string ser(object o)
{
var serializer = new XmlSerializer(o.GetType());
using (var stream = new MemoryStream())
{
stream.SetLength(0);
serializer.Serialize(stream, this);
serializer.Serialize(stream, o);
stream.Position = 0;
var doc = XDocument.Load(stream);
return doc.Root.ToString();
Expand Down
16 changes: 12 additions & 4 deletions Loopstream/LSMixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,22 @@ void doMagic()
mixOut = new WasapiOut(settings.devOut.mm,
AudioClientShareMode.Shared, false, 100);

Logger.mix.a("init mixOut"); mixOut.Init(outVol);
Logger.mix.a("rec.startRec"); recCap.StartRecording();


Logger.mix.a("init mixOut");
mixOut.Init(outVol);

Logger.mix.a("rec.startRec");
recCap.StartRecording();

//System.Threading.Thread.Sleep(100);
if (settings.devMic != null && settings.devMic.mm != null)
{
Logger.mix.a("mic.startRec"); micCap.StartRecording();
Logger.mix.a("mic.startRec");
micCap.StartRecording();
}
Logger.mix.a("mixOut.play (ready)"); mixOut.Play();
Logger.mix.a("mixOut.play (ready)");
mixOut.Play();

if (settings.vu)
{
Expand Down
95 changes: 75 additions & 20 deletions Loopstream/LSSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

namespace Loopstream
{
public class LSSettings
public class LSSettingsI
{
public string sjdflakjdsa;
public LSSettingsI() { }
}

public class LSSettings : LSSettingsI
{
[XmlIgnore]
public static LSSettings singleton;
Expand Down Expand Up @@ -368,9 +374,9 @@ public enum LSRelay { ice, shout, siren }
public bool warn_poor, warn_drop;
public double lim_poor, lim_drop;

public LSSettings()
public LSSettings() : base()
{
s_devRec = s_devMic = s_devOut = null;
s_devRec = s_devMic = s_devOut = "";
micLeft = true;
micRight = false;
mp3 = new LSParams();
Expand Down Expand Up @@ -425,32 +431,58 @@ public LSSettings()
warn_poor = warn_drop = true;
lim_poor = 0.92;
lim_drop = 0.78;

Logger.app.a("Base LSSettings ready, doing init");
init();
}

public void init()
{
List<LSDevice> ldev = new List<LSDevice>();
NAudio.CoreAudioApi.MMDeviceEnumerator mde = new NAudio.CoreAudioApi.MMDeviceEnumerator();
foreach (
NAudio.CoreAudioApi.MMDevice device
in mde.EnumerateAudioEndPoints(
NAudio.CoreAudioApi.DataFlow.All,
NAudio.CoreAudioApi.DeviceState.All))
try
{
LSDevice add = new LSDevice();
add.mm = device;
add.isRec = device.DataFlow == NAudio.CoreAudioApi.DataFlow.Capture;
add.isPlay = device.DataFlow == NAudio.CoreAudioApi.DataFlow.Render;
if (device.DataFlow == NAudio.CoreAudioApi.DataFlow.All)
NAudio.CoreAudioApi.MMDeviceEnumerator mde = new NAudio.CoreAudioApi.MMDeviceEnumerator();
Logger.app.a("Created MM enumerator");
try
{
add.isRec = add.isPlay = true;
foreach (
NAudio.CoreAudioApi.MMDevice device
in mde.EnumerateAudioEndPoints(
NAudio.CoreAudioApi.DataFlow.All,
NAudio.CoreAudioApi.DeviceState.All))
{
try
{
LSDevice add = new LSDevice();
Logger.app.a("Creating LSDevice");
add.mm = device;
add.isRec = device.DataFlow == NAudio.CoreAudioApi.DataFlow.Capture;
add.isPlay = device.DataFlow == NAudio.CoreAudioApi.DataFlow.Render;
if (device.DataFlow == NAudio.CoreAudioApi.DataFlow.All)
{
add.isRec = add.isPlay = true;
}
Logger.app.a("Dataflows OK");

add.id = device.ID;
Logger.app.a("ID: " + add.id);

add.name = device.ToString();
Logger.app.a("Name: " + add.name);

ldev.Add(add);
}
catch { Logger.app.a("Failed"); }
}
}
add.name = device.ToString();
add.id = device.ID;
ldev.Add(add);
catch { Logger.app.a("Failed"); }
}
catch { Logger.app.a("Failed"); }

devs = ldev.ToArray();
if (string.IsNullOrEmpty(s_devRec)) s_devRec = "";
if (string.IsNullOrEmpty(s_devMic)) s_devMic = "";
if (string.IsNullOrEmpty(s_devOut)) s_devOut = "";
if (!string.IsNullOrEmpty(s_devRec)) devRec = getDevByID(s_devRec); // ?? devs.First(x => x.isPlay);
if (!string.IsNullOrEmpty(s_devMic)) devMic = getDevByID(s_devMic);
if (!string.IsNullOrEmpty(s_devOut)) devOut = getDevByID(s_devOut);
Expand Down Expand Up @@ -741,7 +773,7 @@ static int version()
public void save()
{
metaEnc();
XmlSerializer x = new XmlSerializer(this.GetType());
var x = new XmlSerializer(this.GetType());
using (var s = new System.IO.FileStream("Loopstream.ini", System.IO.FileMode.Create))
{
byte[] ver = System.Text.Encoding.UTF8.GetBytes(version().ToString("x") + "\n");
Expand All @@ -750,12 +782,26 @@ public void save()
}
metaDec();
}
public string serialize()
{
var x = new XmlSerializer(this.GetType());
using (var stream = new System.IO.MemoryStream())
{
stream.SetLength(0);
x.Serialize(stream, this);
stream.Position = 0;
var doc = System.Xml.Linq.XDocument.Load(stream);
return doc.Root.ToString();
}
}
public static LSSettings load()
{
Logger.app.a("Loading LSSettings");
LSSettings ret;
XmlSerializer x = new XmlSerializer(typeof(LSSettings));
if (System.IO.File.Exists("Loopstream.ini"))
{
Logger.app.a("Found existing .ini");
try
{
string str = System.IO.File.ReadAllText("Loopstream.ini", Encoding.UTF8);
Expand Down Expand Up @@ -801,6 +847,7 @@ public static LSSettings load()
}
catch (Exception e)
{
Logger.app.a("Deserialize failed, fallback to new");
ret = new LSSettings();
System.Windows.Forms.MessageBox.Show(
"Failed to load settings:\n«Loopstream.ini» is probably from an old version of the program.\n\nDetailed information:\n" + e.Message + "\n" + e.StackTrace,
Expand All @@ -810,6 +857,7 @@ public static LSSettings load()
}
try
{
Logger.app.a("Calling init()");
ret.init();
ret.mp3.FIXME_kbps =
ret.ogg.FIXME_kbps = -1;
Expand All @@ -826,18 +874,25 @@ public static LSSettings load()
ret.metaDec();
}
catch { }
LSSettings.singleton = ret;
Logger.app.a("LSSettings deserialize successful");
LSSettings.singleton = ret; // for exception handler
return ret;
}
catch (Exception e)
{
Logger.app.a("LSSettings deserialize postprocessing failed");
System.Windows.Forms.MessageBox.Show(
"Failed to initialize settings object:\nPossibly from an outdated version of «Loopstream.ini», though more likely a developer fuckup. Go tell ed this:\n\n" +
e.Message + "\n\n" + e.Source + "\n\n" + e.InnerException + "\n\n" + e.StackTrace);
}
}
Logger.app.a("Creating new LSSettings");
ret = new LSSettings();

Logger.app.a("Postprocessing new");
ret.initWhenDeserializationFails(); // it is 06:20 am, what are you looking at

Logger.app.a("LSSettings OK");
LSSettings.singleton = ret; // for exception handler
return ret;
}
Expand Down
26 changes: 15 additions & 11 deletions Loopstream/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ static class Program
public static string tools;
public static string[] args;
public static bool SIGNMODE;
public static bool DUMBCEPTIONS;
public static Random rnd;
//public static System.IO.StreamWriter log;

Expand All @@ -31,22 +32,25 @@ static void Main(string[] args)

DBGLOG = "";
SIGNMODE = false;
DUMBCEPTIONS = false;

Program.args = args;
if (args.Length > 0)
foreach (string str in args)
{
if (args[0] == "sign")
{
SIGNMODE = true;
}
if (str == "sign") SIGNMODE = true;
if (str == "exceptions") DUMBCEPTIONS = true;
}

AppDomain.CurrentDomain.UnhandledException += (ueSender, ueArgs) =>
new UI_Exception(ueArgs.ExceptionObject as Exception, 1).ShowDialog();

Application.ThreadException += (ueSender, ueArgs) =>
new UI_Exception(ueArgs.Exception, 2).ShowDialog();
if (!DUMBCEPTIONS)
{
AppDomain.CurrentDomain.UnhandledException += (ueSender, ueArgs) =>
new UI_Exception(ueArgs.ExceptionObject as Exception, 1).ShowDialog();

Application.ThreadException += (ueSender, ueArgs) =>
new UI_Exception(ueArgs.Exception, 2).ShowDialog();

Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
}

//AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
if (!debug)
Expand Down
4 changes: 2 additions & 2 deletions Loopstream/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.7.2")]
[assembly: AssemblyFileVersion("1.3.7.2")]
[assembly: AssemblyVersion("1.3.7.4")]
[assembly: AssemblyFileVersion("1.3.7.4")]
Loading

0 comments on commit 19276fc

Please sign in to comment.