bool CDROM_Interface_SDL::GetAudioTrackInfo (int track, TMSF& start, unsigned char& attr) { if (CD_INDRIVE(SDL_CDStatus(cd))) { FRAMES_TO_MSF(cd->track[track-1].offset+150,&start.min,&start.sec,&start.fr); attr = cd->track[track-1].type; } return CD_INDRIVE(SDL_CDStatus(cd)); };
bool CDROM_Interface_SDL::GetAudioTracks(int& stTrack, int& end, TMSF& leadOut) { if (CD_INDRIVE(SDL_CDStatus(cd))) { stTrack = 1; end = cd->numtracks; FRAMES_TO_MSF(cd->track[cd->numtracks].offset,&leadOut.min,&leadOut.sec,&leadOut.fr); } return CD_INDRIVE(SDL_CDStatus(cd)); }
/* Start play */ static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) { /* Play MSF * */ struct cd_play_audio_msf msf; int end; bzero(&msf, sizeof(msf)); end = start +length; FRAMES_TO_MSF(start, &msf.msf_starting_M_unit, &msf.msf_starting_S_unit, &msf.msf_starting_F_unit); FRAMES_TO_MSF(end, &msf.msf_ending_M_unit, &msf.msf_ending_S_unit, &msf.msf_ending_F_unit); return(ioctl(cdrom->id, CDROM_PLAY_AUDIO_MSF, &msf)); }
/* Start play - Ready for MCI */ static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) { MCI_GENERIC_PARMS mgp; MCI_STATUS_PARMS msp; MCI_PLAY_PARMS mpp; ULONG min,sec,frm; /* Start MSF */ FRAMES_TO_MSF(start, &min, &sec, &frm); MSF_MINUTE(mpp.ulFrom) = min; MSF_SECOND(mpp.ulFrom) = sec; MSF_FRAME(mpp.ulFrom) = frm; /* End MSF */ FRAMES_TO_MSF(start+length, &min, &sec, &frm); MSF_MINUTE(mpp.ulTo) = min; MSF_SECOND(mpp.ulTo) = sec; MSF_FRAME(mpp.ulTo) = frm; #ifdef DEBUG_CDROM fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0, playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1); #endif /* Verifies if it is paused first... and if it is, unpause before stopping it. */ msp.hwndCallback = (HWND)NULL; /* None */ msp.ulReturn = (ULONG)NULL; /* We want this information */ msp.ulItem = MCI_STATUS_MODE; msp.ulValue = (ULONG)NULL; /* No additional information */ if (LOUSHORT(mciSendCommand(cdrom->id,MCI_STATUS,MCI_WAIT | MCI_STATUS_ITEM,&msp, 0)) == MCIERR_SUCCESS) { if (msp.ulReturn == MCI_MODE_PAUSE) { mgp.hwndCallback = (HWND)NULL; // None mciSendCommand(cdrom->id,MCI_RESUME,0,&mgp, 0); } } /* Now play it. */ mpp.hwndCallback = (HWND)NULL; // We do not want the info. temp if (LOUSHORT(mciSendCommand(cdrom->id,MCI_PLAY,MCI_FROM | MCI_TO,&mpp, 0)) == MCIERR_SUCCESS) return 0; return (CD_ERROR); }
/* Start play */ static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) { struct cd_audio_cmd cmd; /* * My CD Rom is muted by default. I think I read that this is new with * AIX 4.3. SDL does not change the volume, so I need a kludge. Maybe * its better to do this elsewhere? */ cmd.audio_cmds = CD_PLAY_AUDIO | CD_SET_VOLUME; cmd.msf_flag = TRUE; FRAMES_TO_MSF(start, &cmd.indexing.msf.first_mins, &cmd.indexing.msf.first_secs, &cmd.indexing.msf.first_frames); FRAMES_TO_MSF(start+length, &cmd.indexing.msf.last_mins, &cmd.indexing.msf.last_secs, &cmd.indexing.msf.last_frames); cmd.volume_type = CD_VOLUME_ALL; cmd.all_channel_vol = 255; /* This is a uchar. What is a good value? No docu! */ cmd.out_port_0_sel = CD_AUDIO_CHNL_0; cmd.out_port_1_sel = CD_AUDIO_CHNL_1; cmd.out_port_2_sel = CD_AUDIO_CHNL_2; cmd.out_port_3_sel = CD_AUDIO_CHNL_3; #ifdef DEBUG_CDROM fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n", cmd.indexing.msf.first_mins, cmd.indexing.msf.first_secs, cmd.indexing.msf.first_frames, cmd.indexing.msf.last_mins, cmd.indexing.msf.last_secs, cmd.indexing.msf.last_frames); #endif return(SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &cmd)); }
void CDAudio_Play(byte track, qboolean looping) { int len_m, len_s, len_f; if (!cd_handle || !enabled) return; if (!cdValid) { CDAudio_GetAudioDiskInfo(); if (!cdValid) return; } track = remap[track]; if (track < 1 || track > cd_handle->numtracks) { Con_Printf ("%s: Bad track number %d.\n", __thisfunc__, track); return; } if (cd_handle->track[track-1].type == SDL_DATA_TRACK) { Con_Printf ("%s: track %d is not audio\n", __thisfunc__, track); return; } if (playing) { if (playTrack == track) return; CDAudio_Stop (); } if (SDL_CDPlay(cd_handle, cd_handle->track[track-1].offset, cd_handle->track[track-1].length) < 0) { // ok, check for status now int cd_status = SDL_CDStatus(cd_handle); if (cd_status > 0) Con_Printf ("%s: Unable to play %d: %s\n", __thisfunc__, track, SDL_GetError ()); return; } playLooping = looping; playTrack = track; playing = true; FRAMES_TO_MSF(cd_handle->track[track-1].length, &len_m, &len_s, &len_f); endOfTrack = realtime + ((double)len_m * 60.0) + (double)len_s + (double)len_f / (double)CD_FPS; /* * Add the pregap for the next track. This means that disc-at-once CDs * won't loop smoothly, but they wouldn't anyway so it doesn't really * matter. SDL doesn't give us pregap information anyway, so you'll * just have to live with it. */ endOfTrack += 2.0; pausetime = -1.0; if (!hw_vol_works && bgmvolume.value == 0.0) CDAudio_Pause (); }
static void CD_f (void) { const char *command; int ret, n; if (Cmd_Argc() < 2) { Con_Printf("commands:"); Con_Printf("on, off, reset, remap, \n"); Con_Printf("play, stop, loop, pause, resume\n"); Con_Printf("eject, info\n"); return; } command = Cmd_Argv (1); if (q_strcasecmp(command, "on") == 0) { enabled = true; return; } if (q_strcasecmp(command, "off") == 0) { if (playing) CDAudio_Stop(); enabled = false; return; } if (q_strcasecmp(command, "reset") == 0) { enabled = true; if (playing) CDAudio_Stop(); for (n = 0; n < 100; n++) remap[n] = n; CDAudio_GetAudioDiskInfo(); return; } if (q_strcasecmp(command, "remap") == 0) { ret = Cmd_Argc () - 2; if (ret <= 0) { for (n = 1; n < 100; n++) if (remap[n] != n) Con_Printf (" %u -> %u\n", n, remap[n]); return; } for (n = 1; n <= ret; n++) remap[n] = atoi(Cmd_Argv (n + 1)); return; } if (!cdValid) { CDAudio_GetAudioDiskInfo (); if (!cdValid) { Con_Printf("No CD in player.\n"); return; } } if (q_strcasecmp(command, "play") == 0) { CDAudio_Play((byte)atoi(Cmd_Argv (2)), false); return; } if (q_strcasecmp(command, "loop") == 0) { CDAudio_Play((byte)atoi(Cmd_Argv (2)), true); return; } if (q_strcasecmp(command, "stop") == 0) { CDAudio_Stop(); return; } if (q_strcasecmp(command, "pause") == 0) { CDAudio_Pause(); return; } if (q_strcasecmp(command, "resume") == 0) { CDAudio_Resume(); return; } if (q_strcasecmp(command, "eject") == 0) { if (playing) CDAudio_Stop(); CDAudio_Eject(); cdValid = false; return; } if (q_strcasecmp(command, "info") == 0) { int current_min, current_sec, current_frame; int length_min, length_sec, length_frame; Con_Printf ("%u tracks\n", cd_handle->numtracks); if (playing) Con_Printf ("Currently %s track %u\n", playLooping ? "looping" : "playing", playTrack); else if (wasPlaying) Con_Printf ("Paused %s track %u\n", playLooping ? "looping" : "playing", playTrack); if (playing || wasPlaying) { SDL_CDStatus(cd_handle); FRAMES_TO_MSF(cd_handle->cur_frame, ¤t_min, ¤t_sec, ¤t_frame); FRAMES_TO_MSF(cd_handle->track[playTrack-1].length, &length_min, &length_sec, &length_frame); Con_Printf ("Current position: %d:%02d.%02d (of %d:%02d.%02d)\n", current_min, current_sec, current_frame * 60 / CD_FPS, length_min, length_sec, length_frame * 60 / CD_FPS); } Con_Printf ("Volume is %f\n", bgmvolume.value); return; } }
/* Start play */ static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) { CDCntrlParam cdpb; /* Pause the current audio playback to avoid audible artifacts */ if ( SDL_SYS_CDPause(cdrom) < 0 ) { return(-1); } /* Specify the AudioCD playback mode */ SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kSetPlayMode; cdpb.csParam.bytes[0] = false; /* Repeat? */ cdpb.csParam.bytes[1] = kPlayModeSequential; /* Play mode */ /* еее╩Treat as soft error, NEC Drive doesnt support this call еее */ PBControlSync((ParmBlkPtr) &cdpb); #if 1 /* Specify the end of audio playback */ SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioStop; cdpb.csParam.words[0] = kBlockPosition; /* Position Mode */ *(long *) (cdpb.csParam.words + 1) = start+length-1; /* Search Address */ if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) { SDL_SetError("PBControlSync() failed"); return(-1); } /* Specify the start of audio playback, and start it */ SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioPlay; cdpb.csParam.words[0] = kBlockPosition; /* Position Mode */ *(long *) (cdpb.csParam.words + 1) = start+1; /* Search Address */ cdpb.csParam.words[3] = false; /* Stop address? */ cdpb.csParam.words[4] = kStereoPlayMode; /* Audio Play Mode */ if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) { SDL_SetError("PBControlSync() failed"); return(-1); } #else /* Specify the end of audio playback */ FRAMES_TO_MSF(start+length, &m, &s, &f); SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioStop; cdpb.csParam.words[0] = kTrackPosition; /* Position Mode */ cdpb.csParam.words[1] = 0; /* Search Address (hiword)*/ cdpb.csParam.words[2] = /* Search Address (loword)*/ SDL_SYS_ShortToBCD(cdrom->numtracks); if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) { SDL_SetError("PBControlSync() failed"); return(-1); } /* Specify the start of audio playback, and start it */ FRAMES_TO_MSF(start, &m, &s, &f); SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioPlay; cdpb.csParam.words[0] = kTrackPosition; /* Position Mode */ cdpb.csParam.words[1] = 0; /* Search Address (hiword)*/ cdpb.csParam.words[2] = SDL_SYS_ShortToBCD(1); /* Search Address (loword)*/ cdpb.csParam.words[3] = false; /* Stop address? */ cdpb.csParam.words[4] = kStereoPlayMode; /* Audio Play Mode */ if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) { SDL_SetError("PBControlSync() failed"); return(-1); } #endif return(0); }
static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) { CDCntrlParam cdpb; if ( SDL_SYS_CDPause(cdrom) < 0 ) { return(-1); } SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kSetPlayMode; cdpb.csParam.bytes[0] = false; cdpb.csParam.bytes[1] = kPlayModeSequential; PBControlSync((ParmBlkPtr) &cdpb); #if 1 SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioStop; cdpb.csParam.words[0] = kBlockPosition; *(long *) (cdpb.csParam.words + 1) = start+length-1; if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) { SDL_SetError("PBControlSync() failed"); return(-1); } SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioPlay; cdpb.csParam.words[0] = kBlockPosition; *(long *) (cdpb.csParam.words + 1) = start+1; cdpb.csParam.words[3] = false; cdpb.csParam.words[4] = kStereoPlayMode; if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) { SDL_SetError("PBControlSync() failed"); return(-1); } #else FRAMES_TO_MSF(start+length, &m, &s, &f); SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioStop; cdpb.csParam.words[0] = kTrackPosition; cdpb.csParam.words[1] = 0; cdpb.csParam.words[2] = SDL_SYS_ShortToBCD(cdrom->numtracks); if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) { SDL_SetError("PBControlSync() failed"); return(-1); } FRAMES_TO_MSF(start, &m, &s, &f); SDL_memset(&cdpb, 0, sizeof(cdpb)); cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum; cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum; cdpb.csCode = kAudioPlay; cdpb.csParam.words[0] = kTrackPosition; cdpb.csParam.words[1] = 0; cdpb.csParam.words[2] = SDL_SYS_ShortToBCD(1); cdpb.csParam.words[3] = false; cdpb.csParam.words[4] = kStereoPlayMode; if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) { SDL_SetError("PBControlSync() failed"); return(-1); } #endif return(0); }