Example #1
0
void OSystem_SDL::updateCD() {
	if (!_cdrom)
		return;

	if (_cdStopTime != 0 && SDL_GetTicks() >= _cdStopTime) {
		SDL_CDStop(_cdrom);
		_cdNumLoops = 0;
		_cdStopTime = 0;
		return;
	}

	if (_cdNumLoops == 0 || SDL_GetTicks() < _cdEndTime)
		return;

	if (_cdNumLoops != 1 && SDL_CDStatus(_cdrom) != CD_STOPPED) {
		// Wait another second for it to be done
		_cdEndTime += 1000;
		return;
	}

	if (_cdNumLoops > 0)
		_cdNumLoops--;

	if (_cdNumLoops != 0) {
		if (_cdStartFrame == 0 && _cdDuration == 0)
			SDL_CDPlayTracks(_cdrom, _cdTrack, 0, 1, 0);
		else
			SDL_CDPlayTracks(_cdrom, _cdTrack, _cdStartFrame, 0, _cdDuration);
		_cdEndTime = SDL_GetTicks() + _cdrom->track[_cdTrack].length * 1000 / CD_FPS;
	}
}
Example #2
0
bool CDROM_Interface_SDL::StopAudio(void) {
    // Has to be there, otherwise wrong cd status report (dunno why, sdl bug ?)
    SDL_CDClose(cd);
    cd = SDL_CDOpen(driveID);
    bool success = (SDL_CDStop(cd)==0);
    return success;
}
Example #3
0
void SoundManager::TerminateMusic(void)
{
	if (!g_theProfileDB->IsUseRedbookAudio() || !c3files_HasCD()) return;

	if (m_noSound) return;

	if (m_usePlaySound) return;

#if !defined(USE_SDL)
	if (!m_redbook) return;
#else
    if (!m_cdrom) return;
#endif

	
	m_stopRedbookTemporarily = TRUE;

#if !defined(USE_SDL)
	if (AIL_redbook_track(m_redbook)) {		
		AIL_redbook_stop(m_redbook);
	}
#else
    CDstatus status = SDL_CDStatus(m_cdrom);

    if (CD_PLAYING == status) {
        SDL_CDStop(m_cdrom);
    }
#endif
}
Example #4
0
void RBAExit()
{
	if (s_cd)
	{
		SDL_CDStop(s_cd);
		SDL_CDClose(s_cd);
	}
}
Example #5
0
void _CDECL_ RBAExit(void)
{
LogErr ("shutting down SDL CD service\n");
if (initialised) {
	SDL_CDStop(s_cd);
	SDL_CDClose(s_cd);
	}
}
Example #6
0
File: rbaudio.c Project: btb/d2x
void RBAExit()
{
	if (initialised)
	{
		SDL_CDStop(s_cd);
		SDL_CDClose(s_cd);
	}
}
Example #7
0
void SdlAudioCDManager::close() {
	DefaultAudioCDManager::close();

	if (_cdrom) {
                SDL_CDStop(_cdrom);
                SDL_CDClose(_cdrom);
		_cdrom = 0;
        }
}
Example #8
0
void cd_stop()
{
#ifdef __DJGPP__
  bcd_stop();
#elif defined __SDL__
  SDL_CDStop(cdrom);
#endif
  cd_playing = 0;
}
Example #9
0
int I_CDMusStop(void)
{
    int result;

    result = SDL_CDStop(cd_handle);

    cd_Error = 0;

    return result;
}
Example #10
0
void CDAudio_Stop()
{
	int cdstate;
	if(!cd_id || !enabled) return;
	cdstate = SDL_CDStatus(cd_id);
	if((cdstate != CD_PLAYING) && (cdstate != CD_PAUSED)) return;

	if(SDL_CDStop(cd_id))
		Con_DPrintf("CDAudio_Stop: Failed to stop track.\n");
}
void ONScripter::stopBGM( bool continue_flag )
{
    removeBGMFadeEvent();
    if (timer_bgmfade_id) SDL_RemoveTimer( timer_bgmfade_id );
    timer_bgmfade_id = NULL;
    mp3fadeout_duration_internal = 0;

#ifdef USE_CDROM
    if ( cdaudio_flag && cdrom_info ){
        extern SDL_TimerID timer_cdaudio_id;

        if ( timer_cdaudio_id ){
            SDL_RemoveTimer( timer_cdaudio_id );
            timer_cdaudio_id = NULL;
        }
        if (SDL_CDStatus( cdrom_info ) >= CD_PLAYING )
            SDL_CDStop( cdrom_info );
    }
#endif

    if ( wave_sample[MIX_BGM_CHANNEL] ){
        Mix_Pause( MIX_BGM_CHANNEL );
        Mix_FreeChunk( wave_sample[MIX_BGM_CHANNEL] );
        wave_sample[MIX_BGM_CHANNEL] = NULL;
    }

    if ( music_info ){
        ext_music_play_once_flag = true;
        Mix_HaltMusic();
        Mix_FreeMusic( music_info );
        music_info = NULL;
    }

    if ( midi_info ){
        ext_music_play_once_flag = true;
        Mix_HaltMusic();
        Mix_FreeMusic( midi_info );
        midi_info = NULL;
    }

    if ( !continue_flag ){
        setStr( &music_file_name, NULL );
        music_play_loop_flag = false;
        if (music_buffer){
            delete[] music_buffer;
            music_buffer = NULL;
        }

        setStr( &midi_file_name, NULL );
        midi_play_loop_flag = false;

        current_cd_track = -1;
    }
}
Example #12
0
bool CDROM_Interface_SDL::StopAudio(void) {
	// Has to be there, otherwise wrong cd status report (dunno why, sdl bug ?)
	//--Disabled 2009-12-30 by Alun Bestor: no it doesn't, in fact disabling and reenabling the CD like this
	//kills the track listing in OS X owing to another SDL bug.
	/*
	SDL_CDClose(cd);
	cd = SDL_CDOpen(driveID);
	*/
	//--End of modifications
	bool success = (SDL_CDStop(cd)==0);
	return success;
}
Example #13
0
static PyObject*
_cd_stop (PyObject *self)
{
    SDL_CD *cd = ((PyCD*)self)->cd;
    ASSERT_CDROM_OPEN(self, NULL);

    if (SDL_CDStop (cd) == -1)
    {
        PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
        return NULL;
    }
    Py_RETURN_NONE;
}
Example #14
0
static int modcd_stop( INSTANCE * my, int * params )
{
    if ( params[0] < 0 || params[0] >= SDL_CDNumDrives() ) return 0;

    if ( sdl_cd == NULL || sdl_cdnum != params[0] )
    {
        if ( sdl_cd ) SDL_CDClose( sdl_cd );
        sdl_cd = SDL_CDOpen( params[0] );
        if ( sdl_cd == NULL ) return 0;
        sdl_cdnum = params[0];
    }

    return !SDL_CDStop( sdl_cd );
}
Example #15
0
void I_StopCD()
{
  if (cdrom == NULL || !enabled)
    return;
    
  if (!(playing || wasPlaying))
    return;
    
  if (SDL_CDStop(cdrom))
    {
      CONS_Printf("cdromstop failed\n");
    }
    
  wasPlaying = false;
  playing = false;
}
Example #16
0
/**************************************************************************
 *
 * function: StopCD
 *
 * description:
 *
 *
 **************************************************************************/
