mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
Cleanup IAudioDest; CompressionLevel is now part of AudioEncoderSettings.
FLAC encoders no longer offer non-subset compression levels by default.
This commit is contained in:
@@ -87,7 +87,7 @@ namespace CUETools.Processor
|
||||
if (encoder == null)
|
||||
throw new Exception("Unsupported audio type: " + path);
|
||||
if (encoder.path != null)
|
||||
dest = new UserDefinedWriter(path, null, pcm, encoder.path, encoder.parameters, encoder.default_mode, padding);
|
||||
dest = new UserDefinedWriter(path, null, pcm, encoder.path, encoder.parameters, encoder.EncoderMode, padding);
|
||||
else if (encoder.type != null)
|
||||
{
|
||||
object o = Activator.CreateInstance(encoder.type, path, pcm);
|
||||
@@ -97,10 +97,9 @@ namespace CUETools.Processor
|
||||
}
|
||||
else
|
||||
throw new Exception("Unsupported audio type: " + path);
|
||||
dest.CompressionLevel = encoder.DefaultModeIndex;
|
||||
dest.Settings = encoder.settings;
|
||||
dest.FinalSampleCount = finalSampleCount;
|
||||
dest.Padding = padding;
|
||||
dest.Settings = encoder.settings;
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
@@ -325,13 +325,13 @@ return processor.Go();
|
||||
foreach (CUEToolsUDC encoder in encoders)
|
||||
{
|
||||
sw.Save(string.Format("ExternalEncoder{0}Name", nEncoders), encoder.name);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Modes", nEncoders), encoder.supported_modes);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Mode", nEncoders), encoder.default_mode);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Extension", nEncoders), encoder.extension);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Lossless", nEncoders), encoder.lossless);
|
||||
if (encoder.path != null)
|
||||
{
|
||||
sw.Save(string.Format("ExternalEncoder{0}Extension", nEncoders), encoder.extension);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Modes", nEncoders), encoder.SupportedModesStr);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Mode", nEncoders), encoder.EncoderMode);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Path", nEncoders), encoder.path);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Lossless", nEncoders), encoder.lossless);
|
||||
sw.Save(string.Format("ExternalEncoder{0}Parameters", nEncoders), encoder.parameters);
|
||||
}
|
||||
else
|
||||
@@ -493,6 +493,8 @@ return processor.Go();
|
||||
encoder.path = path;
|
||||
encoder.lossless = lossless;
|
||||
encoder.parameters = parameters;
|
||||
encoder.SupportedModesStr = supported_modes;
|
||||
encoder.EncoderMode = default_mode;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -500,14 +502,12 @@ return processor.Go();
|
||||
try
|
||||
{
|
||||
using (TextReader reader = new StringReader(parameters))
|
||||
encoder.settings = encoder.settingsSerializer.Deserialize(reader);
|
||||
encoder.settings = encoder.settingsSerializer.Deserialize(reader) as AudioEncoderSettings;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
encoder.supported_modes = supported_modes;
|
||||
encoder.default_mode = default_mode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,14 @@ namespace CUETools.Processor
|
||||
public string path = "";
|
||||
public string parameters = "";
|
||||
public Type type = null;
|
||||
public object settings = null;
|
||||
public AudioEncoderSettings settings = null;
|
||||
public XmlSerializer settingsSerializer = null;
|
||||
public string supported_modes = "";
|
||||
public string default_mode = "";
|
||||
public bool lossless = false;
|
||||
public int priority = 0;
|
||||
|
||||
private string supported_modes = "";
|
||||
private string default_mode = "";
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public CUEToolsUDC(
|
||||
@@ -47,18 +48,16 @@ namespace CUETools.Processor
|
||||
name = enc.EncoderName;
|
||||
extension = enc.Extension;
|
||||
lossless = enc.Lossless;
|
||||
supported_modes = enc.SupportedModes;
|
||||
default_mode = enc.DefaultMode;
|
||||
priority = enc.Priority;
|
||||
path = null;
|
||||
parameters = "";
|
||||
type = enctype;
|
||||
settingsSerializer = null;
|
||||
settings = null;
|
||||
if (enc.Settings != null && enc.Settings != typeof(object))
|
||||
if (enc.Settings != null && typeof(AudioEncoderSettings).IsAssignableFrom(enc.Settings))
|
||||
{
|
||||
settingsSerializer = new XmlSerializer(enc.Settings);
|
||||
settings = Activator.CreateInstance(enc.Settings);
|
||||
settings = Activator.CreateInstance(enc.Settings) as AudioEncoderSettings;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +66,6 @@ namespace CUETools.Processor
|
||||
name = dec.DecoderName;
|
||||
extension = dec.Extension;
|
||||
lossless = true;
|
||||
supported_modes = "";
|
||||
default_mode = "";
|
||||
priority = dec.Priority;
|
||||
path = null;
|
||||
parameters = null;
|
||||
@@ -105,26 +102,50 @@ namespace CUETools.Processor
|
||||
get { return lossless; }
|
||||
set { lossless = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Lossless")); }
|
||||
}
|
||||
|
||||
public string Extension
|
||||
{
|
||||
get { return extension; }
|
||||
set { extension = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Extension")); }
|
||||
}
|
||||
|
||||
public string DotExtension
|
||||
{
|
||||
get { return "." + extension; }
|
||||
}
|
||||
|
||||
public string SupportedModesStr
|
||||
{
|
||||
get { return supported_modes; }
|
||||
set { supported_modes = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("SupportedModesStr")); }
|
||||
get
|
||||
{
|
||||
return this.settings == null ? this.supported_modes : this.settings.GetSupportedModes();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.settings != null) throw new NotSupportedException();
|
||||
supported_modes = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("SupportedModesStr"));
|
||||
}
|
||||
}
|
||||
|
||||
public string EncoderMode
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.settings != null) return this.settings.EncoderMode;
|
||||
else return this.default_mode;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.settings != null) this.settings.EncoderMode = value;
|
||||
else this.default_mode = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string[] SupportedModes
|
||||
{
|
||||
get
|
||||
{
|
||||
return supported_modes.Split(' ');
|
||||
return this.SupportedModesStr.Split(' ');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,11 +153,11 @@ namespace CUETools.Processor
|
||||
{
|
||||
get
|
||||
{
|
||||
string[] modes = supported_modes.Split(' ');
|
||||
string[] modes = this.SupportedModes;
|
||||
if (modes == null || modes.Length < 2)
|
||||
return -1;
|
||||
for (int i = 0; i < modes.Length; i++)
|
||||
if (modes[i] == default_mode)
|
||||
if (modes[i] == this.EncoderMode)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user