示例#1
0
MPEGaudio:: MPEGaudio(MPEGstream *stream, bool initSDL) : sdl_audio(initSDL)
{
    /* Initialize MPEG audio */
    mpeg = stream;
    initialize();

    /* Just be paranoid.  If all goes well, this will be set to true */
    valid_stream = false;

    /* Analyze the MPEG audio stream */
    if ( loadheader() ) {
        SDL_AudioSpec wanted;
        WantedSpec(&wanted);

        /* Calculate the samples per frame */
        samplesperframe = 32*wanted.channels;
        if( layer == 3 ) {
            samplesperframe *= 18;
            if ( version == 0 ) {
                samplesperframe *= 2;
            }
        } else {
            samplesperframe *= SCALEBLOCK;
            if ( layer == 2 ) {
                samplesperframe *= 3;
            }
        }
        if ( sdl_audio ) {
            /* Open the audio, get actual audio hardware format and convert */
            bool audio_active;
            SDL_AudioSpec actual;
            audio_active = (SDL_OpenAudio(&wanted, &actual) == 0);
            if ( audio_active ) {
                ActualSpec(&actual);
                valid_stream = true;
            } else {
                SetError(SDL_GetError());
            }
            SDL_PauseAudio(0);
        } else { /* The stream is always valid if we don't initialize SDL */
            valid_stream = true; 
        }
        Volume(100);
    }

    /* For using system timestamp */
    for (int i=0; i<N_TIMESTAMPS; i++)
      timestamp[i] = -1;
}
示例#2
0
MPEGaudio:: MPEGaudio(MPEGstream *stream, bool initSDL) : sdl_audio(initSDL)
{
	/* Initialize MPEG audio */
	mpeg = stream;
	initialize();

	/* Just be paranoid.  If all goes well, this will be set to true */
	valid_stream = false;

	/* Analyze the MPEG audio stream */
	if ( loadheader() )
	{
		PSPL_AUDIO_SPEC wanted;
		WantedSpec(&wanted);

		/* Calculate the samples per frame */
		samplesperframe = 32 * wanted.channels;
		if ( layer == 3 )
		{
			samplesperframe *= 18;
			if ( version == 0 )
			{
				samplesperframe *= 2;
			}
		}
		else
		{
			samplesperframe *= SCALEBLOCK;
			if ( layer == 2 )
			{
				samplesperframe *= 3;
			}
		}
		if ( sdl_audio )
		{
			/* ていうか、ここでSDL audio ( PSPL_OpenAudio() )呼ばれると, SDL mixer 的には都合が悪い */
			/* Open the audio, get actual audio hardware format and convert */
			bool audio_active;
			PSPL_AUDIO_SPEC actual;
			audio_active = (PSPL_OpenAudio(&wanted, &actual) == 0);
			if ( audio_active )
			{
				ActualSpec(&actual);
				valid_stream = true;
			}
			else
			{
				smpeg_SetError_bbb(SDL_GetError());
			}
			PSPL_PauseAudio(0);
		}
		else 	/* The stream is always valid if we don't initialize SDL */
		{
			valid_stream = true;
		}
		//volume = (SDL_MIX_MAXVOLUME);//Volume(100);
	}

	/* For using system timestamp */
	{
		int i;
		for (i=0; i<N_TIMESTAMPS; i++)
		{	timestamp[i] = -1;}
	}
}
示例#3
0
MPEGaudio:: MPEGaudio(MPEGstream *stream, bool initSDL)
    : sdl_audio(initSDL)
    , mpeg(stream)
    , valid_stream(0)
    , stereo(false)
    , rate_in_s(0.0)
    , frags_playing(0)
    , frag_time(0)
#ifdef THREADED_AUDIO
    , decoding(false)
    , decode_thread(NULL)
#endif
{
    memset(&sideinfo, '\0', sizeof (sideinfo));

    /* Initialize MPEG audio */
    initialize();

    /* Just be paranoid.  If all goes well, this will be set to true */
    valid_stream = false;

    /* Analyze the MPEG audio stream */
    if ( loadheader() ) {
        SDL_AudioSpec wanted;
        WantedSpec(&wanted);

        /* Calculate the samples per frame */
        samplesperframe = 32*wanted.channels;
        if( layer == 3 ) {
            samplesperframe *= 18;
            if ( version == 0 ) {
                samplesperframe *= 2;
            }
        } else {
            samplesperframe *= SCALEBLOCK;
            if ( layer == 2 ) {
                samplesperframe *= 3;
            }
        }
        if ( sdl_audio ) {
            /* Open the audio, get actual audio hardware format and convert */
            bool audio_active;
            SDL_AudioSpec actual;
            audio_active = (SDL_OpenAudio(&wanted, &actual) == 0);
            if ( audio_active ) {
                ActualSpec(&actual);
                valid_stream = true;
            } else {
                SetError(SDL_GetError());
            }
            SDL_PauseAudio(0);
        } else { /* The stream is always valid if we don't initialize SDL */
            valid_stream = true; 
        }
        Volume(100);
    }

    /* For using system timestamp */
    for (int i=0; i<N_TIMESTAMPS; i++)
      timestamp[i] = -1;
}