mirror of
https://github.com/Boof2015/prism.git
synced 2026-08-12 05:10:51 +02:00
fixes
This commit is contained in:
@@ -39,6 +39,10 @@ namespace
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if JUCE_LINUX
|
||||||
|
constexpr int kLinuxFrameRateHz = 30;
|
||||||
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<ScopeEngine> makeEngine()
|
std::unique_ptr<ScopeEngine> makeEngine()
|
||||||
{
|
{
|
||||||
#if defined(PRISM_SCOPE_WAVEFORM) && PRISM_SCOPE_WAVEFORM
|
#if defined(PRISM_SCOPE_WAVEFORM) && PRISM_SCOPE_WAVEFORM
|
||||||
@@ -188,23 +192,14 @@ PrismSpectrumEditor::PrismSpectrumEditor(PrismSpectrumProcessor& p)
|
|||||||
setResizable(true, true);
|
setResizable(true, true);
|
||||||
setResizeLimits(pref.minWidth, pref.minHeight, 4096, 4096);
|
setResizeLimits(pref.minWidth, pref.minHeight, 4096, 4096);
|
||||||
setSize(pref.defaultWidth, pref.defaultHeight);
|
setSize(pref.defaultWidth, pref.defaultHeight);
|
||||||
|
|
||||||
if (webView != nullptr)
|
|
||||||
{
|
|
||||||
#if JUCE_WINDOWS
|
|
||||||
startTimerHz(resolveWindowsFrameRateHz(*this));
|
|
||||||
#else
|
|
||||||
// Drive frames at the display's refresh rate (adapts to 60/120/144 Hz).
|
|
||||||
vblank = juce::VBlankAttachment(this, [this] { renderFrame(); });
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PrismSpectrumEditor::~PrismSpectrumEditor()
|
PrismSpectrumEditor::~PrismSpectrumEditor()
|
||||||
{
|
{
|
||||||
#if JUCE_WINDOWS
|
#if JUCE_WINDOWS || JUCE_LINUX
|
||||||
stopTimer();
|
stopTimer();
|
||||||
#endif
|
#endif
|
||||||
|
webViewReady = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrismSpectrumEditor::resized()
|
void PrismSpectrumEditor::resized()
|
||||||
@@ -259,13 +254,30 @@ void PrismSpectrumEditor::showWebViewFallback()
|
|||||||
addAndMakeVisible(webViewFallback);
|
addAndMakeVisible(webViewFallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JUCE_WINDOWS
|
#if JUCE_WINDOWS || JUCE_LINUX
|
||||||
void PrismSpectrumEditor::timerCallback()
|
void PrismSpectrumEditor::timerCallback()
|
||||||
{
|
{
|
||||||
renderFrame();
|
renderFrame();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void PrismSpectrumEditor::startFrameDriver()
|
||||||
|
{
|
||||||
|
if (webView == nullptr || ! webViewReady || frameDriverStarted)
|
||||||
|
return;
|
||||||
|
|
||||||
|
frameDriverStarted = true;
|
||||||
|
|
||||||
|
#if JUCE_WINDOWS
|
||||||
|
startTimerHz(resolveWindowsFrameRateHz(*this));
|
||||||
|
#elif JUCE_LINUX
|
||||||
|
startTimerHz(kLinuxFrameRateHz);
|
||||||
|
#else
|
||||||
|
// Drive frames at the display's refresh rate (adapts to 60/120/144 Hz).
|
||||||
|
vblank = juce::VBlankAttachment(this, [this] { renderFrame(); });
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void PrismSpectrumEditor::onSettingsPanel(juce::var payload)
|
void PrismSpectrumEditor::onSettingsPanel(juce::var payload)
|
||||||
{
|
{
|
||||||
const int height = juce::jmax(0, (int) payload.getProperty("height", 0));
|
const int height = juce::jmax(0, (int) payload.getProperty("height", 0));
|
||||||
@@ -295,8 +307,10 @@ void PrismSpectrumEditor::onPrismConfig(juce::var payload)
|
|||||||
|
|
||||||
void PrismSpectrumEditor::onPrismReady()
|
void PrismSpectrumEditor::onPrismReady()
|
||||||
{
|
{
|
||||||
|
webViewReady = true;
|
||||||
pushRestoreSettings();
|
pushRestoreSettings();
|
||||||
sendAppDefaults();
|
sendAppDefaults();
|
||||||
|
startFrameDriver();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrismSpectrumEditor::onScopeNativeConfig(juce::var payload)
|
void PrismSpectrumEditor::onScopeNativeConfig(juce::var payload)
|
||||||
@@ -379,7 +393,7 @@ void PrismSpectrumEditor::sendAppDefaults()
|
|||||||
|
|
||||||
void PrismSpectrumEditor::renderFrame()
|
void PrismSpectrumEditor::renderFrame()
|
||||||
{
|
{
|
||||||
if (webView == nullptr)
|
if (webView == nullptr || ! webViewReady)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if JUCE_MAC
|
#if JUCE_MAC
|
||||||
|
|||||||
@@ -10,12 +10,12 @@
|
|||||||
* Hosts the React webview UI and bridges the reused Prism spectrum DSP to it.
|
* Hosts the React webview UI and bridges the reused Prism spectrum DSP to it.
|
||||||
*
|
*
|
||||||
* Drains stereo audio buffered by the processor, feeds the selected scope engine,
|
* Drains stereo audio buffered by the processor, feeds the selected scope engine,
|
||||||
* and emits frame payloads to the webview. macOS uses display vblank; Windows uses
|
* and emits frame payloads to the webview after the UI reports readiness. macOS
|
||||||
* a steady message-thread timer because some DAW/WebView2 embeddings deliver
|
* uses display vblank; Windows/Linux use steady message-thread timers to avoid
|
||||||
* vblank callbacks too slowly for data-driven scopes.
|
* fragile host/browser embedding behavior.
|
||||||
*/
|
*/
|
||||||
class PrismSpectrumEditor : public juce::AudioProcessorEditor
|
class PrismSpectrumEditor : public juce::AudioProcessorEditor
|
||||||
#if JUCE_WINDOWS
|
#if JUCE_WINDOWS || JUCE_LINUX
|
||||||
, private juce::Timer
|
, private juce::Timer
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
|
|
||||||
void resized() override;
|
void resized() override;
|
||||||
|
|
||||||
#if JUCE_WINDOWS
|
#if JUCE_WINDOWS || JUCE_LINUX
|
||||||
void timerCallback() override;
|
void timerCallback() override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -52,6 +52,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void loadWebView();
|
void loadWebView();
|
||||||
void showWebViewFallback();
|
void showWebViewFallback();
|
||||||
|
void startFrameDriver();
|
||||||
void renderFrame();
|
void renderFrame();
|
||||||
|
|
||||||
PrismSpectrumProcessor& processorRef;
|
PrismSpectrumProcessor& processorRef;
|
||||||
@@ -62,6 +63,8 @@ private:
|
|||||||
|
|
||||||
// Height (px) the editor is currently grown by for the open settings panel.
|
// Height (px) the editor is currently grown by for the open settings panel.
|
||||||
int settingsPanelHeight = 0;
|
int settingsPanelHeight = 0;
|
||||||
|
bool webViewReady = false;
|
||||||
|
bool frameDriverStarted = false;
|
||||||
|
|
||||||
// One-time attempt to lift WKWebView's private 60fps cap (macOS).
|
// One-time attempt to lift WKWebView's private 60fps cap (macOS).
|
||||||
bool frameRateUncapped = false;
|
bool frameRateUncapped = false;
|
||||||
@@ -71,8 +74,8 @@ private:
|
|||||||
juce::Label webViewFallback;
|
juce::Label webViewFallback;
|
||||||
|
|
||||||
// Declared last so it is destroyed first; no vblank callback can fire into a
|
// Declared last so it is destroyed first; no vblank callback can fire into a
|
||||||
// partially-destroyed editor. Windows uses juce::Timer instead.
|
// partially-destroyed editor. Windows/Linux use juce::Timer instead.
|
||||||
#if ! JUCE_WINDOWS
|
#if ! JUCE_WINDOWS && ! JUCE_LINUX
|
||||||
juce::VBlankAttachment vblank;
|
juce::VBlankAttachment vblank;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user