Example #1
0
static void recording_stream_read_callback(pa_stream *stream, size_t nbytes, void *userdata) {
    SoundIoInStreamPrivate *is = (SoundIoInStreamPrivate*)userdata;
    SoundIoInStream *instream = &is->pub;
    assert(nbytes % instream->bytes_per_frame == 0);
    assert(nbytes > 0);
    int available_frame_count = nbytes / instream->bytes_per_frame;
    instream->read_callback(instream, 0, available_frame_count);
}
Example #2
0
static int instream_process_callback(jack_nframes_t nframes, void *arg) {
    SoundIoInStreamPrivate *is = (SoundIoInStreamPrivate *)arg;
    SoundIoInStream *instream = &is->pub;
    SoundIoInStreamJack *isj = &is->backend_data.jack;
    isj->frames_left = nframes;
    for (int ch = 0; ch < instream->layout.channel_count; ch += 1) {
        SoundIoInStreamJackPort *isjp = &isj->ports[ch];
        isj->areas[ch].ptr = (char*)jack_port_get_buffer(isjp->dest_port, nframes);
        isj->areas[ch].step = instream->bytes_per_sample;
    }
    instream->read_callback(instream, isj->frames_left, isj->frames_left);
    return 0;
}