| 115 | } |
| 116 | |
| 117 | int tq_send(ThreadQueue *tq, unsigned int stream_idx, void *data) |
| 118 | { |
| 119 | int *finished; |
| 120 | int ret; |
| 121 | |
| 122 | av_assert0(stream_idx < tq->nb_streams); |
| 123 | finished = &tq->finished[stream_idx]; |
| 124 | |
| 125 | pthread_mutex_lock(&tq->lock); |
| 126 | |
| 127 | if (*finished & FINISHED_SEND) { |
| 128 | ret = AVERROR(EINVAL); |
| 129 | goto finish; |
| 130 | } |
| 131 | |
| 132 | while (!(*finished & FINISHED_RECV) && !av_fifo_can_write(tq->fifo_stream_index)) |
| 133 | pthread_cond_wait(&tq->cond, &tq->lock); |
| 134 | |
| 135 | if (*finished & FINISHED_RECV) { |
| 136 | ret = AVERROR_EOF; |
| 137 | *finished |= FINISHED_SEND; |
| 138 | } else { |
| 139 | ret = av_fifo_write(tq->fifo_stream_index, &stream_idx, 1); |
| 140 | if (ret < 0) |
| 141 | goto finish; |
| 142 | |
| 143 | ret = av_container_fifo_write(tq->fifo, data, 0); |
| 144 | if (ret < 0) |
| 145 | goto finish; |
| 146 | |
| 147 | pthread_cond_broadcast(&tq->cond); |
| 148 | } |
| 149 | |
| 150 | finish: |
| 151 | pthread_mutex_unlock(&tq->lock); |
| 152 | |
| 153 | return ret; |
| 154 | } |
| 155 | |
| 156 | static int receive_locked(ThreadQueue *tq, int *stream_idx, |
| 157 | void *data) |
no test coverage detected