Skip to content

Commit

Permalink
Move buffer information from pwr_on_event to pwr_handle_stream_add_bu…
Browse files Browse the repository at this point in the history
…ffer
  • Loading branch information
columbarius committed Nov 6, 2020
1 parent 4c51e3c commit 03bc8d6
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/screencast/pipewire_screencast.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,17 @@ static void pwr_on_event(void *data, uint64_t expirations) {

spa_buf = pw_buf->buffer;
d = spa_buf->datas;
if ((d[0].data) == NULL) {
logprint(TRACE, "pipewire: data pointer undefined");
return;
}
if ((h = spa_buffer_find_meta_data(spa_buf, SPA_META_Header, sizeof(*h)))) {
h->pts = -1;
h->flags = 0;
h->seq = cast->seq++;
h->dts_offset = 0;
}

d[0].type = SPA_DATA_MemPtr;
d[0].maxsize = cast->simple_frame.size;
d[0].mapoffset = 0;
d[0].chunk->size = cast->simple_frame.size;
d[0].chunk->stride = cast->simple_frame.stride;
d[0].chunk->offset = 0;
d[0].flags = 0;
d[0].fd = -1;
if ((d[0].data) == NULL) {
logprint(TRACE, "pipewire: data pointer undefined");
return;
}

writeFrameData(d[0].data, cast->simple_frame.data, cast->simple_frame.height,
cast->simple_frame.stride, cast->simple_frame.y_invert);
Expand Down Expand Up @@ -151,6 +143,18 @@ static void pwr_handle_stream_add_buffer(void *data, struct pw_buffer *buffer) {
} else {
logprint(ERROR, "pipewire: unsupported buffer type");
cast->err = 1;
return;
}

// Prepare buffer for choosen type
if (d[0].type == SPA_DATA_MemPtr) {
d[0].maxsize = cast->simple_frame.size;
d[0].mapoffset = 0;
d[0].chunk->size = cast->simple_frame.size;
d[0].chunk->stride = cast->simple_frame.stride;
d[0].chunk->offset = 0;
d[0].flags = 0;
d[0].fd = -1;
}
}

Expand Down

0 comments on commit 03bc8d6

Please sign in to comment.