Question concerning SDL_CDxxx

Hi,

I’m new to SDL and I am not shure this is the wright list - but I didn’t
find any other.

My Problem:
SDL_CDNumDrives reports the wrong number of drives: just 1 instead of 2
SDL_CDStatus reports: CD_STOPPED, while the CD is playing.
I am shure, that it is the wright drive (the one with the CD in) because
when I take off the CD, CD_TRAYEMPTY is reported.

Any hints?
Gerd

Hello.

I’m not familiar with the SDL_CD-functions but please do tell which;

  • version of SDL you are using
  • what OS and version you are running
  • are the cd-drives ide/sata/scsi

Have you tried this on another platform/computer to see if the same error appears?

Ideally also a small snippet of code which demonstrates the calls and which people can quickly compile and try on their systems.

Gerd Schering wrote:> Hi,

I’m new to SDL and I am not shure this is the wright list - but I didn’t
find any other.

My Problem:
SDL_CDNumDrives reports the wrong number of drives: just 1 instead of 2
SDL_CDStatus reports: CD_STOPPED, while the CD is playing.
I am shure, that it is the wright drive (the one with the CD in) because
when I take off the CD, CD_TRAYEMPTY is reported.

Any hints?
Gerd


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

andreas wrote:

Hello.

I’m not familiar with the SDL_CD-functions but please do tell which;

  • version of SDL you are using
    1.2.13
  • what OS and version you are running

linux with kernel 2.6.24.4 with desktop kde-3.5.9

  • are the cd-drives ide/sata/scsi

both ide: /dev/hda and /dev/hdc

Have you tried this on another platform/computer to see if the same error appears?

It’ s the only machine with 2 cd drives I own :-(.
But I tested it on my laptop with nearly identical installation, only difrference:
I use a laptop kernel and the cdrom is /dev/sr0 i.e. a sata device.
Results: SDL_CDNumDrives reports 1 drive, which is correct :-), but SDL_CDStatus reports: CD_STOPPED, while the CD is playing.
Could the KDE artsd daemon be the problem?

Ideally also a small snippet of code which demonstrates the calls and which people can quickly compile and try on their systems.

here it comes (I borrowed the whole thing from an internet SDL tutorial):

#include <SDL.h>
#include <stdlib.h>
#include <stdio.h>

int main(void) {

printf(“Initializing SDL.\n”);
if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_CDROM) < 0 ) {
printf(“Error: Could not initialize SDL: %s.\n”, SDL_GetError());
exit(-1);
}
atexit(SDL_Quit);

printf(“SDL initialized.\n”);

printf(“CD drive(s): available: %d\n”, SDL_CDNumDrives());
int i;
for ( i=0; i<SDL_CDNumDrives(); ++i ) {
printf(“Drive %d: “%s”\n”, i, SDL_CDName(i));
}
SDL_CD *cdrom;
CDstatus status;
char *status_str;

cdrom = SDL_CDOpen(0);
if ( cdrom == NULL ) {
fprintf(stderr, “Couldn’t open default CD drive: %s\n”, SDL_GetError());
exit(2);
}

status = SDL_CDStatus(cdrom);
switch (status) {
case CD_TRAYEMPTY:
status_str = “No CD.”;
break;
case CD_STOPPED:
status_str = “CD Stopped.”;
break;
case CD_PLAYING:
status_str = “CD Playing.”;
break;
case CD_PAUSED:
status_str = “CD Paused.”;
break;
case CD_ERROR:
status_str = “CD Error.”;
break;
}
printf(“Drive status: %s\n”, status_str);
if ( status >= CD_PLAYING ) {
int m, s, f;
FRAMES_TO_MSF(cdrom->cur_frame, &m, &s, &f);
printf(“Currently playing track %d, %d:%2.2d\n”,
cdrom->track[cdrom->cur_track].id, m, s);
}
return(0);
}

Thanks a lot for your help!
Gerd> Gerd Schering wrote:

Hi,

I’m new to SDL and I am not shure this is the wright list - but I didn’t
find any other.

My Problem:
SDL_CDNumDrives reports the wrong number of drives: just 1 instead of 2
SDL_CDStatus reports: CD_STOPPED, while the CD is playing.
I am shure, that it is the wright drive (the one with the CD in) because
when I take off the CD, CD_TRAYEMPTY is reported.

Any hints?
Gerd


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Could the KDE artsd daemon be the problem?

Unlikely. The CD audio stuff hasn’t been touched in a long time. It’s
more likely that the Linux device interface changed.

We try a handful of reasonable devices, /dev/cdrom, /dev/hdX, /dev/sdX,
etc…we decide if they are CD-ROM drives with a Linux-specific ioctl()
call that may not return the information we expect anymore on modern
kernels.

(Or maybe works through /dev/cdrom but not /dev/hda, even if /dev/hda IS
a cd-rom).

It’s possible you only have access to the second drive as root, too,
though. Double-check permissions.

As for why it reports STOPPED when playing: same reason. ioctl() change?

–ryan.