Loading media/libstagefright/CCodec.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -182,7 +182,7 @@ void CCodec::allocate(const AString &componentName) { mListener.reset(new CCodecListener(mChannel)); std::shared_ptr<C2Component> comp(new C2SoftAvcDec(componentName.c_str(), 0)); comp->setListener_sm(mListener); comp->setListener_vb(mListener, C2_DONT_BLOCK); { Mutexed<State>::Locked state(mState); if (state->mState != ALLOCATING) { Loading media/libstagefright/codec2/SimpleC2Component.cpp +13 −4 Original line number Diff line number Diff line Loading @@ -29,12 +29,19 @@ SimpleC2Component::SimpleC2Component( : mIntf(intf) { } c2_status_t SimpleC2Component::setListener_sm(const std::shared_ptr<C2Component::Listener> &listener) { c2_status_t SimpleC2Component::setListener_vb( const std::shared_ptr<C2Component::Listener> &listener, c2_blocking_t mayBlock) { Mutexed<ExecState>::Locked state(mExecState); if (state->mState == RUNNING) { if (listener) { return C2_BAD_STATE; } else if (!mayBlock) { return C2_BLOCKING; } } state->mListener = listener; // TODO: wait for listener change to have taken place before returning // (e.g. if there is an ongoing listener callback) return C2_OK; } Loading Loading @@ -167,7 +174,7 @@ c2_status_t SimpleC2Component::stop() { return C2_OK; } void SimpleC2Component::reset() { c2_status_t SimpleC2Component::reset() { { Mutexed<ExecState>::Locked state(mExecState); state->mState = UNINITIALIZED; Loading @@ -181,15 +188,17 @@ void SimpleC2Component::reset() { pending->clear(); } onReset(); return C2_OK; } void SimpleC2Component::release() { c2_status_t SimpleC2Component::release() { { Mutexed<ExecState>::Locked state(mExecState); mExitRequested = true; state->mThread.join(); } onRelease(); return C2_OK; } std::shared_ptr<C2ComponentInterface> SimpleC2Component::intf() { Loading media/libstagefright/codec2/include/C2.h +20 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,7 @@ enum c2_status_t : int32_t { TIMED_OUT = -ETIMEDOUT, UNKNOWN_ERROR = -EFAULT, UNKNOWN_TRANSACTION = -EBADMSG, WOULD_BLOCK = -EWOULDBLOCK, #endif C2_OK = OK, ///< operation completed successfully Loading @@ -141,6 +142,7 @@ enum c2_status_t : int32_t { C2_DUPLICATE = ALREADY_EXISTS, ///< object already exists C2_NOT_FOUND = NAME_NOT_FOUND, ///< object not found C2_BAD_STATE = INVALID_OPERATION, ///< operation is not permitted in the current state C2_BLOCKING = WOULD_BLOCK, ///< operation would block but blocking is not permitted // bad environment C2_NO_MEMORY = NO_MEMORY, ///< not enough memory to complete operation Loading @@ -156,6 +158,24 @@ enum c2_status_t : int32_t { C2_NO_INIT = NO_INIT, ///< status has not been initialized }; /** * Type that describes the desired blocking behavior for variable blocking calls. Blocking in this * API is used in a somewhat modified meaning such that operations that merely update variables * protected by mutexes are still considered "non-blocking" (always used in quotes). */ enum c2_blocking_t : int32_t { /** * The operation SHALL be "non-blocking". This means that it shall not perform any file * operations, or call/wait on other processes. It may use a protected region as long as the * mutex is never used to protect code that is otherwise "may block". */ C2_DONT_BLOCK = false, /** * The operation MAY be temporarily blocking. */ C2_MAY_BLOCK = true, }; /// @} /// \defgroup utils Utilities Loading media/libstagefright/codec2/include/C2Component.h +202 −161 File changed.Preview size limit exceeded, changes collapsed. Show changes media/libstagefright/codec2/include/SimpleC2Component.h +12 −10 Original line number Diff line number Diff line Loading @@ -35,17 +35,19 @@ public: virtual ~SimpleC2Component() = default; // C2Component virtual c2_status_t setListener_sm(const std::shared_ptr<C2Component::Listener> &listener) final; virtual c2_status_t queue_nb(std::list<std::unique_ptr<C2Work>> * const items) final; virtual c2_status_t announce_nb(const std::vector<C2WorkOutline> &items) final; // From C2Component virtual c2_status_t setListener_vb( const std::shared_ptr<Listener> &listener, c2_blocking_t mayBlock) override; virtual c2_status_t queue_nb(std::list<std::unique_ptr<C2Work>>* const items) override; virtual c2_status_t announce_nb(const std::vector<C2WorkOutline> &items) override; virtual c2_status_t flush_sm( flush_mode_t flushThrough, std::list<std::unique_ptr<C2Work>>* const flushedWork) final; virtual c2_status_t drain_nb(drain_mode_t drainThrough) final; virtual c2_status_t start() final; virtual c2_status_t stop() final; virtual void reset() final; virtual void release() final; virtual std::shared_ptr<C2ComponentInterface> intf() final; flush_mode_t mode, std::list<std::unique_ptr<C2Work>>* const flushedWork) override; virtual c2_status_t drain_nb(drain_mode_t mode) override; virtual c2_status_t start() override; virtual c2_status_t stop() override; virtual c2_status_t reset() override; virtual c2_status_t release() override; virtual std::shared_ptr<C2ComponentInterface> intf() override; // for thread inline bool exitRequested() { return mExitRequested; } Loading Loading
media/libstagefright/CCodec.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -182,7 +182,7 @@ void CCodec::allocate(const AString &componentName) { mListener.reset(new CCodecListener(mChannel)); std::shared_ptr<C2Component> comp(new C2SoftAvcDec(componentName.c_str(), 0)); comp->setListener_sm(mListener); comp->setListener_vb(mListener, C2_DONT_BLOCK); { Mutexed<State>::Locked state(mState); if (state->mState != ALLOCATING) { Loading
media/libstagefright/codec2/SimpleC2Component.cpp +13 −4 Original line number Diff line number Diff line Loading @@ -29,12 +29,19 @@ SimpleC2Component::SimpleC2Component( : mIntf(intf) { } c2_status_t SimpleC2Component::setListener_sm(const std::shared_ptr<C2Component::Listener> &listener) { c2_status_t SimpleC2Component::setListener_vb( const std::shared_ptr<C2Component::Listener> &listener, c2_blocking_t mayBlock) { Mutexed<ExecState>::Locked state(mExecState); if (state->mState == RUNNING) { if (listener) { return C2_BAD_STATE; } else if (!mayBlock) { return C2_BLOCKING; } } state->mListener = listener; // TODO: wait for listener change to have taken place before returning // (e.g. if there is an ongoing listener callback) return C2_OK; } Loading Loading @@ -167,7 +174,7 @@ c2_status_t SimpleC2Component::stop() { return C2_OK; } void SimpleC2Component::reset() { c2_status_t SimpleC2Component::reset() { { Mutexed<ExecState>::Locked state(mExecState); state->mState = UNINITIALIZED; Loading @@ -181,15 +188,17 @@ void SimpleC2Component::reset() { pending->clear(); } onReset(); return C2_OK; } void SimpleC2Component::release() { c2_status_t SimpleC2Component::release() { { Mutexed<ExecState>::Locked state(mExecState); mExitRequested = true; state->mThread.join(); } onRelease(); return C2_OK; } std::shared_ptr<C2ComponentInterface> SimpleC2Component::intf() { Loading
media/libstagefright/codec2/include/C2.h +20 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,7 @@ enum c2_status_t : int32_t { TIMED_OUT = -ETIMEDOUT, UNKNOWN_ERROR = -EFAULT, UNKNOWN_TRANSACTION = -EBADMSG, WOULD_BLOCK = -EWOULDBLOCK, #endif C2_OK = OK, ///< operation completed successfully Loading @@ -141,6 +142,7 @@ enum c2_status_t : int32_t { C2_DUPLICATE = ALREADY_EXISTS, ///< object already exists C2_NOT_FOUND = NAME_NOT_FOUND, ///< object not found C2_BAD_STATE = INVALID_OPERATION, ///< operation is not permitted in the current state C2_BLOCKING = WOULD_BLOCK, ///< operation would block but blocking is not permitted // bad environment C2_NO_MEMORY = NO_MEMORY, ///< not enough memory to complete operation Loading @@ -156,6 +158,24 @@ enum c2_status_t : int32_t { C2_NO_INIT = NO_INIT, ///< status has not been initialized }; /** * Type that describes the desired blocking behavior for variable blocking calls. Blocking in this * API is used in a somewhat modified meaning such that operations that merely update variables * protected by mutexes are still considered "non-blocking" (always used in quotes). */ enum c2_blocking_t : int32_t { /** * The operation SHALL be "non-blocking". This means that it shall not perform any file * operations, or call/wait on other processes. It may use a protected region as long as the * mutex is never used to protect code that is otherwise "may block". */ C2_DONT_BLOCK = false, /** * The operation MAY be temporarily blocking. */ C2_MAY_BLOCK = true, }; /// @} /// \defgroup utils Utilities Loading
media/libstagefright/codec2/include/C2Component.h +202 −161 File changed.Preview size limit exceeded, changes collapsed. Show changes
media/libstagefright/codec2/include/SimpleC2Component.h +12 −10 Original line number Diff line number Diff line Loading @@ -35,17 +35,19 @@ public: virtual ~SimpleC2Component() = default; // C2Component virtual c2_status_t setListener_sm(const std::shared_ptr<C2Component::Listener> &listener) final; virtual c2_status_t queue_nb(std::list<std::unique_ptr<C2Work>> * const items) final; virtual c2_status_t announce_nb(const std::vector<C2WorkOutline> &items) final; // From C2Component virtual c2_status_t setListener_vb( const std::shared_ptr<Listener> &listener, c2_blocking_t mayBlock) override; virtual c2_status_t queue_nb(std::list<std::unique_ptr<C2Work>>* const items) override; virtual c2_status_t announce_nb(const std::vector<C2WorkOutline> &items) override; virtual c2_status_t flush_sm( flush_mode_t flushThrough, std::list<std::unique_ptr<C2Work>>* const flushedWork) final; virtual c2_status_t drain_nb(drain_mode_t drainThrough) final; virtual c2_status_t start() final; virtual c2_status_t stop() final; virtual void reset() final; virtual void release() final; virtual std::shared_ptr<C2ComponentInterface> intf() final; flush_mode_t mode, std::list<std::unique_ptr<C2Work>>* const flushedWork) override; virtual c2_status_t drain_nb(drain_mode_t mode) override; virtual c2_status_t start() override; virtual c2_status_t stop() override; virtual c2_status_t reset() override; virtual c2_status_t release() override; virtual std::shared_ptr<C2ComponentInterface> intf() override; // for thread inline bool exitRequested() { return mExitRequested; } Loading