Loading media/libaaudio/src/client/AudioStreamInternal.cpp +0 −50 Original line number Diff line number Diff line Loading @@ -287,56 +287,6 @@ aaudio_result_t AudioStreamInternal::stopCallback() } } aaudio_result_t AudioStreamInternal::requestPauseInternal() { if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { ALOGE("AudioStreamInternal::requestPauseInternal() mServiceStreamHandle invalid = 0x%08X", mServiceStreamHandle); return AAUDIO_ERROR_INVALID_STATE; } mClockModel.stop(AudioClock::getNanoseconds()); setState(AAUDIO_STREAM_STATE_PAUSING); return AAudioConvert_androidToAAudioResult(pauseWithStatus()); } aaudio_result_t AudioStreamInternal::requestPause() { aaudio_result_t result = stopCallback(); if (result != AAUDIO_OK) { return result; } result = requestPauseInternal(); return result; } aaudio_result_t AudioStreamInternal::requestFlush() { if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { ALOGE("AudioStreamInternal::requestFlush() mServiceStreamHandle invalid = 0x%08X", mServiceStreamHandle); return AAUDIO_ERROR_INVALID_STATE; } setState(AAUDIO_STREAM_STATE_FLUSHING); return mServiceInterface.flushStream(mServiceStreamHandle); } // TODO for Play only void AudioStreamInternal::onFlushFromServer() { int64_t readCounter = mAudioEndpoint.getDataReadCounter(); int64_t writeCounter = mAudioEndpoint.getDataWriteCounter(); // Bump offset so caller does not see the retrograde motion in getFramesRead(). int64_t framesFlushed = writeCounter - readCounter; mFramesOffsetFromService += framesFlushed; ALOGD("AudioStreamInternal::onFlushFromServer() readN = %lld, writeN = %lld, offset = %lld", (long long)readCounter, (long long)writeCounter, (long long)mFramesOffsetFromService); // Flush written frames by forcing writeCounter to readCounter. // This is because we cannot move the read counter in the hardware. mAudioEndpoint.setDataWriteCounter(readCounter); } aaudio_result_t AudioStreamInternal::requestStopInternal() { if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { Loading media/libaaudio/src/client/AudioStreamInternal.h +3 −9 Original line number Diff line number Diff line Loading @@ -41,13 +41,8 @@ public: AudioStreamInternal(AAudioServiceInterface &serviceInterface, bool inService); virtual ~AudioStreamInternal(); // =========== Begin ABSTRACT methods =========================== aaudio_result_t requestStart() override; aaudio_result_t requestPause() override; aaudio_result_t requestFlush() override; aaudio_result_t requestStop() override; aaudio_result_t getTimestamp(clockid_t clockId, Loading @@ -55,7 +50,6 @@ public: int64_t *timeNanoseconds) override; virtual aaudio_result_t updateStateWhileWaiting() override; // =========== End ABSTRACT methods =========================== aaudio_result_t open(const AudioStreamBuilder &builder) override; Loading Loading @@ -113,13 +107,12 @@ protected: aaudio_result_t processCommands(); aaudio_result_t requestPauseInternal(); aaudio_result_t requestStopInternal(); aaudio_result_t stopCallback(); void onFlushFromServer(); virtual void onFlushFromServer() {} aaudio_result_t onEventFromServer(AAudioServiceMessage *message); Loading Loading @@ -160,6 +153,8 @@ protected: // The service uses this for SHARED mode. bool mInService = false; // Is this running in the client or the service? AAudioServiceInterface &mServiceInterface; // abstract interface to the service private: /* * Asynchronous write with data conversion. Loading @@ -175,7 +170,6 @@ private: AudioEndpointParcelable mEndPointParcelable; // description of the buffers filled by service EndpointDescriptor mEndpointDescriptor; // buffer description with resolved addresses AAudioServiceInterface &mServiceInterface; // abstract interface to the service }; Loading media/libaaudio/src/client/AudioStreamInternalPlay.cpp +49 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,55 @@ AudioStreamInternalPlay::AudioStreamInternalPlay(AAudioServiceInterface &servic AudioStreamInternalPlay::~AudioStreamInternalPlay() {} aaudio_result_t AudioStreamInternalPlay::requestPauseInternal() { if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { ALOGE("AudioStreamInternal::requestPauseInternal() mServiceStreamHandle invalid = 0x%08X", mServiceStreamHandle); return AAUDIO_ERROR_INVALID_STATE; } mClockModel.stop(AudioClock::getNanoseconds()); setState(AAUDIO_STREAM_STATE_PAUSING); return AAudioConvert_androidToAAudioResult(pauseWithStatus()); } aaudio_result_t AudioStreamInternalPlay::requestPause() { aaudio_result_t result = stopCallback(); if (result != AAUDIO_OK) { return result; } result = requestPauseInternal(); return result; } aaudio_result_t AudioStreamInternalPlay::requestFlush() { if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { ALOGE("AudioStreamInternal::requestFlush() mServiceStreamHandle invalid = 0x%08X", mServiceStreamHandle); return AAUDIO_ERROR_INVALID_STATE; } setState(AAUDIO_STREAM_STATE_FLUSHING); return mServiceInterface.flushStream(mServiceStreamHandle); } void AudioStreamInternalPlay::onFlushFromServer() { int64_t readCounter = mAudioEndpoint.getDataReadCounter(); int64_t writeCounter = mAudioEndpoint.getDataWriteCounter(); // Bump offset so caller does not see the retrograde motion in getFramesRead(). int64_t framesFlushed = writeCounter - readCounter; mFramesOffsetFromService += framesFlushed; ALOGD("AudioStreamInternal::onFlushFromServer() readN = %lld, writeN = %lld, offset = %lld", (long long)readCounter, (long long)writeCounter, (long long)mFramesOffsetFromService); // Flush written frames by forcing writeCounter to readCounter. // This is because we cannot move the read counter in the hardware. mAudioEndpoint.setDataWriteCounter(readCounter); } // Write the data, block if needed and timeoutMillis > 0 aaudio_result_t AudioStreamInternalPlay::write(const void *buffer, int32_t numFrames, int64_t timeoutNanoseconds) Loading media/libaaudio/src/client/AudioStreamInternalPlay.h +9 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,10 @@ public: AudioStreamInternalPlay(AAudioServiceInterface &serviceInterface, bool inService = false); virtual ~AudioStreamInternalPlay(); aaudio_result_t requestPause() override; aaudio_result_t requestFlush() override; aaudio_result_t write(const void *buffer, int32_t numFrames, int64_t timeoutNanoseconds) override; Loading @@ -47,6 +51,11 @@ public: } protected: aaudio_result_t requestPauseInternal(); void onFlushFromServer() override; /** * Low level write that will not block. It will just write as much as it can. * Loading media/libaaudio/src/core/AudioStream.h +12 −2 Original line number Diff line number Diff line Loading @@ -48,8 +48,18 @@ public: * Use waitForStateChange() to wait for completion. */ virtual aaudio_result_t requestStart() = 0; virtual aaudio_result_t requestPause() = 0; virtual aaudio_result_t requestFlush() = 0; virtual aaudio_result_t requestPause() { // Only implement this for OUTPUT streams. return AAUDIO_ERROR_UNIMPLEMENTED; } virtual aaudio_result_t requestFlush() { // Only implement this for OUTPUT streams. return AAUDIO_ERROR_UNIMPLEMENTED; } virtual aaudio_result_t requestStop() = 0; virtual aaudio_result_t getTimestamp(clockid_t clockId, Loading Loading
media/libaaudio/src/client/AudioStreamInternal.cpp +0 −50 Original line number Diff line number Diff line Loading @@ -287,56 +287,6 @@ aaudio_result_t AudioStreamInternal::stopCallback() } } aaudio_result_t AudioStreamInternal::requestPauseInternal() { if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { ALOGE("AudioStreamInternal::requestPauseInternal() mServiceStreamHandle invalid = 0x%08X", mServiceStreamHandle); return AAUDIO_ERROR_INVALID_STATE; } mClockModel.stop(AudioClock::getNanoseconds()); setState(AAUDIO_STREAM_STATE_PAUSING); return AAudioConvert_androidToAAudioResult(pauseWithStatus()); } aaudio_result_t AudioStreamInternal::requestPause() { aaudio_result_t result = stopCallback(); if (result != AAUDIO_OK) { return result; } result = requestPauseInternal(); return result; } aaudio_result_t AudioStreamInternal::requestFlush() { if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { ALOGE("AudioStreamInternal::requestFlush() mServiceStreamHandle invalid = 0x%08X", mServiceStreamHandle); return AAUDIO_ERROR_INVALID_STATE; } setState(AAUDIO_STREAM_STATE_FLUSHING); return mServiceInterface.flushStream(mServiceStreamHandle); } // TODO for Play only void AudioStreamInternal::onFlushFromServer() { int64_t readCounter = mAudioEndpoint.getDataReadCounter(); int64_t writeCounter = mAudioEndpoint.getDataWriteCounter(); // Bump offset so caller does not see the retrograde motion in getFramesRead(). int64_t framesFlushed = writeCounter - readCounter; mFramesOffsetFromService += framesFlushed; ALOGD("AudioStreamInternal::onFlushFromServer() readN = %lld, writeN = %lld, offset = %lld", (long long)readCounter, (long long)writeCounter, (long long)mFramesOffsetFromService); // Flush written frames by forcing writeCounter to readCounter. // This is because we cannot move the read counter in the hardware. mAudioEndpoint.setDataWriteCounter(readCounter); } aaudio_result_t AudioStreamInternal::requestStopInternal() { if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { Loading
media/libaaudio/src/client/AudioStreamInternal.h +3 −9 Original line number Diff line number Diff line Loading @@ -41,13 +41,8 @@ public: AudioStreamInternal(AAudioServiceInterface &serviceInterface, bool inService); virtual ~AudioStreamInternal(); // =========== Begin ABSTRACT methods =========================== aaudio_result_t requestStart() override; aaudio_result_t requestPause() override; aaudio_result_t requestFlush() override; aaudio_result_t requestStop() override; aaudio_result_t getTimestamp(clockid_t clockId, Loading @@ -55,7 +50,6 @@ public: int64_t *timeNanoseconds) override; virtual aaudio_result_t updateStateWhileWaiting() override; // =========== End ABSTRACT methods =========================== aaudio_result_t open(const AudioStreamBuilder &builder) override; Loading Loading @@ -113,13 +107,12 @@ protected: aaudio_result_t processCommands(); aaudio_result_t requestPauseInternal(); aaudio_result_t requestStopInternal(); aaudio_result_t stopCallback(); void onFlushFromServer(); virtual void onFlushFromServer() {} aaudio_result_t onEventFromServer(AAudioServiceMessage *message); Loading Loading @@ -160,6 +153,8 @@ protected: // The service uses this for SHARED mode. bool mInService = false; // Is this running in the client or the service? AAudioServiceInterface &mServiceInterface; // abstract interface to the service private: /* * Asynchronous write with data conversion. Loading @@ -175,7 +170,6 @@ private: AudioEndpointParcelable mEndPointParcelable; // description of the buffers filled by service EndpointDescriptor mEndpointDescriptor; // buffer description with resolved addresses AAudioServiceInterface &mServiceInterface; // abstract interface to the service }; Loading
media/libaaudio/src/client/AudioStreamInternalPlay.cpp +49 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,55 @@ AudioStreamInternalPlay::AudioStreamInternalPlay(AAudioServiceInterface &servic AudioStreamInternalPlay::~AudioStreamInternalPlay() {} aaudio_result_t AudioStreamInternalPlay::requestPauseInternal() { if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { ALOGE("AudioStreamInternal::requestPauseInternal() mServiceStreamHandle invalid = 0x%08X", mServiceStreamHandle); return AAUDIO_ERROR_INVALID_STATE; } mClockModel.stop(AudioClock::getNanoseconds()); setState(AAUDIO_STREAM_STATE_PAUSING); return AAudioConvert_androidToAAudioResult(pauseWithStatus()); } aaudio_result_t AudioStreamInternalPlay::requestPause() { aaudio_result_t result = stopCallback(); if (result != AAUDIO_OK) { return result; } result = requestPauseInternal(); return result; } aaudio_result_t AudioStreamInternalPlay::requestFlush() { if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { ALOGE("AudioStreamInternal::requestFlush() mServiceStreamHandle invalid = 0x%08X", mServiceStreamHandle); return AAUDIO_ERROR_INVALID_STATE; } setState(AAUDIO_STREAM_STATE_FLUSHING); return mServiceInterface.flushStream(mServiceStreamHandle); } void AudioStreamInternalPlay::onFlushFromServer() { int64_t readCounter = mAudioEndpoint.getDataReadCounter(); int64_t writeCounter = mAudioEndpoint.getDataWriteCounter(); // Bump offset so caller does not see the retrograde motion in getFramesRead(). int64_t framesFlushed = writeCounter - readCounter; mFramesOffsetFromService += framesFlushed; ALOGD("AudioStreamInternal::onFlushFromServer() readN = %lld, writeN = %lld, offset = %lld", (long long)readCounter, (long long)writeCounter, (long long)mFramesOffsetFromService); // Flush written frames by forcing writeCounter to readCounter. // This is because we cannot move the read counter in the hardware. mAudioEndpoint.setDataWriteCounter(readCounter); } // Write the data, block if needed and timeoutMillis > 0 aaudio_result_t AudioStreamInternalPlay::write(const void *buffer, int32_t numFrames, int64_t timeoutNanoseconds) Loading
media/libaaudio/src/client/AudioStreamInternalPlay.h +9 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,10 @@ public: AudioStreamInternalPlay(AAudioServiceInterface &serviceInterface, bool inService = false); virtual ~AudioStreamInternalPlay(); aaudio_result_t requestPause() override; aaudio_result_t requestFlush() override; aaudio_result_t write(const void *buffer, int32_t numFrames, int64_t timeoutNanoseconds) override; Loading @@ -47,6 +51,11 @@ public: } protected: aaudio_result_t requestPauseInternal(); void onFlushFromServer() override; /** * Low level write that will not block. It will just write as much as it can. * Loading
media/libaaudio/src/core/AudioStream.h +12 −2 Original line number Diff line number Diff line Loading @@ -48,8 +48,18 @@ public: * Use waitForStateChange() to wait for completion. */ virtual aaudio_result_t requestStart() = 0; virtual aaudio_result_t requestPause() = 0; virtual aaudio_result_t requestFlush() = 0; virtual aaudio_result_t requestPause() { // Only implement this for OUTPUT streams. return AAUDIO_ERROR_UNIMPLEMENTED; } virtual aaudio_result_t requestFlush() { // Only implement this for OUTPUT streams. return AAUDIO_ERROR_UNIMPLEMENTED; } virtual aaudio_result_t requestStop() = 0; virtual aaudio_result_t getTimestamp(clockid_t clockId, Loading