mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-09 07:05:43 +01:00
Add Lua binding for unit-tests to sync with process-cb
This commit is contained in:
parent
c87ef15e82
commit
62e47fb57c
3 changed files with 52 additions and 0 deletions
|
|
@ -228,6 +228,15 @@ namespace ARDOUR { namespace LuaAPI {
|
|||
*/
|
||||
int timecode_to_sample_lua (lua_State *L);
|
||||
|
||||
/**
|
||||
* Delay execution until next prcess cycle starts.
|
||||
* @param n_cycles process-cycles to wait for.
|
||||
* 0: means wait until next cycle-start, otherwise skip given number of cycles.
|
||||
* @param timeout_ms wait at most this many milliseconds
|
||||
* @return true on success, false if timeout was reached or engine was not running
|
||||
*/
|
||||
bool wait_for_process_callback (size_t n_cycles, int64_t timeout_ms);
|
||||
|
||||
class Vamp {
|
||||
/** Vamp Plugin Interface
|
||||
*
|
||||
|
|
|
|||
|
|
@ -25,8 +25,10 @@
|
|||
#include "pbd/failed_constructor.h"
|
||||
|
||||
#include "ardour/analyser.h"
|
||||
#include "ardour/audioengine.h"
|
||||
#include "ardour/audiofilesource.h"
|
||||
#include "ardour/audiosource.h"
|
||||
#include "ardour/internal_send.h"
|
||||
#include "ardour/lua_api.h"
|
||||
#include "ardour/luaproc.h"
|
||||
#include "ardour/luascripting.h"
|
||||
|
|
@ -424,6 +426,46 @@ ARDOUR::LuaAPI::timecode_to_sample_lua (lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void proc_cycle_start (size_t* cnt)
|
||||
{
|
||||
++*cnt;
|
||||
}
|
||||
|
||||
bool
|
||||
ARDOUR::LuaAPI::wait_for_process_callback (size_t n_cycles, int64_t timeout_ms)
|
||||
{
|
||||
if (!AudioEngine::instance()->running()) {
|
||||
return false;
|
||||
}
|
||||
#if 0
|
||||
if (AudioEngine::instance()->freewheeling()) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (AudioEngine::instance()->measuring_latency() != AudioEngine::MeasureNone) {
|
||||
return false;
|
||||
}
|
||||
if (!AudioEngine::instance()->session() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t cnt = 0;
|
||||
ScopedConnection c;
|
||||
|
||||
InternalSend::CycleStart.connect_same_thread (c, boost::bind (&proc_cycle_start, &cnt));
|
||||
while (cnt <= n_cycles) {
|
||||
Glib::usleep (1000);
|
||||
if (timeout_ms > 0) {
|
||||
if (--timeout_ms == 0) {
|
||||
return cnt > n_cycles;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
ARDOUR::LuaOSC::Address::send (lua_State *L)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2554,6 +2554,7 @@ LuaBindings::common (lua_State* L)
|
|||
.addFunction ("note_list", ARDOUR::LuaAPI::note_list)
|
||||
.addCFunction ("sample_to_timecode", ARDOUR::LuaAPI::sample_to_timecode)
|
||||
.addCFunction ("timecode_to_sample", ARDOUR::LuaAPI::timecode_to_sample)
|
||||
.addFunction ("wait_for_process_callback", ARDOUR::LuaAPI::wait_for_process_callback)
|
||||
|
||||
.beginNamespace ("FileTest")
|
||||
.addConst ("IsRegular", Glib::FILE_TEST_IS_REGULAR)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue