Created
March 9, 2023 19:12
-
-
Save saivert/76aac3defe68db4cf55f190449999eeb 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) { | |
struct data *data = userdata; | |
struct pw_buffer *b = NULL; | |
struct spa_buffer *buf = NULL; | |
int16_t *dst = NULL; | |
if (!_setformat_requested) { | |
int stride = (plugin.fmt.channels * plugin.fmt.bps) / 8; | |
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 len = b->requested ? b->requested : 25; | |
len *= stride; | |
printf("maxsize: %d\n", len); | |
int bytesread=0; | |
if (deadbeef->streamer_ok_to_read(-1)) { | |
bytesread = deadbeef->streamer_read (buf->datas[0].data , len); | |
} | |
buf->datas[0].chunk->offset = 0; | |
buf->datas[0].chunk->stride = stride; | |
buf->datas[0].chunk->size = len; | |
memset(buf->datas[0].data+bytesread, 0, len-bytesread); | |
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