2 * DISTRHO Plugin Framework (DPF)
3 * Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
5 * Permission to use, copy, modify, and/or distribute this software for any purpose with
6 * or without fee is hereby granted, provided that the above copyright notice and this
7 * permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10 * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include "ApplicationPrivateData.hpp"
20 # include <emscripten/emscripten.h>
25 // --------------------------------------------------------------------------------------------------------------------
28 static void app_idle(void* const app
)
30 static_cast<Application
*>(app
)->idle();
34 Application::Application(const bool isStandalone
)
35 : pData(new PrivateData(isStandalone
)) {}
37 Application::~Application()
42 void Application::idle()
47 void Application::exec(const uint idleTimeInMs
)
49 DISTRHO_SAFE_ASSERT_RETURN(pData
->isStandalone
,);
52 emscripten_set_main_loop_arg(app_idle
, this, 0, true);
54 while (! pData
->isQuitting
)
55 pData
->idle(idleTimeInMs
);
59 void Application::quit()
64 bool Application::isQuitting() const noexcept
66 return pData
->isQuitting
|| pData
->isQuittingInNextCycle
;
69 bool Application::isStandalone() const noexcept
71 return pData
->isStandalone
;
74 double Application::getTime() const
76 return pData
->getTime();
79 void Application::addIdleCallback(IdleCallback
* const callback
)
81 DISTRHO_SAFE_ASSERT_RETURN(callback
!= nullptr,)
83 pData
->idleCallbacks
.push_back(callback
);
86 void Application::removeIdleCallback(IdleCallback
* const callback
)
88 DISTRHO_SAFE_ASSERT_RETURN(callback
!= nullptr,)
90 pData
->idleCallbacks
.remove(callback
);
93 void Application::setClassName(const char* const name
)
95 pData
->setClassName(name
);
98 // --------------------------------------------------------------------------------------------------------------------