Revert "OmxEncoder: new function set_state, set and wait state changed (#19906)"
This reverts commit 36a596eb1e
.
albatross
parent
36a596eb1e
commit
20a2bfdd31
|
@ -34,8 +34,7 @@ extern ExitHandler do_exit;
|
|||
|
||||
// ***** OMX callback functions *****
|
||||
|
||||
void OmxEncoder::set_state_blocking(OMX_STATETYPE state) {
|
||||
OMX_CHECK(OMX_SendCommand(this->handle, OMX_CommandStateSet, state, NULL));
|
||||
void OmxEncoder::wait_for_state(OMX_STATETYPE state) {
|
||||
pthread_mutex_lock(&this->state_lock);
|
||||
while (this->state != state) {
|
||||
pthread_cond_wait(&this->state_cv, &this->state_lock);
|
||||
|
@ -305,7 +304,7 @@ OmxEncoder::OmxEncoder(const char* filename, int width, int height, int fps, int
|
|||
// printf("profile %d level 0x%x\n", params.eProfile, params.eLevel);
|
||||
// }
|
||||
|
||||
set_state_blocking(OMX_StateIdle);
|
||||
OMX_CHECK(OMX_SendCommand(this->handle, OMX_CommandStateSet, OMX_StateIdle, NULL));
|
||||
|
||||
for (auto &buf : this->in_buf_headers) {
|
||||
OMX_CHECK(OMX_AllocateBuffer(this->handle, &buf, PORT_INDEX_IN, this,
|
||||
|
@ -317,7 +316,11 @@ OmxEncoder::OmxEncoder(const char* filename, int width, int height, int fps, int
|
|||
out_port.nBufferSize));
|
||||
}
|
||||
|
||||
set_state_blocking(OMX_StateExecuting);
|
||||
wait_for_state(OMX_StateIdle);
|
||||
|
||||
OMX_CHECK(OMX_SendCommand(this->handle, OMX_CommandStateSet, OMX_StateExecuting, NULL));
|
||||
|
||||
wait_for_state(OMX_StateExecuting);
|
||||
|
||||
// give omx all the output buffers
|
||||
for (auto &buf : this->out_buf_headers) {
|
||||
|
@ -590,8 +593,11 @@ void OmxEncoder::encoder_close() {
|
|||
OmxEncoder::~OmxEncoder() {
|
||||
assert(!this->is_open);
|
||||
|
||||
set_state_blocking(OMX_StateIdle);
|
||||
set_state_blocking(OMX_StateLoaded);
|
||||
OMX_CHECK(OMX_SendCommand(this->handle, OMX_CommandStateSet, OMX_StateIdle, NULL));
|
||||
|
||||
wait_for_state(OMX_StateIdle);
|
||||
|
||||
OMX_CHECK(OMX_SendCommand(this->handle, OMX_CommandStateSet, OMX_StateLoaded, NULL));
|
||||
|
||||
for (auto &buf : this->in_buf_headers) {
|
||||
OMX_CHECK(OMX_FreeBuffer(this->handle, PORT_INDEX_IN, buf));
|
||||
|
@ -601,6 +607,8 @@ OmxEncoder::~OmxEncoder() {
|
|||
OMX_CHECK(OMX_FreeBuffer(this->handle, PORT_INDEX_OUT, buf));
|
||||
}
|
||||
|
||||
wait_for_state(OMX_StateLoaded);
|
||||
|
||||
OMX_CHECK(OMX_FreeHandle(this->handle));
|
||||
|
||||
OMX_BUFFERHEADERTYPE *out_buf;
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
OMX_BUFFERHEADERTYPE *buffer);
|
||||
|
||||
private:
|
||||
void set_state_blocking(OMX_STATETYPE state);
|
||||
void wait_for_state(OMX_STATETYPE state);
|
||||
static void handle_out_buf(OmxEncoder *e, OMX_BUFFERHEADERTYPE *out_buf);
|
||||
|
||||
pthread_mutex_t lock;
|
||||
|
|
Loading…
Reference in New Issue