Ejemplo n.º 1
0
void
SDL_sound_handler::fetchSamples(boost::int16_t* to, unsigned int nSamples)
{
    boost::mutex::scoped_lock lock(_mutex);
    sound_handler::fetchSamples(to, nSamples);

    // TODO: move this to base class !
    if (file_stream)
    {
        // NOTE: if muted, the samples will be silent already
        boost::uint8_t* stream = reinterpret_cast<boost::uint8_t*>(to);
        unsigned int len = nSamples*2;
        file_stream.write((char*) stream, len);

        // now, mute all audio
        std::fill(to, to+nSamples, 0);
    }

    // If nothing is left to play there is no reason to keep polling.
    if ( ! hasInputStreams() )
    {
#ifdef GNASH_DEBUG_SDL_AUDIO_PAUSING
        log_debug("Pausing SDL Audio...");
#endif
        SDL_PauseAudio(1);
    }
}
Ejemplo n.º 2
0
void
AOS4_sound_handler::fetchSamples(boost::int16_t* to, unsigned int nSamples)
{
	if (!_closing)
	{
		AHIRequest *req = AHIios[AHICurBuf];
		UWORD AHIOtherBuf = AHICurBuf^1;

	    boost::mutex::scoped_lock lock(_mutex);
    	if (!_closing) 
    	{
	    		sound_handler::fetchSamples(to, nSamples);
    	}
		else		
			return;
		
		//memcpy(BufferPointer, inSamples, nBytes);
		memcpy(BufferPointer, to, nSamples*2);

		if (AHIReqSent[AHICurBuf])
		{
			if (req->ahir_Std.io_Data)
			{
				IExec->WaitIO((struct IORequest *)req);
				req->ahir_Std.io_Data = NULL;

				IExec->GetMsg(AHImp);
				IExec->GetMsg(AHImp);
			}
		}

		req->ahir_Std.io_Message.mn_Node.ln_Pri = 127;
		req->ahir_Std.io_Command  	= CMD_WRITE;
		req->ahir_Std.io_Offset   	= 0;
		req->ahir_Frequency       	= (ULONG) 44100;
		req->ahir_Volume          	= 0x10000;          // Full volume
		req->ahir_Position        	= 0x8000;           // Centered
		req->ahir_Std.io_Data     	= PlayBuffer[AHIOtherBuf];
		req->ahir_Std.io_Length  	= (ULONG) nSamples*2; //BUFSIZE;
		req->ahir_Type 			 	= AHIST_S16S;
		req->ahir_Link            	= (AHIReqSent[AHIOtherBuf] && !IExec->CheckIO((IORequest *) AHIios[AHIOtherBuf])) ? AHIios[AHIOtherBuf] : NULL;

		IExec->SendIO( (struct IORequest *) req);

		AHIReqSent[AHICurBuf] = true;
		AHICurBuf = AHIOtherBuf;

		BufferPointer = PlayBuffer[AHICurBuf];
	}


    // If nothing is left to play there is no reason to keep polling.
   	if ( ! hasInputStreams() )
    {
#ifdef GNASH_DEBUG_AOS4_AUDIO_PAUSING
   	    log_debug("Pausing AOS4 Audio...");
#endif
		sound_handler::pause();
   	}
}
Ejemplo n.º 3
0
void
SDL_sound_handler::unpause() 
{
    if (hasInputStreams()) {
        openAudio();
        SDL_PauseAudio(0);
    }

    sound_handler::unpause();
}
Ejemplo n.º 4
0
void
AOS4_sound_handler::unpause()
{
    if ( hasInputStreams() )
    {
		log_debug(_("AOS4: AOS4_sound_handler::unpause"));
		sound_handler::unpause();
		log_debug(_("AOS4: unpaused"));
    }

    sound_handler::unpause();
}
Ejemplo n.º 5
0
void
Mkit_sound_handler::unpause()
{
    if ( hasInputStreams() )
    {
        log_debug(_("Mkit: Mkit_sound_handler::unpause"));
        if (_soundplayer != NULL)
            _soundplayer->SetHasData(true);
        sound_handler::unpause();
        log_debug(_("Mkit: unpaused"));
    }
}
Ejemplo n.º 6
0
void
SDL_sound_handler::fetchSamples(boost::int16_t* to, unsigned int nSamples)
{
    boost::mutex::scoped_lock lock(_mutex);
    sound_handler::fetchSamples(to, nSamples);

    // If nothing is left to play there is no reason to keep polling.
    if ( ! hasInputStreams() )
    {
#ifdef GNASH_DEBUG_SDL_AUDIO_PAUSING
        log_debug("Pausing SDL Audio...");
#endif
        SDL_PauseAudio(1);
    }
}