Sigrid Solveig Haflínudóttircompile stuff50243ce5 years agoHistory
58 lines · 1.1 KB · C
RawDownload
/* This code is placed in the public domain. */ #include <stdlib.h>#include "soundpipe.h"#include "../lib/spa/spa.h" #define SPA_BUFSIZE 4096 int sp_spa_create(sp_spa **p){    *p = malloc(sizeof(sp_spa));    return SP_OK;} int sp_spa_destroy(sp_spa **p){    sp_spa *pp = *p;    spa_close(&pp->spa);    free(pp->buf);    free(*p);    return SP_OK;} int sp_spa_init(sp_data *sp, sp_spa *p, const char *filename){    if(spa_open(sp, &p->spa, filename, SPA_READ) != SP_OK) {        return SP_NOT_OK;    }     p->pos = 0;     p->bufsize = SPA_BUFSIZE;    p->buf = calloc(1, sizeof(SPFLOAT) * p->bufsize);     return SP_OK;} int sp_spa_compute(sp_data *sp, sp_spa *p, SPFLOAT *in, SPFLOAT *out){    USED(in);     if (p->bufsize == 0) {        *out = 0.0;        return SP_OK;    }     if (p->pos == 0) {        p->bufsize = spa_read_buf(sp, &p->spa, p->buf, SPA_BUFSIZE);        if(p->bufsize == 0) {            *out = 0.0;            return SP_OK;        }    }     *out = p->buf[p->pos];    p->pos = (p->pos + 1) % p->bufsize;    return SP_OK;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t