CD-ROM

SDL Library Documentation
Prev |  | Next

# Chapter 11. CD-ROM

SDL supports audio control of up to 32 local CD-ROM drives at once.

You use this API to perform all the basic functions of a CD player, including listing the tracks, playing, stopping, and ejecting the CD-ROM. (Currently, multi-changer CD drives are not supported.)

Before you call any of the SDL CD-ROM functions, you must first call "`SDL_Init(SDL_INIT_CDROM)`", which scans the system for CD-ROM drives, and sets the program up for audio control. Check the return code, which should be 0, to see if there were any errors in starting up.

After you have initialized the library, you can find out how many drives are available using the `SDL_CDNumDrives()` function. The first drive listed is the system default CD-ROM drive. After you have chosen a drive, and have opened it with `SDL_CDOpen()`, you can check the status and start playing if there's a CD in the drive.

A CD-ROM is organized into one or more tracks, each consisting of a certain number of "frames". Each frame is ~2K in size, and at normal playing speed, a CD plays 75 frames per second. SDL works with the number of frames on a CD, but this can easily be converted to the more familiar minutes/seconds format by using the `FRAMES_TO_MSF()` macro.

Prev | Home | Next
SDL_CloseAudio | Up | SDL_CDNumDrives