Skip to content

Commit 1066af2

Browse files
committed
uvstream: add missing callback triggering in async mode
1 parent f3de75b commit 1066af2

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/arvuvstream.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ typedef struct {
108108
ArvBuffer *buffer;
109109
ArvStream *stream;
110110

111+
ArvStreamCallback callback;
112+
gpointer callback_data;
113+
111114
GMutex* transfer_completed_mtx;
112115
GCond* transfer_completed_event;
113116

@@ -292,6 +295,10 @@ void LIBUSB_CALL arv_uv_stream_trailer_cb (struct libusb_transfer *transfer)
292295
}
293296

294297
arv_stream_push_output_buffer (ctx->stream, ctx->buffer);
298+
if (ctx->callback != NULL)
299+
ctx->callback (ctx->callback_data,
300+
ARV_STREAM_CALLBACK_TYPE_BUFFER_DONE,
301+
ctx->buffer);
295302
ctx->buffer = NULL;
296303
}
297304

@@ -310,6 +317,8 @@ arv_uv_stream_buffer_context_new (ArvBuffer *buffer, ArvUvStreamThreadData *thre
310317

311318
ctx->buffer = NULL;
312319
ctx->stream = thread_data->stream;
320+
ctx->callback = thread_data->callback;
321+
ctx->callback_data = thread_data->callback_data;
313322
ctx->transfer_completed_mtx = &thread_data->stream_mtx;
314323
ctx->transfer_completed_event = &thread_data->stream_event;
315324

@@ -374,6 +383,10 @@ arv_uv_stream_buffer_context_free (gpointer data)
374383
if (ctx->buffer != NULL) {
375384
ctx->buffer->priv->status = ARV_BUFFER_STATUS_ABORTED;
376385
arv_stream_push_output_buffer (ctx->stream, ctx->buffer);
386+
if (ctx->callback != NULL)
387+
ctx->callback (ctx->callback_data,
388+
ARV_STREAM_CALLBACK_TYPE_BUFFER_DONE,
389+
ctx->buffer);
377390
ctx->buffer = NULL;
378391
}
379392

@@ -422,6 +435,11 @@ arv_uv_stream_buffer_context_submit (ArvUvStreamBufferContext* ctx, ArvBuffer *b
422435
{
423436
int i;
424437

438+
if (ctx->callback != NULL)
439+
ctx->callback (ctx->callback_data,
440+
ARV_STREAM_CALLBACK_TYPE_START_BUFFER,
441+
buffer);
442+
425443
ctx->buffer = buffer;
426444
ctx->total_payload_transferred = 0;
427445
buffer->priv->status = ARV_BUFFER_STATUS_FILLING;

0 commit comments

Comments
 (0)