Ejemplo n.º 1
0
/* Stop playback */
static int SDL_SYS_CDStop(SDL_CD *cdrom)
{
    if (fakeCD) {
        SDL_SetError (kErrorFakeDevice);
        return -1;
    }
    
    Lock ();
    
    if (PauseFile () < 0) {
        Unlock ();
        return -2;
    }
        
    if (ReleaseFile () < 0) {
        Unlock ();
        return -3;
    }
        
    status = CD_STOPPED;
    
    Unlock ();
    
    return 0;
}
Ejemplo n.º 2
0
/* Setup another file for playback, or stop playback (called from another thread) */
static void
CompletionProc(SDL_CD * cdrom)
{

    Lock();

    if (nextTrackFrame > 0 && nextTrackFramesRemaining > 0) {

        /* Load the next file to play */
        int startFrame, stopFrame;
        FSRef *file;

        PauseFile();
        ReleaseFile();

        file = GetFileForOffset(cdrom, nextTrackFrame,
                                nextTrackFramesRemaining, &startFrame,
                                &stopFrame);

        if (file == NULL) {
            status = CD_STOPPED;
            Unlock();
            return;
        }

        LoadFile(file, startFrame, stopFrame);

        SetCompletionProc(CompletionProc, cdrom);

        PlayFile();
    } else {

        /* Release the current file */
        PauseFile();
        ReleaseFile();
        status = CD_STOPPED;
    }

    Unlock();
}
Ejemplo n.º 3
0
/* Eject the CD-ROM (Unmount the volume) */
static int SDL_SYS_CDEject(SDL_CD *cdrom)
{
    OSStatus err;
	HParamBlockRec  pb;
    
    if (fakeCD) {
        SDL_SetError (kErrorFakeDevice);
        return -1;
    }
    
    Lock ();
    
    if (PauseFile () < 0) {
        Unlock ();
        return -2;
    }
        
    if (ReleaseFile () < 0) {
        Unlock ();
        return -3;
    }
    
    status = CD_STOPPED;
    
	// Eject the volume
	pb.ioParam.ioNamePtr = NULL;
	pb.ioParam.ioVRefNum = volumes[cdrom->id];
	err = PBUnmountVol((ParamBlockRec *) &pb);

	if (err != noErr) {
        Unlock ();
		SDL_SetError ("PBUnmountVol returned %d", err);
		return -4;
	}
    
    status = CD_TRAYEMPTY;

    /* Invalidate volume and track info */
    volumes[cdrom->id] = 0;
    free (tracks[cdrom->id]);
    tracks[cdrom->id] = NULL;
    
    Unlock ();
    
    return 0;
}
Ejemplo n.º 4
0
/* Eject the CD-ROM (Unmount the volume) */
static int
SDL_SYS_CDEject(SDL_CD * cdrom)
{
    OSStatus err;
    pid_t dissenter;

    if (fakeCD) {
        SDL_SetError(kErrorFakeDevice);
        return -1;
    }

    Lock();

    if (PauseFile() < 0) {
        Unlock();
        return -2;
    }

    if (ReleaseFile() < 0) {
        Unlock();
        return -3;
    }

    status = CD_STOPPED;

    /* Eject the volume */
    err = FSEjectVolumeSync(volumes[cdrom->id], kNilOptions, &dissenter);

    if (err != noErr) {
        Unlock();
        SDL_SetError("PBUnmountVol returned %d", err);
        return -4;
    }

    status = CD_TRAYEMPTY;

    /* Invalidate volume and track info */
    volumes[cdrom->id] = 0;
    free(tracks[cdrom->id]);
    tracks[cdrom->id] = NULL;

    Unlock();

    return 0;
}
Ejemplo n.º 5
0
/* Start playback */
static int
SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length)
{
    int startFrame, stopFrame;
    FSRef *ref;

    if (fakeCD) {
        SDL_SetError(kErrorFakeDevice);
        return -1;
    }

    Lock();

    if (LoadTracks(cdrom) < 0)
        return -2;

    if (PauseFile() < 0)
        return -3;

    if (ReleaseFile() < 0)
        return -4;

    ref = GetFileForOffset(cdrom, start, length, &startFrame, &stopFrame);
    if (ref == NULL) {
        SDL_SetError("SDL_SYS_CDPlay: No file for start=%d, length=%d",
                     start, length);
        return -5;
    }

    if (LoadFile(ref, startFrame, stopFrame) < 0)
        return -6;

    SetCompletionProc(CompletionProc, cdrom);

    if (PlayFile() < 0)
        return -7;

    status = CD_PLAYING;

    Unlock();

    return 0;
}
Ejemplo n.º 6
0
/* Pause playback */
static int SDL_SYS_CDPause(SDL_CD *cdrom)
{
    if (fakeCD) {
        SDL_SetError (kErrorFakeDevice);
        return -1;
    }
    
    Lock ();
    
    if (PauseFile () < 0) {
        Unlock ();
        return -2;
    }
    
    status = CD_PAUSED;
    
    Unlock ();
    
    return 0;
}