void VolumeBarLogic::openConnection () { if(!mPAThread){ mPAThread = new pulseaudio_thread(); connect(mPAThread,SIGNAL(volumeChanged(quint32,quint32)),this,SLOT(stepsUpdated(quint32,quint32))); connect(this,SIGNAL(changeVolume(quint32)),mPAThread,SLOT(changeVolume(quint32))); mPAThread->start(); hwkeys->start(); } }
VolumeControl::VolumeControl(QObject *parent) : QObject(parent), window(0), pulseAudioControl(new PulseAudioControl(this)), hwKeyResource(new ResourcePolicy::ResourceSet("event")), hwKeysAcquired(false), volume_(0), maximumVolume_(0), audioWarning(new MGConfItem("/desktop/nemo/audiowarning", this)), safeVolume_(0), callActive_(false) { hwKeyResource->setAlwaysReply(); hwKeyResource->addResourceObject(new ResourcePolicy::ScaleButtonResource); connect(hwKeyResource, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)), this, SLOT(hwKeyResourceAcquired())); connect(hwKeyResource, SIGNAL(lostResources()), this, SLOT(hwKeyResourceLost())); // Set up key repeat: initial delay and per-repeat delay keyRepeatDelayTimer.setSingleShot(true); keyRepeatDelayTimer.setInterval(600); keyRepeatTimer.setInterval(75); connect(&keyRepeatDelayTimer, SIGNAL(timeout()), &keyRepeatTimer, SLOT(start())); connect(&keyRepeatTimer, SIGNAL(timeout()), this, SLOT(changeVolume())); connect(pulseAudioControl, SIGNAL(volumeChanged(int,int)), this, SLOT(setVolume(int,int))); connect(pulseAudioControl, SIGNAL(highVolume(int)), SLOT(handleHighVolume(int))); connect(pulseAudioControl, SIGNAL(longListeningTime(int)), SLOT(handleLongListeningTime(int))); connect(pulseAudioControl, SIGNAL(callActiveChanged(bool)), SLOT(handleCallActive(bool))); pulseAudioControl->update(); qApp->installEventFilter(this); acquireKeys(); }
void VolumeHandlePropertyWidget::volumeRemoved(const VolumeCollection* /*source*/, const VolumeHandleBase* handle) { VolumeHandleProperty* handleProp = dynamic_cast<VolumeHandleProperty*>(prop_); if (!handleProp) return; int selected = volumeSelectorBox_->currentIndex(); int removed = -1; for (int i = 0; i < volumeSelectorBox_->count(); i++) { if (volumeSelectorBox_->itemText(i).toStdString() == VolumeViewHelper::getStrippedVolumeName(const_cast<VolumeHandleBase*>(handle)) && volumeSelectorBox_->findData(QString::fromStdString(VolumeViewHelper::getVolumeName(const_cast<VolumeHandleBase*>(handle))))== i ){ volumeSelectorBox_->removeItem(i); removed = i; break; } } tgtAssert(volumeContainer_->size()+1 == static_cast<size_t>(volumeSelectorBox_->count()), "Sizes of volume container and volume selector box do not match"); // update volume selector box if (selected == removed) { volumeSelectorBox_->setCurrentIndex(0); changeVolume(0); } else if (selected > 0 && removed <= selected) { volumeSelectorBox_->setCurrentIndex(selected-1); } updateFromProperty(); // disable selector box, when no volume available volumeSelectorBox_->setEnabled(volumeSelectorBox_->count() > 1); emit modified(); }
static void raiseMusicVolume() { Widget *w = menu.widgets[menu.index]; changeVolume(&game.musicDefaultVolume, w, 1); updateMusicVolume(); }
void KNMusicStandardBackend::setVolume(const int &volumeSize) { if(m_mute) { m_mute=false; emit muteStateChanged(m_mute); } changeVolume(volumeSize); }
void VolumeBarLogic::hwKeyEvent(uint key, int state) { static int counter = 0; counter++; if (state == KeyRelease) { // Do nothing on key releases return; } quint32 volumeChange = 0; switch (key) { case KEY_VOLUMEUP: case KEY_F7: volumeChange = 1; break; case KEY_VOLUMEDOWN: case KEY_F8: volumeChange = -1; break; default: // no-op for other hw keys return; } int volume = currentvolume + volumeChange; // Keep the volume within limits if (volume >= (int)currentmax) { volume = currentmax - 1; } else if (volume < 0) { volume = 0; } // Take the new volume into use emit changeVolume((quint32)volume); setVolume(volume); // Create the volume bar window if it does not exist yet if (volumeBarWindow == NULL) { volumeBarWindow = new VolumeBarWindow(this); volumeBarWindow->installEventFilter(new CloseEventEater(this)); connect(mHideTimer, SIGNAL(timeout()), volumeBarWindow, SLOT(hide())); } // Show the volume bar if the window is not visible if (!volumeBarWindow->isVisible()) { volumeBarWindow->show(); } volumeBarWindow->raise(); mHideTimer->start(VOLUMECLICKTIMEOUT); // Update the volume bar geometry volumeBarWindow->updateVolume(); }
// private slot void VolumeHandlePropertyWidget::volumeLoaded(const VolumeHandleBase* handle) { tgtAssert(handle, "null pointer passed"); if (!volumeContainer_) return; // select loaded volume for (size_t i=0; i<volumeContainer_->size(); i++) { if (handle == volumeContainer_->at(i)) changeVolume(static_cast<int>(i+1)); } }
void PlayerControls::MrccatoCommand(TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction aButtonAct) { if (!coreTarget) return; switch (aOperationId){ case ERemConCoreApiVolumeUp: if ((aButtonAct == ERemConCoreApiButtonClick) || (aButtonAct == ERemConCoreApiButtonPress) || (aButtonAct == ERemConCoreApiButtonRelease)) emit changeVolume((iplayer->volume()) + 10); break; case ERemConCoreApiVolumeDown: if ((aButtonAct == ERemConCoreApiButtonClick) || (aButtonAct == ERemConCoreApiButtonPress) || (aButtonAct == ERemConCoreApiButtonRelease)) emit changeVolume((iplayer->volume()) - 10); break; case ERemConCoreApiPausePlayFunction: if (aButtonAct == ERemConCoreApiButtonClick) playClicked(); break; case ERemConCoreApiStop: if (aButtonAct == ERemConCoreApiButtonClick) emit stop(); break; case ERemConCoreApiBackward: if (aButtonAct == ERemConCoreApiButtonClick) emit previous(); break; case ERemConCoreApiForward: if (aButtonAct == ERemConCoreApiButtonClick) emit next(); break; } }
void KNMusicStandardBackend::setMute(const bool &mute) { //Check the state is the same or not, if is the same, do nothing. if(m_mute==mute) { return; } //Set state. m_mute=mute; if(m_mute) { //Backup the original volume, mute it. m_volumeBeforeMute=volume(); changeVolume(0); } else { //Set the volume to the backup volume. changeVolume(m_volumeBeforeMute); } //Emit changed signal. emit muteStateChanged(m_mute); }
// Decodes the set volume instruction through tokens and sends the buttonID of the sample specified (if it exists) // through to the changeVolume function void set_(char *string_pointer) { char *volumeCommand, *desiredVolume; char *buttonID; if(string_pointer) { // now points to "volume" and the digit after it. volumeCommand = strtok(NULL, " \n.()"); desiredVolume = strtok(NULL, " \n.()"); if (strcmp(volumeCommand, "volume") == 0) { buttonID = findSampleInArray(string_pointer); changeVolume(buttonID, desiredVolume); } } }
bool VolumeControl::eventFilter(QObject *, QEvent *event) { if (hwKeysAcquired && (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease)) { QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); if (keyEvent->key() == Qt::Key_VolumeUp || keyEvent->key() == Qt::Key_VolumeDown) { if (event->type() == QEvent::KeyPress) { // Key down: set which way to change the volume on each repeat, start the repeat delay timer and change the volume once volumeChange = keyEvent->key() == Qt::Key_VolumeUp ? 1 : -1; if (!keyRepeatDelayTimer.isActive() && !keyRepeatTimer.isActive()) { keyRepeatDelayTimer.start(); changeVolume(); } } else { // Key up: stop any key repeating in progress and the repeat delay timer stopKeyRepeat(); } return true; } } return false; }
void VolumeBarLogic::setVolume (quint32 value) { currentvolume = value; emit changeVolume(value); }
static void raiseSFXVolume() { Widget *w = menu.widgets[menu.index]; changeVolume(&game.sfxDefaultVolume, w, 1); }
void Output::run() { mutex()->lock (); if (!bytes_per_millisecond_) { qWarning("Output: invalid audio parameters"); mutex()->unlock (); return; } mutex()->unlock (); bool done = false; Buffer *b = 0; qint64 l, m = 0; dispatch(PlayerUtils::Playing); while (!done) { mutex()->lock(); recycler()->mutex()->lock(); done = user_stop_; while (!done && (recycler()->empty() || pause_)) { mutex()->unlock(); recycler()->cond()->wakeOne(); recycler()->cond()->wait(recycler()->mutex()); mutex()->lock (); done = user_stop_; } status(); if (!b) { b = recycler()->next(); if (b && b->rate) { kbps_ = b->rate; } } recycler()->cond()->wakeOne(); recycler()->mutex()->unlock(); mutex()->unlock(); if (b) { changeVolume(b->data, b->nbytes, channels_); l = 0; m = 0; if (is_seeking_) { enable(b->seeking_finished); is_seeking_ = !b->seeking_finished; } while (l < b->nbytes) { m = writeAudio(b->data + l, b->nbytes - l); if(m >= 0) { total_written_ += m; l+= m; } else { break; } } if(m < 0) { break; } } mutex()->lock(); //force buffer change recycler()->mutex()->lock (); recycler()->done(); recycler()->mutex()->unlock(); b = 0; mutex()->unlock(); } mutex()->lock (); //write remaining data if(finish_) { flush(); qDebug("Output: total written %lld", total_written_); } dispatch(PlayerUtils::Stopped); mutex()->unlock(); }
void menuHandleAction(int menuAction) { if (menuAction >= 100 && menuAction < 200) { _menuSet(menuAction, 0); } else { switch (menuAction) { case MENU_ACTION_MENU_BACK: _menuSet(curMenu->parentMenu, 1); break; case MENU_ACTION_REMAP_KEYBOARD: menuState = MENU_STATE_REDEFINE_KEYS; remapDevice = 0; break; case MENU_ACTION_REMAP_JOYSTICK: menuState = MENU_STATE_REDEFINE_KEYS; remapDevice = 1; break; case (MENU_ACTION_SET_SAMPLE_RATE + 0): audioSampleRate = 11025; saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_SAMPLE_RATE + 1): audioSampleRate = 22050; saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_SAMPLE_RATE + 2): audioSampleRate = 44100; saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_MUSIC_VOL + 0): musicVol = 0; enableMusic = 0; Mix_VolumeMusic(musicVol); saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_MUSIC_VOL + 1): musicVol = 20; enableMusic = 1; Mix_VolumeMusic(musicVol); saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_MUSIC_VOL + 2): musicVol = 40; enableMusic = 1; Mix_VolumeMusic(musicVol); saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_MUSIC_VOL + 3): musicVol = 60; enableMusic = 1; Mix_VolumeMusic(musicVol); saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_MUSIC_VOL + 4): musicVol = 80; enableMusic = 1; saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_MUSIC_VOL + 5): musicVol = 100; enableMusic = 1; Mix_VolumeMusic(musicVol); saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_SFX_VOL + 0): sfxVol = 0; enableSfx = 0; changeVolume(-1, sfxVol); saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_SFX_VOL + 1): sfxVol = 20; enableSfx = 1; changeVolume(-1, sfxVol); saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_SFX_VOL + 2): sfxVol = 40; enableSfx = 1; changeVolume(-1, sfxVol); saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_SFX_VOL + 3): sfxVol = 60; enableSfx = 1; changeVolume(-1, sfxVol); saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_SFX_VOL + 4): sfxVol = 80; enableSfx = 1; saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_SFX_VOL + 5): sfxVol = 100; enableSfx = 1; changeVolume(-1, sfxVol); saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_SCALE + 0): changeVideoMode(screenWidth, screenHeight, 1, isFullscreen); saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_SCALE + 1): changeVideoMode(screenWidth, screenHeight, 2, isFullscreen); saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_SCALE + 2): changeVideoMode(screenWidth, screenHeight, 4, isFullscreen); saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_FULLSCREEN + 0): if (isFullscreen) { changeVideoMode(screenWidth, screenHeight, scale, 0); saveConfig(DATA_PATH "/data/config.cfg"); } break; case (MENU_ACTION_SET_FULLSCREEN + 1): if (!isFullscreen) { changeVideoMode(screenWidth, screenHeight, scale, 1); saveConfig(DATA_PATH "/data/config.cfg"); } break; case (MENU_ACTION_SET_FPS + 0): showFps = 0; saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_FPS + 1): showFps = 1; saveConfig(DATA_PATH "/data/config.cfg"); break; case (MENU_ACTION_SET_VISIBILITY_LAYER0 + 0): showBackground = 0; break; case (MENU_ACTION_SET_VISIBILITY_LAYER0 + 1): showBackground = 1; break; case (MENU_ACTION_SET_VISIBILITY_LAYER1 + 0): showForeground = 0; break; case (MENU_ACTION_SET_VISIBILITY_LAYER1 + 1): showForeground = 1; break; case (MENU_ACTION_SET_EDIT_LAYER + 0): selectedEditLayer = 0; break; case (MENU_ACTION_SET_EDIT_LAYER + 1): selectedEditLayer = 1; break; } } }