Skip to content

Commit 1a415d9

Browse files
committed
wip
1 parent 33b04bc commit 1a415d9

File tree

5 files changed

+193
-1
lines changed

5 files changed

+193
-1
lines changed

app/build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ android {
5050
}
5151

5252
buildFeatures {
53+
aidl = true
5354
buildConfig = true
5455
prefab = true
5556
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright (C) 2021 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.media.audio.common;
18+
19+
import android.media.audio.common.AudioFormatType;
20+
import android.media.audio.common.PcmType;
21+
22+
/**
23+
* An extensible type for specifying audio formats. All formats are largely
24+
* divided into two classes: PCM and non-PCM (bitstreams). Bitstreams can
25+
* be encapsulated into PCM streams.
26+
*
27+
* The type defined in a way to make each format uniquely identifiable, so
28+
* that if the framework and the HAL construct a value for the same type
29+
* (e.g. PCM 16 bit), they will produce identical parcelables which will have
30+
* identical hashes. This makes possible deduplicating type descriptions
31+
* by the framework when they are received from different HAL modules without
32+
* relying on having some centralized registry of enumeration values.
33+
*
34+
* {@hide}
35+
*/
36+
@JavaDerive(equals=true, toString=true)
37+
//@VintfStability
38+
parcelable AudioFormatDescription {
39+
/**
40+
* The type of the audio format. See the 'AudioFormatType' for the
41+
* list of supported values.
42+
*/
43+
AudioFormatType type = AudioFormatType.DEFAULT;
44+
/**
45+
* The type of the PCM stream or the transport stream for PCM
46+
* encapsulations. See 'PcmType' for the list of supported values.
47+
*/
48+
PcmType pcm = PcmType.DEFAULT;
49+
/**
50+
* Optional encoding specification. Must be left empty when:
51+
*
52+
* - 'type == DEFAULT && pcm == DEFAULT' -- that means "default" type;
53+
* - 'type == PCM' -- that means a regular PCM stream (not an encapsulation
54+
* of an encoded bitstream).
55+
*
56+
* For PCM encapsulations of encoded bitstreams (e.g. an encapsulation
57+
* according to IEC-61937 standard), the value of the 'pcm' field must
58+
* be set accordingly, as an example, PCM_INT_16_BIT must be used for
59+
* IEC-61937. Note that 'type == NON_PCM' in this case.
60+
*
61+
* Encoding names mostly follow IANA standards for media types (MIME), and
62+
* frameworks/av/media/module/foundation/MediaDefs.cpp with the latter
63+
* having priority. Since there are still many audio types not found in any
64+
* of these lists, the following rules are applied:
65+
*
66+
* - If there is a direct MIME type for the encoding, the MIME type name
67+
* is used as is, e.g. "audio/eac3" for the EAC-3 format.
68+
* - If the encoding is a "subformat" of a MIME-registered format,
69+
* the latter is augmented with a suffix, e.g. "audio/eac3-joc" for the
70+
* JOC extension of EAC-3.
71+
* - If it's a proprietary format, a "vnd." prefix is added, similar to
72+
* IANA rules, e.g. "audio/vnd.dolby.truehd".
73+
* - Otherwise, "x-" prefix is added, e.g. "audio/x-iec61937".
74+
* - All MIME types not found in the IANA formats list have an associated
75+
* comment.
76+
*/
77+
@utf8InCpp String encoding;
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (C) 2021 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.media.audio.common;
18+
19+
/**
20+
* The type of the audio format. Only used as part of 'AudioFormatDescription'
21+
* structure.
22+
*
23+
* {@hide}
24+
*/
25+
//@VintfStability
26+
@Backing(type="byte")
27+
enum AudioFormatType {
28+
/**
29+
* "Default" type is used when the client does not care about the actual
30+
* format. All fields of 'AudioFormatDescription' must have default / empty
31+
* / null values.
32+
*/
33+
DEFAULT = 0,
34+
/**
35+
* When the 'encoding' field of 'AudioFormatDescription' is not empty, it
36+
* specifies the codec used for bitstream (non-PCM) data. It is also used
37+
* in the case when the bitstream data is encapsulated into a PCM stream,
38+
* see the documentation for 'AudioFormatDescription'.
39+
*/
40+
NON_PCM = DEFAULT,
41+
/**
42+
* PCM type. The 'pcm' field of 'AudioFormatDescription' is used to specify
43+
* the actual sample size and representation.
44+
*/
45+
PCM = 1,
46+
/**
47+
* Value reserved for system use only. HALs must never return this value to
48+
* the system or accept it from the system.
49+
*/
50+
SYS_RESERVED_INVALID = -1,
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (C) 2021 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.media.audio.common;
18+
19+
/**
20+
* The type of the encoding used for representing PCM samples. Only used as
21+
* part of 'AudioFormatDescription' structure.
22+
*
23+
* {@hide}
24+
*/
25+
//@VintfStability
26+
@Backing(type="byte")
27+
enum PcmType {
28+
/**
29+
* "Default" value used when the type 'AudioFormatDescription' is "default".
30+
*/
31+
DEFAULT = 0,
32+
/**
33+
* Unsigned 8-bit integer.
34+
*/
35+
UINT_8_BIT = DEFAULT,
36+
/**
37+
* Signed 16-bit integer.
38+
*/
39+
INT_16_BIT = 1,
40+
/**
41+
* Signed 32-bit integer.
42+
*/
43+
INT_32_BIT = 2,
44+
/**
45+
* Q8.24 fixed point format.
46+
*/
47+
FIXED_Q_8_24 = 3,
48+
/**
49+
* IEEE 754 32-bit floating point format.
50+
*/
51+
FLOAT_32_BIT = 4,
52+
/**
53+
* Signed 24-bit integer.
54+
*/
55+
INT_24_BIT = 5,
56+
}

app/src/main/kotlin/org/akanework/gramophone/logic/utils/MediaRoutes.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import android.media.AudioManager
88
import android.media.AudioTrack
99
import android.media.MediaRoute2Info
1010
import android.media.MediaRouter2
11+
import android.media.audio.common.AudioFormatDescription
12+
import android.media.audio.common.AudioFormatType
1113
import android.os.Build
1214
import android.os.IBinder
1315
import android.os.Parcel
@@ -318,6 +320,7 @@ object AudioTrackHalInfoDetector {
318320
}
319321
if (ret != null && ret != 0)
320322
return ret
323+
return null
321324
}
322325
val output = getOutput(audioTrack)
323326
if (output == null)
@@ -488,6 +491,7 @@ object AudioTrackHalInfoDetector {
488491
}
489492
if (ret != null && ret != 0)
490493
return ret
494+
return null
491495
}
492496
val output = getOutput(audioTrack)
493497
if (output == null)
@@ -507,7 +511,9 @@ object AudioTrackHalInfoDetector {
507511
if (!readStatus(outParcel))
508512
return null
509513
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
510-
TODO()
514+
val format = AudioFormatDescription.CREATOR.createFromParcel(outParcel)
515+
// TODO...
516+
return null
511517
} else
512518
return outParcel.readInt()
513519
} finally {

0 commit comments

Comments
 (0)