Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Jan 25, 2007, 08:23 PM   #1
macrumors newbie
Join Date: Jan 2007
using IODVDServices


I know next to nothing about programming on a mac but am trying to fix a hardware problem by writing a simple program. Specifically, my Mac Mini's CD drive spins up to full speed when playing a CD, which sounds like a jet engine and is incredibly annoying. Having scoured the internet, I'm pretty much convinced that there is no software out there to set CD drive speed on a mac.

There is a command for setting the drive speed in the class IODVDServices which I am trying to figure out how to use. Apple has some sample code called "SCSIOldAndNew" which just looks for all the SCSI devices on your system and reports back basic info about them. I'm trying to set the drive speed by adding a slight modification to the code. It will find the IODVDServices object for me and theoretically everything should be easy from there, but due to my lack of knowledge, I'm running into some problems. What I have so far is:

while ((scsiDevice = IOIteratorNext(iterator))) {
// Get the object's class name just to display it
kr = IOObjectGetClass(scsiDevice, className);

if (kr != kIOReturnSuccess) {
fprintf(stderr, "Failed to get class name. (0x%08x)\n", kr);
else {
fprintf(stderr, "Found device class \"%s\" using STUC.\n", className);
if (className == "IODVDServices") {
fprintf(stderr, "attempting to check device speed");
fprintf(stderr, "Device speed = %d", speed);

The stuff after "if (className == "IODVDServices")" is what I've added. So, it appears that in the case of a CD drive, scsiDevice is an IODVDServices object, and I should just be able to call the getSpeed or setSpeed methods to do those things. However, xcode will not let me compile that code as written. I get an error that says "request for member 'getSpeed' in something that is not a structure or union". ?? While scsiDevice is declared as

io_service_t scsiDevice = IO_OBJECT_NULL;

if the class name is "IODVDServices" then I would assume it is an object of that type. Do I need to cast it or something? That leads to my second question... if I try to use the word IODVDServices anywhere in the code, I get an error, even though I've included the appropriate IODVDServices.h file. I am somewhat baffled why this is happening, my only guess is that there's a line in the header saying:

#if defined(KERNEL) && defined(__cplusplus)

so if either of those things are not defined, the compiler won't pick up all the IODVDServices definitions. I would assume cplusplus is defined, so is KERNEL not defined for some reason? Do I have to be writing kernel code to access IODVDServices?

If you've read this far, thanks for your attention. Also, I'm still holding out on the possibility that someone knows of a way to set the drive speed without having to write a program! Do tell..
hoek2000 is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Forum Jump

All times are GMT -5. The time now is 01:25 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC