Commit 634a77cc authored by Miller Puckette's avatar Miller Puckette
Browse files

add -batch flag

parent 141cf3c2
......@@ -450,11 +450,11 @@ static void m_pollingscheduler( void)
if (!(idlecount & 31))
{
static double idletime;
if (sched_useaudio != SCHED_AUDIO_POLL)
{
bug("m_pollingscheduler\n");
return;
}
if (sched_useaudio != SCHED_AUDIO_POLL)
{
bug("m_pollingscheduler\n");
return;
}
/* on 32nd idle, start a clock watch; every
32 ensuing idles, check it */
if (idlecount == 32)
......@@ -566,6 +566,15 @@ int m_mainloop(void)
return (0);
}
int m_batchmain(void)
{
sys_time_per_dsp_tick = (TIMEUNITPERSEC) *
((double)sys_schedblocksize) / sys_dacsr;
while (sys_quit != SYS_QUIT_QUIT)
sched_tick(sys_time + sys_time_per_dsp_tick);
return (0);
}
/* ------------ thread locking ------------------- */
#ifdef THREAD_LOCKING
......
......@@ -35,6 +35,7 @@ void sys_findprogdir(char *progname);
int sys_startgui(const char *guipath);
int sys_rcfile(void);
int m_mainloop(void);
int m_batchmain(void);
void sys_addhelppath(char *p);
#ifdef USEAPI_ALSA
void alsa_adddev(char *name);
......@@ -75,6 +76,7 @@ static int sys_listplease;
int sys_externalschedlib;
char sys_externalschedlibname[MAXPDSTRING];
static int sys_batch;
int sys_extraflags;
char sys_extraflagsstring[MAXPDSTRING];
int sys_run_scheduler(const char *externalschedlibname,
......@@ -299,6 +301,8 @@ int sys_main(int argc, char **argv)
if (sys_externalschedlib)
return (sys_run_scheduler(sys_externalschedlibname,
sys_extraflagsstring));
else if (sys_batch)
return (m_batchmain());
else
{
/* open audio and MIDI */
......@@ -394,6 +398,7 @@ static char *(usagemessage[]) = {
"-nosleep -- spin, don't sleep (may lower latency on multi-CPUs)\n",
"-schedlib <file> -- plug in external scheduler\n",
"-extraflags <s> -- string argument to send schedlib\n",
"-batch -- run off-line as a batch process\n",
};
static void sys_parsedevlist(int *np, int *vecp, int max, char *str)
......@@ -828,6 +833,12 @@ int sys_argparse(int argc, char **argv)
argv += 2;
argc -= 2;
}
else if (!strcmp(*argv, "-batch"))
{
sys_batch = 1;
sys_printtostderr = sys_nogui = 1;
argc--; argv++;
}
#ifdef UNISTD
else if (!strcmp(*argv, "-rt") || !strcmp(*argv, "-realtime"))
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment