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) ...@@ -450,11 +450,11 @@ static void m_pollingscheduler( void)
if (!(idlecount & 31)) if (!(idlecount & 31))
{ {
static double idletime; static double idletime;
if (sched_useaudio != SCHED_AUDIO_POLL) if (sched_useaudio != SCHED_AUDIO_POLL)
{ {
bug("m_pollingscheduler\n"); bug("m_pollingscheduler\n");
return; return;
} }
/* on 32nd idle, start a clock watch; every /* on 32nd idle, start a clock watch; every
32 ensuing idles, check it */ 32 ensuing idles, check it */
if (idlecount == 32) if (idlecount == 32)
...@@ -566,6 +566,15 @@ int m_mainloop(void) ...@@ -566,6 +566,15 @@ int m_mainloop(void)
return (0); 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 ------------------- */ /* ------------ thread locking ------------------- */
#ifdef THREAD_LOCKING #ifdef THREAD_LOCKING
......
...@@ -35,6 +35,7 @@ void sys_findprogdir(char *progname); ...@@ -35,6 +35,7 @@ void sys_findprogdir(char *progname);
int sys_startgui(const char *guipath); int sys_startgui(const char *guipath);
int sys_rcfile(void); int sys_rcfile(void);
int m_mainloop(void); int m_mainloop(void);
int m_batchmain(void);
void sys_addhelppath(char *p); void sys_addhelppath(char *p);
#ifdef USEAPI_ALSA #ifdef USEAPI_ALSA
void alsa_adddev(char *name); void alsa_adddev(char *name);
...@@ -75,6 +76,7 @@ static int sys_listplease; ...@@ -75,6 +76,7 @@ static int sys_listplease;
int sys_externalschedlib; int sys_externalschedlib;
char sys_externalschedlibname[MAXPDSTRING]; char sys_externalschedlibname[MAXPDSTRING];
static int sys_batch;
int sys_extraflags; int sys_extraflags;
char sys_extraflagsstring[MAXPDSTRING]; char sys_extraflagsstring[MAXPDSTRING];
int sys_run_scheduler(const char *externalschedlibname, int sys_run_scheduler(const char *externalschedlibname,
...@@ -299,6 +301,8 @@ int sys_main(int argc, char **argv) ...@@ -299,6 +301,8 @@ int sys_main(int argc, char **argv)
if (sys_externalschedlib) if (sys_externalschedlib)
return (sys_run_scheduler(sys_externalschedlibname, return (sys_run_scheduler(sys_externalschedlibname,
sys_extraflagsstring)); sys_extraflagsstring));
else if (sys_batch)
return (m_batchmain());
else else
{ {
/* open audio and MIDI */ /* open audio and MIDI */
...@@ -394,6 +398,7 @@ static char *(usagemessage[]) = { ...@@ -394,6 +398,7 @@ static char *(usagemessage[]) = {
"-nosleep -- spin, don't sleep (may lower latency on multi-CPUs)\n", "-nosleep -- spin, don't sleep (may lower latency on multi-CPUs)\n",
"-schedlib <file> -- plug in external scheduler\n", "-schedlib <file> -- plug in external scheduler\n",
"-extraflags <s> -- string argument to send schedlib\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) static void sys_parsedevlist(int *np, int *vecp, int max, char *str)
...@@ -828,6 +833,12 @@ int sys_argparse(int argc, char **argv) ...@@ -828,6 +833,12 @@ int sys_argparse(int argc, char **argv)
argv += 2; argv += 2;
argc -= 2; argc -= 2;
} }
else if (!strcmp(*argv, "-batch"))
{
sys_batch = 1;
sys_printtostderr = sys_nogui = 1;
argc--; argv++;
}
#ifdef UNISTD #ifdef UNISTD
else if (!strcmp(*argv, "-rt") || !strcmp(*argv, "-realtime")) else if (!strcmp(*argv, "-rt") || !strcmp(*argv, "-realtime"))
{ {
......
Supports Markdown
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