mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
Reset encoding mode to default for codecs with dynamic modes list,
when settings become incompatible with the chosen mode. E.g. for flac if -11 was selected and nonsubset modes are disabled, -7 is chosen instead.
This commit is contained in:
@@ -996,11 +996,8 @@ namespace CUERipper
|
|||||||
|
|
||||||
private void resetEncoderModes(CUEToolsUDC encoder)
|
private void resetEncoderModes(CUEToolsUDC encoder)
|
||||||
{
|
{
|
||||||
if (encoder.settings != null)
|
if (encoder.settings != null) encoder.settings.PCM = AudioPCMConfig.RedBook;
|
||||||
{
|
buttonEncoderSettings.Enabled = encoder.settings != null && encoder.settings.HasBrowsableAttributes();
|
||||||
encoder.settings.PCM = AudioPCMConfig.RedBook;
|
|
||||||
buttonEncoderSettings.Enabled = encoder.settings.HasBrowsableAttributes();
|
|
||||||
}
|
|
||||||
string[] modes = encoder.SupportedModes;
|
string[] modes = encoder.SupportedModes;
|
||||||
if (modes == null || modes.Length < 2)
|
if (modes == null || modes.Length < 2)
|
||||||
{
|
{
|
||||||
@@ -1011,8 +1008,14 @@ namespace CUERipper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (encoder.EncoderModeIndex == -1 && encoder.settings != null)
|
||||||
|
{
|
||||||
|
string defaultMode;
|
||||||
|
encoder.settings.GetSupportedModes(out defaultMode);
|
||||||
|
encoder.EncoderMode = defaultMode;
|
||||||
|
}
|
||||||
trackBarEncoderMode.Maximum = modes.Length - 1;
|
trackBarEncoderMode.Maximum = modes.Length - 1;
|
||||||
trackBarEncoderMode.Value = encoder.DefaultModeIndex == -1 ? modes.Length - 1 : encoder.DefaultModeIndex;
|
trackBarEncoderMode.Value = encoder.EncoderModeIndex == -1 ? modes.Length - 1 : encoder.EncoderModeIndex;
|
||||||
labelEncoderMode.Text = encoder.EncoderMode;
|
labelEncoderMode.Text = encoder.EncoderMode;
|
||||||
labelEncoderMinMode.Text = modes[0];
|
labelEncoderMinMode.Text = modes[0];
|
||||||
labelEncoderMaxMode.Text = modes[modes.Length - 1];
|
labelEncoderMaxMode.Text = modes[modes.Length - 1];
|
||||||
|
|||||||
@@ -34,12 +34,13 @@ namespace CUETools.Codecs.FLACCL
|
|||||||
public class FLACCLWriterSettings : AudioEncoderSettings
|
public class FLACCLWriterSettings : AudioEncoderSettings
|
||||||
{
|
{
|
||||||
public FLACCLWriterSettings()
|
public FLACCLWriterSettings()
|
||||||
: base("", "8")
|
: base()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GetSupportedModes()
|
public override string GetSupportedModes(out string defaultMode)
|
||||||
{
|
{
|
||||||
|
defaultMode = "8";
|
||||||
return this.AllowNonSubset ? "0 1 2 3 4 5 6 7 8 9 10 11" : "0 1 2 3 4 5 6 7 8";
|
return this.AllowNonSubset ? "0 1 2 3 4 5 6 7 8 9 10 11" : "0 1 2 3 4 5 6 7 8";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,12 +37,13 @@ namespace CUETools.Codecs.FLAKE
|
|||||||
public class FlakeWriterSettings : AudioEncoderSettings
|
public class FlakeWriterSettings : AudioEncoderSettings
|
||||||
{
|
{
|
||||||
public FlakeWriterSettings()
|
public FlakeWriterSettings()
|
||||||
: base("", "7")
|
: base()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GetSupportedModes()
|
public override string GetSupportedModes(out string defaultMode)
|
||||||
{
|
{
|
||||||
|
defaultMode = "7";
|
||||||
return this.AllowNonSubset ? "0 1 2 3 4 5 6 7 8 9 10 11" : "0 1 2 3 4 5 6 7 8";
|
return this.AllowNonSubset ? "0 1 2 3 4 5 6 7 8 9 10 11" : "0 1 2 3 4 5 6 7 8";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -188,9 +188,11 @@ namespace CUETools.Codecs.WMA
|
|||||||
return formats;
|
return formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GetSupportedModes()
|
public override string GetSupportedModes(out string defaultMode)
|
||||||
{
|
{
|
||||||
return string.Join(" ", GetFormats(null).ConvertAll(s => s.modeName).ToArray());
|
var fmts = GetFormats(null);
|
||||||
|
defaultMode = fmts.Count > 0 ? fmts[fmts.Count - 1].modeName : "";
|
||||||
|
return string.Join(" ", fmts.ConvertAll(s => s.modeName).ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace CUETools.Codecs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// When plugins with classes that provide <see cref="IAudioDest" /> are
|
/// When plugins with classes that provide <see cref="IAudioDest" /> are
|
||||||
/// registered, their <see cref="AudioEncoderClass" /> attributes are read.
|
/// registered, their <see cref="AudioEncoderClassAttribute" /> attributes are read.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <example>
|
/// <example>
|
||||||
/// <code lang="C#">using CUETools.Codecs;
|
/// <code lang="C#">using CUETools.Codecs;
|
||||||
@@ -19,7 +19,7 @@ namespace CUETools.Codecs
|
|||||||
///}</code>
|
///}</code>
|
||||||
/// </example>
|
/// </example>
|
||||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||||
public sealed class AudioEncoderClass : Attribute
|
public sealed class AudioEncoderClassAttribute : Attribute
|
||||||
{
|
{
|
||||||
private string _encoderName, _extension;
|
private string _encoderName, _extension;
|
||||||
private bool _lossless;
|
private bool _lossless;
|
||||||
@@ -51,7 +51,7 @@ namespace CUETools.Codecs
|
|||||||
get { return _settings; }
|
get { return _settings; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public AudioEncoderClass(string encoderName, string extension, bool lossless, int priority, Type settings)
|
public AudioEncoderClassAttribute(string encoderName, string extension, bool lossless, int priority, Type settings)
|
||||||
{
|
{
|
||||||
_encoderName = encoderName;
|
_encoderName = encoderName;
|
||||||
_extension = extension;
|
_extension = extension;
|
||||||
|
|||||||
@@ -25,13 +25,17 @@ namespace CUETools.Codecs
|
|||||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this))
|
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this))
|
||||||
property.ResetValue(this);
|
property.ResetValue(this);
|
||||||
this.m_supported_modes = supported_modes;
|
this.m_supported_modes = supported_modes;
|
||||||
this.EncoderMode = default_mode;
|
this.m_default_mode = default_mode;
|
||||||
|
//GetSupportedModes(out m_default_mode);
|
||||||
|
this.EncoderMode = m_default_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string m_supported_modes;
|
protected string m_supported_modes;
|
||||||
|
protected string m_default_mode;
|
||||||
|
|
||||||
public virtual string GetSupportedModes()
|
public virtual string GetSupportedModes(out string defaultMode)
|
||||||
{
|
{
|
||||||
|
defaultMode = m_default_mode;
|
||||||
return this.m_supported_modes;
|
return this.m_supported_modes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,23 +105,14 @@ namespace CUETools.Codecs
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
[XmlIgnore]
|
|
||||||
[Browsable(false)]
|
|
||||||
public string[] SupportedModes
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return this.GetSupportedModes().Split(' ');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
[Browsable(false)]
|
[Browsable(false)]
|
||||||
public int EncoderModeIndex
|
public int EncoderModeIndex
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
string[] modes = this.SupportedModes;
|
string defaultMode;
|
||||||
|
string[] modes = this.GetSupportedModes(out defaultMode).Split(' ');
|
||||||
if (modes == null || modes.Length < 1)
|
if (modes == null || modes.Length < 1)
|
||||||
return -1;
|
return -1;
|
||||||
for (int i = 0; i < modes.Length; i++)
|
for (int i = 0; i < modes.Length; i++)
|
||||||
@@ -128,7 +123,8 @@ namespace CUETools.Codecs
|
|||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
string[] modes = this.SupportedModes;
|
string defaultMode;
|
||||||
|
string[] modes = this.GetSupportedModes(out defaultMode).Split(' ');
|
||||||
if (modes.Length == 0 && value < 0)
|
if (modes.Length == 0 && value < 0)
|
||||||
return;
|
return;
|
||||||
if (value < 0 || value >= modes.Length)
|
if (value < 0 || value >= modes.Length)
|
||||||
|
|||||||
@@ -90,6 +90,7 @@
|
|||||||
<Compile Include="PlaybackState.cs" />
|
<Compile Include="PlaybackState.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="SilenceGenerator.cs" />
|
<Compile Include="SilenceGenerator.cs" />
|
||||||
|
<Compile Include="UserDefinedEncoderSettings.cs" />
|
||||||
<Compile Include="UserDefinedReader.cs" />
|
<Compile Include="UserDefinedReader.cs" />
|
||||||
<Compile Include="UserDefinedWriter.cs" />
|
<Compile Include="UserDefinedWriter.cs" />
|
||||||
<Compile Include="WAVReader.cs" />
|
<Compile Include="WAVReader.cs" />
|
||||||
|
|||||||
39
CUETools.Codecs/UserDefinedEncoderSettings.cs
Normal file
39
CUETools.Codecs/UserDefinedEncoderSettings.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace CUETools.Codecs
|
||||||
|
{
|
||||||
|
public class UserDefinedEncoderSettings : AudioEncoderSettings
|
||||||
|
{
|
||||||
|
public UserDefinedEncoderSettings()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SupportedModes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_supported_modes;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_supported_modes = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DefaultMode
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_default_mode;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_default_mode = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -153,7 +153,7 @@ namespace CUETools.Processor
|
|||||||
|
|
||||||
encoders = new CUEToolsUDCList();
|
encoders = new CUEToolsUDCList();
|
||||||
foreach (Type type in CUEProcessorPlugins.encs)
|
foreach (Type type in CUEProcessorPlugins.encs)
|
||||||
foreach (AudioEncoderClass enc in Attribute.GetCustomAttributes(type, typeof(AudioEncoderClass)))
|
foreach (AudioEncoderClassAttribute enc in Attribute.GetCustomAttributes(type, typeof(AudioEncoderClassAttribute)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace CUETools.Processor
|
|||||||
decs.Add(type);
|
decs.Add(type);
|
||||||
}
|
}
|
||||||
//if (type.IsClass && !type.IsAbstract && typeof(IAudioDest).IsAssignableFrom(type))
|
//if (type.IsClass && !type.IsAbstract && typeof(IAudioDest).IsAssignableFrom(type))
|
||||||
if (Attribute.GetCustomAttributes(type, typeof(AudioEncoderClass)).Length > 0)
|
if (Attribute.GetCustomAttributes(type, typeof(AudioEncoderClassAttribute)).Length > 0)
|
||||||
{
|
{
|
||||||
encs.Add(type);
|
encs.Add(type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace CUETools.Processor
|
|||||||
type = null;
|
type = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CUEToolsUDC(AudioEncoderClass enc, Type enctype)
|
public CUEToolsUDC(AudioEncoderClassAttribute enc, Type enctype)
|
||||||
{
|
{
|
||||||
name = enc.EncoderName;
|
name = enc.EncoderName;
|
||||||
extension = enc.Extension;
|
extension = enc.Extension;
|
||||||
@@ -118,7 +118,8 @@ namespace CUETools.Processor
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return this.settings == null ? this.supported_modes : this.settings.GetSupportedModes();
|
string defaultMode;
|
||||||
|
return this.settings == null ? this.supported_modes : this.settings.GetSupportedModes(out defaultMode);
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@@ -149,7 +150,7 @@ namespace CUETools.Processor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int DefaultModeIndex
|
public int EncoderModeIndex
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2465,8 +2465,14 @@ namespace JDP
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (encoder.EncoderModeIndex == -1 && encoder.settings != null)
|
||||||
|
{
|
||||||
|
string defaultMode;
|
||||||
|
encoder.settings.GetSupportedModes(out defaultMode);
|
||||||
|
encoder.EncoderMode = defaultMode;
|
||||||
|
}
|
||||||
trackBarEncoderMode.Maximum = modes.Length - 1;
|
trackBarEncoderMode.Maximum = modes.Length - 1;
|
||||||
trackBarEncoderMode.Value = encoder.DefaultModeIndex == -1 ? modes.Length - 1 : encoder.DefaultModeIndex;
|
trackBarEncoderMode.Value = encoder.EncoderModeIndex == -1 ? modes.Length - 1 : encoder.EncoderModeIndex;
|
||||||
labelEncoderMode.Text = encoder.EncoderMode;
|
labelEncoderMode.Text = encoder.EncoderMode;
|
||||||
labelEncoderMinMode.Text = modes[0];
|
labelEncoderMinMode.Text = modes[0];
|
||||||
labelEncoderMaxMode.Text = modes[modes.Length - 1];
|
labelEncoderMaxMode.Text = modes[modes.Length - 1];
|
||||||
|
|||||||
Reference in New Issue
Block a user