示例#1
0
文件: cd_revol.c 项目: Izhido/qrevpak
void CDAudio_Update(void)
{
	if (!enabled)
		return;

	if (bgmvolume.value != cdvolume)
	{
		cdvolume = bgmvolume.value;
		CDAudio_SetVolume (cdvolume);
		if (cdvolume)
		{
			if(!playing)
				CDAudio_Resume ();
		}
		else
		{
			if(playing)
				CDAudio_Pause ();
		}
	};

	if(StatusOgg() == OGG_STATUS_EOF)
	{
		if(playing)
		{
			playing = false;
		};
	};
}
示例#2
0
void CDAudio_Update(void)
{
	if (!enabled)
		return;

	if (old_cdvolume != bgmvolume.value)
		CDAudio_SetVolume (&bgmvolume);
}
示例#3
0
void CDAudio_Update(void)
{
    struct ioc_read_subchannel subchnl;
    struct cd_sub_channel_info data;
    static time_t lastchk;

    if (cdfile == -1 || !enabled)
        return;

    if (old_cdvolume != bgmvolume.value)
        CDAudio_SetVolume (&bgmvolume);

    if (playing && lastchk < time(NULL))
    {
        lastchk = time(NULL) + 2; //two seconds between chks

        memset (&subchnl, 0, sizeof(subchnl));
        subchnl.data = &data;
        subchnl.data_len = sizeof(data);
        subchnl.address_format = CD_MSF_FORMAT;
        subchnl.data_format = CD_CURRENT_POSITION;
        subchnl.track = playTrack;
        if (ioctl(cdfile, CDIOCREADSUBCHANNEL, &subchnl) == -1 )
        {
            IOCTL_FAILURE(CDIOCREADSUBCHANNEL);
            playing = false;
            return;
        }
        if (data.header.audio_status != CD_AS_PLAY_IN_PROGRESS &&
                data.header.audio_status != CD_AS_PLAY_PAUSED)
        {
            playing = false;
            if (playLooping)
                CDAudio_Play(playTrack, true);
        }
        else
        {
            playTrack = data.what.position.track_number;
        }
    }
}
示例#4
0
int CDAudio_Init(void)
{
    int i;

    if (safemode || COM_CheckParm("-nocdaudio"))
        return -1;

    if ((i = COM_CheckParm("-cddev")) != 0 && i < com_argc - 1)
        cd_dev = com_argv[i + 1];

    if ((cdfile = open(cd_dev, O_RDONLY | O_NONBLOCK)) == -1)
    {
        Con_Printf("%s: open of \"%s\" failed (%i)\n", __thisfunc__, cd_dev, errno);
        cdfile = -1;
        return -1;
    }

    for (i = 0; i < 100; i++)
        remap[i] = i;
    initialized = true;
    enabled = true;
    old_cdvolume = bgmvolume.value;

    Con_Printf("CDAudio initialized (using BSD ioctls)\n");

    if (CDAudio_GetAudioDiskInfo())
    {
        Con_Printf("%s: No CD in drive\n", __thisfunc__);
        cdValid = false;
    }

    Cmd_AddCommand ("cd", CD_f);

    hw_vol_works = CD_GetVolume (&orig_vol);
    if (hw_vol_works)
        hw_vol_works = CDAudio_SetVolume (&bgmvolume);

    return 0;
}
示例#5
0
void CDAudio_Update(void)
{
	CDstatus	curstat;

	if (!cd_handle || !enabled)
		return;

	if (old_cdvolume != bgmvolume.value)
		CDAudio_SetVolume (&bgmvolume);

	if (playing && realtime > endOfTrack)
	{
	//	curstat = cd_handle->status;
		curstat = SDL_CDStatus(cd_handle);
		if (curstat != CD_PLAYING && curstat != CD_PAUSED)
		{
			playing = false;
			endOfTrack = -1.0;
			if (playLooping)
				CDAudio_Play(playTrack, true);
		}
	}
}
示例#6
0
void CDAudio_Update (void)
{
	static int lastplaylist = -1;
	if (!enabled)
		return;

	CDAudio_SetVolume (bgmvolume.value);
	if (music_playlist_playing > 0 && CDAudio_GetPosition() < 0)
	{
		// this track ended, start a new track from the beginning
		CDAudio_StartPlaylist(false);
		lastplaylist = music_playlist_index.integer;
	}
	else if (lastplaylist != music_playlist_index.integer
	|| (bgmvolume.value > 0 && !music_playlist_playing && music_playlist_index.integer >= 0))
	{
		// active playlist changed, save position and switch track
		CDAudio_StartPlaylist(true);
		lastplaylist = music_playlist_index.integer;
	}

	if (faketrack == -1 && cdaudio.integer != 0 && bgmvolume.value != 0)
		CDAudio_SysUpdate();
}
示例#7
0
int CDAudio_Init(void)
{
	int	i, x, sdl_num_drives;

	if (safemode || COM_CheckParm("-nocdaudio"))
		return -1;

	if (SDL_InitSubSystem(SDL_INIT_CDROM) < 0)
	{
		Con_Printf("Couldn't init SDL cdrom: %s\n", SDL_GetError());
		return -1;
	}

	sdl_num_drives = SDL_CDNumDrives ();
	Con_Printf ("SDL detected %d CD-ROM drive%c\n", sdl_num_drives,
					sdl_num_drives == 1 ? ' ' : 's');

	if (sdl_num_drives < 1)
		return -1;

	if ((i = COM_CheckParm("-cddev")) != 0 && i < com_argc - 1)
	{
		for (x = 0; x < sdl_num_drives; x++)
		{
			if (!q_strcasecmp(SDL_CDName(x), com_argv[i+1]))
			{
				cd_dev = x;
				break;
			}
		}
		if (cd_dev == -1)
		{
			Con_Printf("SDL couldn't find cdrom device %s\n", com_argv[i+1]);
			return -1;
		}
	}

	if (cd_dev == -1)
		cd_dev = 0;	// default drive

	cd_handle = SDL_CDOpen(cd_dev);
	if (!cd_handle)
	{
		Con_Printf ("%s: Unable to open CD-ROM drive %s (%s)\n",
				__thisfunc__, SDL_CDName(cd_dev), SDL_GetError());
		return -1;
	}

	for (i = 0; i < 100; i++)
		remap[i] = i;
	enabled = true;
	old_cdvolume = bgmvolume.value;

	Con_Printf("CDAudio initialized (SDL, using %s)\n", SDL_CDName(cd_dev));

	if (CDAudio_GetAudioDiskInfo())
	{
		Con_Printf("%s: No CD in drive\n", __thisfunc__);
		cdValid = false;
	}

	Cmd_AddCommand ("cd", CD_f);

// cd hardware volume: no SDL support at present.
	hw_vol_works = CD_GetVolume (NULL);
	if (hw_vol_works)
		hw_vol_works = CDAudio_SetVolume (&bgmvolume);

	return 0;
}