Refactoring: moved Padding and BlockSize from IAudioDest to AudioEncoderSettings;

This commit is contained in:
Grigory Chudov
2013-04-04 22:07:15 -04:00
parent 1c9e76c421
commit b44e482dee
31 changed files with 255 additions and 550 deletions

View File

@@ -13,24 +13,54 @@ namespace CUETools.Codecs
// Iterate through each property and call ResetValue()
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this))
property.ResetValue(this);
this.supported_modes = "";
this.m_supported_modes = "";
this.EncoderMode = "";
}
public AudioEncoderSettings(string _supported_modes, string _default_mode)
public AudioEncoderSettings(string supported_modes, string default_mode)
{
// Iterate through each property and call ResetValue()
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this))
property.ResetValue(this);
this.supported_modes = _supported_modes;
this.EncoderMode = _default_mode;
this.m_supported_modes = supported_modes;
this.EncoderMode = default_mode;
}
private string supported_modes;
private string m_supported_modes;
public virtual string GetSupportedModes()
{
return this.supported_modes;
return this.m_supported_modes;
}
public virtual bool IsValid()
{
return BlockSize == 0 && Padding >= 0;
}
public T Clone<T>() where T : AudioEncoderSettings
{
if (this as T == null)
throw new Exception("Unsupported options " + this);
var result = this.MemberwiseClone() as T;
if (!result.IsValid())
throw new Exception("unsupported encoder settings");
return result;
}
[Browsable(false)]
[DefaultValue(0)]
public int BlockSize
{
get; set;
}
[Browsable(false)]
[DefaultValue(4096)]
public int Padding
{
get;
set;
}
[Browsable(false)]

View File

@@ -37,16 +37,6 @@ namespace CUETools.Codecs
}
}
public long Padding
{
set { }
}
public long BlockSize
{
set { }
}
public AudioPCMConfig PCM
{
get { return _pcm; }

View File

@@ -7,8 +7,6 @@
AudioEncoderSettings Settings { get; set; }
long FinalSampleCount { set; }
long BlockSize { set; }
long Padding { set; }
void Write(AudioBuffer buffer);
void Close();

View File

@@ -28,30 +28,21 @@ namespace CUETools.Codecs
set { _finalSampleCount = wrt.FinalSampleCount = value; }
}
public long BlockSize
{
set { }
}
// !!!! Must not start the process in constructor, so that we can set CompressionLevel via Settings!
private AudioEncoderSettings m_settings = new AudioEncoderSettings();
public AudioEncoderSettings Settings
{
get
{
return new AudioEncoderSettings();
return m_settings;
}
set
{
if (value != null && value.GetType() != typeof(AudioEncoderSettings))
throw new Exception("Unsupported options " + value);
m_settings = value.Clone<AudioEncoderSettings>();
}
}
public long Padding
{
set { }
}
public AudioPCMConfig PCM
{
get { return wrt.PCM; }

View File

@@ -31,11 +31,6 @@ namespace CUETools.Codecs
set { _finalSampleCount = value; }
}
public long BlockSize
{
set { }
}
public AudioEncoderSettings Settings
{
get
@@ -49,11 +44,6 @@ namespace CUETools.Codecs
}
}
public long Padding
{
set { }
}
public AudioPCMConfig PCM
{
get { return _pcm; }