diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-06-25 01:15:07 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-06-25 01:15:07 +0000 |
commit | 31a9eb462b8e4f9427179b6975a0ace8984d9fcb (patch) | |
tree | 4b3aad8a1b2387822264a7a4cdee1e7ead270b4e | |
parent | 7169b302a7679b07f0731661548059052396ae53 (diff) | |
parent | c898b974e7579f4b3a02900b885d418c8127935c (diff) | |
download | device_generic_goldfish-31a9eb462b8e4f9427179b6975a0ace8984d9fcb.tar.gz device_generic_goldfish-31a9eb462b8e4f9427179b6975a0ace8984d9fcb.tar.bz2 device_generic_goldfish-31a9eb462b8e4f9427179b6975a0ace8984d9fcb.zip |
Snap for 6626121 from c898b974e7579f4b3a02900b885d418c8127935c to rvc-releaseandroid-vts-11.0_r5android-vts-11.0_r4android-vts-11.0_r3android-vts-11.0_r2android-vts-11.0_r1android-security-11.0.0_r1android-cts-11.0_r5android-cts-11.0_r4android-cts-11.0_r3android-cts-11.0_r2android-cts-11.0_r1android-11.0.0_r5android-11.0.0_r4android-11.0.0_r3android-11.0.0_r25android-11.0.0_r2android-11.0.0_r17android-11.0.0_r1android11-tests-releaseandroid11-security-releaseandroid11-s1-releaseandroid11-release
Change-Id: Ida63690cf0eb50a95354c338e0c9d67c17852924
-rw-r--r-- | audio/Android.bp | 1 | ||||
-rw-r--r-- | audio/io_thread.cpp | 1 | ||||
-rw-r--r-- | audio/io_thread.h | 7 | ||||
-rw-r--r-- | audio/stream_in.cpp | 42 | ||||
-rw-r--r-- | audio/stream_out.cpp | 42 | ||||
-rw-r--r-- | gnss/gnss_measurement.cpp | 2 |
6 files changed, 63 insertions, 32 deletions
diff --git a/audio/Android.bp b/audio/Android.bp index 4b80fd73..4905fe57 100644 --- a/audio/Android.bp +++ b/audio/Android.bp @@ -41,6 +41,7 @@ cc_library_shared { "libtinyalsa", "libutils", "libfmq", + "libprocessgroup", ], header_libs: [ "libaudio_system_headers", diff --git a/audio/io_thread.cpp b/audio/io_thread.cpp index 35a4d2ad..81982b36 100644 --- a/audio/io_thread.cpp +++ b/audio/io_thread.cpp @@ -32,7 +32,6 @@ bool IOThread::standby() { } void IOThread::requestExit() { - Thread::requestExit(); notify(EXIT_REQUEST); } diff --git a/audio/io_thread.h b/audio/io_thread.h index 355a29c7..698df499 100644 --- a/audio/io_thread.h +++ b/audio/io_thread.h @@ -15,7 +15,6 @@ */ #pragma once -#include <utils/Thread.h> #include <fmq/EventFlag.h> namespace android { @@ -24,15 +23,15 @@ namespace audio { namespace V6_0 { namespace implementation { -struct IOThread : public ::android::Thread { +struct IOThread { static constexpr uint32_t STAND_BY_REQUEST = 1 << 20; static constexpr uint32_t EXIT_REQUEST = 1 << 21; - IOThread() : Thread(false /*canCallJava*/) {} + virtual ~IOThread() {} virtual EventFlag *getEventFlag() = 0; virtual bool notify(uint32_t mask); virtual bool standby(); - void requestExit() override; + virtual void requestExit(); }; } // namespace implementation diff --git a/audio/stream_in.cpp b/audio/stream_in.cpp index 172617d3..89ca7e60 100644 --- a/audio/stream_in.cpp +++ b/audio/stream_in.cpp @@ -23,6 +23,12 @@ #include "deleters.h" #include "talsa.h" #include "util.h" +#include <sys/resource.h> +#include <pthread.h> +#include <cutils/sched_policy.h> +#include <utils/ThreadDefs.h> +#include <future> +#include <thread> namespace android { namespace hardware { @@ -75,29 +81,39 @@ struct ReadThread : public IOThread { mEfGroup.reset(rawEfGroup); } - status = run("reader", PRIORITY_URGENT_AUDIO); - if (status != OK) { - ALOGE("ReadThread::%s:%d: failed to start the thread: %s", - __func__, __LINE__, strerror(-status)); - } + mThread = std::thread(&ReadThread::threadLoop, this); } ~ReadThread() { - requestExit(); - LOG_ALWAYS_FATAL_IF(join() != OK); + if (mThread.joinable()) { + requestExit(); + mThread.join(); + } } EventFlag *getEventFlag() override { return mEfGroup.get(); } - bool threadLoop() override { - while (!exitPending()) { + bool isRunning() const { + return mThread.joinable(); + } + + std::future<pthread_t> getTid() { + return mTid.get_future(); + } + + void threadLoop() { + setpriority(PRIO_PROCESS, 0, PRIORITY_URGENT_AUDIO); + set_sched_policy(0, SP_FOREGROUND); + mTid.set_value(pthread_self()); + + while (true) { uint32_t efState = 0; mEfGroup->wait(MessageQueueFlagBits::NOT_FULL | EXIT_REQUEST | STAND_BY_REQUEST, &efState); if (efState & EXIT_REQUEST) { - return false; + return; } if (efState & STAND_BY_REQUEST) { @@ -122,8 +138,6 @@ struct ReadThread : public IOThread { processCommand(); } } - - return false; // do not restart threadLoop } void processCommand() { @@ -217,6 +231,8 @@ struct ReadThread : public IOThread { std::unique_ptr<uint8_t[]> mBuffer; talsa::PcmPtr mPcm; util::StreamPosition mPos; + std::thread mThread; + std::promise<pthread_t> mTid; }; } // namespace @@ -413,7 +429,7 @@ Return<void> StreamIn::prepareForReading(uint32_t frameSize, *(t->mCommandMQ.getDesc()), *(t->mDataMQ.getDesc()), *(t->mStatusMQ.getDesc()), - {.pid = getpid(), .tid = t->getTid()}); + {.pid = getpid(), .tid = t->getTid().get()}); mReadThread = std::move(t); } else { diff --git a/audio/stream_out.cpp b/audio/stream_out.cpp index 4665efb6..8de19638 100644 --- a/audio/stream_out.cpp +++ b/audio/stream_out.cpp @@ -24,6 +24,12 @@ #include "talsa.h" #include "deleters.h" #include "util.h" +#include <sys/resource.h> +#include <pthread.h> +#include <cutils/sched_policy.h> +#include <utils/ThreadDefs.h> +#include <future> +#include <thread> namespace android { namespace hardware { @@ -78,29 +84,39 @@ struct WriteThread : public IOThread { mEfGroup.reset(rawEfGroup); } - status = run("writer", PRIORITY_URGENT_AUDIO); - if (status != OK) { - ALOGE("WriteThread::%s:%d: failed to start the thread: %s", - __func__, __LINE__, strerror(-status)); - } + mThread = std::thread(&WriteThread::threadLoop, this); } ~WriteThread() { - requestExit(); - LOG_ALWAYS_FATAL_IF(join() != OK); + if (mThread.joinable()) { + requestExit(); + mThread.join(); + } } EventFlag *getEventFlag() override { return mEfGroup.get(); } - bool threadLoop() override { - while (!exitPending()) { + bool isRunning() const { + return mThread.joinable(); + } + + std::future<pthread_t> getTid() { + return mTid.get_future(); + } + + void threadLoop() { + setpriority(PRIO_PROCESS, 0, PRIORITY_URGENT_AUDIO); + set_sched_policy(0, SP_FOREGROUND); + mTid.set_value(pthread_self()); + + while (true) { uint32_t efState = 0; mEfGroup->wait(MessageQueueFlagBits::NOT_EMPTY | STAND_BY_REQUEST | EXIT_REQUEST, &efState); if (efState & EXIT_REQUEST) { - return false; + return; } if (efState & STAND_BY_REQUEST) { @@ -125,8 +141,6 @@ struct WriteThread : public IOThread { processCommand(); } } - - return false; // do not restart threadLoop } void processCommand() { @@ -235,6 +249,8 @@ struct WriteThread : public IOThread { std::unique_ptr<uint8_t[]> mBuffer; talsa::PcmPtr mPcm; util::StreamPosition mPos; + std::thread mThread; + std::promise<pthread_t> mTid; }; } // namespace @@ -431,7 +447,7 @@ Return<void> StreamOut::prepareForWriting(uint32_t frameSize, *(t->mCommandMQ.getDesc()), *(t->mDataMQ.getDesc()), *(t->mStatusMQ.getDesc()), - {.pid = getpid(), .tid = t->getTid()}); + {.pid = getpid(), .tid = t->getTid().get()}); mWriteThread = std::move(t); } else { diff --git a/gnss/gnss_measurement.cpp b/gnss/gnss_measurement.cpp index 746167df..6acedd4f 100644 --- a/gnss/gnss_measurement.cpp +++ b/gnss/gnss_measurement.cpp @@ -88,7 +88,7 @@ void GnssMeasurement20::update() { .receivedSvTimeUncertaintyInNs = 15, .cN0DbHz = 30.0, .pseudorangeRateMps = -484.13739013671875, - .pseudorangeRateUncertaintyMps = 1.0379999876022339, + .pseudorangeRateUncertaintyMps = 0.12, .accumulatedDeltaRangeState = GnssAccumulatedDeltaRangeState10::ADR_STATE_UNKNOWN | 0, .accumulatedDeltaRangeM = 0.0, .accumulatedDeltaRangeUncertaintyM = 0.0, |