~hecanjog/pippi

609d61358c154c3bcefe8c5f3abd8a4336bbee84 — Erik Schoster 10 days ago 02ed654
Cleanup on SIGTERM, stub out sampler api
M libpippi/console.py => libpippi/console.py +2 -2
@@ 106,10 106,10 @@ class AstridConsole(cmd.Cmd):
            self.instruments[instrument].terminate()

        if self.dac is not None:
            self.dac.kill()
            self.dac.terminate()

        if self.adc is not None:
            self.adc.kill()
            self.adc.terminate()

        exit(0)


M libpippi/cython/cyrenderer.pyx => libpippi/cython/cyrenderer.pyx +14 -0
@@ 83,6 83,12 @@ cdef SoundBuffer read_from_adc(double length, double offset=0, int channels=2, i

    return snd

cdef void create_from_sampler(SoundBuffer snd, int bankid):
    pass

cdef SoundBuffer dub_into_sampler(SoundBuffer snd, int bankid):
    return snd

cdef SoundBuffer read_from_sampler(int bankid):
    cdef size_t i
    cdef size_t pos = 0


@@ 179,6 185,14 @@ cdef class EventContext:
        bankid %= 10000
        return read_from_sampler(bankid)

    def write_sampler(self, buf, bankid):
        bankid %= 10000
        create_from_sampler(buf, bankid)

    def dub_sampler(self, buf, bankid):
        bankid %= 10000
        return dub_into_sampler(buf, bankid)

    def log(self, msg):
        logger.info(msg)


M libpippi/src/adc.c => libpippi/src/adc.c +8 -2
@@ 64,10 64,16 @@ int main() {
    sigemptyset(&action.sa_mask);
    action.sa_flags = 0;
    if(sigaction(SIGINT, &action, NULL) == -1) {
        fprintf(stderr, "Could not init signal handler.\n");
        goto exit_with_error;
        fprintf(stderr, "Could not init SIGINT signal handler.\n");
        exit(1);
    }

    if(sigaction(SIGTERM, &action, NULL) == -1) {
        fprintf(stderr, "Could not init SIGTERM signal handler.\n");
        exit(1);
    }


    /* Connect to redis for status polling */
    struct timeval redis_timeout = {15, 0};
    status_redis = redisConnectWithTimeout("127.0.0.1", 6379, redis_timeout);

M libpippi/src/dac.c => libpippi/src/dac.c +9 -1
@@ 191,7 191,15 @@ int main() {
    shutdown_action.sa_handler = handle_shutdown;
    sigemptyset(&shutdown_action.sa_mask);
    shutdown_action.sa_flags = 0;
    sigaction(SIGINT, &shutdown_action, NULL);
    if(sigaction(SIGINT, &shutdown_action, NULL) == -1) {
        fprintf(stderr, "Could not init SIGINT signal handler.\n");
        exit(1);
    }

    if(sigaction(SIGTERM, &shutdown_action, NULL) == -1) {
        fprintf(stderr, "Could not init SIGTERM signal handler.\n");
        exit(1);
    }

    /* init scheduler and ctx */
    astrid_scheduler = LPScheduler.create(astrid_channels);

M libpippi/src/renderer.c => libpippi/src/renderer.c +10 -1
@@ 40,7 40,16 @@ int main() {
    shutdown_action.sa_handler = handle_shutdown;
    sigemptyset(&shutdown_action.sa_mask);
    shutdown_action.sa_flags = 0;
    sigaction(SIGINT, &shutdown_action, NULL);
    if(sigaction(SIGINT, &shutdown_action, NULL) == -1) {
        fprintf(stderr, "Could not init SIGINT signal handler.\n");
        exit(1);
    }

    if(sigaction(SIGTERM, &shutdown_action, NULL) == -1) {
        fprintf(stderr, "Could not init SIGTERM signal handler.\n");
        exit(1);
    }


    /* Get python path from env */
    astrid_pythonpath_env = getenv("ASTRID_PYTHONPATH");