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

Commit df576995 authored by Eric Laurent's avatar Eric Laurent
Browse files

AudioTrack: fix obtainBuffer timeout calculation

AudioTrack::obtainBuffer() passes a pointer to a timeout
variable that has gone out of scope when calling
ClientProxy::obtainBuffer().

Same fix for AudioRecord.

Bug: 11968591.
Change-Id: I22af8f94fa2f8cc54ab5c25c89167c805e754317
parent b2b9b2db
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -570,13 +570,13 @@ status_t AudioRecord::obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
    }
    }


    const struct timespec *requested;
    const struct timespec *requested;
    struct timespec timeout;
    if (waitCount == -1) {
    if (waitCount == -1) {
        requested = &ClientProxy::kForever;
        requested = &ClientProxy::kForever;
    } else if (waitCount == 0) {
    } else if (waitCount == 0) {
        requested = &ClientProxy::kNonBlocking;
        requested = &ClientProxy::kNonBlocking;
    } else if (waitCount > 0) {
    } else if (waitCount > 0) {
        long long ms = WAIT_PERIOD_MS * (long long) waitCount;
        long long ms = WAIT_PERIOD_MS * (long long) waitCount;
        struct timespec timeout;
        timeout.tv_sec = ms / 1000;
        timeout.tv_sec = ms / 1000;
        timeout.tv_nsec = (int) (ms % 1000) * 1000000;
        timeout.tv_nsec = (int) (ms % 1000) * 1000000;
        requested = &timeout;
        requested = &timeout;
+1 −1
Original line number Original line Diff line number Diff line
@@ -1133,13 +1133,13 @@ status_t AudioTrack::obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
    }
    }


    const struct timespec *requested;
    const struct timespec *requested;
    struct timespec timeout;
    if (waitCount == -1) {
    if (waitCount == -1) {
        requested = &ClientProxy::kForever;
        requested = &ClientProxy::kForever;
    } else if (waitCount == 0) {
    } else if (waitCount == 0) {
        requested = &ClientProxy::kNonBlocking;
        requested = &ClientProxy::kNonBlocking;
    } else if (waitCount > 0) {
    } else if (waitCount > 0) {
        long long ms = WAIT_PERIOD_MS * (long long) waitCount;
        long long ms = WAIT_PERIOD_MS * (long long) waitCount;
        struct timespec timeout;
        timeout.tv_sec = ms / 1000;
        timeout.tv_sec = ms / 1000;
        timeout.tv_nsec = (int) (ms % 1000) * 1000000;
        timeout.tv_nsec = (int) (ms % 1000) * 1000000;
        requested = &timeout;
        requested = &timeout;