MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / async_read_internal

Function async_read_internal

libavformat/async.c:340–385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338}
339
340static int async_read_internal(URLContext *h, void *dest, int size)
341{
342 AsyncContext *c = h->priv_data;
343 RingBuffer *ring = &c->ring;
344 int read_complete = !dest;
345 int to_read = size;
346 int ret = 0;
347
348 pthread_mutex_lock(&c->mutex);
349
350 while (to_read > 0) {
351 int fifo_size, to_copy;
352 if (async_check_interrupt(h)) {
353 ret = AVERROR_EXIT;
354 break;
355 }
356 fifo_size = ring_size(ring);
357 to_copy = FFMIN(to_read, fifo_size);
358 if (to_copy > 0) {
359 ring_read(ring, dest, to_copy);
360 if (dest)
361 dest = (uint8_t *)dest + to_copy;
362 c->logical_pos += to_copy;
363 to_read -= to_copy;
364 ret = size - to_read;
365
366 if (to_read <= 0 || !read_complete)
367 break;
368 } else if (c->io_eof_reached) {
369 if (ret <= 0) {
370 if (c->io_error)
371 ret = c->io_error;
372 else
373 ret = AVERROR_EOF;
374 }
375 break;
376 }
377 pthread_cond_signal(&c->cond_wakeup_background);
378 pthread_cond_wait(&c->cond_wakeup_main, &c->mutex);
379 }
380
381 pthread_cond_signal(&c->cond_wakeup_background);
382 pthread_mutex_unlock(&c->mutex);
383
384 return ret;
385}
386
387static int async_read(URLContext *h, unsigned char *buf, int size)
388{

Callers 2

async_readFunction · 0.85
async_seekFunction · 0.85

Calls 7

async_check_interruptFunction · 0.85
ring_sizeFunction · 0.85
ring_readFunction · 0.85
pthread_mutex_lockFunction · 0.50
pthread_cond_signalFunction · 0.50
pthread_cond_waitFunction · 0.50
pthread_mutex_unlockFunction · 0.50

Tested by

no test coverage detected