Skip to content

Commit 892a9b8

Browse files
authored
Do not use conversion if it is compressed format. (#2187)
This is one part of #2180.
1 parent 836d5a2 commit 892a9b8

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎include/oboe/Utilities.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ bool isAtLeastPreReleaseCodename(const std::string& codename);
9494

9595
int getChannelCountFromChannelMask(ChannelMask channelMask);
9696

97+
bool isCompressedFormat(AudioFormat format);
98+
9799
} // namespace oboe
98100

99101
#endif //OBOE_UTILITIES_H

‎src/common/QuirksManager.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <oboe/AudioStreamBuilder.h>
1818
#include <oboe/Oboe.h>
19+
#include <oboe/Utilities.h>
1920

2021
#include "OboeDebug.h"
2122
#include "QuirksManager.h"
@@ -201,13 +202,20 @@ bool QuirksManager::isConversionNeeded(
201202
const bool isInput = builder.getDirection() == Direction::Input;
202203
const bool isFloat = builder.getFormat() == AudioFormat::Float;
203204
const bool isIEC61937 = builder.getFormat() == AudioFormat::IEC61937;
205+
const bool isCompressed = isCompressedFormat(builder.getFormat());
204206

205207
// There should be no conversion for IEC61937. Sample rates and channel counts must be set explicitly.
206208
if (isIEC61937) {
207209
LOGI("QuirksManager::%s() conversion not needed for IEC61937", __func__);
208210
return false;
209211
}
210212

213+
if (isCompressed) {
214+
LOGI("QuirksManager::%s() conversion not needed for compressed format %d",
215+
__func__, builder.getFormat());
216+
return false;
217+
}
218+
211219
// There are multiple bugs involving using callback with a specified callback size.
212220
// Issue #778: O to Q had a problem with Legacy INPUT streams for FLOAT streams
213221
// and a specified callback size. It would assert because of a bad buffer size.

‎src/common/Utilities.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <stdlib.h>
1919
#include <unistd.h>
20+
#include <set>
2021
#include <sstream>
2122

2223
#ifdef __ANDROID__
@@ -344,4 +345,13 @@ int getChannelCountFromChannelMask(ChannelMask channelMask) {
344345
return __builtin_popcount(static_cast<uint32_t>(channelMask));
345346
}
346347

348+
349+
std::set<AudioFormat> COMPRESSED_FORMATS = {
350+
AudioFormat::MP3, AudioFormat::AAC_LC, AudioFormat::AAC_HE_V1, AudioFormat::AAC_HE_V2,
351+
AudioFormat::AAC_ELD, AudioFormat::AAC_XHE, AudioFormat::OPUS
352+
};
353+
bool isCompressedFormat(AudioFormat format) {
354+
return COMPRESSED_FORMATS.count(format) != 0;
355+
}
356+
347357
}// namespace oboe

0 commit comments

Comments
 (0)