void I_StopCD(void)
{
#ifndef NOSDLCD
	if (!cdrom || !cdEnabled)
		return;

	if (!(cdPlaying || wasPlaying))
		return;

	if (SDL_CDStop(cdrom))
		I_OutputMsg("cdromstop failed\n");

	wasPlaying = SDL_FALSE;
	cdPlaying = SDL_FALSE;
#endif
}
Example #17
0
void CDAudio_Stop(void)
{
	if (!cd_handle || !enabled)
		return;

	if (!playing)
		return;

	if (SDL_CDStop(cd_handle) < 0)
		Con_Printf ("%s: Unable to stop CD-ROM (%s)\n", __thisfunc__, SDL_GetError());

	wasPlaying = false;
	playing = false;
	pausetime = -1.0;
	endOfTrack = -1.0;
}
Example #18
0
static PyObject*
cd_stop (PyObject* self)
{
    int cd_id = PyCD_AsID (self);
    SDL_CD* cdrom = cdrom_drivedata[cd_id];
    int result;

    CDROM_INIT_CHECK ();
    if (!cdrom) {
        return RAISE (PyExc_SDLError, "CD drive not initialized");
    }

    result = SDL_CDStop (cdrom);
    if (result == -1) {
        return RAISE (PyExc_SDLError, SDL_GetError ());
    }
    Py_RETURN_NONE;
}
Example #19
0
//------------------------------------------------------------------------------
bool UnixRedBookDevice::stop()
{
#if !defined(__FreeBSD__)
   if(!mAcquired)
   {
      setLastError("Device has not been acquired");
      return(false);
   }

   AssertFatal(mCD, "mCD is NULL");

   if (SDL_CDStop(mCD) == -1)
   {
      setLastError(SDL_GetError());
      return(false);
   }

   mPlaying = false;

   setLastError("");
   return(true);
#endif	// !defined(__FreeBSD__)
}
Example #20
0
void
CDAudio_Stop ()
{
	int cdstate;

	if ( !cd_id || !enabled )
	{
		return;
	}

	cdstate = SDL_CDStatus( cd_id );

	if ( ( cdstate != CD_PLAYING ) && ( cdstate != CD_PAUSED ) )
	{
		return;
	}

	if ( SDL_CDStop( cd_id ) )
	{
		Com_DPrintf( "CDAudio_Stop: Failed to stop track.\n" );
	}

	playLooping = 0;
}
Example #21
0
File: rbaudio.c Project: btb/d2x
void RBAStop()
{
	if (!initialised) return;
	SDL_CDStop(s_cd);
}
Example #22
0
void RBAStop()
{
	if (!s_cd) return;
	SDL_CDStop(s_cd);
	redbook_finished_hook = NULL;	// no calling the finished hook - stopped means stopped here
}
Example #23
0
int main(int argc, char *argv[])
{
	int drive;
	int i;
	SDL_CD *cdrom;

	/* Initialize SDL first */
	if ( SDL_Init(SDL_INIT_CDROM) < 0 ) {
		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
		return(1);
	}

	/* Find out how many CD-ROM drives are connected to the system */
	if ( SDL_CDNumDrives() == 0 ) {
		printf("No CD-ROM devices detected\n");
		quit(0);
	}
	printf("Drives available: %d\n", SDL_CDNumDrives());
	for ( i=0; i<SDL_CDNumDrives(); ++i ) {
		printf("Drive %d:  \"%s\"\n", i, SDL_CDName(i));
	}

	/* Open the CD-ROM */
	drive = 0;
	i=1;
	if ( argv[i] && isdigit(argv[i][0]) ) {
		drive = atoi(argv[i++]);
	}
	cdrom = SDL_CDOpen(drive);
	if ( cdrom == NULL ) {
		fprintf(stderr, "Couldn't open drive %d: %s\n", drive,
							SDL_GetError());
		quit(2);
	}
#ifdef TEST_NULLCD
	cdrom = NULL;
#endif
	
	/* Find out which function to perform */
	for ( ; argv[i]; ++i ) {
		if ( strcmp(argv[i], "-status") == 0 ) {
			/* PrintStatus(drive, cdrom); */
		} else
		if ( strcmp(argv[i], "-list") == 0 ) {
			ListTracks(cdrom);
		} else
		if ( strcmp(argv[i], "-play") == 0 ) {
			int strack, sframe;
			int ntrack, nframe;

			strack = 0;
			if ( argv[i+1] && isdigit(argv[i+1][0]) ) {
				strack = atoi(argv[++i]);
			}
			sframe = 0;
			if ( argv[i+1] && isdigit(argv[i+1][0]) ) {
				sframe = atoi(argv[++i]);
			}
			ntrack = 0;
			if ( argv[i+1] && isdigit(argv[i+1][0]) ) {
				ntrack = atoi(argv[++i]);
			}
			nframe = 0;
			if ( argv[i+1] && isdigit(argv[i+1][0]) ) {
				nframe = atoi(argv[++i]);
			}
			if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
				if ( SDL_CDPlayTracks(cdrom, strack, sframe,
							ntrack, nframe) < 0 ) {
					fprintf(stderr,
			"Couldn't play tracks %d/%d for %d/%d: %s\n",
				strack, sframe, ntrack, nframe, SDL_GetError());
				}
			} else {
				fprintf(stderr, "No CD in drive!\n");
			}
		} else
		if ( strcmp(argv[i], "-pause") == 0 ) {
			if ( SDL_CDPause(cdrom) < 0 ) {
				fprintf(stderr, "Couldn't pause CD: %s\n",
								SDL_GetError());
			}
		} else
		if ( strcmp(argv[i], "-resume") == 0 ) {
			if ( SDL_CDResume(cdrom) < 0 ) {
				fprintf(stderr, "Couldn't resume CD: %s\n",
								SDL_GetError());
			}
		} else
		if ( strcmp(argv[i], "-stop") == 0 ) {
			if ( SDL_CDStop(cdrom) < 0 ) {
				fprintf(stderr, "Couldn't eject CD: %s\n",
								SDL_GetError());
			}
		} else
		if ( strcmp(argv[i], "-eject") == 0 ) {
			if ( SDL_CDEject(cdrom) < 0 ) {
				fprintf(stderr, "Couldn't eject CD: %s\n",
								SDL_GetError());
			}
		} else
		if ( (strcmp(argv[i], "-sleep") == 0) &&
				(argv[i+1] && isdigit(argv[i+1][0])) ) {
			SDL_Delay(atoi(argv[++i]));
			printf("Delayed %d milliseconds\n", atoi(argv[i]));
		} else {
			PrintUsage(argv[0]);
			SDL_CDClose(cdrom);
			quit(1);
		}
	}
	PrintStatus(drive, cdrom);
	SDL_CDClose(cdrom);
	SDL_Quit();

	return(0);
}
Example #24
0
int CDAudio_SysStop (void)
{
	return SDL_CDStop( cd );
}
Example #25
0
SdlAudioCDManager::~SdlAudioCDManager() {
	if (_cdrom) {
		SDL_CDStop(_cdrom);
		SDL_CDClose(_cdrom);
	}
}