pure-data/src/m_sched.c

/* Copyright (c) 1997-1999 Miller Puckette.
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */

/*  scheduling stuff  */

#include "m_pd.h"
#include "m_imp.h"
#include "s_stuff.h"
#ifdef _WIN32
#include <windows.h>
#include <sys/timeb.h>
#else
#include <sys/time.h>
#endif
#include <errno.h>
#include <pthread.h>

    /* LATER consider making this variable.  It's now the LCM of all sample
    rates we expect to see: 32000, 44100, 48000, 88200, 96000. */
#define TIMEUNITPERMSEC
#define TIMEUNITPERSECOND
#define SYSTIMEPERTICK
#define APPROXTICKSPERSEC

#define SYS_QUIT_QUIT
#define SYS_QUIT_REOPEN
#define SYS_QUIT_CLOSE
static int sys_quit;
static pthread_cond_t sched_cond;
static pthread_mutex_t sched_mutex;
static int sched_useaudio =;
static double sched_referencerealtime, sched_referencelogicaltime;

static int sys_exitcode;
extern int sys_nosleep;

int sys_usecsincelastsleep(void);
int sys_sleepgrain;

t_clockmethod;

struct _clock
{};

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

t_clock *clock_new(void *owner, t_method fn)
{}

void clock_unset(t_clock *x)
{}

    /* set the clock to call back at an absolute system time */
void clock_set(t_clock *x, double setticks)
{}

    /* set the clock to call back after a delay in msec */
void clock_delay(t_clock *x, double delaytime)
{}

    /* set the time unit in msec or (if 'samps' is set) in samples.  This
    is flagged by setting c_unit negative.  If the clock is currently set,
    recalculate the delay based on the new unit and reschedule */
void clock_setunit(t_clock *x, double timeunit, int sampflag)
{}

    /* get current logical time.  We don't specify what units this is in;
    use clock_gettimesince() to measure intervals from time of this call. */
double clock_getlogicaltime(void)
{}

    /* OBSOLETE (misleading) function name kept for compatibility */
double clock_getsystime(void) {}

    /* elapsed time in milliseconds since the given system time */
double clock_gettimesince(double prevsystime)
{}

    /* elapsed time in units, ala clock_setunit(), since given system time */
double clock_gettimesincewithunits(double prevsystime,
    double units, int sampflag)
{}

    /* what value the system clock will have after a delay */
double clock_getsystimeafter(double delaytime)
{}

void clock_free(t_clock *x)
{}


void glob_audiostatus(void)
{}

static int sched_diored;
static int sched_dioredtime;
static int sched_meterson;
static int sched_counter;

static void sys_addhist(int n) {}   /* maybe revive this later for profiling */
static void sys_clearhist(void) {}

void sys_log_error(int type)
{}

static int sched_lastinclip, sched_lastoutclip,
    sched_lastindb, sched_lastoutdb;

void glob_watchdog(void *dummy);

static float sched_fastforward;

void glob_fastforward(void *dummy, t_floatarg f)
{}

void sched_init(void)
{}

void sched_term(void)
{}

void dsp_tick(void);

    /* ask the scheduler to quit; this is thread-safe, so it
       can be safely called from within the audio callback. */
void sys_exit(int status)
{}

    /* ask the scheduler to (re)open the audio system; thread-safe! */
void sys_reopen_audio(void)
{}

    /* ask the scheduler to close the audio system; thread-safe! */
void sys_close_audio(void)
{}

    /* called by sys_do_reopen_audio() and sys_do_close_audio() */
void sched_set_using_audio(int flag)
{}

int sched_get_using_audio(void)
{}

    /* take the scheduler forward one DSP tick, also handling clock timeouts */
void sched_tick(void)
{}

int sched_get_sleepgrain(void)
{}

    /* old stuff for extern binary compatibility -- remove someday */
int *get_sys_sleepgrain(void)
{}

/*
Here is Pd's "main loop."  This routine dispatches clock timeouts and DSP
"ticks" deterministically, and polls for input from MIDI and the GUI.  If
we're left idle we also poll for graphics updates; but these are considered
lower priority than the rest.

The time source is normally the audio I/O subsystem via the "sys_send_dacs()"
call.  This call returns true if samples were transferred; false means that
the audio I/O system is still busy with previous transfers.
*/

void sys_pollmidiqueue(void);
void sys_initmidiqueue(void);

 /* sys_idlehook is a hook the user can fill in to grab idle time.  Return
nonzero if you actually used the time; otherwise we're really really idle and
will now sleep. */
int (*sys_idlehook)(void);

    /* when audio is idle, see to GUI and other stuff */
int sched_idletask(void)
{}

static void m_pollingscheduler(void)
{}

static volatile int callback_inprogress;

void sched_audio_callbackfn(void)
{}

    /* callback scheduler timeout in seconds */
#define CALLBACK_TIMEOUT

int sys_try_reopen_audio(void);

static void m_callbackscheduler(void)
{}

void sys_do_reopen_audio(void);
void sys_do_close_audio(void);

int m_mainloop(void)
{}

int m_batchmain(void)
{}