SDL_CDStatus(3)
πΏ SDL_CDStatus πΏ
okay bestie, this one's from the SDL API Reference β it's the lil function that tells you what your CD drive is even doing right now. she's nosy in the best way. π
β¨ NAME β¨
SDL_CDStatus β Returns the current status of the given drive. that's it, that's the whole job, and she does it flawlessly. π
πΈ SYNOPSIS πΈ
#include "SDL.h"
CDstatus SDL_CDStatus(SDL_CD *cdrom); /* Given a status, returns true if
there's a disk in the drive */ #define CD_INDRIVE(status)
((int)status > 0)
like. you hand her a CD drive, she hands you back the vibe check on it. iconic behavior tbh. β¨
π¦ DESCRIPTION π¦
So this function returns the current status of the given drive. and the status is described like this β the whole enum, no gatekeeping:
typedef enum {
CD_TRAYEMPTY,
CD_STOPPED,
CD_PLAYING,
CD_PAUSED,
CD_ERROR = -1
} CDstatus;
If the drive has a CD in it, the table of contents of the CD and the current play position of the CD get stored in the SDL_CD structure. so she's not just telling you the tea, she's writing it down for you. π«Ά
The macro CD_INDRIVE is provided for convenience, and given a status it returns true if there's a disk in the drive. tiny helper, big main character energy. π
Note:SDL_CDStatusalso updates theSDL_CDstructure passed to it. so like, heads up β she's mutating your struct while you're not looking. it's fine, it's on purpose, but bestie. be aware. π
π₯ EXAMPLE π₯
here's the whole thing, copied exactly, no notes:
int playTrack(int track)
{
int playing = 0;
if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
/* clamp to the actual number of tracks on the CD */
if (track >= cdrom->numtracks) {
track = cdrom->numtracks-1;
}
if ( SDL_CDPlayTracks(cdrom, track, 0, 1, 0) == 0 ) {
playing = 1;
}
}
return playing;
}
look at her. checks the drive, clamps the track so you don't go asking for track 99 on a 12-track CD, plays the thing, tells you if it worked. that's a complete thought. we love a function that finishes what it starts. π
π SEE ALSO π
SDL_CDβ the structure she keeps updating behind your back. go read up, iykyk. π
k bye ily, go check ur drives π
this has been your girl from the SDL crew β page dated Tue 11 Sep 2001, 22:58, so yeah, vintage, retro, archival even. still serving. periodt. πβ¨π¦
π¦ where this page comes from
- debian bookworm: libsdl1.2-dev 1.2.15+dfsg2-8 Β· LGPL-2.1-or-later
- nixos 26.05: SDL_sixel 0-unstable-2016-02-06
- nixpkgs unstable: SDL_sixel 0-unstable-2016-02-06
- ubuntu jammy: libsdl1.2-dev 1.2.15+dfsg2-6 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms