mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
CTDB 2.0: pregap handling
This commit is contained in:
@@ -15,19 +15,13 @@ namespace CUETools.CTDB.EACPlugin
|
|||||||
private int confidence, quality;
|
private int confidence, quality;
|
||||||
private string artist, title, agent, drivename;
|
private string artist, title, agent, drivename;
|
||||||
|
|
||||||
public FormSubmitParity(CUEToolsDB ctdb, int confidence, int quality, string artist, string title)
|
public FormSubmitParity(CUEToolsDB ctdb, string agent, string drivename, int confidence, int quality, string artist, string title)
|
||||||
{
|
{
|
||||||
this.ctdb = ctdb;
|
this.ctdb = ctdb;
|
||||||
this.confidence = confidence;
|
this.confidence = confidence;
|
||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
this.artist = artist;
|
this.artist = artist;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormSubmitParity(CUEToolsDB ctdb, string agent, string drivename)
|
|
||||||
{
|
|
||||||
this.ctdb = ctdb;
|
|
||||||
this.agent = agent;
|
this.agent = agent;
|
||||||
this.drivename = drivename;
|
this.drivename = drivename;
|
||||||
this.InitializeComponent();
|
this.InitializeComponent();
|
||||||
@@ -47,15 +41,14 @@ namespace CUETools.CTDB.EACPlugin
|
|||||||
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
|
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
|
||||||
{
|
{
|
||||||
this.ctdb.UploadHelper.onProgress += UploadProgress;
|
this.ctdb.UploadHelper.onProgress += UploadProgress;
|
||||||
if (this.agent != null)
|
#if DEBUG
|
||||||
{
|
string server = "hq.cuetools.net";
|
||||||
this.ctdb.ContactDB(null, this.agent, this.drivename, true, false, CTDBMetadataSearch.None);
|
#else
|
||||||
}
|
string server = null;
|
||||||
else
|
#endif
|
||||||
{
|
this.ctdb.ContactDB(server, this.agent, this.drivename, true, true, CTDBMetadataSearch.None);
|
||||||
this.ctdb.DoVerify();
|
this.ctdb.DoVerify();
|
||||||
this.ctdb.Submit(this.confidence, this.quality, this.artist, this.title, null);
|
this.ctdb.Submit(this.confidence, this.quality, this.artist, this.title, null);
|
||||||
}
|
|
||||||
this.ctdb.UploadHelper.onProgress -= UploadProgress;
|
this.ctdb.UploadHelper.onProgress -= UploadProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ namespace AudioDataPlugIn
|
|||||||
bool is_secure_mode;
|
bool is_secure_mode;
|
||||||
bool is_offset_set;
|
bool is_offset_set;
|
||||||
string m_drivename;
|
string m_drivename;
|
||||||
|
#if DEBUG
|
||||||
|
StringWriter m_trace;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// This functions just returns an unique identifier.
|
// This functions just returns an unique identifier.
|
||||||
@@ -97,6 +100,10 @@ namespace AudioDataPlugIn
|
|||||||
// Copy the CD metadata to the object
|
// Copy the CD metadata to the object
|
||||||
m_data = data;
|
m_data = data;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
m_trace = new StringWriter();
|
||||||
|
#endif
|
||||||
|
|
||||||
var parts = drivename.Split(' ');
|
var parts = drivename.Split(' ');
|
||||||
m_drivename = parts[0].PadRight(8, ' ') + " -";
|
m_drivename = parts[0].PadRight(8, ' ') + " -";
|
||||||
for (int i = 1; i < parts.Length; i++)
|
for (int i = 1; i < parts.Length; i++)
|
||||||
@@ -122,9 +129,6 @@ namespace AudioDataPlugIn
|
|||||||
ArId = AccurateRipVerify.CalculateAccurateRipId(TOC);
|
ArId = AccurateRipVerify.CalculateAccurateRipId(TOC);
|
||||||
ar.ContactAccurateRip(ArId);
|
ar.ContactAccurateRip(ArId);
|
||||||
#endif
|
#endif
|
||||||
var form = new FormSubmitParity(ctdb, "EAC" + m_data.HostVersion + " CTDB 2.1.3", m_drivename);
|
|
||||||
//ctdb.ContactDB("EAC" + m_data.HostVersion + " CTDB 2.1.2", m_drivename, false, false);
|
|
||||||
form.ShowDialog();
|
|
||||||
ctdb.Init(ar);
|
ctdb.Init(ar);
|
||||||
this.sequence_ok = true;
|
this.sequence_ok = true;
|
||||||
this.m_start_pos = 0;
|
this.m_start_pos = 0;
|
||||||
@@ -150,9 +154,27 @@ namespace AudioDataPlugIn
|
|||||||
{
|
{
|
||||||
var thisAr = m_test_mode ? arTest : ar;
|
var thisAr = m_test_mode ? arTest : ar;
|
||||||
if (this.m_start_pos * 588 != thisAr.Position)
|
if (this.m_start_pos * 588 != thisAr.Position)
|
||||||
|
{
|
||||||
|
if (thisAr.Position == 0 && this.m_start_pos == (int)TOC[TOC.FirstAudio].Pregap)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
m_trace.WriteLine("Adding pregap");
|
||||||
|
#endif
|
||||||
|
var ad = new byte[588 * 4];
|
||||||
|
AudioBuffer buff = new AudioBuffer(AudioPCMConfig.RedBook, ad, ad.Length / 4);
|
||||||
|
for (int i = 0; i < (int)TOC[TOC.FirstAudio].Pregap; i++)
|
||||||
|
thisAr.Write(buff);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
m_trace.WriteLine("Sequence broken on new trasfer");
|
||||||
|
#endif
|
||||||
this.sequence_ok = false;
|
this.sequence_ok = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// This function received the extracted (and
|
// This function received the extracted (and
|
||||||
@@ -186,9 +208,14 @@ namespace AudioDataPlugIn
|
|||||||
{
|
{
|
||||||
var thisAr = m_test_mode ? arTest : ar;
|
var thisAr = m_test_mode ? arTest : ar;
|
||||||
if ((m_start_pos + m_length) * 588 != thisAr.Position)
|
if ((m_start_pos + m_length) * 588 != thisAr.Position)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
m_trace.WriteLine("Sequence broken on end of trasfer");
|
||||||
|
#endif
|
||||||
this.sequence_ok = false;
|
this.sequence_ok = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// The extraction has finished, the log dialog will
|
// The extraction has finished, the log dialog will
|
||||||
@@ -202,40 +229,68 @@ namespace AudioDataPlugIn
|
|||||||
if (this.sequence_ok)
|
if (this.sequence_ok)
|
||||||
{
|
{
|
||||||
if (TOC.AudioLength * 588 != ar.Position)
|
if (TOC.AudioLength * 588 != ar.Position)
|
||||||
this.sequence_ok = false;
|
{
|
||||||
if (ar.Position != arTest.Position && arTest.Position > 0)
|
#if DEBUG
|
||||||
|
m_trace.WriteLine("Sequence broken on end of session");
|
||||||
|
#endif
|
||||||
this.sequence_ok = false;
|
this.sequence_ok = false;
|
||||||
}
|
}
|
||||||
|
if (ar.Position != arTest.Position && arTest.Position > 0)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
m_trace.WriteLine("Sequence broken on end of session");
|
||||||
|
#endif
|
||||||
|
this.sequence_ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!this.sequence_ok)
|
if (!this.sequence_ok)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
return m_trace.ToString();
|
||||||
|
#else
|
||||||
return "";
|
return "";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#if DEBUG
|
||||||
|
sw.Write(m_trace.ToString());
|
||||||
|
#endif
|
||||||
if (this.sequence_ok)
|
if (this.sequence_ok)
|
||||||
{
|
{
|
||||||
var form = new FormSubmitParity(
|
var form = new FormSubmitParity(
|
||||||
ctdb,
|
ctdb,
|
||||||
|
"EAC" + m_data.HostVersion + " CTDB 2.1.3",
|
||||||
|
m_drivename,
|
||||||
#if USEAR
|
#if USEAR
|
||||||
(int)ar.WorstConfidence() + 1,
|
(int)ar.WorstConfidence() + 1,
|
||||||
#else
|
#else
|
||||||
1,
|
1,
|
||||||
#endif
|
#endif
|
||||||
(arTest.Position == 0 && this.is_secure_mode) || arTest.CRC32(0) == ar.CRC32(0) ? 100 : 0,
|
(arTest.Position == 0 && this.is_secure_mode) || (arTest.Position != 0 && arTest.CRC32(0) == ar.CRC32(0)) ? 100 : 0,
|
||||||
m_data.AlbumArtist,
|
m_data.AlbumArtist,
|
||||||
m_data.AlbumTitle);
|
m_data.AlbumTitle);
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
sw.WriteLine("[CTDB TOCID: {0}] {1}{2}",
|
sw.WriteLine("[CTDB TOCID: {0}] {1}",
|
||||||
TOC.TOCID,
|
TOC.TOCID,
|
||||||
ctdb.DBStatus ?? "found");
|
ctdb.DBStatus ?? "found");
|
||||||
if (ctdb.SubStatus != null)
|
if (ctdb.SubStatus != null)
|
||||||
sw.WriteLine("Submit result: " + ctdb.SubStatus);
|
sw.WriteLine("Submit result: " + ctdb.SubStatus);
|
||||||
|
#if DEBUG
|
||||||
|
ctdb.GenerateLog(sw, true);
|
||||||
|
#else
|
||||||
ctdb.GenerateLog(sw, false);
|
ctdb.GenerateLog(sw, false);
|
||||||
bool canFix = false;
|
#endif
|
||||||
|
int fixConf = -1;
|
||||||
|
int myConf = 0;
|
||||||
if (ctdb.QueryExceptionStatus == WebExceptionStatus.Success)
|
if (ctdb.QueryExceptionStatus == WebExceptionStatus.Success)
|
||||||
{
|
{
|
||||||
foreach (DBEntry entry in ctdb.Entries)
|
foreach (DBEntry entry in ctdb.Entries)
|
||||||
if (entry.hasErrors && entry.canRecover)
|
if (!entry.hasErrors)
|
||||||
canFix = true;
|
myConf += entry.conf;
|
||||||
|
else if (entry.canRecover)
|
||||||
|
fixConf = Math.Max(fixConf, entry.conf);
|
||||||
}
|
}
|
||||||
if (canFix)
|
if (fixConf > myConf)
|
||||||
sw.WriteLine("You can use CUETools to repair this rip.");
|
sw.WriteLine("If you are sure that your rip contains errors, you can use CUETools to repair it.");
|
||||||
|
|
||||||
#if USEAR
|
#if USEAR
|
||||||
ar.GenerateFullLog(sw, false, ArId);
|
ar.GenerateFullLog(sw, false, ArId);
|
||||||
|
|||||||
Reference in New Issue
Block a user