Using AudioCDBurner and AudioCDReader together...?


#1

Hello!

As usual, I did a search and read the code before asking this question.

Now that I can get a CDDB id from a CD, I’m wanting to be able to recognize when a CD is inserted into the drive and then react accordingly.

However, there are two different classes here. AudioCDBurner seems to be the class that I use to get notifications on things entering or leaving the CD drive; to get CDDB id and other information, I need an AudioCDReader and it’s not entirely clear how I get this.

There are two lists of names… AudioCDBurner::findAvailableDevices() and AudioCDReader::getAvailableCDNames(). Are there any guarantees that these would be the same, or that one is a subset of the other?


#2

Those two lists are certainly different - e.g. if you had a read-only device and also a cd burner, they’d definitely not be the same. I guess that checking for an audio cd involves checking for a volume insertion (http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=5695&hilit=volume), but that probably won’t work for a writable disc, because a blank disc is unlikely to show up as a mountable volume, so for that you’d need to use the burner class to monitor the status.


#3

Well, I’m sort of willing to ignore that case since very few people these days have read-only devices.

I don’t (right now) actually care about writeable disks either - I just want to recognize pre-recorded CDs when they’re put into the drive! I’m not willing to go so far as to write this volume notification.

But the lists might not be the same - will the name of a device appear as the same in the two lists?


#4

I don’t think that’d be something you could rely on - the APIs used are completely different.


#5

Urg, I feared as much.

[edit: Whine whine whine…]

How do I successfully perform this operation of simply being notified when a CD enters a drive - without writing platform-specific code to put into JUCE?

As you’ve probably noticed, I’m not totally against that, but I’m spending quite a lot of time writing JUCEy things already… but more important, I know nothing at all about Windows programming (I have another programmer part-time porting, testing and building on Windows but I don’t have so much time out of him that I can get him to do this…).

And I’m almost there right now. As I said, I really don’t care much about read-only devices, and I am already getting a notification from CD burners when a disk is inserted - all I need to do is to be able to open that CD burner as a CD reader.

[edit: this is probably a perfectly good solution anyway]

It’s likely that I’m going to put in a “quick hack” for the moment. My assumption is that 90%+ of the world has exactly one optical drive in their system, which is also a CD burner. In this most common case, I do know that the single CD burner and the single CDReader must be one and the same.

Otherwise, when I get a notification on any burner, I can simply try to open ALL the CDReaders until I get something. Not so unreasonable, really.