OMXEncoder: remove pthread_mutex_t lock from member variables (#19948)
* remove mutex * rebase masterpull/19980/head
parent
2d0c249f40
commit
9a9641a296
|
@ -198,7 +198,6 @@ selfdrive/common/clutil.cc
|
|||
selfdrive/common/clutil.h
|
||||
selfdrive/common/params.h
|
||||
selfdrive/common/params.cc
|
||||
selfdrive/common/mutex.h
|
||||
|
||||
selfdrive/common/modeldata.h
|
||||
selfdrive/common/mat.h
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#ifndef COMMON_MUTEX_H
|
||||
#define COMMON_MUTEX_H
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
static inline void mutex_init_reentrant(pthread_mutex_t *mutex) {
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
pthread_mutex_init(mutex, &attr);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -18,7 +18,6 @@
|
|||
#include <libyuv.h>
|
||||
#include <msm_media_info.h>
|
||||
|
||||
#include "common/mutex.h"
|
||||
#include "common/util.h"
|
||||
#include "common/swaglog.h"
|
||||
|
||||
|
@ -173,7 +172,6 @@ OmxEncoder::OmxEncoder(const char* filename, int width, int height, int fps, int
|
|||
this->fps = fps;
|
||||
this->remuxing = !h265;
|
||||
|
||||
mutex_init_reentrant(&this->lock);
|
||||
pthread_mutex_init(&this->state_lock, NULL);
|
||||
pthread_cond_init(&this->state_cv, NULL);
|
||||
|
||||
|
@ -408,10 +406,7 @@ int OmxEncoder::encode_frame(const uint8_t *y_ptr, const uint8_t *u_ptr, const u
|
|||
int in_width, int in_height,
|
||||
int *frame_segment, uint64_t ts) {
|
||||
int err;
|
||||
pthread_mutex_lock(&this->lock);
|
||||
|
||||
if (!this->is_open) {
|
||||
pthread_mutex_unlock(&this->lock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -421,7 +416,6 @@ int OmxEncoder::encode_frame(const uint8_t *y_ptr, const uint8_t *u_ptr, const u
|
|||
OMX_BUFFERHEADERTYPE* in_buf = nullptr;
|
||||
while (!this->free_in.try_pop(in_buf, 20)) {
|
||||
if (do_exit) {
|
||||
pthread_mutex_unlock(&this->lock);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -487,15 +481,12 @@ int OmxEncoder::encode_frame(const uint8_t *y_ptr, const uint8_t *u_ptr, const u
|
|||
*frame_segment = this->segment;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&this->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void OmxEncoder::encoder_open(const char* path, int segment) {
|
||||
int err;
|
||||
|
||||
pthread_mutex_lock(&this->lock);
|
||||
|
||||
this->segment = segment;
|
||||
snprintf(this->vid_path, sizeof(this->vid_path), "%s/%s", path, this->filename);
|
||||
LOGD("encoder_open %s remuxing:%d", this->vid_path, this->remuxing);
|
||||
|
@ -543,13 +534,9 @@ void OmxEncoder::encoder_open(const char* path, int segment) {
|
|||
|
||||
this->is_open = true;
|
||||
this->counter = 0;
|
||||
|
||||
pthread_mutex_unlock(&this->lock);
|
||||
}
|
||||
|
||||
void OmxEncoder::encoder_close() {
|
||||
pthread_mutex_lock(&this->lock);
|
||||
|
||||
if (this->is_open) {
|
||||
if (this->dirty) {
|
||||
// drain output only if there could be frames in the encoder
|
||||
|
@ -586,8 +573,6 @@ void OmxEncoder::encoder_close() {
|
|||
unlink(this->lock_path);
|
||||
}
|
||||
this->is_open = false;
|
||||
|
||||
pthread_mutex_unlock(&this->lock);
|
||||
}
|
||||
|
||||
OmxEncoder::~OmxEncoder() {
|
||||
|
|
|
@ -38,7 +38,6 @@ private:
|
|||
void wait_for_state(OMX_STATETYPE state);
|
||||
static void handle_out_buf(OmxEncoder *e, OMX_BUFFERHEADERTYPE *out_buf);
|
||||
|
||||
pthread_mutex_t lock;
|
||||
int width, height, fps;
|
||||
char vid_path[1024];
|
||||
char lock_path[1024];
|
||||
|
|
Loading…
Reference in New Issue