return < 0 if aborted, 0 if no packet and > 0 if packet. */
| 532 | |
| 533 | /* return < 0 if aborted, 0 if no packet and > 0 if packet. */ |
| 534 | static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block, int *serial) |
| 535 | { |
| 536 | MyAVPacketList pkt1; |
| 537 | int ret; |
| 538 | |
| 539 | SDL_LockMutex(q->mutex); |
| 540 | |
| 541 | for (;;) { |
| 542 | if (q->abort_request) { |
| 543 | ret = -1; |
| 544 | break; |
| 545 | } |
| 546 | |
| 547 | if (av_fifo_read(q->pkt_list, &pkt1, 1) >= 0) { |
| 548 | q->nb_packets--; |
| 549 | q->size -= pkt1.pkt->size + sizeof(pkt1); |
| 550 | q->duration -= pkt1.pkt->duration; |
| 551 | av_packet_move_ref(pkt, pkt1.pkt); |
| 552 | if (serial) |
| 553 | *serial = pkt1.serial; |
| 554 | av_packet_free(&pkt1.pkt); |
| 555 | ret = 1; |
| 556 | break; |
| 557 | } else if (!block) { |
| 558 | ret = 0; |
| 559 | break; |
| 560 | } else { |
| 561 | SDL_CondWait(q->cond, q->mutex); |
| 562 | } |
| 563 | } |
| 564 | SDL_UnlockMutex(q->mutex); |
| 565 | return ret; |
| 566 | } |
| 567 | |
| 568 | static int decoder_init(Decoder *d, AVCodecContext *avctx, PacketQueue *queue, SDL_cond *empty_queue_cond) { |
| 569 | memset(d, 0, sizeof(Decoder)); |
no test coverage detected