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

Commit 693cb2bd authored by Phil Burk's avatar Phil Burk Committed by Android (Google) Code Review
Browse files

Merge "aaudio: use xruns detected in the service"

parents 720e24cf 2329638e
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -38,14 +38,17 @@ typedef enum aaudio_service_event_e : uint32_t {
    AAUDIO_SERVICE_EVENT_FLUSHED,
    AAUDIO_SERVICE_EVENT_CLOSED,
    AAUDIO_SERVICE_EVENT_DISCONNECTED,
    AAUDIO_SERVICE_EVENT_VOLUME
    AAUDIO_SERVICE_EVENT_VOLUME,
    AAUDIO_SERVICE_EVENT_XRUN
} aaudio_service_event_t;

struct AAudioMessageEvent {
    aaudio_service_event_t event;
    union {
        double  dataDouble;
        int64_t dataLong;
    };
};

typedef struct AAudioServiceMessage_s {
    enum class code : uint32_t {
+3 −0
Original line number Diff line number Diff line
@@ -492,6 +492,9 @@ aaudio_result_t AudioStreamInternal::onEventFromServer(AAudioServiceMessage *mes
            doSetVolume();
            ALOGD("%s - AAUDIO_SERVICE_EVENT_VOLUME %lf", __func__, message->event.dataDouble);
            break;
        case AAUDIO_SERVICE_EVENT_XRUN:
            mXRunCount = static_cast<int32_t>(message->event.dataLong);
            break;
        default:
            ALOGE("%s - Unrecognized event = %d", __func__, (int) message->event.event);
            break;
+2 −1
Original line number Diff line number Diff line
@@ -102,7 +102,8 @@ aaudio_result_t AudioStreamInternalCapture::processDataNow(void *buffer, int32_t
    }

    // If the write index passed the read index then consider it an overrun.
    if (mAudioEndpoint.getEmptyFramesAvailable() < 0) {
    // For shared streams, the xRunCount is passed up from the service.
    if (mAudioEndpoint.isFreeRunning() && mAudioEndpoint.getEmptyFramesAvailable() < 0) {
        mXRunCount++;
        if (ATRACE_ENABLED()) {
            ATRACE_INT("aaOverRuns", mXRunCount);
+2 −1
Original line number Diff line number Diff line
@@ -140,7 +140,8 @@ aaudio_result_t AudioStreamInternalPlay::processDataNow(void *buffer, int32_t nu
    }

    // If the read index passed the write index then consider it an underrun.
    if (mAudioEndpoint.getFullFramesAvailable() < 0) {
    // For shared streams, the xRunCount is passed up from the service.
    if (mAudioEndpoint.isFreeRunning() && mAudioEndpoint.getFullFramesAvailable() < 0) {
        mXRunCount++;
        if (ATRACE_ENABLED()) {
            ATRACE_INT("aaUnderRuns", mXRunCount);
+2 −2
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ void AAudioMixer::clear() {
    memset(mOutputBuffer, 0, mBufferSizeInBytes);
}

bool AAudioMixer::mix(int streamIndex, FifoBuffer *fifo, bool allowUnderflow) {
int32_t AAudioMixer::mix(int streamIndex, FifoBuffer *fifo, bool allowUnderflow) {
    WrappingBuffer wrappingBuffer;
    float *destination = mOutputBuffer;

@@ -105,7 +105,7 @@ bool AAudioMixer::mix(int streamIndex, FifoBuffer *fifo, bool allowUnderflow) {
    ATRACE_END();
#endif /* AAUDIO_MIXER_ATRACE_ENABLED */

    return (framesLeft > 0); // did not get all the frames we needed, ie. "underflow"
    return (framesDesired - framesLeft); // framesRead
}

void AAudioMixer::mixPart(float *destination, float *source, int32_t numFrames) {
Loading