Ejemplo n.º 1
0
static mrb_value
mrb_sdl2_mixer_get_channel_chunk(mrb_state *mrb, mrb_value self)
{
  mrb_int v;
  mrb_get_args(mrb, "i", &v);
  return mrb_sdl2_chunk(mrb, Mix_GetChunk(v));
}
Ejemplo n.º 2
0
static void channel_complete_callback(int chan)
{
	Mix_Chunk *done_chunk = Mix_GetChunk(chan);
	fprintf(stderr, "We were just alerted that Mixer channel #%d is done.\n", chan);
	fprintf(stderr, "Channel's chunk pointer is (%p).\n", done_chunk);
	fprintf(stderr, " Which %s correct.\n", (wave == done_chunk) ? "is" : "is NOT");
	channel_is_done = 1;
}
Ejemplo n.º 3
0
/**\brief Destructor to free the sound file.
 */
Sound::~Sound(){
	// Halts any channel this sound is playing on
	for ( int i = 0; i < Audio::Instance().GetTotalChannels(); i++ ){
		if ( Mix_GetChunk( i ) == this->sound)
			Mix_HaltChannel( i );
	}
	if(this->sound) Mix_FreeChunk( this->sound );
}
Ejemplo n.º 4
0
/**\brief Plays the sound if not playing, but do not restart if already playing.
 * \details
 * This is sort of a roundabout way to implement engine sounds.
 */
bool Sound::PlayNoRestart( Coordinate offset ){
	if ( this->sound == NULL )
		return false;

	if ( (this->channel != -1) &&
			Mix_Playing( this->channel ) &&
			(Mix_GetChunk( this->channel ) == this->sound ) )
		return false;

	this->Play( offset );
	return true;
}
Ejemplo n.º 5
0
/* Check that the given channel is (still) loaded with the given chunk. */
static int _rg_sound_channel_check( RG_Sound *sound )
{
	/* channel is unset, so it doesn't belong. */
	if( sound->channel == -1 )
	{
		return 0;
	}

	Mix_Chunk *chan_chunk = Mix_GetChunk(sound->channel);	

	/* Check that the channel chunk is the same as the given one */
	return ( sound->wrap->chunk == chan_chunk );
}
Ejemplo n.º 6
0
void evenement_Click1( SDL_Event event,Pions* TourJoueur,ComposantsFonctionPourJeu Charger,int terrain[][3],int*coups,SDL_Surface **Curseur,int*Variable_Pour_Image )
{
    if( event.button.button == SDL_BUTTON_LEFT && event.button.x<=720 && event.button.y<=320)
    {
        if (collision(event.button.x, event.button.y, Charger.position_Grille))
        {
            if( *TourJoueur == CROIX )
            {
                if (terrain[(event.button.x -420)/ 100][(event.button.y -80)/ 80]==VIDE)/*Si la case est vide*/
                {
                    Mix_PlayChannel(1, Mix_GetChunk(0) , 0);
                    terrain[(event.button.x -420)/ 100][(event.button.y -80)/ 80]= CROIX;/*on attribut Croix à la case*/
                    *TourJoueur = ROND;/*on change de joueur*/
                    (*coups)--;
                    SDL_FreeSurface(*Curseur);
                    *Curseur= SDL_LoadBMP("images/petitRond.bmp");
                }
            }
            else
            {
                if (terrain[(event.button.x -420)/ 100][(event.button.y -80)/ 80]==VIDE)/*Si la case est vide*/
                {
                    Mix_PlayChannel(1, Mix_GetChunk(0), 0);
                    terrain[(event.button.x -420)/ 100][(event.button.y -80)/ 80]= ROND;/*on attribut ROND à la case*/
                    *TourJoueur = CROIX;
                    (*coups)--;
                    SDL_FreeSurface(*Curseur);
                    *Curseur= SDL_LoadBMP("images/petiteCroix.bmp");
                }
            }
        }
        (*Variable_Pour_Image)++;/*l'anim change à chaque clic*/
        if (*Variable_Pour_Image==3)
        {
            *Variable_Pour_Image=0;
        }
    }
}
Ejemplo n.º 7
0
void SoundEngine::stopSound( std::string soundFile )
{
    if( !Configuration::soundenabled && soundFile != "" )
    {
        return;
    }

    /// load our sound file we want to stop in a Mix_Chunk to be able to compare it later.
    Mix_Chunk *ourSample = soundCache->getSoundFromCache( soundFile );

    /// get the number of channels in use.
    int numOfChannelsPlaying = Mix_Playing( -1 );

    /// here we check all channels we have to see if they are playing our chunk we want to stop.
    for( int curChannel = 0; curChannel <= numOfChannelsPlaying; curChannel++ )
    {
        if( ourSample == Mix_GetChunk( curChannel ) )
        {
            Mix_HaltChannel( curChannel );
        }
    }
}