diff --git a/Bwg.Scsi/DeviceInfo.cs b/Bwg.Scsi/DeviceInfo.cs
index 3296b4f..6f3b4aa 100644
--- a/Bwg.Scsi/DeviceInfo.cs
+++ b/Bwg.Scsi/DeviceInfo.cs
@@ -155,6 +155,16 @@ namespace Bwg.Scsi
m_devices.Add(newdev);
return newdev;
}
+ ///
+ /// This method returns or creates a unique device info structure based on the
+ /// drive letter for a given drive.
+ ///
+ /// the drive letter for the drive
+ /// the single DeviceInfo object that represents this drive
+ public static DeviceInfo CreateDevice(string letter)
+ {
+ return CreateDevice(DeviceManager.GetNtDeviceNameForDrive(letter),letter);
+ }
#endregion
}
}
diff --git a/Bwg.Scsi/DeviceManager.cs b/Bwg.Scsi/DeviceManager.cs
index 46dc819..a244a7e 100644
--- a/Bwg.Scsi/DeviceManager.cs
+++ b/Bwg.Scsi/DeviceManager.cs
@@ -168,7 +168,12 @@ namespace Bwg.Scsi
#region private methods
- private static string GetNtDeviceNameForDrive(string name)
+ ///
+ /// Return the NT name for a drive given its drive letter
+ ///
+ /// the drive letter
+ /// the NT name
+ public static string GetNtDeviceNameForDrive(string name)
{
string result;
const int buflen = 512;
diff --git a/CUETools.Ripper.Console/Program.cs b/CUETools.Ripper.Console/Program.cs
index 0b56d25..2fc6b16 100644
--- a/CUETools.Ripper.Console/Program.cs
+++ b/CUETools.Ripper.Console/Program.cs
@@ -25,6 +25,7 @@ using System.Text;
using System.Collections.Generic;
using CUETools.Ripper.SCSI;
using CUETools.Codecs;
+using CUETools.CDImage;
using CUETools.AccurateRip;
namespace CUERipper
@@ -50,12 +51,19 @@ namespace CUERipper
return;
}
string destFile = args[0];
+ char[] drives = CDDriveReader.DrivesAvailable();
+ if (drives.Length < 1)
+ {
+ Console.WriteLine("No CD drives found.");
+ return;
+ }
+ char driveLetter = drives[0];
#if !DEBUG
try
#endif
{
CDDriveReader audioSource = new CDDriveReader();
- audioSource.Open('D');
+ audioSource.Open(driveLetter);
audioSource.DriveOffset = 48;
bool toStdout = false;
@@ -67,7 +75,8 @@ namespace CUERipper
arVerify.ContactAccurateRip(ArId);
- Console.WriteLine("File Info : {0}kHz; {1} channel; {2} bit; {3}", audioSource.SampleRate, audioSource.ChannelCount, audioSource.BitsPerSample, TimeSpan.FromSeconds(audioSource.Length * 1.0 / audioSource.SampleRate));
+ Console.WriteLine("Drive : {0}", audioSource.Path);
+ Console.WriteLine("File Info : {0}kHz; {1} channel; {2} bit; {3}", audioSource.SampleRate, audioSource.ChannelCount, audioSource.BitsPerSample, CDImageLayout.TimeToString((uint)(audioSource.Length / 588)));
Console.WriteLine("Filename : {0}", destFile);
Console.WriteLine("AR status : {0}", arVerify.ARStatus == null ? "ok" : arVerify.ARStatus);
diff --git a/CUETools.Ripper.SCSI/SCSIDrive.cs b/CUETools.Ripper.SCSI/SCSIDrive.cs
index eca8cc5..6a1c56d 100644
--- a/CUETools.Ripper.SCSI/SCSIDrive.cs
+++ b/CUETools.Ripper.SCSI/SCSIDrive.cs
@@ -24,6 +24,7 @@ using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
+using System.IO;
using Bwg.Scsi;
using Bwg.Logging;
using CUETools.CDImage;
@@ -46,8 +47,9 @@ namespace CUETools.Ripper.SCSI
const int CB_AUDIO = 588 * 4 + 16;
const int NSECTORS = 32;
int _currentTrack = -1, _currentIndex = -1, _currentTrackActualStart = -1;
- Logger m_logger = null;
+ Logger m_logger;
CDImageLayout _toc;
+ DeviceInfo m_info;
public CDImageLayout TOC
{
@@ -59,17 +61,23 @@ namespace CUETools.Ripper.SCSI
public CDDriveReader()
{
+ m_logger = new Logger();
}
public bool Open(char Drive)
{
Device.CommandStatus st;
+ m_info = DeviceInfo.CreateDevice(Drive + ":");
+
// Open the base device
m_device = new Device(m_logger);
if (!m_device.Open(Drive))
throw new Exception("SCSI error");
+ if (!m_info.ExtractInfo(m_device))
+ throw new Exception("SCSI error");
+
//// Open/Initialize the driver
//Drive m_drive = new Drive(dev);
//DiskOperationError status = m_drive.Initialize();
@@ -370,7 +378,7 @@ namespace CUETools.Ripper.SCSI
{
get
{
- return m_device.Name;
+ return m_info.LongDesc;
}
}
@@ -413,5 +421,14 @@ namespace CUETools.Ripper.SCSI
{
return (hex >> 4) * 10 + (hex & 15);
}
+
+ public static char[] DrivesAvailable()
+ {
+ List result = new List();
+ foreach (DriveInfo info in DriveInfo.GetDrives())
+ if (info.DriveType == DriveType.CDRom)
+ result.Add(info.Name[0]);
+ return result.ToArray();
+ }
}
}
diff --git a/CUEToolsLib/Main.cs b/CUEToolsLib/Main.cs
index 9bc2b91..4255a37 100644
--- a/CUEToolsLib/Main.cs
+++ b/CUEToolsLib/Main.cs
@@ -816,7 +816,6 @@ namespace CUETools.Processor
if (_accurateRipId == null && _dataTrackLength == null && _eacLog != null)
{
sr = new StringReader(_eacLog);
- uint lastAudioSector = 0;
bool isEACLog = false;
CDImageLayout tocFromLog = new CDImageLayout();
while ((lineStr = sr.ReadLine()) != null)