Last active
February 2, 2021 15:29
-
-
Save saivert/bec575da0e20976ba6dc06db66b3ea26 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 int _apply_format(struct spa_loop *loop, | |
| bool async, | |
| uint32_t seq, | |
| const void *_data, | |
| size_t size, | |
| void *user_data) | |
| { | |
| deadbeef->mutex_lock(mutex); | |
| pw_stream_disconnect(data.stream); | |
| ddbpw_set_spec(&requested_fmt); // This calls pw_stream_connect eventuall after setting up the format. | |
| _setformat_requested = 0; // Reset our flag | |
| deadbeef->mutex_unlock(mutex); | |
| trace("Pipewire: from loop invoked callback!\n"); | |
| return 0; | |
| } | |
| static void on_process(void *userdata) | |
| { | |
| struct data *data = userdata; | |
| struct pw_buffer *b; | |
| struct spa_buffer *buf; | |
| int16_t *dst; | |
| 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 len = 4096; | |
| 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 = 1; | |
| buf->datas[0].chunk->size = bytesread; | |
| pw_stream_queue_buffer(data->stream, b); | |
| } else { | |
| pw_loop_invoke(pw_thread_loop_get_loop(data->loop), _apply_format, 1, NULL, 0, false, NULL); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment