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

Commit 9bba7f17 authored by Chih-Hung Hsieh's avatar Chih-Hung Hsieh Committed by Chih-hung Hsieh
Browse files

Use -Werror in frameworks/av/media/libaaudio

* Remove unused local variables, labels, functions, private fields.
* Fix warning of unused return result.
* Use template functions in .h file to avoid warning of unused static functions.

Bug: 66996870
Test: build with WITH_TIDY=1
Exempt-From-Owner-Approval: to fix broken build
Merged-In: I54962a7fd36a405e54366130b9c0a24e26fe8ebb
(cherry picked from commit 68326fe0)

Change-Id: If5804a74ca2c0560debd56407d8d1c1a25e11129
parent 899b78c1
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -80,7 +80,8 @@ const char *getDirectionText(aaudio_direction_t direction) {
    return text;
}

static void convertNanosecondsToTimespec(int64_t nanoseconds, struct timespec *time) {
template <class T = int64_t>
void convertNanosecondsToTimespec(int64_t nanoseconds, struct timespec *time) {
    time->tv_sec = nanoseconds / NANOS_PER_SECOND;
    // Calculate the fractional nanoseconds. Avoids expensive % operation.
    time->tv_nsec = nanoseconds - (time->tv_sec * NANOS_PER_SECOND);
@@ -96,6 +97,7 @@ int64_t getNanoseconds(clockid_t clockId = CLOCK_MONOTONIC) {
    return (time.tv_sec * NANOS_PER_SECOND) + time.tv_nsec;
}

template <class T = float>
void displayPeakLevel(float peakLevel) {
    printf("%5.3f ", peakLevel);
    const int maxStars = 50; // arbitrary, fits on one line
@@ -114,6 +116,7 @@ void displayPeakLevel(float peakLevel) {
 * @param sampleRate
 * @return latency in milliseconds
 */
template <class T = int64_t>
double calculateLatencyMillis(int64_t position1, int64_t nanoseconds1,
                              int64_t position2, int64_t nanoseconds2,
                              int64_t sampleRate) {
@@ -128,7 +131,8 @@ double calculateLatencyMillis(int64_t position1, int64_t nanoseconds1,

// ================================================================================
// These Futex calls are common online examples.
static android::status_t sys_futex(void *addr1, int op, int val1,
template <class T = int>
android::status_t sys_futex(void *addr1, int op, int val1,
                      struct timespec *timeout, void *addr2, int val3) {
    android::status_t result = (android::status_t) syscall(SYS_futex, addr1,
                                                           op, val1, timeout,
@@ -136,12 +140,14 @@ static android::status_t sys_futex(void *addr1, int op, int val1,
    return (result == 0) ? 0 : -errno;
}

static android::status_t futex_wake(void *addr, int numWake) {
template <class T = int>
android::status_t futex_wake(void *addr, int numWake) {
    // Use _PRIVATE because we are just using the futex in one process.
    return sys_futex(addr, FUTEX_WAKE_PRIVATE, numWake, NULL, NULL, 0);
}

static android::status_t futex_wait(void *addr, int current, struct timespec *time) {
template <class T = int>
android::status_t futex_wait(void *addr, int current, struct timespec *time) {
    // Use _PRIVATE because we are just using the futex in one process.
    return sys_futex(addr, FUTEX_WAIT_PRIVATE, current, time, NULL, 0);
}
+1 −3
Original line number Diff line number Diff line
@@ -111,8 +111,6 @@ static aaudio_result_t testTimeStamps(aaudio_policy_t mmapPolicy,
    aaudio_result_t result = AAUDIO_OK;

    int32_t framesPerBurst = 0;
    float *buffer = nullptr;

    int32_t actualChannelCount = 0;
    int32_t actualSampleRate = 0;
    int32_t originalBufferSize = 0;
@@ -287,7 +285,7 @@ finish:

int main(int argc, char **argv) {
    (void) argc;
    (void *) argv;
    (void) argv;

    aaudio_result_t result = AAUDIO_OK;