mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 19:23:56 +08:00
* Squashed vipc
* Update release files
* Remove else
* add visionipc to release files
* use poller in vipc receive
* opencl framework instead of lib on macos
* Fix camera webcam
* Fix opencl on mac in ui
* more webcam fixes
* typo in ui sconsfile
* Use cur_yuv_buf
* visionbuf c++ class
* Camera qcom was still using visionbuf_allocate
* Turn loggerd back on
* fix snapshot
* No build needed
* update test camerad
* no more release callback
* make encoder c++
* Revert "no more release callback"
This reverts commit e5707b07002fee665d0483d90713154efc2d70d4.
* fix exit handlers
* No need to check errno
* move release callback call
* s/VIPCBufExtra/VisionIpcBufExtra/g
* use non blocking connect
* ui use non blocking connect
* Lower condition variable wait time
* Snapshot cleanup
* bump cereal
* bump cereal
old-commit-hash: fb496c692a
55 lines
1.1 KiB
C
55 lines
1.1 KiB
C
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <assert.h>
|
|
|
|
#include "cqueue.h"
|
|
|
|
// TODO: replace by C++ queue and CV. See camerad
|
|
|
|
void queue_init(Queue *q) {
|
|
memset(q, 0, sizeof(*q));
|
|
TAILQ_INIT(&q->q);
|
|
pthread_mutex_init(&q->lock, NULL);
|
|
pthread_cond_init(&q->cv, NULL);
|
|
}
|
|
|
|
void* queue_pop(Queue *q) {
|
|
pthread_mutex_lock(&q->lock);
|
|
while (TAILQ_EMPTY(&q->q)) {
|
|
pthread_cond_wait(&q->cv, &q->lock);
|
|
}
|
|
QueueEntry *entry = TAILQ_FIRST(&q->q);
|
|
TAILQ_REMOVE(&q->q, entry, entries);
|
|
pthread_mutex_unlock(&q->lock);
|
|
|
|
void* r = entry->data;
|
|
free(entry);
|
|
return r;
|
|
}
|
|
|
|
void* queue_try_pop(Queue *q) {
|
|
pthread_mutex_lock(&q->lock);
|
|
|
|
void* r = NULL;
|
|
if (!TAILQ_EMPTY(&q->q)) {
|
|
QueueEntry *entry = TAILQ_FIRST(&q->q);
|
|
TAILQ_REMOVE(&q->q, entry, entries);
|
|
r = entry->data;
|
|
free(entry);
|
|
}
|
|
|
|
pthread_mutex_unlock(&q->lock);
|
|
return r;
|
|
}
|
|
|
|
void queue_push(Queue *q, void *data) {
|
|
QueueEntry *entry = calloc(1, sizeof(QueueEntry));
|
|
assert(entry);
|
|
entry->data = data;
|
|
|
|
pthread_mutex_lock(&q->lock);
|
|
TAILQ_INSERT_TAIL(&q->q, entry, entries);
|
|
pthread_cond_signal(&q->cv);
|
|
pthread_mutex_unlock(&q->lock);
|
|
}
|