Loading media/libaaudio/src/legacy/AudioStreamLegacy.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -72,7 +72,7 @@ aaudio_data_callback_result_t AudioStreamLegacy::callDataCallbackFrames(uint8_t // Implement FixedBlockProcessor // Implement FixedBlockProcessor int32_t AudioStreamLegacy::onProcessFixedBlock(uint8_t *buffer, int32_t numBytes) { int32_t AudioStreamLegacy::onProcessFixedBlock(uint8_t *buffer, int32_t numBytes) { int32_t numFrames = numBytes / getBytesPerDeviceFrame(); int32_t numFrames = numBytes / mBlockAdapterBytesPerFrame; return (int32_t) callDataCallbackFrames(buffer, numFrames); return (int32_t) callDataCallbackFrames(buffer, numFrames); } } Loading media/libaaudio/src/legacy/AudioStreamLegacy.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -133,6 +133,7 @@ protected: MonotonicCounter mTimestampPosition; MonotonicCounter mTimestampPosition; FixedBlockAdapter *mBlockAdapter = nullptr; FixedBlockAdapter *mBlockAdapter = nullptr; int32_t mBlockAdapterBytesPerFrame = 0; aaudio_wrapping_frames_t mPositionWhenStarting = 0; aaudio_wrapping_frames_t mPositionWhenStarting = 0; int32_t mCallbackBufferSize = 0; int32_t mCallbackBufferSize = 0; const android::sp<StreamDeviceCallback> mDeviceCallback; const android::sp<StreamDeviceCallback> mDeviceCallback; Loading media/libaaudio/src/legacy/AudioStreamRecord.cpp +4 −1 Original line number Original line Diff line number Diff line Loading @@ -213,7 +213,10 @@ aaudio_result_t AudioStreamRecord::open(const AudioStreamBuilder& builder) // We may need to pass the data through a block size adapter to guarantee constant size. // We may need to pass the data through a block size adapter to guarantee constant size. if (mCallbackBufferSize != AAUDIO_UNSPECIFIED) { if (mCallbackBufferSize != AAUDIO_UNSPECIFIED) { int callbackSizeBytes = getBytesPerFrame() * mCallbackBufferSize; // The block adapter runs before the format conversion. // So we need to use the device frame size. mBlockAdapterBytesPerFrame = getBytesPerDeviceFrame(); int callbackSizeBytes = mBlockAdapterBytesPerFrame * mCallbackBufferSize; mFixedBlockWriter.open(callbackSizeBytes); mFixedBlockWriter.open(callbackSizeBytes); mBlockAdapter = &mFixedBlockWriter; mBlockAdapter = &mFixedBlockWriter; } else { } else { Loading media/libaaudio/src/legacy/AudioStreamTrack.cpp +4 −1 Original line number Original line Diff line number Diff line Loading @@ -196,7 +196,10 @@ aaudio_result_t AudioStreamTrack::open(const AudioStreamBuilder& builder) // We may need to pass the data through a block size adapter to guarantee constant size. // We may need to pass the data through a block size adapter to guarantee constant size. if (mCallbackBufferSize != AAUDIO_UNSPECIFIED) { if (mCallbackBufferSize != AAUDIO_UNSPECIFIED) { int callbackSizeBytes = getBytesPerFrame() * mCallbackBufferSize; // This may need to change if we add format conversion before // the block size adaptation. mBlockAdapterBytesPerFrame = getBytesPerFrame(); int callbackSizeBytes = mBlockAdapterBytesPerFrame * mCallbackBufferSize; mFixedBlockReader.open(callbackSizeBytes); mFixedBlockReader.open(callbackSizeBytes); mBlockAdapter = &mFixedBlockReader; mBlockAdapter = &mFixedBlockReader; } else { } else { Loading Loading
media/libaaudio/src/legacy/AudioStreamLegacy.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -72,7 +72,7 @@ aaudio_data_callback_result_t AudioStreamLegacy::callDataCallbackFrames(uint8_t // Implement FixedBlockProcessor // Implement FixedBlockProcessor int32_t AudioStreamLegacy::onProcessFixedBlock(uint8_t *buffer, int32_t numBytes) { int32_t AudioStreamLegacy::onProcessFixedBlock(uint8_t *buffer, int32_t numBytes) { int32_t numFrames = numBytes / getBytesPerDeviceFrame(); int32_t numFrames = numBytes / mBlockAdapterBytesPerFrame; return (int32_t) callDataCallbackFrames(buffer, numFrames); return (int32_t) callDataCallbackFrames(buffer, numFrames); } } Loading
media/libaaudio/src/legacy/AudioStreamLegacy.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -133,6 +133,7 @@ protected: MonotonicCounter mTimestampPosition; MonotonicCounter mTimestampPosition; FixedBlockAdapter *mBlockAdapter = nullptr; FixedBlockAdapter *mBlockAdapter = nullptr; int32_t mBlockAdapterBytesPerFrame = 0; aaudio_wrapping_frames_t mPositionWhenStarting = 0; aaudio_wrapping_frames_t mPositionWhenStarting = 0; int32_t mCallbackBufferSize = 0; int32_t mCallbackBufferSize = 0; const android::sp<StreamDeviceCallback> mDeviceCallback; const android::sp<StreamDeviceCallback> mDeviceCallback; Loading
media/libaaudio/src/legacy/AudioStreamRecord.cpp +4 −1 Original line number Original line Diff line number Diff line Loading @@ -213,7 +213,10 @@ aaudio_result_t AudioStreamRecord::open(const AudioStreamBuilder& builder) // We may need to pass the data through a block size adapter to guarantee constant size. // We may need to pass the data through a block size adapter to guarantee constant size. if (mCallbackBufferSize != AAUDIO_UNSPECIFIED) { if (mCallbackBufferSize != AAUDIO_UNSPECIFIED) { int callbackSizeBytes = getBytesPerFrame() * mCallbackBufferSize; // The block adapter runs before the format conversion. // So we need to use the device frame size. mBlockAdapterBytesPerFrame = getBytesPerDeviceFrame(); int callbackSizeBytes = mBlockAdapterBytesPerFrame * mCallbackBufferSize; mFixedBlockWriter.open(callbackSizeBytes); mFixedBlockWriter.open(callbackSizeBytes); mBlockAdapter = &mFixedBlockWriter; mBlockAdapter = &mFixedBlockWriter; } else { } else { Loading
media/libaaudio/src/legacy/AudioStreamTrack.cpp +4 −1 Original line number Original line Diff line number Diff line Loading @@ -196,7 +196,10 @@ aaudio_result_t AudioStreamTrack::open(const AudioStreamBuilder& builder) // We may need to pass the data through a block size adapter to guarantee constant size. // We may need to pass the data through a block size adapter to guarantee constant size. if (mCallbackBufferSize != AAUDIO_UNSPECIFIED) { if (mCallbackBufferSize != AAUDIO_UNSPECIFIED) { int callbackSizeBytes = getBytesPerFrame() * mCallbackBufferSize; // This may need to change if we add format conversion before // the block size adaptation. mBlockAdapterBytesPerFrame = getBytesPerFrame(); int callbackSizeBytes = mBlockAdapterBytesPerFrame * mCallbackBufferSize; mFixedBlockReader.open(callbackSizeBytes); mFixedBlockReader.open(callbackSizeBytes); mBlockAdapter = &mFixedBlockReader; mBlockAdapter = &mFixedBlockReader; } else { } else { Loading