Refactoring codecs infrastructure:

AudioWriterSettings passed to IAdioDest constructors now
AudioWriterSettings now includes AudioPCMConfig
This commit is contained in:
Grigory Chudov
2013-04-07 20:41:58 -04:00
parent b44e482dee
commit 9670c6c891
43 changed files with 652 additions and 723 deletions

View File

@@ -74,7 +74,7 @@ namespace CUETools.Processor
IAudioDest dest;
if (audioEncoderType == AudioEncoderType.NoAudio || extension == ".dummy")
{
dest = new DummyWriter(path, pcm);
dest = new DummyWriter(path, new AudioEncoderSettings(pcm));
dest.FinalSampleCount = finalSampleCount;
return dest;
}
@@ -86,19 +86,21 @@ namespace CUETools.Processor
null;
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.EncoderMode, padding);
var settings = encoder.settings.Clone();
settings.PCM = pcm;
settings.Padding = padding;
settings.Validate();
if (encoder.path != null)
dest = new UserDefinedWriter(path, null, settings, encoder.path, encoder.parameters, encoder.EncoderMode, padding);
else if (encoder.type != null)
{
object o = Activator.CreateInstance(encoder.type, path, pcm);
object o = Activator.CreateInstance(encoder.type, path, settings);
if (o == null || !(o is IAudioDest))
throw new Exception("Unsupported audio type: " + path + ": " + encoder.type.FullName);
dest = o as IAudioDest;
}
else
throw new Exception("Unsupported audio type: " + path);
dest.Settings = encoder.settings;
dest.Settings.Padding = padding;
dest.FinalSampleCount = finalSampleCount;
return dest;
}
@@ -114,7 +116,7 @@ namespace CUETools.Processor
AudioPCMConfig lossypcm = new AudioPCMConfig((config.detectHDCD && config.decodeHDCD && !config.decodeHDCDtoLW16) ? 24 : 16, pcm.ChannelCount, pcm.SampleRate);
IAudioDest lossyDest = GetAudioDest(AudioEncoderType.Lossless, path, lossypcm, finalSampleCount, padding, extension, config);
IAudioDest lwcdfDest = audioEncoderType == AudioEncoderType.Hybrid ? GetAudioDest(AudioEncoderType.Lossless, lwcdfPath, lossypcm, finalSampleCount, padding, extension, config) : null;
return new LossyWAVWriter(lossyDest, lwcdfDest, config.lossyWAVQuality, pcm);
return new LossyWAVWriter(lossyDest, lwcdfDest, config.lossyWAVQuality, new AudioEncoderSettings(pcm));
}
}
}

View File

@@ -154,7 +154,15 @@ namespace CUETools.Processor
encoders = new CUEToolsUDCList();
foreach (Type type in CUEProcessorPlugins.encs)
foreach (AudioEncoderClass enc in Attribute.GetCustomAttributes(type, typeof(AudioEncoderClass)))
encoders.Add(new CUEToolsUDC(enc, type));
{
try
{
encoders.Add(new CUEToolsUDC(enc, type));
}
catch (Exception)
{
}
}
decoders = new CUEToolsUDCList();
foreach (Type type in CUEProcessorPlugins.decs)
foreach (AudioDecoderClass dec in Attribute.GetCustomAttributes(type, typeof(AudioDecoderClass)))

View File

@@ -3877,7 +3877,7 @@ namespace CUETools.Processor
{
var pcm = new AudioPCMConfig(bps, 2, 44100);
if (noOutput)
return new DummyWriter(path, pcm);
return new DummyWriter(path, new AudioEncoderSettings(pcm));
return AudioReadWrite.GetAudioDest(_audioEncoderType, path, finalSampleCount, padding, pcm, _config);
}