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

Commit a49482ae authored by Ray Essick's avatar Ray Essick
Browse files

Limit an NdkMediaCodec diagnostic

Reduce the frequency of a diagnostic when we have error codes that are
not mapped between stagefright and the NDK. Reduced from every
occurrence to 1 time per different error per process.

Bug: 223724888
Test: cts tests, examine logs
Change-Id: I246f808fe0ada8ccaeb7166c420110748eca6522
parent bc7238fe
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */

#include <inttypes.h>
#include <mutex>
#include <set>

//#define LOG_NDEBUG 0
#define LOG_TAG "NdkMediaCodec"
@@ -42,6 +44,7 @@ using namespace android;


static media_status_t translate_error(status_t err) {

    if (err == OK) {
        return AMEDIA_OK;
    } else if (err == -EAGAIN) {
@@ -51,7 +54,18 @@ static media_status_t translate_error(status_t err) {
    } else if (err == DEAD_OBJECT) {
        return AMEDIACODEC_ERROR_RECLAIMED;
    }
    ALOGE("sf error code: %d", err);

    {
        // minimize log flooding. Some CTS behavior made this noisy and apps could do the same.
        static std::set<status_t> untranslated;
        static std::mutex mutex;
        std::lock_guard lg(mutex);

        if (untranslated.find(err) == untranslated.end()) {
            ALOGE("untranslated sf error code: %d", err);
            untranslated.insert(err);
        }
    }
    return AMEDIA_ERROR_UNKNOWN;
}