void Movie::play() { AC_INFO << "playing movie: "<< getSrc() << " (volume: " << _volume <<")"; masl::MovieEngineSingleton::get().getNative()->playMovie(this); setVolume(_volume); }
void MusicNode::unsetPanTrack() { _pantrack = false; setVolume(_volume); }
static void spk_setVolume (volatile SpeechSynthesizer *spk, unsigned char setting) { setVolume(getIntegerSpeechVolume(setting, 100)); }
status_t BnMediaPlayer::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case DISCONNECT: { CHECK_INTERFACE(IMediaPlayer, data, reply); disconnect(); return NO_ERROR; } break; case SET_VIDEO_SURFACE: { CHECK_INTERFACE(IMediaPlayer, data, reply); sp<ISurface> surface = interface_cast<ISurface>(data.readStrongBinder()); reply->writeInt32(setVideoSurface(surface)); return NO_ERROR; } break; case PREPARE_ASYNC: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(prepareAsync()); return NO_ERROR; } break; case START: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(start()); return NO_ERROR; } break; case STOP: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(stop()); return NO_ERROR; } break; case IS_PLAYING: { CHECK_INTERFACE(IMediaPlayer, data, reply); bool state; status_t ret = isPlaying(&state); reply->writeInt32(state); reply->writeInt32(ret); return NO_ERROR; } break; case PAUSE: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(pause()); return NO_ERROR; } break; case SEEK_TO: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(seekTo(data.readInt32())); return NO_ERROR; } break; case GET_CURRENT_POSITION: { CHECK_INTERFACE(IMediaPlayer, data, reply); int msec; status_t ret = getCurrentPosition(&msec); reply->writeInt32(msec); reply->writeInt32(ret); return NO_ERROR; } break; case GET_DURATION: { CHECK_INTERFACE(IMediaPlayer, data, reply); int msec; status_t ret = getDuration(&msec); reply->writeInt32(msec); reply->writeInt32(ret); return NO_ERROR; } break; case RESET: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(reset()); return NO_ERROR; } break; case SET_AUDIO_STREAM_TYPE: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setAudioStreamType(data.readInt32())); return NO_ERROR; } break; case SET_LOOPING: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setLooping(data.readInt32())); return NO_ERROR; } break; case SET_VOLUME: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setVolume(data.readFloat(), data.readFloat())); return NO_ERROR; } break; case INVOKE: { CHECK_INTERFACE(IMediaPlayer, data, reply); invoke(data, reply); return NO_ERROR; } break; case SET_METADATA_FILTER: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setMetadataFilter(data)); return NO_ERROR; } break; case SUSPEND: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(suspend()); return NO_ERROR; } break; case RESUME: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(resume()); return NO_ERROR; } break; case GET_METADATA: { CHECK_INTERFACE(IMediaPlayer, data, reply); const status_t retcode = getMetadata(data.readInt32(), data.readInt32(), reply); reply->setDataPosition(0); reply->writeInt32(retcode); reply->setDataPosition(0); return NO_ERROR; } break; case SET_AUX_EFFECT_SEND_LEVEL: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setAuxEffectSendLevel(data.readFloat())); return NO_ERROR; } break; case ATTACH_AUX_EFFECT: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(attachAuxEffect(data.readInt32())); return NO_ERROR; } break; #ifdef OMAP_ENHANCEMENT case REQUEST_CLONE_MODE: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(requestVideoCloneMode(data.readInt32())); return NO_ERROR; } break; #endif default: return BBinder::onTransact(code, data, reply, flags); } }
bool BaseSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { return setVolume(type, percent * 255 / 100); }
bool AudioDecoder::resample() { if (_result.sampleRate == _sampleRate) { ALOGI("No need to resample since the sample rate (%d) of the decoded pcm data is the same as the device output sample rate", _sampleRate); return true; } ALOGV("Resample: %d --> %d", _result.sampleRate, _sampleRate); auto r = _result; PcmBufferProvider provider; provider.init(r.pcmBuffer->data(), r.numFrames, r.pcmBuffer->size() / r.numFrames); const int outFrameRate = _sampleRate; int outputChannels = 2; size_t outputFrameSize = outputChannels * sizeof(int32_t); size_t outputFrames = ((int64_t) r.numFrames * outFrameRate) / r.sampleRate; size_t outputSize = outputFrames * outputFrameSize; void *outputVAddr = malloc(outputSize); auto resampler = AudioResampler::create(AUDIO_FORMAT_PCM_16_BIT, r.numChannels, outFrameRate, AudioResampler::MED_QUALITY); resampler->setSampleRate(r.sampleRate); resampler->setVolume(AudioResampler::UNITY_GAIN_FLOAT, AudioResampler::UNITY_GAIN_FLOAT); memset(outputVAddr, 0, outputSize); ALOGV("resample() %zu output frames", outputFrames); std::vector<int> Ovalues; if (Ovalues.empty()) { Ovalues.push_back(outputFrames); } for (size_t i = 0, j = 0; i < outputFrames;) { size_t thisFrames = Ovalues[j++]; if (j >= Ovalues.size()) { j = 0; } if (thisFrames == 0 || thisFrames > outputFrames - i) { thisFrames = outputFrames - i; } int outFrames = resampler->resample((int *) outputVAddr + outputChannels * i, thisFrames, &provider); ALOGV("outFrames: %d", outFrames); i += thisFrames; } ALOGV("resample() complete"); resampler->reset(); ALOGV("reset() complete"); delete resampler; resampler = nullptr; // mono takes left channel only (out of stereo output pair) // stereo and multichannel preserve all channels. int channels = r.numChannels; int32_t *out = (int32_t *) outputVAddr; int16_t *convert = (int16_t *) malloc(outputFrames * channels * sizeof(int16_t)); const int volumeShift = 12; // shift requirement for Q4.27 to Q.15 // round to half towards zero and saturate at int16 (non-dithered) const int roundVal = (1 << (volumeShift - 1)) - 1; // volumePrecision > 0 for (size_t i = 0; i < outputFrames; i++) { for (int j = 0; j < channels; j++) { int32_t s = out[i * outputChannels + j] + roundVal; // add offset here if (s < 0) { s = (s + 1) >> volumeShift; // round to 0 if (s < -32768) { s = -32768; } } else { s = s >> volumeShift; if (s > 32767) { s = 32767; } } convert[i * channels + j] = int16_t(s); }
SinOsc::SinOsc(float freq, float volume) { phase = 0.0f; setFreq(freq); setVolume(volume); }
void hammerMain() { uprint("\r\n ######################## BOOT UP (HAMMER) ######################## \r\n"); initHammerState(); HammerState *hs = getHammerStatePtr(); configureAccelerometer(); configureAudio(); audioReset(); int sta = configureRadio(0x0A00, 0x0000111111111111); uprint_int("Configured radio: ", sta); configureIRReceive(); configureLightMCU_SPI(); updateLightMCUAll(hs->health, hs->charge); char sendString[2] = "x"; char rxbuf[50]; char doneString[] = "DONE"; DELAY_MS(400); playSound(HS_BOOT); DELAY_MS(HS_BOOT_LEN); while (1) { uprint("Beginning of main loop"); hs->charge = 0; updateLightMCUAll(hs->health, hs->charge); uprint("Waiting for spin..."); startTrackingSpin(); while (!checkSpinComplete()); uprint("Spin complete!"); playSound(HS_SPINCOMPLETE); DELAY_MS(HS_SPINCOMPLETE_LEN); setVolume(5); // Charging is really damn loud // This sound is very long, we just start it playing playSound(HS_CHARGING); uprint("Charging ..."); hs->charge = 0; hs->charging = 1; while (hs->charge < 100) { hs->charge ++; updateLightMCUCharge(hs->charge); DELAY_MS((0.9 * hs->health) + 10); } hs->charging = 0; setVolume(8); // Back to normal playSound(HS_CHARGECOMPLETE); DELAY_MS(HS_CHARGECOMPLETE_LEN); uprint("Finished charging!"); uprint("Waiting for thrust..."); startTrackingThrust(); while (!checkThrustComplete()); setLightMCUHitAnim(); uprint("Thrust complete!"); playSound(HS_FIRE); DELAY_MS(HS_FIRE_LEN); setLightMCURainbow(); // Become invincible disableIRReceive(); uprint("Sending radio message"); sendString[0] = hs->health; radioSendMessage(sendString, 0x0A00); uprint("Waiting for cloud message"); radioGetMessage(rxbuf, 50); if (memcmp(rxbuf, doneString, 4) != 0) { uprint("Invalid message from cloud!"); } enableIRReceive(); uprint("Got cloud message"); setLightMCUOff(); DELAY_MS(30); } }
bool UrlAudioPlayer::prepare(const std::string &url, SLuint32 locatorType, std::shared_ptr<AssetFd> assetFd, int start, int length) { _url = url; _assetFd = assetFd; const char* locatorTypeStr= "UNKNOWN"; if (locatorType == SL_DATALOCATOR_ANDROIDFD) locatorTypeStr = "SL_DATALOCATOR_ANDROIDFD"; else if (locatorType == SL_DATALOCATOR_URI) locatorTypeStr = "SL_DATALOCATOR_URI"; else { ALOGE("Oops, invalid locatorType: %d", (int)locatorType); return false; } ALOGV("UrlAudioPlayer::prepare: %s, %s, %d, %d, %d", _url.c_str(), locatorTypeStr, _assetFd->getFd(), start, length); SLDataSource audioSrc; SLDataFormat_MIME formatMime = {SL_DATAFORMAT_MIME, nullptr, SL_CONTAINERTYPE_UNSPECIFIED}; audioSrc.pFormat = &formatMime; //Note: locFd & locUri should be outside of the following if/else block // Although locFd & locUri are only used inside if/else block, its lifecycle // will be destroyed right after '}' block. And since we pass a pointer to // 'audioSrc.pLocator=&locFd/&locUri', pLocator will point to an invalid address // while invoking Engine::createAudioPlayer interface. So be care of change the position // of these two variables. SLDataLocator_AndroidFD locFd; SLDataLocator_URI locUri; if (locatorType == SL_DATALOCATOR_ANDROIDFD) { locFd = {locatorType, _assetFd->getFd(), start, length}; audioSrc.pLocator = &locFd; } else if (locatorType == SL_DATALOCATOR_URI) { locUri = {locatorType, (SLchar *) _url.c_str()}; audioSrc.pLocator = &locUri; ALOGV("locUri: locatorType: %d", (int)locUri.locatorType); } // configure audio sink SLDataLocator_OutputMix locOutmix = {SL_DATALOCATOR_OUTPUTMIX, _outputMixObj}; SLDataSink audioSnk = {&locOutmix, nullptr}; // create audio player const SLInterfaceID ids[3] = {SL_IID_SEEK, SL_IID_PREFETCHSTATUS, SL_IID_VOLUME}; const SLboolean req[3] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE}; SLresult result = (*_engineItf)->CreateAudioPlayer(_engineItf, &_playObj, &audioSrc, &audioSnk, 3, ids, req); SL_RETURN_VAL_IF_FAILED(result, false, "CreateAudioPlayer failed"); // realize the player result = (*_playObj)->Realize(_playObj, SL_BOOLEAN_FALSE); SL_RETURN_VAL_IF_FAILED(result, false, "Realize failed"); // get the play interface result = (*_playObj)->GetInterface(_playObj, SL_IID_PLAY, &_playItf); SL_RETURN_VAL_IF_FAILED(result, false, "GetInterface SL_IID_PLAY failed"); // get the seek interface result = (*_playObj)->GetInterface(_playObj, SL_IID_SEEK, &_seekItf); SL_RETURN_VAL_IF_FAILED(result, false, "GetInterface SL_IID_SEEK failed"); // get the volume interface result = (*_playObj)->GetInterface(_playObj, SL_IID_VOLUME, &_volumeItf); SL_RETURN_VAL_IF_FAILED(result, false, "GetInterface SL_IID_VOLUME failed"); result = (*_playItf)->RegisterCallback(_playItf, SLUrlAudioPlayerCallbackProxy::playEventCallback, this); SL_RETURN_VAL_IF_FAILED(result, false, "RegisterCallback failed"); result = (*_playItf)->SetCallbackEventsMask(_playItf, SL_PLAYEVENT_HEADATEND); SL_RETURN_VAL_IF_FAILED(result, false, "SetCallbackEventsMask SL_PLAYEVENT_HEADATEND failed"); setState(State::INITIALIZED); setVolume(1.0f); return true; }
void EnginePhonon::volumeDec( ) { int percent = volume() > 0 ? volume() -1 : 0; setVolume(percent); };
/* ******************************************************************************** * * * Class EnginePhonon * * * ******************************************************************************** */ EnginePhonon::EnginePhonon() : EngineBase("phonon") { m_type = ENGINE::PHONON; m_mediaObject = new Phonon::MediaObject(this); m_audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); /* ----- by default tick every 1 second ----- */ m_mediaObject->setTickInterval(100); Debug::debug() << "[EnginePhonon] -> tick Interval (actual): " << m_mediaObject->tickInterval(); /* ----- get the next track when there is 2 seconds left on the current one ----- */ /* in case of playing track from track view */ m_mediaObject->setPrefinishMark( 2000 ); m_mediaObject->setTransitionTime(100); /* GAPLESS/CROSSFADE */ connect(m_mediaObject,SIGNAL(finished()),this,SLOT(slot_on_media_finished())); connect(m_mediaObject,SIGNAL(aboutToFinish()),this,SLOT(slot_on_media_about_to_finish())); connect(m_mediaObject,SIGNAL(stateChanged(Phonon::State,Phonon::State)),this,SLOT(slot_on_phonon_state_changed(Phonon::State,Phonon::State)),Qt::DirectConnection); connect(m_mediaObject,SIGNAL(tick(qint64)),this,SLOT(slot_on_time_change(qint64))); connect(m_mediaObject,SIGNAL(totalTimeChanged(qint64)),this,SLOT(slot_on_duration_change(qint64))); connect(m_mediaObject,SIGNAL(currentSourceChanged( const Phonon::MediaSource & )),this,SLOT(slot_on_media_change())); connect(m_mediaObject, SIGNAL(metaDataChanged()), this,SLOT(slot_on_metadata_change())); /* needed for Mplayer2 backend */ connect( m_audioOutput, SIGNAL( volumeChanged( qreal ) ),this, SIGNAL( volumeChanged() ) ); connect( m_audioOutput, SIGNAL( mutedChanged( bool ) ), this, SIGNAL( muteStateChanged() ) ); m_phononPath = Phonon::createPath(m_mediaObject,m_audioOutput); /* ----- only create pre-amp if we have replaygain on, VolumeFaderEffect can cause phonon issues */ m_preamp = 0; if( SETTINGS()->_replaygain != SETTING::ReplayGainOff ) { m_preamp = new Phonon::VolumeFaderEffect( this ); m_phononPath.insertEffect( m_preamp ); } /* ----- add an equalizer effect if available */ m_equalizer = 0; QList<Phonon::EffectDescription> mEffectDescriptions = Phonon::BackendCapabilities::availableAudioEffects(); foreach ( const Phonon::EffectDescription &mDescr, mEffectDescriptions ) { if ( mDescr.name() == QLatin1String( "KEqualizer" ) ) { m_equalizer = new Phonon::Effect( mDescr, this ); if( SETTINGS()->_enableEq ) { addEqualizer(); loadEqualizerSettings(); } } } /* ----- initial volume setup ----- */ setVolume( SETTINGS()->_volumeLevel ); m_current_state = ENGINE::STOPPED; m_old_state = ENGINE::STOPPED; m_version = QString(); }
void EnginePhonon::volumeInc( ) { int percent = volume() < 100 ? volume() + 1 : 100; setVolume(percent); };
void RingControl::profileChanged() { QPhoneProfile prof = d->profileManager->activeProfile(); setVolume(prof.volume()); setMsgRingTime(prof.msgAlertDuration()); }
void MidiPlayer::adjustVolume(int diff) { debugC(3, kDebugMusic, "MidiPlayer::adjustVolume"); setVolume(_masterVolume + diff); }
void MediaPlayer::decrementVolume() { setVolume(volume()-1); }
void AudioPlayerGnu::unmute() { if(_isMuted) setVolume(volumeForMute); _isMuted=false; }
MeshPartition::MeshPartition(QString volume_name) { m_TrackGrid = false; resetTimeStamps(); setVolume(volume_name); }
void Sound::emit2D(f32 Volume, bool UseEffectSlot) { setVolumetric(false); setVolume(Volume); play(); }
void PlaybackControls::setVolume() { int vol = mpParentWindow->volumeBar->value(); setVolume(vol); }
bool MpvHandler::event(QEvent *event) { if(event->type() == QEvent::User) { while(mpv) { mpv_event *event = mpv_wait_event(mpv, 0); if(event == nullptr || event->event_id == MPV_EVENT_NONE) { break; } HandleErrorCode(event->error); switch (event->event_id) { case MPV_EVENT_PROPERTY_CHANGE: { mpv_event_property *prop = (mpv_event_property*)event->data; if(QString(prop->name) == "playback-time") // playback-time does the same thing as time-pos but works for streaming media { if(prop->format == MPV_FORMAT_DOUBLE) { setTime((int)*(double*)prop->data); lastTime = time; } } else if(QString(prop->name) == "volume") { if(prop->format == MPV_FORMAT_DOUBLE) setVolume((int)*(double*)prop->data); } else if(QString(prop->name) == "sid") { if(prop->format == MPV_FORMAT_INT64) setSid(*(int*)prop->data); } else if(QString(prop->name) == "aid") { if(prop->format == MPV_FORMAT_INT64) setAid(*(int*)prop->data); } else if(QString(prop->name) == "sub-visibility") { if(prop->format == MPV_FORMAT_FLAG) setSubtitleVisibility((bool)*(unsigned*)prop->data); } else if(QString(prop->name) == "mute") { if(prop->format == MPV_FORMAT_FLAG) setMute((bool)*(unsigned*)prop->data); } else if(QString(prop->name) == "core-idle") { if(prop->format == MPV_FORMAT_FLAG) { if((bool)*(unsigned*)prop->data && playState == Mpv::Playing) ShowText(tr("Buffering..."), 0); else ShowText(QString(), 0); } } else if(QString(prop->name) == "paused-for-cache") { if(prop->format == MPV_FORMAT_FLAG) { if((bool)*(unsigned*)prop->data && playState == Mpv::Playing) ShowText(tr("Your network is slow or stuck, please wait a bit"), 0); else ShowText(QString(), 0); } } break; } case MPV_EVENT_IDLE: fileInfo.length = 0; setTime(0); setPlayState(Mpv::Idle); break; // these two look like they're reversed but they aren't. the names are misleading. case MPV_EVENT_START_FILE: setPlayState(Mpv::Loaded); break; case MPV_EVENT_FILE_LOADED: setPlayState(Mpv::Started); LoadFileInfo(); SetProperties(); case MPV_EVENT_UNPAUSE: setPlayState(Mpv::Playing); break; case MPV_EVENT_PAUSE: setPlayState(Mpv::Paused); ShowText(QString(), 0); break; case MPV_EVENT_END_FILE: if(playState == Mpv::Loaded) ShowText(tr("File couldn't be opened")); setPlayState(Mpv::Stopped); break; case MPV_EVENT_SHUTDOWN: QCoreApplication::quit(); break; case MPV_EVENT_LOG_MESSAGE: { mpv_event_log_message *message = static_cast<mpv_event_log_message*>(event->data); if(message != nullptr) emit messageSignal(message->text); break; } default: // unhandled events break; } } return true; } return QObject::event(event); }
bool QOpenSLESAudioOutput::preparePlayer() { if (m_startRequiresInit) destroyPlayer(); else return true; SLEngineItf engine = QOpenSLESEngine::instance()->slEngine(); if (!engine) { qWarning() << "No engine"; setError(QAudio::FatalError); return false; } SLDataLocator_BufferQueue bufferQueueLocator = { SL_DATALOCATOR_BUFFERQUEUE, BUFFER_COUNT }; SLDataFormat_PCM pcmFormat = QOpenSLESEngine::audioFormatToSLFormatPCM(m_format); SLDataSource audioSrc = { &bufferQueueLocator, &pcmFormat }; // OutputMix if (SL_RESULT_SUCCESS != (*engine)->CreateOutputMix(engine, &m_outputMixObject, 0, Q_NULLPTR, Q_NULLPTR)) { qWarning() << "Unable to create output mix"; setError(QAudio::FatalError); return false; } if (SL_RESULT_SUCCESS != (*m_outputMixObject)->Realize(m_outputMixObject, SL_BOOLEAN_FALSE)) { qWarning() << "Unable to initialize output mix"; setError(QAudio::FatalError); return false; } SLDataLocator_OutputMix outputMixLocator = { SL_DATALOCATOR_OUTPUTMIX, m_outputMixObject }; SLDataSink audioSink = { &outputMixLocator, Q_NULLPTR }; #ifndef ANDROID const int iids = 2; const SLInterfaceID ids[iids] = { SL_IID_BUFFERQUEUE, SL_IID_VOLUME }; const SLboolean req[iids] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE }; #else const int iids = 3; const SLInterfaceID ids[iids] = { SL_IID_BUFFERQUEUE, SL_IID_VOLUME, SL_IID_ANDROIDCONFIGURATION }; const SLboolean req[iids] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE }; #endif // ANDROID // AudioPlayer if (SL_RESULT_SUCCESS != (*engine)->CreateAudioPlayer(engine, &m_playerObject, &audioSrc, &audioSink, iids, ids, req)) { qWarning() << "Unable to create AudioPlayer"; setError(QAudio::OpenError); return false; } #ifdef ANDROID // Set profile/category SLAndroidConfigurationItf playerConfig; if (SL_RESULT_SUCCESS == (*m_playerObject)->GetInterface(m_playerObject, SL_IID_ANDROIDCONFIGURATION, &playerConfig)) { (*playerConfig)->SetConfiguration(playerConfig, SL_ANDROID_KEY_STREAM_TYPE, &m_streamType, sizeof(SLint32)); } #endif // ANDROID if (SL_RESULT_SUCCESS != (*m_playerObject)->Realize(m_playerObject, SL_BOOLEAN_FALSE)) { qWarning() << "Unable to initialize AudioPlayer"; setError(QAudio::OpenError); return false; } // Buffer interface if (SL_RESULT_SUCCESS != (*m_playerObject)->GetInterface(m_playerObject, SL_IID_BUFFERQUEUE, &m_bufferQueueItf)) { setError(QAudio::FatalError); return false; } if (SL_RESULT_SUCCESS != (*m_bufferQueueItf)->RegisterCallback(m_bufferQueueItf, bufferQueueCallback, this)) { setError(QAudio::FatalError); return false; } // Play interface if (SL_RESULT_SUCCESS != (*m_playerObject)->GetInterface(m_playerObject, SL_IID_PLAY, &m_playItf)) { setError(QAudio::FatalError); return false; } if (SL_RESULT_SUCCESS != (*m_playItf)->RegisterCallback(m_playItf, playCallback, this)) { setError(QAudio::FatalError); return false; } if (m_notifyInterval && SL_RESULT_SUCCESS == (*m_playItf)->SetPositionUpdatePeriod(m_playItf, m_notifyInterval)) { m_eventMask |= SL_PLAYEVENT_HEADATNEWPOS; } if (SL_RESULT_SUCCESS != (*m_playItf)->SetCallbackEventsMask(m_playItf, m_eventMask)) { setError(QAudio::FatalError); return false; } // Volume interface if (SL_RESULT_SUCCESS != (*m_playerObject)->GetInterface(m_playerObject, SL_IID_VOLUME, &m_volumeItf)) { setError(QAudio::FatalError); return false; } setVolume(m_volume); // Buffer size if (m_bufferSize <= 0) { m_bufferSize = m_format.bytesForDuration(DEFAULT_PERIOD_TIME_MS * 1000); } else { const int minimumBufSize = m_format.bytesForDuration(MINIMUM_PERIOD_TIME_MS * 1000); if (m_bufferSize < minimumBufSize) m_bufferSize = minimumBufSize; } m_periodSize = m_bufferSize; if (!m_buffers) m_buffers = new char[BUFFER_COUNT * m_bufferSize]; m_clockStamp.restart(); setError(QAudio::NoError); m_startRequiresInit = false; return true; }
void Tune::setVolume(byte volume) { setVolume(volume, volume); }
void PanelPreviewSound::onVolumeChange(wxScrollEvent &UNUSED(event)) { setVolume(); }
void MediaPluginGStreamer010::receiveMessage(const char *message_string) { //std::cerr << "MediaPluginGStreamer010::receiveMessage: received message: \"" << message_string << "\"" << std::endl; LLPluginMessage message_in; if(message_in.parse(message_string) >= 0) { std::string message_class = message_in.getClass(); std::string message_name = message_in.getName(); if(message_class == LLPLUGIN_MESSAGE_CLASS_BASE) { if(message_name == "init") { LLPluginMessage message("base", "init_response"); LLSD versions = LLSD::emptyMap(); versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION; versions[LLPLUGIN_MESSAGE_CLASS_MEDIA] = LLPLUGIN_MESSAGE_CLASS_MEDIA_VERSION; versions[LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME] = LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME_VERSION; message.setValueLLSD("versions", versions); if ( load() ) { DEBUGMSG("GStreamer010 media instance set up"); } else { WARNMSG("GStreamer010 media instance failed to set up"); } message.setValue("plugin_version", getVersion()); sendMessage(message); } else if(message_name == "idle") { // no response is necessary here. double time = message_in.getValueReal("time"); // Convert time to milliseconds for update() update((int)(time * 1000.0f)); } else if(message_name == "cleanup") { unload(); closedown(); } else if(message_name == "shm_added") { SharedSegmentInfo info; info.mAddress = message_in.getValuePointer("address"); info.mSize = (size_t)message_in.getValueS32("size"); std::string name = message_in.getValue("name"); std::ostringstream str; INFOMSG("MediaPluginGStreamer010::receiveMessage: shared memory added, name: %s, size: %d, address: %p", name.c_str(), int(info.mSize), info.mAddress); mSharedSegments.insert(SharedSegmentMap::value_type(name, info)); } else if(message_name == "shm_remove") { std::string name = message_in.getValue("name"); DEBUGMSG("MediaPluginGStreamer010::receiveMessage: shared memory remove, name = %s", name.c_str()); SharedSegmentMap::iterator iter = mSharedSegments.find(name); if(iter != mSharedSegments.end()) { if(mPixels == iter->second.mAddress) { // This is the currently active pixel buffer. Make sure we stop drawing to it. mPixels = NULL; mTextureSegmentName.clear(); // Make sure the movie decoder is no longer pointed at the shared segment. sizeChanged(); } mSharedSegments.erase(iter); } else { WARNMSG("MediaPluginGStreamer010::receiveMessage: unknown shared memory region!"); } // Send the response so it can be cleaned up. LLPluginMessage message("base", "shm_remove_response"); message.setValue("name", name); sendMessage(message); } else { std::ostringstream str; INFOMSG("MediaPluginGStreamer010::receiveMessage: unknown base message: %s", message_name.c_str()); } } else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA) { if(message_name == "init") { // Plugin gets to decide the texture parameters to use. LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params"); // lame to have to decide this now, it depends on the movie. Oh well. mDepth = 4; mCurrentWidth = 1; mCurrentHeight = 1; mPreviousWidth = 1; mPreviousHeight = 1; mNaturalWidth = 1; mNaturalHeight = 1; mWidth = 1; mHeight = 1; mTextureWidth = 1; mTextureHeight = 1; message.setValueU32("format", GL_RGBA); message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8_REV); message.setValueS32("depth", mDepth); message.setValueS32("default_width", mWidth); message.setValueS32("default_height", mHeight); message.setValueU32("internalformat", GL_RGBA8); message.setValueBoolean("coords_opengl", true); // true == use OpenGL-style coordinates, false == (0,0) is upper left. message.setValueBoolean("allow_downsample", true); // we respond with grace and performance if asked to downscale sendMessage(message); } else if(message_name == "size_change") { std::string name = message_in.getValue("name"); S32 width = message_in.getValueS32("width"); S32 height = message_in.getValueS32("height"); S32 texture_width = message_in.getValueS32("texture_width"); S32 texture_height = message_in.getValueS32("texture_height"); std::ostringstream str; INFOMSG("---->Got size change instruction from application with shm name: %s - size is %d x %d", name.c_str(), width, height); LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_response"); message.setValue("name", name); message.setValueS32("width", width); message.setValueS32("height", height); message.setValueS32("texture_width", texture_width); message.setValueS32("texture_height", texture_height); sendMessage(message); if(!name.empty()) { // Find the shared memory region with this name SharedSegmentMap::iterator iter = mSharedSegments.find(name); if(iter != mSharedSegments.end()) { INFOMSG("*** Got size change with matching shm, new size is %d x %d", width, height); INFOMSG("*** Got size change with matching shm, texture size size is %d x %d", texture_width, texture_height); mPixels = (unsigned char*)iter->second.mAddress; mTextureSegmentName = name; mWidth = width; mHeight = height; if (texture_width > 1 || texture_height > 1) // not a dummy size from the app, a real explicit forced size { INFOMSG("**** = REAL RESIZE REQUEST FROM APP"); GST_OBJECT_LOCK(mVideoSink); mVideoSink->resize_forced_always = true; mVideoSink->resize_try_width = texture_width; mVideoSink->resize_try_height = texture_height; GST_OBJECT_UNLOCK(mVideoSink); } mTextureWidth = texture_width; mTextureHeight = texture_height; } } } else if(message_name == "load_uri") { std::string uri = message_in.getValue("uri"); navigateTo( uri ); sendStatus(); } else if(message_name == "mouse_event") { std::string event = message_in.getValue("event"); S32 x = message_in.getValueS32("x"); S32 y = message_in.getValueS32("y"); if(event == "down") { mouseDown(x, y); } else if(event == "up") { mouseUp(x, y); } else if(event == "move") { mouseMove(x, y); }; }; } else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME) { if(message_name == "stop") { stop(); } else if(message_name == "start") { double rate = 0.0; if(message_in.hasValue("rate")) { rate = message_in.getValueReal("rate"); } // NOTE: we don't actually support rate. play(rate); } else if(message_name == "pause") { pause(); } else if(message_name == "seek") { double time = message_in.getValueReal("time"); // defer the actual seek in case we haven't // really truly started yet in which case there // is nothing to seek upon mSeekWanted = true; mSeekDestination = time; } else if(message_name == "set_loop") { bool loop = message_in.getValueBoolean("loop"); mIsLooping = loop; } else if(message_name == "set_volume") { double volume = message_in.getValueReal("volume"); setVolume(volume); } } else { INFOMSG("MediaPluginGStreamer010::receiveMessage: unknown message class: %s", message_class.c_str()); } } }
void GameSound::init() { #ifdef HAVE_SDL_SDL_MIXER_H initLsSound( &lsTrapSafe, "trap/safe/" ); initLsSound( &lsTrapDisarm, "trap/disarm/" ); initLsSound( &lsTrapCaught, "trap/caught/" ); initLsSound( &lsSpellSor, "spell/sor/" ); initLsSound( &lsSpellEnc, "spell/enc/" ); initLsSound( &lsSpellNin, "spell/nin/" ); initLsSound( &lsSpellBar, "spell/bar/" ); initLsSound( &lsSpellMag, "spell/mag/" ); initLsSound( &lsSpellSum, "spell/sum/" ); initLsSound( &lsSpellSha, "spell/sha/" ); initLsSound( &lsSpellPri, "spell/pri/" ); initLsSound( &lsBlastMember, "blast/member/" ); initLsSound( &lsBlastMonster, "blast/monster/" ); initLsSound( &lsBlastDestruction, "blast/destruction/" ); initLsSound( &lsMenuCancel, "menu/cancel/" ); initLsSound( &lsMenuSelect, "menu/select/" ); initLsSound( &lsFightDieMember, "fight/die/member/" ); initLsSound( &lsFightDieMonsterBossLast, "fight/die/monster/boss/last/" ); initLsSound( &lsFightDieMonsterBoss, "fight/die/monster/boss/" ); initLsSound( &lsFightDieMonster, "fight/die/monster/" ); initLsSound( &lsFightDefenseMissMember, "fight/defense/miss/member/" ); initLsSound( &lsFightDefenseMissMonsterBossLast, "fight/defense/miss/monster/boss/last/" ); initLsSound( &lsFightDefenseMissMonster, "fight/defense/miss/monster/" ); initLsSound( &lsFightDefenseHitMember, "fight/defense/hit/member/" ); initLsSound( &lsFightDefenseHitMonster, "fight/defense/hit/monster/" ); initLsSound( &lsFightDefenseCriticalMember, "fight/defense/critical/member/" ); initLsSound( &lsFightDefenseCriticalMonster, "fight/defense/critical/monster/" ); initLsSound( &lsFightFindMember, "fight/find/member/" ); initLsSound( &lsFightFindMonsterBoss, "fight/find/monster/boss/" ); initLsSound( &lsFightFindMonster, "fight/find/monster/" ); initLsSound( &lsFightAttackLastBossAttack, "fight/attack/last_boss/attack/" ); initLsSound( &lsFightAttackLastBossWeaken, "fight/attack/last_boss/weaken/" ); initLsSound( &lsFightAttackLastBossSlap, "fight/attack/last_boss/slap/" ); initLsSound( &lsFightAttackThrowMember, "fight/attack/throw/member/" ); initLsSound( &lsFightAttackThrowMonster, "fight/attack/throw/monster/" ); initLsSound( &lsRequestFinish, "request/finish/" ); initLsSound( &lsShopSale, "shop/sale/" ); initLsSound( &lsShopBuyDrink, "shop/buy/drink/" ); initLsSound( &lsShopBuy, "shop/buy/" ); initLsSound( &lsEventGate, "event/gate/" ); initLsSound( &lsEventDrive, "event/drive/" ); initLsSound( &lsEventEarthquake, "event/earthquake/" ); initLsSound( &lsLevelDown, "level/down/" ); initLsSound( &lsLevelUp, "level/up/" ); initLsSound( &lsDoorClose, "door/close/" ); initLsSound( &lsDoorOpen, "door/open/" ); initLsSound( &lsStairsDown, "stairs/down/" ); initLsSound( &lsStairsUp, "stairs/up/" ); initLsSound( &lsItemUse, "item/use/" ); initLsSound( &lsItemOpen, "item/open/" ); initLsSound( &lsItemSmoke, "item/smoke/" ); initLsSound( &lsActionAppear, "action/appear/" ); initLsSound( &lsActionTeleportRecall, "action/teleport/recall/" ); initLsSound( &lsActionTeleportParty, "action/teleport/party/" ); initLsSound( &lsActionTeleportShort, "action/teleport/short/" ); initLsSound( &lsActionTeleportLong, "action/teleport/long/" ); #endif // 音量 setVolume( get_sound_volume_rate() ); flagEnable = true; }
void PrefetchData::initialize(Volume* v) { setVolume(v); }
bool open(xine_t* xine, const std::string& filename) { if (filename==getFileName()) return true; _xine = xine; // create visual rgbout_visual_info_t* visual = new rgbout_visual_info_t; visual->levels = PXLEVEL_ALL; visual->format = PX_RGB32; visual->user_data = this; visual->callback = my_render_frame; // set up video driver _vo = xine_open_video_driver(_xine, "rgb", XINE_VISUAL_TYPE_RGBOUT, (void*)visual); // set up audio driver char* audio_driver = getenv("OSG_XINE_AUDIO_DRIVER"); _ao = audio_driver ? xine_open_audio_driver(_xine, audio_driver, NULL) : xine_open_audio_driver(_xine, "auto", NULL); if (!_vo) { OSG_NOTICE<<"XineImageStream::open() : Failed to create video driver"<<std::endl; return false; } // set up stream _stream = xine_stream_new(_xine, _ao, _vo); if (_stream) { if (_volume < 0.0) { _volume = static_cast<float>(xine_get_param(_stream, XINE_PARAM_AUDIO_VOLUME))/100.0f; } else { setVolume(_volume); } } _event_queue = xine_event_new_queue(_stream); xine_event_create_listener_thread(_event_queue, event_listener, this); int result = xine_open(_stream, filename.c_str()); if (result==0) { OSG_INFO<<"XineImageStream::open() : Could not ready movie file."<<std::endl; close(); return false; } _ready = false; int width = xine_get_stream_info(_stream,XINE_STREAM_INFO_VIDEO_WIDTH); int height = xine_get_stream_info(_stream,XINE_STREAM_INFO_VIDEO_HEIGHT); allocateImage(width,height,1,GL_RGB,GL_UNSIGNED_BYTE,1); OSG_INFO<<"XineImageStream::open() size "<<width<<" "<<height<<std::endl; // play(); return true; }
void MediaPlayer::incrementVolume() { setVolume(volume()+1); }
HRESULT XAudio2SubmixVoiceProxy::SetVolume(float Volume, UINT32 OperationSet) { setVolume(Volume, OperationSet); return S_OK; }
void ProcessCommand(char *command) { char *s; char *s2; char *s3; char *s4; char *response2 = NULL; int i; char NextPlaylist[128] = "No playlist scheduled."; char NextScheduleStartText[64] = ""; char CommandStr[64]; LogExcess(VB_COMMAND, "CMD: %s\n", command); s = strtok(command,","); strcpy(CommandStr, s); if (!strcmp(CommandStr, "s")) { Json::Value info = player->GetCurrentPlaylistInfo(); char currentEntryType = 'u'; // Unknown const char *currentSequenceName = NULL; const char *currentMediaName = NULL; if (info["currentEntry"].isMember("sequenceName")) currentSequenceName = info["currentEntry"]["sequenceName"].asString().c_str(); if (info["currentEntry"].isMember("mediaFilename")) currentMediaName = info["currentEntry"]["mediaFilename"].asString().c_str(); if (info["currentEntry"].isMember("type")) { std::string type = info["currentEntry"]["type"].asString(); if (type == "both") currentEntryType = 'b'; else if (type == "event") currentEntryType = 'e'; else if (type == "media") currentEntryType = 'm'; else if (type == "pause") currentEntryType = 'p'; else if (type == "plugin") currentEntryType = 'P'; else if (type == "sequence") currentEntryType = 's'; } player->GetNextScheduleStartText(NextScheduleStartText); player->GetNextPlaylistText(NextPlaylist); if(FPPstatus==FPP_STATUS_IDLE) { if (getFPPmode() == REMOTE_MODE) { sprintf(response,"%d,%d,%d,%s,%s,%d,%d\n", getFPPmode(), 0, getVolume(), currentSequenceName, currentMediaName, player->GetPlaybackSecondsElapsed(), player->GetPlaybackSecondsRemaining()); } else { sprintf(response,"%d,%d,%d,%s,%s\n", getFPPmode(),0,getVolume(), NextPlaylist,NextScheduleStartText); } } else { sprintf(response,"%d,%d,%d,%s,%c,%s,%s,%d,%d,%d,%d,%s,%s,%d\n", getFPPmode(),FPPstatus,getVolume(), info["name"].asString().c_str(), currentEntryType, currentSequenceName, currentMediaName, info["currentPosition"].asInt() + 1, info["size"].asInt(), info["currentEntry"]["secondsElapsed"].asInt(), info["currentEntry"]["secondsRemaining"].asInt(), NextPlaylist,NextScheduleStartText, info["repeat"].asInt()); } } else if ((!strcmp(CommandStr, "p")) || (!strcmp(CommandStr, "P"))) { if(FPPstatus==FPP_STATUS_PLAYLIST_PLAYING || FPPstatus==FPP_STATUS_STOPPING_GRACEFULLY) { player->PlaylistStopNow(); sleep(1); } s = strtok(NULL,","); if (s) { std::string playlistName(s); int repeat = !strcmp(CommandStr, "p") ? 1 : 0; int position = 0; s = strtok(NULL,","); if (s) position = atoi(s); if (player->PlaylistStart(playlistName, position, repeat)) { sprintf(response,"%d,%d,Playlist Started,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS); } else { sprintf(response,"%d,%d,Playlist Start Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED); } } else { sprintf(response,"%d,%d,Unknown Playlist,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED); } } else if (!strcmp(CommandStr, "S")) { if(FPPstatus==FPP_STATUS_PLAYLIST_PLAYING) { player->PlaylistStopGracefully(); player->ReLoadCurrentScheduleInfo(); sprintf(response,"%d,%d,Playlist Stopping Gracefully,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS); } else { sprintf(response,"%d,Not playing,,,,,,,,,,,\n",COMMAND_FAILED); } } else if (!strcmp(CommandStr, "d")) { if(FPPstatus==FPP_STATUS_PLAYLIST_PLAYING || FPPstatus==FPP_STATUS_STOPPING_GRACEFULLY) { player->PlaylistStopNow(); player->ReLoadCurrentScheduleInfo(); sprintf(response,"%d,%d,Playlist Stopping Now,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS); } else { sprintf(response,"%d,%d,Not playing,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED); } } else if (!strcmp(CommandStr, "R")) { if(FPPstatus==FPP_STATUS_IDLE) { player->ReLoadCurrentScheduleInfo(); } player->ReLoadNextScheduleInfo(); sprintf(response,"%d,%d,Reloading Schedule,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS); } else if (!strcmp(CommandStr, "v")) { s = strtok(NULL,","); if (s) { setVolume(atoi(s)); sprintf(response,"%d,%d,Setting Volume,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS); } else { sprintf(response,"%d,%d,Invalid Volume,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED); } } else if (!strcmp(CommandStr, "w")) { LogInfo(VB_SETTING, "Sending Falcon hardware config\n"); if (!DetectFalconHardware(1)) SendFPDConfig(); } else if (!strcmp(CommandStr, "r")) { WriteBytesReceivedFile(); sprintf(response,"true\n"); } else if (!strcmp(CommandStr, "q")) { // Quit/Shutdown fppd ShutdownFPPD(); } else if (!strcmp(CommandStr, "e")) { // Start an Effect s = strtok(NULL,","); s2 = strtok(NULL,","); s3 = strtok(NULL,","); if (s && s2) { i = StartEffect(s, atoi(s2), atoi(s3)); if (i >= 0) sprintf(response,"%d,%d,Starting Effect,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i); else sprintf(response,"%d,%d,Invalid Effect,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED); } else sprintf(response,"%d,%d,Invalid Effect,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED); } else if (!strcmp(CommandStr, "t")) { // Trigger an event s = strtok(NULL,","); pluginCallbackManager.eventCallback(s, "command"); i = TriggerEventByID(s); if (i >= 0) sprintf(response,"%d,%d,Event Triggered,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i); else sprintf(response,"%d,%d,Event Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED); } else if (!strcmp(CommandStr, "GetTestMode")) { strcpy(response, channelTester->GetConfig().c_str()); strcat(response, "\n"); } else if (!strcmp(CommandStr, "SetTestMode")) { if (channelTester->SetupTest(std::string(s + strlen(s) + 1))) { sprintf(response, "0,%d,Test Mode Activated,,,,,,,,,\n", COMMAND_SUCCESS); } else { sprintf(response, "0,%d,Test Mode Deactivated,,,,,,,,,\n", COMMAND_SUCCESS); } } else if (!strcmp(CommandStr, "LogLevel")) { s = strtok(NULL,","); if (SetLogLevel(s)) { sprintf(response,"%d,%d,Log Level Updated,%d,%d,,,,,,,,,\n", getFPPmode(),COMMAND_SUCCESS,logLevel,logMask); } else { sprintf(response,"%d,%d,Error Updating Log Level,%d,%d,,,,,,,,,\n", getFPPmode(),COMMAND_FAILED,logLevel,logMask); } } else if (!strcmp(CommandStr, "LogMask")) { s = strtok(NULL,","); if ((s && SetLogMask(s)) || SetLogMask("")) { sprintf(response,"%d,%d,Log Mask Updated,%d,%d,,,,,,,,,\n", getFPPmode(),COMMAND_SUCCESS,logLevel,logMask); } else { sprintf(response,"%d,%d,Error Updating Log Mask,%d,%d,,,,,,,,,\n", getFPPmode(),COMMAND_FAILED,logLevel,logMask); } } else if (!strcmp(CommandStr, "SetSetting")) { char name[128]; s = strtok(NULL,","); if (s) { strcpy(name, s); s = strtok(NULL,","); if (s) parseSetting(name, s); } } else if (!strcmp(CommandStr, "StopAllEffects")) { StopAllEffects(); sprintf(response,"%d,%d,All Effects Stopped,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS); } else if (!strcmp(CommandStr, "StopEffectByName")) { s = strtok(NULL,","); if (strlen(s)) { if (StopEffect(s)) sprintf(response,"%d,%d,Stopping Effect,%s,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,s); else sprintf(response,"%d,%d,Stop Effect Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED); } } else if (!strcmp(CommandStr, "StopEffect")) { s = strtok(NULL,","); i = atoi(s); if (StopEffect(i)) sprintf(response,"%d,%d,Stopping Effect,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,i); else sprintf(response,"%d,%d,Stop Effect Failed,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED); } else if (!strcmp(CommandStr, "GetRunningEffects")) { sprintf(response,"%d,%d,Running Effects",getFPPmode(),COMMAND_SUCCESS); GetRunningEffects(response, &response2); } else if (!strcmp(CommandStr, "ReloadChannelRemapData")) { if ((FPPstatus==FPP_STATUS_IDLE) && (LoadChannelRemapData())) { sprintf(response,"%d,%d,Channel Remap Data Reloaded,,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS); } else { sprintf(response,"%d,%d,Failed to reload Channel Remap Data,,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED); } } else if (!strcmp(CommandStr, "GetFPPDUptime")) { sprintf(response,"%d,%d,FPPD Uptime,%d,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS, time(NULL) - fppdStartTime); } else if (!strcmp(CommandStr, "StartSequence")) { s = strtok(NULL,","); s2 = strtok(NULL,","); if (s && s2) { i = atoi(s2); player->StartSequence(s, 0, i); sprintf(response,"%d,%d,Sequence Started,,,,,,,,,,,,\n", getFPPmode(), COMMAND_SUCCESS); } else { LogErr(VB_COMMAND, "Tried to start a sequence when a playlist or " "sequence is already running\n"); sprintf(response,"%d,%d,Sequence Failed,,,,,,,,,,,,\n", getFPPmode(), COMMAND_FAILED); } } else if (!strcmp(CommandStr, "StopSequence")) { s = strtok(NULL,","); if (s) { player->StopSequence(s); sprintf(response,"%d,%d,Sequence Stopped,,,,,,,,,,,,\n", getFPPmode(), COMMAND_SUCCESS); } else { LogDebug(VB_COMMAND, "Invalid command: %s\n", command); sprintf(response,"%d,%d,Sequence Name Missing,,,,,,,,,,,,\n", getFPPmode(), COMMAND_FAILED); } } else if (!strcmp(CommandStr, "ToggleSequencePause")) { if ((player->SequencesRunning()) && ((FPPstatus == FPP_STATUS_IDLE) || (FPPstatus != FPP_STATUS_IDLE))) { player->ToggleSequencePause(); } } else if (!strcmp(CommandStr, "SingleStepSequence")) { if ((player->SequencesRunning()) && (player->SequencesArePaused()) && ((FPPstatus == FPP_STATUS_IDLE) || ((FPPstatus != FPP_STATUS_IDLE)))) { player->SingleStepSequences(); } } else if (!strcmp(CommandStr, "SingleStepSequenceBack")) { if ((player->SequencesRunning()) && (player->SequencesArePaused()) && ((FPPstatus == FPP_STATUS_IDLE) || ((FPPstatus != FPP_STATUS_IDLE)))) { player->SingleStepSequencesBack(); } } else if (!strcmp(CommandStr, "NextPlaylistItem")) { switch (FPPstatus) { case FPP_STATUS_IDLE: sprintf(response,"%d,%d,No playlist running\n",getFPPmode(),COMMAND_FAILED); break; case FPP_STATUS_PLAYLIST_PLAYING: sprintf(response,"%d,%d,Skipping to next playlist item\n",getFPPmode(),COMMAND_SUCCESS); player->NextPlaylistItem(); break; case FPP_STATUS_STOPPING_GRACEFULLY: sprintf(response,"%d,%d,Playlist is stopping gracefully\n",getFPPmode(),COMMAND_FAILED); break; } } else if (!strcmp(CommandStr, "PrevPlaylistItem")) { switch (FPPstatus) { case FPP_STATUS_IDLE: sprintf(response,"%d,%d,No playlist running\n",getFPPmode(),COMMAND_FAILED); break; case FPP_STATUS_PLAYLIST_PLAYING: sprintf(response,"%d,%d,Skipping to previous playlist item\n",getFPPmode(),COMMAND_SUCCESS); player->PrevPlaylistItem(); break; case FPP_STATUS_STOPPING_GRACEFULLY: sprintf(response,"%d,%d,Playlist is stopping gracefully\n",getFPPmode(),COMMAND_FAILED); break; } } else if (!strcmp(CommandStr, "SetupExtGPIO")) { // Configure the given GPIO to the given mode s = strtok(NULL,","); s2 = strtok(NULL,","); if (s && s2) { if (!SetupExtGPIO(atoi(s), s2)) { sprintf(response, "%d,%d,Configuring GPIO,%d,%s,,,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,atoi(s),s2); } else { sprintf(response, "%d,%d,Configuring GPIO,%d,%s,,,,,,,,,\n",getFPPmode(),COMMAND_FAILED,atoi(s),s2); } } } else if (!strcmp(CommandStr, "ExtGPIO")) { s = strtok(NULL,","); s2 = strtok(NULL,","); s3 = strtok(NULL,","); if (s && s2 && s3) { i = ExtGPIO(atoi(s), s2, atoi(s3)); if (i >= 0) { sprintf(response, "%d,%d,Setting GPIO,%d,%s,%d,%d,,,,,,,\n",getFPPmode(),COMMAND_SUCCESS,atoi(s),s2,atoi(s3),i); } else { sprintf(response, "%d,%d,Setting GPIO,%d,%s,%d,,,,,,,,\n",getFPPmode(),COMMAND_FAILED,atoi(s),s2,atoi(s3)); } } } else { sprintf(response,"Invalid command: '%s'\n", CommandStr); } if (response2) { bytes_sent = sendto(socket_fd, response2, strlen(response2), 0, (struct sockaddr *) &(client_address), sizeof(struct sockaddr_un)); LogDebug(VB_COMMAND, "%s %s", CommandStr, response2); free(response2); response2 = NULL; } else { bytes_sent = sendto(socket_fd, response, strlen(response), 0, (struct sockaddr *) &(client_address), sizeof(struct sockaddr_un)); LogDebug(VB_COMMAND, "%s %s", CommandStr, response); } }