// Remove stopped sounds void maintain() { verbosestream<<"OpenALSoundManager::maintain(): " <<m_sounds_playing.size()<<" playing sounds, " <<m_buffers.size()<<" sound names loaded"<<std::endl; std::set<int> del_list; for(std::map<int, PlayingSound*>::iterator i = m_sounds_playing.begin(); i != m_sounds_playing.end(); ++i) { int id = i->first; PlayingSound *sound = i->second; // If not playing, remove it { ALint state; alGetSourcei(sound->source_id, AL_SOURCE_STATE, &state); if(state != AL_PLAYING){ del_list.insert(id); } } } if(!del_list.empty()) verbosestream<<"OpenALSoundManager::maintain(): deleting " <<del_list.size()<<" playing sounds"<<std::endl; for(std::set<int>::iterator i = del_list.begin(); i != del_list.end(); ++i) { deleteSound(*i); } }
// Remove stopped sounds void maintain() { verbosestream<<"OpenALSoundManager::maintain(): " <<m_sounds_playing.size()<<" playing sounds, " <<m_buffers.size()<<" sound names loaded"<<std::endl; std::set<int> del_list; for (auto &sp : m_sounds_playing) { int id = sp.first; PlayingSound *sound = sp.second; // If not playing, remove it { ALint state; alGetSourcei(sound->source_id, AL_SOURCE_STATE, &state); if(state != AL_PLAYING){ del_list.insert(id); } } } if(!del_list.empty()) verbosestream<<"OpenALSoundManager::maintain(): deleting " <<del_list.size()<<" playing sounds"<<std::endl; for (int i : del_list) { deleteSound(i); } }
void SoundButton::addActions(){ editAction = new QAction(tr("&Edit"), this); connect(editAction, SIGNAL(triggered()), this, SLOT(edit())); deleteAction = new QAction(tr("&Delete"), this); connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteSound())); }
void Audio::clear(){ int index = sounds.getCount(); while (index--){ deleteSound(index); } index = soundSources.getCount(); while (index--){ deleteSoundSource(index); } }
static void deleteOldest() { if (cacheSize <= 0) return; long oldestTime = currentTimeMillis(); std::list<Sound*>::iterator it = cache.begin(); std::list<Sound*>::iterator oldest; while (it != cache.end()) { Sound* s = *it; if (s->lastPlayedTime < oldestTime) { oldestTime = s->lastPlayedTime; oldest = it; } it++; } deleteSound(*oldest); cache.erase(oldest); }
void SoundEditWidget::contextMenuEvent( QContextMenuEvent *event ) { QMenu menu; if ( mHasSound ) { menu.addAction( i18n( "Play" ), this, SLOT(playSound()) ); } if ( !mReadOnly ) { menu.addAction( i18n( "Change..." ), this, SLOT(changeSound()) ); } if ( mHasSound ) { menu.addAction( i18n( "Save..." ), this, SLOT(saveSound()) ); if ( !mReadOnly ) { menu.addAction( i18n( "Remove" ), this, SLOT(deleteSound()) ); } } menu.exec( event->globalPos() ); }
void stopSound(int sound) { maintain(); deleteSound(sound); }