void gdPluginList::refreshList() { /* delete the previous list */ list->clear(); list->scroll_to(0, 0); /* add new buttons, as many as the plugin in pluginHost::stack + 1, * the 'add new' button. Warning: if ch == NULL we are working with * master in/master out stacks. */ int numPlugins = G_PluginHost.countPlugins(stackType, ch); int i = 0; while (i<numPlugins) { Plugin *pPlugin = G_PluginHost.getPluginByIndex(i, stackType, ch); gdPlugin *gdp = new gdPlugin(this, pPlugin, list->x(), list->y()-list->yposition()+(i*24), 800); list->add(gdp); i++; } int addPlugY = numPlugins == 0 ? 90 : list->y()-list->yposition()+(i*24); addPlugin = new gClick(8, addPlugY, 452, 20, "-- add new plugin --"); addPlugin->callback(cb_addPlugin, (void*)this); list->add(addPlugin); /* if num(plugins) > 7 make room for the side scrollbar. * Scrollbar.width = 20 + 4(margin) */ if (i>7) size(492, h()); else size(468, h()); redraw(); /* set 'full' flag to FX button */ /* TODO - awful stuff... we should subclass into gdPluginListChannel and gdPluginListMaster */ if (stackType == PluginHost::MASTER_OUT) { mainWin->inOut->setMasterFxOutFull(G_PluginHost.countPlugins(stackType, ch) > 0); } else if (stackType == PluginHost::MASTER_IN) { mainWin->inOut->setMasterFxInFull(G_PluginHost.countPlugins(stackType, ch) > 0); } else { ch->guiChannel->fx->full = G_PluginHost.countPlugins(stackType, ch) > 0; ch->guiChannel->fx->redraw(); } }
void gdPlugin::__cb_shiftUp() { /*nothing to do if there's only one plugin */ if (G_PluginHost.countPlugins(pParent->stackType, pParent->ch) == 1) return; int pluginIndex = G_PluginHost.getPluginIndex(pPlugin->getId(), pParent->stackType, pParent->ch); if (pluginIndex == 0) // first of the stack, do nothing return; G_PluginHost.swapPlugin(pluginIndex, pluginIndex-1, pParent->stackType, pParent->ch); pParent->refreshList(); }
void gdPlugin::__cb_shiftDown() { /*nothing to do if there's only one plugin */ if (G_PluginHost.countPlugins(pParent->stackType, pParent->ch) == 1) return; unsigned pluginIndex = G_PluginHost.getPluginIndex(pPlugin->getId(), pParent->stackType, pParent->ch); unsigned stackSize = (G_PluginHost.getStack(pParent->stackType, pParent->ch))->size(); if (pluginIndex == stackSize-1) // last one in the stack, do nothing return; G_PluginHost.swapPlugin(pluginIndex, pluginIndex+1, pParent->stackType, pParent->ch); pParent->refreshList(); }
void PluginManager::loadPlugins() { foreach(const QString& d, pluginsDirs()) { QDir dir(d); if(dir.exists()) { foreach(const QString& file, dir.entryList(QDir::Files)) { PluginHost* host = new PluginHost(d + '/' + file, this); if(host->isValid()) { bool en = isPluginEnabled(host->name()); PluginPair pp = qMakePair(host, en); plugins_.append(pp); if(en) en = host->load(); emit pluginStatusChanged(host->name(), en); } else delete host; } }
status_t MediaStreamSource::getSize(off64_t *size) { uint64_t length = mPluginHost->GetLength(mDecoder); if (length == static_cast<uint64_t>(-1)) return ERROR_UNSUPPORTED; *size = length; return OK; }
void SampleChannel::process(float *buffer) { #ifdef WITH_VST G_PluginHost.processStack(vChan, PluginHost::CHANNEL, this); #endif for (int j=0; j<bufferSize; j+=2) { buffer[j] += vChan[j] * volume * panLeft * boost; buffer[j+1] += vChan[j+1] * volume * panRight * boost; } }
void glue_resetToInitState(bool resetGui) { G_Mixer.running = false; for (unsigned i=0; i<MAX_NUM_CHAN; i++) mh_freeChan(i); recorder::init(); G_Patch.setDefault(); G_Mixer.init(); #ifdef WITH_VST G_PluginHost.freeAllStacks(); #endif if (resetGui) gu_update_controls(); }
void gdPluginList::refreshList() { /* delete the previous list */ list->clear(); list->scroll_to(0, 0); /* add new buttons, as many as the plugin in pluginHost::stack + 1, * the 'add new' button. Warning: if ch == NULL we are working with * master in/master out stacks. */ int numPlugins = G_PluginHost.countPlugins(stackType, ch); int i = 0; while (i<numPlugins) { Plugin *pPlugin = G_PluginHost.getPluginByIndex(i, stackType, ch); gdPlugin *gdp = new gdPlugin(this, pPlugin, list->x(), list->y()-list->yposition()+(i*24), 800); list->add(gdp); i++; } int addPlugY = numPlugins == 0 ? 90 : list->y()-list->yposition()+(i*24); addPlugin = new gClick(8, addPlugY, 452, 20, "-- add new plugin --"); addPlugin->callback(cb_addPlugin, (void*)this); list->add(addPlugin); /* if num(plugins) > 7 make room for the side scrollbar. * Scrollbar.width = 20 + 4(margin) */ if (i>7) size(492, h()); else size(468, h()); redraw(); }
ssize_t MediaStreamSource::readAt(off64_t offset, void *data, size_t size) { char *ptr = reinterpret_cast<char *>(data); size_t todo = size; while (todo > 0) { uint32_t bytesRead; if (!mPluginHost->Read(mDecoder, ptr, offset, todo, &bytesRead)) { return ERROR_IO; } offset += bytesRead; todo -= bytesRead; ptr += bytesRead; } return size; }
void gdPlugin::__cb_removePlugin() { /* os x hack: show window before deleting it */ #ifdef __APPLE__ gdPluginWindowGUImac* w = (gdPluginWindowGUImac*) pParent->getChild(pPlugin->getId()+1); if (w) w->show(); #endif /* any subwindow linked to the plugin must be destroyed */ pParent->delSubWindow(pPlugin->getId()+1); G_PluginHost.freePlugin(pPlugin->getId(), pParent->stackType, pParent->ch); pParent->refreshList(); }
void gdBrowser::__cb_loadPlugin() { if (browser->text(browser->value()) == NULL) return; int res = G_PluginHost.addPlugin(browser->get_selected_item(), stackType, ch); /* store the folder path inside G_Conf, in order to reuse it the * next time. */ G_Conf.setPath(G_Conf.pluginPath, where->value()); if (res) do_callback(); else gdAlert("Unable to load the selected plugin!"); }
static int __mh_readPatchPlugins__(vector<Patch::plugin_t> *list, int type) { int ret = 1; for (unsigned i=0; i<list->size(); i++) { Patch::plugin_t *ppl = &list->at(i); Plugin *plugin = G_PluginHost.addPlugin(ppl->path.c_str(), type, NULL); if (plugin != NULL) { plugin->setBypass(ppl->bypass); for (unsigned j=0; j<ppl->params.size(); j++) plugin->setParameter(j, ppl->params.at(j)); ret &= 1; } else ret &= 0; } return ret; }
void gdMainWindow::__cb_endprogram() { if (!gdConfirmWin("Warning", "Quit Giada: are you sure?")) return; G_quit = true; /* close any open subwindow, especially before cleaning PluginHost to * avoid mess */ puts("GUI closing..."); gu_closeAllSubwindows(); /* write configuration file */ if (!G_Conf.write()) puts("Error while saving configuration file!"); else puts("Configuration saved"); puts("Mixer cleanup..."); /* if G_audio_status we close the kernelAudio FIRST, THEN the mixer. * The opposite could cause random segfaults (even now with RtAudio?). */ if (G_audio_status) { kernelAudio::closeDevice(); G_Mixer.close(); } puts("Recorder cleanup..."); recorder::clearAll(); #ifdef WITH_VST puts("Plugin Host cleanup..."); G_PluginHost.freeAllStacks(); #endif puts("Giada "VERSIONE" closed."); hide(); delete this; }
bool OmxDecoder::Init() { //register sniffers, if they are not registered in this process. DataSource::RegisterDefaultSniffers(); sp<DataSource> dataSource = new MediaStreamSource(mPluginHost, mDecoder); if (dataSource->initCheck()) { return false; } mPluginHost->SetMetaDataReadMode(mDecoder); sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource); if (extractor == NULL) { return false; } ssize_t audioTrackIndex = -1; ssize_t videoTrackIndex = -1; const char *audioMime = NULL; for (size_t i = 0; i < extractor->countTracks(); ++i) { sp<MetaData> meta = extractor->getTrackMetaData(i); int32_t bitRate; if (!meta->findInt32(kKeyBitRate, &bitRate)) bitRate = 0; const char *mime; if (!meta->findCString(kKeyMIMEType, &mime)) { continue; } if (videoTrackIndex == -1 && !strncasecmp(mime, "video/", 6)) { videoTrackIndex = i; } else if (audioTrackIndex == -1 && !strncasecmp(mime, "audio/", 6)) { audioTrackIndex = i; audioMime = mime; } } if (videoTrackIndex == -1 && audioTrackIndex == -1) { return false; } mPluginHost->SetPlaybackReadMode(mDecoder); int64_t totalDurationUs = 0; sp<MediaSource> videoTrack; sp<MediaSource> videoSource; if (videoTrackIndex != -1 && (videoTrack = extractor->getTrack(videoTrackIndex)) != NULL) { videoSource = OMXCodec::Create(GetOMX(), videoTrack->getFormat(), false, // decoder videoTrack, NULL, 0); // flags (prefer hw codecs) if (videoSource == NULL) { return false; } if (videoSource->start() != OK) { return false; } int64_t durationUs; if (videoTrack->getFormat()->findInt64(kKeyDuration, &durationUs)) { if (durationUs > totalDurationUs) totalDurationUs = durationUs; } } sp<MediaSource> audioTrack; sp<MediaSource> audioSource; if (audioTrackIndex != -1 && (audioTrack = extractor->getTrack(audioTrackIndex)) != NULL) { if (!strcasecmp(audioMime, "audio/raw")) { audioSource = audioTrack; } else { audioSource = OMXCodec::Create(GetOMX(), audioTrack->getFormat(), false, // decoder audioTrack); } if (audioSource == NULL) { return false; } if (audioSource->start() != OK) { return false; } int64_t durationUs; if (audioTrack->getFormat()->findInt64(kKeyDuration, &durationUs)) { if (durationUs > totalDurationUs) totalDurationUs = durationUs; } } // set decoder state mVideoTrack = videoTrack; mVideoSource = videoSource; mAudioTrack = audioTrack; mAudioSource = audioSource; mDurationUs = totalDurationUs; if (mVideoSource.get() && !SetVideoFormat()) return false; // To reliably get the channel and sample rate data we need to read from the // audio source until we get a INFO_FORMAT_CHANGE status if (mAudioSource.get()) { if (mAudioSource->read(&mAudioBuffer) != INFO_FORMAT_CHANGED) { sp<MetaData> meta = mAudioSource->getFormat(); if (!meta->findInt32(kKeyChannelCount, &mAudioChannels) || !meta->findInt32(kKeySampleRate, &mAudioSampleRate)) { return false; } mAudioMetadataRead = true; } else if (!SetAudioFormat()) { return false; } } return true; }
void gdPluginWindowGUI::__cb_refresh() { //gu_log("[gdPluginWindowGUI::__cb_refresh] refresh!\n"); G_PluginHost.runDispatchLoop(); Fl::repeat_timeout(GUI_PLUGIN_RATE, cb_refresh, (void*) this); }
bool OmxDecoder::Init() { //register sniffers, if they are not registered in this process. DataSource::RegisterDefaultSniffers(); sp<DataSource> dataSource = new MediaStreamSource(mPluginHost, mDecoder); if (dataSource->initCheck()) { return false; } mPluginHost->SetMetaDataReadMode(mDecoder); sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource); if (extractor == NULL) { return false; } ssize_t audioTrackIndex = -1; ssize_t videoTrackIndex = -1; const char *audioMime = NULL; const char *videoMime = NULL; for (size_t i = 0; i < extractor->countTracks(); ++i) { sp<MetaData> meta = extractor->getTrackMetaData(i); const char *mime; if (!meta->findCString(kKeyMIMEType, &mime)) { continue; } if (videoTrackIndex == -1 && !strncasecmp(mime, "video/", 6)) { videoTrackIndex = i; videoMime = mime; } else if (audioTrackIndex == -1 && !strncasecmp(mime, "audio/", 6)) { audioTrackIndex = i; audioMime = mime; } } if (videoTrackIndex == -1 && audioTrackIndex == -1) { return false; } mPluginHost->SetPlaybackReadMode(mDecoder); int64_t totalDurationUs = 0; #ifdef MOZ_WIDGET_GONK sp<IOMX> omx = GetOMX(); #else // OMXClient::connect() always returns OK and abort's fatally if // it can't connect. We may need to implement the connect functionality // ourselves if this proves to be an issue. if (mClient.connect() != OK) { LOG("OMXClient failed to connect"); } sp<IOMX> omx = mClient.interface(); #endif sp<MediaSource> videoTrack; sp<MediaSource> videoSource; if (videoTrackIndex != -1 && (videoTrack = extractor->getTrack(videoTrackIndex)) != NULL) { uint32_t flags = GetVideoCreationFlags(mPluginHost); videoSource = OMXCodec::Create(omx, videoTrack->getFormat(), false, // decoder videoTrack, NULL, flags); if (videoSource == NULL) { LOG("OMXCodec failed to initialize video decoder for \"%s\"", videoMime); return false; } status_t status = videoSource->start(); if (status != OK) { LOG("videoSource->start() failed with status %#x", status); return false; } int64_t durationUs; if (videoTrack->getFormat()->findInt64(kKeyDuration, &durationUs)) { if (durationUs < 0) LOG("video duration %lld should be nonnegative", durationUs); if (durationUs > totalDurationUs) totalDurationUs = durationUs; } } sp<MediaSource> audioTrack; sp<MediaSource> audioSource; if (audioTrackIndex != -1 && (audioTrack = extractor->getTrack(audioTrackIndex)) != NULL) { if (!strcasecmp(audioMime, "audio/raw")) { audioSource = audioTrack; } else { audioSource = OMXCodec::Create(omx, audioTrack->getFormat(), false, // decoder audioTrack); } if (audioSource == NULL) { LOG("OMXCodec failed to initialize audio decoder for \"%s\"", audioMime); return false; } status_t status = audioSource->start(); if (status != OK) { LOG("audioSource->start() failed with status %#x", status); return false; } int64_t durationUs; if (audioTrack->getFormat()->findInt64(kKeyDuration, &durationUs)) { if (durationUs < 0) LOG("audio duration %lld should be nonnegative", durationUs); if (durationUs > totalDurationUs) totalDurationUs = durationUs; } } // set decoder state mVideoTrack = videoTrack; mVideoSource = videoSource; mAudioTrack = audioTrack; mAudioSource = audioSource; mDurationUs = totalDurationUs; if (mVideoSource.get() && !SetVideoFormat()) return false; // To reliably get the channel and sample rate data we need to read from the // audio source until we get a INFO_FORMAT_CHANGE status if (mAudioSource.get()) { if (mAudioSource->read(&mAudioBuffer) != INFO_FORMAT_CHANGED) { sp<MetaData> meta = mAudioSource->getFormat(); if (!meta->findInt32(kKeyChannelCount, &mAudioChannels) || !meta->findInt32(kKeySampleRate, &mAudioSampleRate)) { return false; } mAudioMetadataRead = true; if (mAudioChannels < 0) { LOG("audio channel count %d must be nonnegative", mAudioChannels); return false; } if (mAudioSampleRate < 0) { LOG("audio sample rate %d must be nonnegative", mAudioSampleRate); return false; } } else if (!SetAudioFormat()) { return false; } } return true; }
VstIntPtr VSTCALLBACK PluginHost::HostCallback(AEffect *effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void *ptr, float opt) { return G_PluginHost.gHostCallback(effect, opcode, index, value, ptr, opt); }
bool OmxDecoder::Init() { //register sniffers, if they are not registered in this process. DataSource::RegisterDefaultSniffers(); sp<DataSource> dataSource = new MediaStreamSource(mPluginHost, mDecoder); if (dataSource->initCheck()) { return false; } mPluginHost->SetMetaDataReadMode(mDecoder); sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource); if (extractor == NULL) { return false; } sp<MediaSource> videoTrack; sp<MediaSource> audioTrack; const char *audioMime = NULL; bool audioMetaFound = false; for (size_t i = 0; i < extractor->countTracks(); ++i) { sp<MetaData> meta = extractor->getTrackMetaData(i); int32_t bitRate; if (!meta->findInt32(kKeyBitRate, &bitRate)) bitRate = 0; const char *mime; if (!meta->findCString(kKeyMIMEType, &mime)) { continue; } if (videoTrack == NULL && !strncasecmp(mime, "video/", 6)) { videoTrack = extractor->getTrack(i); } else if (audioTrack == NULL && !strncasecmp(mime, "audio/", 6)) { audioTrack = extractor->getTrack(i); audioMime = mime; if (!meta->findInt32(kKeyChannelCount, &mAudioChannels) || !meta->findInt32(kKeySampleRate, &mAudioSampleRate)) { return false; } audioMetaFound = true; LOG("channelCount: %d sampleRate: %d", mAudioChannels, mAudioSampleRate); } } if (videoTrack == NULL && audioTrack == NULL) { return false; } mPluginHost->SetPlaybackReadMode(mDecoder); int64_t totalDurationUs = 0; sp<MediaSource> videoSource; if (videoTrack != NULL) { videoSource = OMXCodec::Create(GetOMX(), videoTrack->getFormat(), false, // decoder videoTrack, NULL, 0); // flags (prefer hw codecs) if (videoSource == NULL) { return false; } if (videoSource->start() != OK) { return false; } int64_t durationUs; if (videoTrack->getFormat()->findInt64(kKeyDuration, &durationUs)) { if (durationUs > totalDurationUs) totalDurationUs = durationUs; } } sp<MediaSource> audioSource; if (audioTrack != NULL) { if (!strcasecmp(audioMime, "audio/raw")) { audioSource = audioTrack; } else { audioSource = OMXCodec::Create(GetOMX(), audioTrack->getFormat(), false, // decoder audioTrack); } if (audioSource == NULL) { return false; } if (audioSource->start() != OK) { return false; } int64_t durationUs; if (audioTrack->getFormat()->findInt64(kKeyDuration, &durationUs)) { if (durationUs > totalDurationUs) totalDurationUs = durationUs; } } // set decoder state mVideoTrack = videoTrack; mVideoSource = videoSource; mAudioTrack = audioTrack; mAudioSource = audioSource; mDurationUs = totalDurationUs; if (mVideoSource.get() && !SetVideoFormat()) return false; if (!audioMetaFound && mAudioSource.get() && !SetAudioFormat()) return false; return true; }