Skip to content

Commit d6974d8

Browse files
thjnkjemoreira
authored andcommitted
Introduction of Audio mixer
* Audio configuration was extended (available only via protobuf config) * Only one audio sink is created now and all the streams are new being mixed Bug: 449972591
1 parent 62ef31a commit d6974d8

File tree

13 files changed

+711
-237
lines changed

13 files changed

+711
-237
lines changed

base/cvd/cuttlefish/host/commands/assemble_cvd/guest_config.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,8 @@ Result<void> ParseGuestConfigTextProto(const std::string& guest_config_path,
112112
DefaultHostArtifactsPath(input_config.domkey_mapping_config());
113113
}
114114

115-
const auto& audio_config = proto_config.audio();
116-
if (audio_config.has_output_audio_streams_count()) {
117-
guest_config.output_audio_streams_count =
118-
audio_config.output_audio_streams_count();
115+
if(proto_config.has_audio()) {
116+
guest_config.audio_settings = proto_config.audio();
119117
}
120118

121119
const auto& network_config = proto_config.network();

base/cvd/cuttlefish/host/commands/assemble_cvd/guest_config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include "cuttlefish/host/commands/assemble_cvd/flags/kernel_path.h"
2626
#include "cuttlefish/host/commands/assemble_cvd/flags/system_image_dir.h"
2727

28+
#include "cuttlefish/host/commands/assemble_cvd/proto/guest_config.pb.h"
29+
2830
namespace cuttlefish {
2931

3032
struct GuestConfig {
@@ -44,6 +46,7 @@ struct GuestConfig {
4446
std::optional<std::string> custom_keyboard_config;
4547
std::optional<std::string> domkey_mapping_config;
4648
int output_audio_streams_count = 1;
49+
std::optional<::cuttlefish::config::Audio> audio_settings;
4750
std::optional<bool> enforce_mac80211_hwsim;
4851
int blank_data_image_mb = 0;
4952
};

base/cvd/cuttlefish/host/commands/assemble_cvd/proto/guest_config.proto

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,41 @@ message Graphics {
3535
}
3636

3737
message Audio {
38-
// The number of output audio streams the guest device supports.
39-
int32 output_audio_streams_count = 1;
38+
enum ChannelLayout {
39+
option features.enum_type = CLOSED;
40+
41+
// Single channel
42+
MONO = 0;
43+
// Channel order: FL, FR
44+
STEREO = 1;
45+
// Channel order: FL, FR, FC, LFE, SL, SR
46+
SURROUND51 = 2;
47+
}
48+
49+
enum SampleRate {
50+
option features.enum_type = CLOSED;
51+
RATE_32000 = 0;
52+
RATE_44100 = 1;
53+
RATE_48000 = 2;
54+
RATE_64000 = 3;
55+
}
56+
57+
message AudioMixer {
58+
ChannelLayout channel_layout = 1;
59+
SampleRate sample_rate = 2;
60+
}
61+
62+
message PCMDevice {
63+
message Stream {
64+
uint32 id = 1;
65+
ChannelLayout channel_layout = 2;
66+
}
67+
repeated Stream capture_streams = 1;
68+
repeated Stream playback_streams = 2;
69+
AudioMixer mixer = 3;
70+
}
71+
72+
repeated PCMDevice pcm_devices = 1;
4073
}
4174

4275
message Input {
@@ -76,22 +109,21 @@ message Virtualization {
76109

77110
// Specifies the type of the emulated device
78111
enum DeviceType {
79-
Phone = 0;
80-
Wear = 1;
81-
Auto = 2;
82-
Foldable = 3;
83-
Tv = 4;
84-
Minidroid = 5;
85-
Go = 6;
86-
Unknown = 7;
112+
Phone = 0;
113+
Wear = 1;
114+
Auto = 2;
115+
Foldable = 3;
116+
Tv = 4;
117+
Minidroid = 5;
118+
Go = 6;
119+
Unknown = 7;
87120
}
88121

89122
// GuestConfigFile represents the configuration for a Cuttlefish guest device,
90123
// typically parsed from an cuttlefish-guest-config.txtpb file. It defines the
91124
// device's hardware capabilities, software features, and virtualization
92125
// settings.
93126
message GuestConfigFile {
94-
95127
DeviceType device_type = 1;
96128

97129
Graphics graphics = 2;

base/cvd/cuttlefish/host/frontend/webrtc/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ cf_cc_binary(
3333
"adb_handler.h",
3434
"audio_handler.cpp",
3535
"audio_handler.h",
36+
"audio_mixer.cpp",
37+
"audio_mixer.h",
38+
"audio_settings.h",
3639
"bluetooth_handler.cpp",
3740
"bluetooth_handler.h",
3841
"client_server.cpp",
@@ -68,6 +71,7 @@ cf_cc_binary(
6871
"//cuttlefish/common/libs/utils:json",
6972
"//cuttlefish/common/libs/utils:result",
7073
"//cuttlefish/common/libs/utils:size_utils",
74+
"//cuttlefish/host/commands/assemble_cvd:guest_config_cc_proto",
7175
"//cuttlefish/host/commands/kernel_log_monitor:kernel_log_monitor_utils",
7276
"//cuttlefish/host/frontend/webrtc/libcommon:audio_source",
7377
"//cuttlefish/host/frontend/webrtc/libdevice",
@@ -97,5 +101,6 @@ cf_cc_binary(
97101
"@libwebrtc",
98102
"@libwebsockets",
99103
"@libyuv",
104+
"@protobuf",
100105
],
101106
)

0 commit comments

Comments
 (0)