Browse Source

Fix for AudioCDReader::createReaderForCD() on strange win32 systems with phantom CD-rom drives.

tags/2021-05-28
jules 13 years ago
parent
commit
8ed15bd9f0
2 changed files with 10 additions and 13 deletions
  1. +4
    -12
      modules/juce_audio_devices/audio_cd/juce_AudioCDReader.h
  2. +6
    -1
      modules/juce_audio_devices/native/juce_win32_AudioCDReader.cpp

+ 4
- 12
modules/juce_audio_devices/audio_cd/juce_AudioCDReader.h View File

@@ -57,7 +57,7 @@ public:
@param index the index of one of the available CDs - use getAvailableCDNames() @param index the index of one of the available CDs - use getAvailableCDNames()
to find out how many there are. to find out how many there are.
@returns a new AudioCDReader object, or 0 if it couldn't be created. The
@returns a new AudioCDReader object, or nullptr if it couldn't be created. The
caller will be responsible for deleting the object returned. caller will be responsible for deleting the object returned.
*/ */
static AudioCDReader* createReaderForCD (const int index); static AudioCDReader* createReaderForCD (const int index);
@@ -70,23 +70,19 @@ public:
bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer, bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer,
int64 startSampleInFile, int numSamples); int64 startSampleInFile, int numSamples);
/** Checks whether the CD has been removed from the drive.
*/
/** Checks whether the CD has been removed from the drive. */
bool isCDStillPresent() const; bool isCDStillPresent() const;
/** Returns the total number of tracks (audio + data).
*/
/** Returns the total number of tracks (audio + data). */
int getNumTracks() const; int getNumTracks() const;
/** Finds the sample offset of the start of a track. /** Finds the sample offset of the start of a track.
@param trackNum the track number, where trackNum = 0 is the first track @param trackNum the track number, where trackNum = 0 is the first track
and trackNum = getNumTracks() means the end of the CD. and trackNum = getNumTracks() means the end of the CD.
*/ */
int getPositionOfTrackStart (int trackNum) const; int getPositionOfTrackStart (int trackNum) const;
/** Returns true if a given track is an audio track. /** Returns true if a given track is an audio track.
@param trackNum the track number, where 0 is the first track. @param trackNum the track number, where 0 is the first track.
*/ */
bool isTrackAudio (int trackNum) const; bool isTrackAudio (int trackNum) const;
@@ -105,7 +101,6 @@ public:
void refreshTrackLengths(); void refreshTrackLengths();
/** Enables scanning for indexes within tracks. /** Enables scanning for indexes within tracks.
@see getLastIndex @see getLastIndex
*/ */
void enableIndexScanning (bool enabled); void enableIndexScanning (bool enabled);
@@ -126,7 +121,6 @@ public:
int getLastIndex() const; int getLastIndex() const;
/** Scans a track to find the position of any indexes within it. /** Scans a track to find the position of any indexes within it.
@param trackNumber the track to look in, where 0 is the first track on the disc @param trackNumber the track to look in, where 0 is the first track on the disc
@returns an array of sample positions of any index points found (not including @returns an array of sample positions of any index points found (not including
the index that marks the start of the track) the index that marks the start of the track)
@@ -134,14 +128,12 @@ public:
Array<int> findIndexesInTrack (const int trackNumber); Array<int> findIndexesInTrack (const int trackNumber);
/** Returns the CDDB id number for the CD. /** Returns the CDDB id number for the CD.
It's not a great way of identifying a disc, but it's traditional. It's not a great way of identifying a disc, but it's traditional.
*/ */
int getCDDBId(); int getCDDBId();
/** Tries to eject the disk. /** Tries to eject the disk.
Of course this might not be possible, if some other process is using it.
Ejecting the disk might not actually be possible, e.g. if some other process is using it.
*/ */
void ejectDisk(); void ejectDisk();


+ 6
- 1
modules/juce_audio_devices/native/juce_win32_AudioCDReader.cpp View File

@@ -993,7 +993,12 @@ AudioCDReader* AudioCDReader::createReaderForCD (const int deviceIndex)
HANDLE h = createSCSIDeviceHandle (list [deviceIndex].scsiDriveLetter); HANDLE h = createSCSIDeviceHandle (list [deviceIndex].scsiDriveLetter);
if (h != INVALID_HANDLE_VALUE) if (h != INVALID_HANDLE_VALUE)
return new AudioCDReader (new CDDeviceWrapper (list [deviceIndex], h));
{
ScopedPointer<AudioCDReader> cd (new AudioCDReader (new CDDeviceWrapper (list [deviceIndex], h)));
if (cd->lengthInSamples > 0)
return cd.release();
}
} }
return nullptr; return nullptr;


Loading…
Cancel
Save