Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 984a5432 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

stagefright: fix issues with OMX message passing

- added destructor for MessageList so messages are freed
- check if notify has been initialized
- do not call onMessages if there are no messages

Bug: 21659665
Change-Id: Idb4eaa63dc2f8be8b282be79e6234f83a7669481
parent 4599da7f
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -110,6 +110,8 @@ static void InitOMXParams(T *params) {
struct MessageList : public RefBase {
struct MessageList : public RefBase {
    MessageList() {
    MessageList() {
    }
    }
    virtual ~MessageList() {
    }
    std::list<sp<AMessage> > &getList() { return mList; }
    std::list<sp<AMessage> > &getList() { return mList; }
private:
private:
    std::list<sp<AMessage> > mList;
    std::list<sp<AMessage> > mList;
@@ -126,15 +128,19 @@ struct CodecObserver : public BnOMXObserver {


    // from IOMXObserver
    // from IOMXObserver
    virtual void onMessages(const std::list<omx_message> &messages) {
    virtual void onMessages(const std::list<omx_message> &messages) {
        sp<AMessage> notify;
        if (messages.empty()) {
            return;
        }

        sp<AMessage> notify = mNotify->dup();
        bool first = true;
        bool first = true;
        sp<MessageList> msgList = new MessageList();
        sp<MessageList> msgList = new MessageList();
        for (std::list<omx_message>::const_iterator it = messages.cbegin();
        for (std::list<omx_message>::const_iterator it = messages.cbegin();
              it != messages.cend(); ++it) {
              it != messages.cend(); ++it) {
            const omx_message &omx_msg = *it;
            const omx_message &omx_msg = *it;
            if (first) {
            if (first) {
                notify = mNotify->dup();
                notify->setInt32("node", omx_msg.node);
                notify->setInt32("node", omx_msg.node);
                first = false;
            }
            }


            sp<AMessage> msg = new AMessage;
            sp<AMessage> msg = new AMessage;
+3 −1
Original line number Original line Diff line number Diff line
@@ -1423,8 +1423,10 @@ void OMXNodeInstance::onMessages(std::list<omx_message> &messages) {
        }
        }
    }
    }


    if (!messages.empty()) {
        mObserver->onMessages(messages);
        mObserver->onMessages(messages);
    }
    }
}


void OMXNodeInstance::onObserverDied(OMXMaster *master) {
void OMXNodeInstance::onObserverDied(OMXMaster *master) {
    ALOGE("!!! Observer died. Quickly, do something, ... anything...");
    ALOGE("!!! Observer died. Quickly, do something, ... anything...");