void SciMusic::clearPlayList() { // we must NOT lock our mutex here. Playlist is modified inside soundKill() which will lock the mutex // during deletion. If we lock it here, a deadlock may occur within soundStop() because that one // calls the mixer, which will also lock the mixer mutex and if the mixer thread is active during // that time, we will get a deadlock. while (!_playList.empty()) { soundStop(_playList[0]); soundKill(_playList[0]); } }
void RainReset() { // stop all sounds while(sounds) soundStop(&sound[--sounds]); // reset amplification MIDASsetAmplification(AMPLIFY_ALL*AMPLIFY_MP3*100); // reset handle number (clients always start from 1) rainhandles=0; // delete errors while(errGet()); }
static void RainFreeStopped() { int i; for(i=0;i<sounds;i++) if(!soundGetStatus(&sound[i])) { _bprintf(errBuf,errBufLen,"end of %i",sound[i].rainhandle); errAdd(errBuf); soundStop(&sound[i]); sound[i--]=sound[--sounds]; } }
/** * main program * * This program reads D0-D2 of the port G and write it to D0-D2 of port F. */ void main(void) { const char * soundFiles[] = {sound1, sound2, sound3, sound4, sound5}; uint8 count = sizeof(soundFiles) / sizeof(soundFiles[0]); uint8 playIndex = 0; PTDDD_PTDDD2 = 1; initPorts(); // Ports konfigurieren ifrRxFrontInit(); // init IR receiver initTimer(); // Timer init init_timer1_ch0(); // init channel 1 EnableInterrupts; // Interrupts aktivieren for(;;) { switch (ifrRxFrontGetKey()) //switch (ifrRxRearGetKey()) { case 'S' : // play/pause soundTooglePlayPause(); break; case 'W' : // play next melody playIndex++; if (playIndex >= count) playIndex = 0; soundPlay(soundFiles[playIndex]); break; case 'T' : // play previous melody if (playIndex == 0) playIndex = count; playIndex--; soundPlay(soundFiles[playIndex]); break; case '+' : break; case '-' : soundStop(); break; } } }
// sound void SoundManager::soundPlay(ALuint sourceID, bool reset) { int sourceState = 0; alGetSourcei(sourceID, AL_SOURCE_STATE, &sourceState); if (sourceState == AL_PLAYING) { if (reset) { soundStop(sourceID); } else { return; } } alSourcePlay(sourceID); CHK_AL_ERROR; }
int RainCommand(int command,int param1,int param2,int param3, char *filename,int fileofs,int filesize) { int result=0; int i; if (command==CMD_PLAY) _bprintf(hint,hintlen,"%s,%i,%i",filename,fileofs,filesize); else _bprintf(hint,hintlen,"%i(%i,%i)",command,param1,param2); switch (command) { case CMD_NONE: RainFreeStopped(); MIDASpoll(); break; case CMD_PLAY: rainhandles++; if (sounds<SOUNDS) { sound[sounds].type=None; sound[sounds].rainhandle=rainhandles; sound[sounds].datahandle=0; sound[sounds].playhandle=0; soundPlay(&sound[sounds],filename,fileofs,filesize,param1); soundSetVolume(&sound[sounds],param2); soundSetPanning(&sound[sounds],param3); sounds++; } result=rainhandles; break; case CMD_VOL: for(i=0;i<sounds;i++) if(sound[i].rainhandle==param1) { soundSetVolume(&sound[i],param2); } break; case CMD_PAN: for(i=0;i<sounds;i++) if(sound[i].rainhandle==param1) { soundSetPanning(&sound[i],param2); } break; case CMD_STOP: for(i=0;i<sounds;i++) if(sound[i].rainhandle==param1) { soundStop(&sound[i]); sound[i--]=sound[--sounds]; } break; case CMD_AMPLIFY: MIDASsetAmplification(AMPLIFY_ALL*AMPLIFY_MP3*param1); break; default: _bprintf(errBuf,errBufLen," Unknown command %i.",command); errAdd(errBuf); } MIDASreportErr(); return result; }
void SciMusic::stopAll() { const MusicList::iterator end = _playList.end(); for (MusicList::iterator i = _playList.begin(); i != end; ++i) { soundStop(*i); } }