Created
March 14, 2023 17:14
-
-
Save saivert/32f8d8ca957f7f77c09fb85558997042 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void on_process(void *userdata) { | |
static int counter; | |
struct data *data = userdata; | |
struct pw_buffer *b = NULL; | |
struct spa_buffer *buf = NULL; | |
int16_t *dst = NULL; | |
if (!_setformat_requested) { | |
if ((b = pw_stream_dequeue_buffer(data->stream)) == NULL) { | |
pw_log_warn("out of buffers: %m"); | |
return; | |
} | |
buf = b->buffer; | |
if ((dst = buf->datas[0].data) == NULL) { | |
return; | |
} | |
int stride = plugin.fmt.channels * (plugin.fmt.bps / 8); | |
// node.latency is set to 1024/48000 | |
uint32_t ownnframes = SPA_SCALE32_UP(plugin.fmt.samplerate, 1024, 48000); | |
uint32_t nframes = ownnframes; | |
#if PW_CHECK_VERSION(0, 3, 49) | |
if (b->requested != 0) { | |
nframes = SPA_MIN(b->requested, ownnframes); | |
} | |
#endif | |
int len = nframes * stride; | |
int bytesread=0; | |
if (deadbeef->streamer_ok_to_read(-1)) { | |
bytesread = deadbeef->streamer_read (buf->datas[0].data , len); | |
} | |
if (bytesread != 0) { | |
b->size = bytesread / stride; | |
} | |
buf->datas[0].chunk->offset = 0; | |
buf->datas[0].chunk->stride = stride; | |
buf->datas[0].chunk->size = bytesread; | |
printf("%d len: %d stride: %d requested: %ld nframes: %d maxsize: %u own nframes %d\n", | |
counter++, len, stride, b->requested, nframes, buf->datas[0].maxsize, ownnframes); | |
pw_stream_queue_buffer(data->stream, b); | |
// if (bytesread <= 0) { | |
// pw_stream_flush(data->stream, 0); | |
// } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment