Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IEC61937 for API 34 #1758

Merged
merged 3 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/OboeTester/app/src/main/cpp/FormatConverterBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ FormatConverterBox::FormatConverterBox(int32_t numSamples,
mSource.reset();
switch (mInputFormat) {
case oboe::AudioFormat::I16:
case oboe::AudioFormat::IEC61937:
philburk marked this conversation as resolved.
Show resolved Hide resolved
mSource = std::make_unique<oboe::flowgraph::SourceI16>(1);
break;
case oboe::AudioFormat::I24:
Expand All @@ -46,6 +47,7 @@ FormatConverterBox::FormatConverterBox(int32_t numSamples,
mSink.reset();
switch (mOutputFormat) {
case oboe::AudioFormat::I16:
case oboe::AudioFormat::IEC61937:
mSink = std::make_unique<oboe::flowgraph::SinkI16>(1);
break;
case oboe::AudioFormat::I24:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class StreamConfiguration {
public static final int AUDIO_FORMAT_PCM_FLOAT = 2; // must match AAUDIO
public static final int AUDIO_FORMAT_PCM_24 = 3; // must match AAUDIO
public static final int AUDIO_FORMAT_PCM_32 = 4; // must match AAUDIO
public static final int AUDIO_FORMAT_IEC61937 = 5; // must match AAUDIO

public static final int DIRECTION_OUTPUT = 0; // must match AAUDIO
public static final int DIRECTION_INPUT = 1; // must match AAUDIO
Expand Down Expand Up @@ -493,6 +494,8 @@ public static String convertFormatToText(int format) {
return "I32";
case AUDIO_FORMAT_PCM_FLOAT:
return "Float";
case AUDIO_FORMAT_IEC61937:
return "Float";
robertwu1 marked this conversation as resolved.
Show resolved Hide resolved
default:
return "Invalid";
}
Expand Down
1 change: 1 addition & 0 deletions apps/OboeTester/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<item>PCM_FLOAT</item>
<item>PCM_I24</item>
<item>PCM_I32</item>
<item>IEC61937</item>
</string-array>

<string name="input_preset_prompt">InPreset:</string>
Expand Down
1 change: 1 addition & 0 deletions include/oboe/AudioStreamBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ class AudioStreamBase {
case AudioFormat::Float:
case AudioFormat::I24:
case AudioFormat::I32:
case AudioFormat::IEC61937:
break;

default:
Expand Down
13 changes: 13 additions & 0 deletions include/oboe/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ namespace oboe {
*/
I32 = 4, // AAUDIO_FORMAT_PCM_I32

/**
* This format is used for compressed audio wrapped in IEC61937 for HDMI
* or S/PDIF passthrough.
*
* Unlike PCM playback, the Android framework is not able to do format
* conversion for IEC61937. In that case, when IEC61937 is requested, sampling
* rate and channel count or channel mask must be specified. Otherwise, it may
* fail when opening the stream. Apps are able to get the correct configuration
* for the playback by calling AudioManager#getDevices(int).
*
* Available since API 34 (U).
*/
IEC61937 = 5, // AAUDIO_FORMAT_IEC61937
};

/**
Expand Down
7 changes: 7 additions & 0 deletions src/common/QuirksManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ bool QuirksManager::isConversionNeeded(
const bool isLowLatency = builder.getPerformanceMode() == PerformanceMode::LowLatency;
const bool isInput = builder.getDirection() == Direction::Input;
const bool isFloat = builder.getFormat() == AudioFormat::Float;
const bool isIEC61937 = builder.getFormat() == AudioFormat::IEC61937;

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

// There are multiple bugs involving using callback with a specified callback size.
// Issue #778: O to Q had a problem with Legacy INPUT streams for FLOAT streams
Expand Down
4 changes: 4 additions & 0 deletions src/common/Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ int32_t convertFormatToSizeInBytes(AudioFormat format) {
case AudioFormat::I32:
size = sizeof(int32_t);
break;
case AudioFormat::IEC61937:
size = sizeof(int16_t);
break;
default:
break;
}
Expand Down Expand Up @@ -106,6 +109,7 @@ const char *convertToText<AudioFormat>(AudioFormat format) {
case AudioFormat::Float: return "Float";
case AudioFormat::I24: return "I24";
case AudioFormat::I32: return "I32";
case AudioFormat::IEC61937: return "IEC61937";
default: return "Unrecognized format";
}
}
Expand Down
1 change: 1 addition & 0 deletions src/opensles/OpenSLESUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ SLuint32 OpenSLES_ConvertFormatToRepresentation(AudioFormat format) {
return SL_ANDROID_PCM_REPRESENTATION_FLOAT;
case AudioFormat::I24:
case AudioFormat::I32:
case AudioFormat::IEC61937:
case AudioFormat::Invalid:
case AudioFormat::Unspecified:
default:
Expand Down