feat: audio mixer, Audio app, fix Installer crash
This commit is contained in:
@@ -162,6 +162,11 @@ namespace Montauk {
|
||||
static constexpr uint64_t SYS_NETSTATUS = 125;
|
||||
static constexpr uint64_t SYS_DRIVEKIND = 127;
|
||||
|
||||
// Audio mixer enumeration
|
||||
static constexpr uint64_t SYS_AUDIOLIST = 128;
|
||||
// Block until the mixer state serial differs from the caller's snapshot.
|
||||
static constexpr uint64_t SYS_AUDIOWAIT = 129;
|
||||
|
||||
static constexpr uint32_t CLIPBOARD_MAX_TEXT_BYTES = 256 * 1024;
|
||||
|
||||
static constexpr uint32_t IPC_SIGNAL_READABLE = 1u << 0;
|
||||
@@ -170,14 +175,23 @@ namespace Montauk {
|
||||
static constexpr uint32_t IPC_SIGNAL_EXITED = 1u << 3;
|
||||
static constexpr uint32_t IPC_SIGNAL_READY = 1u << 4;
|
||||
|
||||
// Audio control commands (for SYS_AUDIOCTL)
|
||||
static constexpr int AUDIO_CTL_SET_VOLUME = 0;
|
||||
static constexpr int AUDIO_CTL_GET_VOLUME = 1;
|
||||
static constexpr int AUDIO_CTL_GET_POS = 2;
|
||||
static constexpr int AUDIO_CTL_PAUSE = 3;
|
||||
static constexpr int AUDIO_CTL_GET_OUTPUT = 4; // 0=HDA, 1=Bluetooth
|
||||
static constexpr int AUDIO_CTL_SET_OUTPUT = 5; // Switch audio output
|
||||
static constexpr int AUDIO_CTL_BT_STATUS = 6; // Get Bluetooth connection status
|
||||
// Audio control commands (for SYS_AUDIOCTL).
|
||||
//
|
||||
// Commands 0..3 act on the stream named by the handle argument.
|
||||
// Commands 7..12 act on the global master and ignore the handle.
|
||||
static constexpr int AUDIO_CTL_SET_VOLUME = 0;
|
||||
static constexpr int AUDIO_CTL_GET_VOLUME = 1;
|
||||
static constexpr int AUDIO_CTL_GET_POS = 2;
|
||||
static constexpr int AUDIO_CTL_PAUSE = 3;
|
||||
static constexpr int AUDIO_CTL_GET_OUTPUT = 4; // 0=HDA, 1=Bluetooth
|
||||
static constexpr int AUDIO_CTL_SET_OUTPUT = 5; // Switch audio output
|
||||
static constexpr int AUDIO_CTL_BT_STATUS = 6; // Get Bluetooth status
|
||||
static constexpr int AUDIO_CTL_SET_MASTER_VOLUME = 7; // 0-100
|
||||
static constexpr int AUDIO_CTL_GET_MASTER_VOLUME = 8;
|
||||
static constexpr int AUDIO_CTL_SET_MUTE = 9; // 0/1, per-stream
|
||||
static constexpr int AUDIO_CTL_GET_MUTE = 10;
|
||||
static constexpr int AUDIO_CTL_SET_MASTER_MUTE = 11;
|
||||
static constexpr int AUDIO_CTL_GET_MASTER_MUTE = 12;
|
||||
|
||||
static constexpr int SOCK_TCP = 1;
|
||||
static constexpr int SOCK_UDP = 2;
|
||||
@@ -252,6 +266,20 @@ namespace Montauk {
|
||||
uint64_t serial;
|
||||
};
|
||||
|
||||
// One entry per active mixer stream; returned by SYS_AUDIOLIST.
|
||||
struct AudioStreamInfo {
|
||||
int32_t handle;
|
||||
int32_t ownerPid;
|
||||
char name[64];
|
||||
uint32_t sampleRate;
|
||||
uint8_t channels;
|
||||
uint8_t bitsPerSample;
|
||||
uint8_t volume; // 0-100
|
||||
uint8_t muted; // 0/1
|
||||
uint8_t paused; // 0/1
|
||||
uint8_t _pad[7];
|
||||
};
|
||||
|
||||
// Window server shared types
|
||||
struct WinEvent {
|
||||
uint8_t type; // 0=key, 1=mouse, 2=resize, 3=close, 4=scale
|
||||
|
||||
@@ -171,6 +171,7 @@ struct DesktopState {
|
||||
int vol_pre_mute; // volume before mute
|
||||
bool vol_dragging; // slider drag in progress
|
||||
uint64_t vol_last_poll;
|
||||
uint64_t vol_serial; // last seen mixer state serial
|
||||
|
||||
// Temperature monitoring
|
||||
static constexpr int MAX_THERMAL_ZONES = 8;
|
||||
|
||||
@@ -477,6 +477,33 @@ namespace montauk {
|
||||
inline int audio_bt_status(int handle) {
|
||||
return audio_ctl(handle, Montauk::AUDIO_CTL_BT_STATUS, 0);
|
||||
}
|
||||
inline int audio_set_master_volume(int percent) {
|
||||
return audio_ctl(-1, Montauk::AUDIO_CTL_SET_MASTER_VOLUME, percent);
|
||||
}
|
||||
inline int audio_get_master_volume() {
|
||||
return audio_ctl(-1, Montauk::AUDIO_CTL_GET_MASTER_VOLUME, 0);
|
||||
}
|
||||
inline int audio_set_master_mute(bool muted) {
|
||||
return audio_ctl(-1, Montauk::AUDIO_CTL_SET_MASTER_MUTE, muted ? 1 : 0);
|
||||
}
|
||||
inline int audio_get_master_mute() {
|
||||
return audio_ctl(-1, Montauk::AUDIO_CTL_GET_MASTER_MUTE, 0);
|
||||
}
|
||||
inline int audio_set_mute(int handle, bool muted) {
|
||||
return audio_ctl(handle, Montauk::AUDIO_CTL_SET_MUTE, muted ? 1 : 0);
|
||||
}
|
||||
inline int audio_get_mute(int handle) {
|
||||
return audio_ctl(handle, Montauk::AUDIO_CTL_GET_MUTE, 0);
|
||||
}
|
||||
inline int audio_list(Montauk::AudioStreamInfo* buf, int maxCount) {
|
||||
return (int)syscall2(Montauk::SYS_AUDIOLIST, (uint64_t)buf, (uint64_t)maxCount);
|
||||
}
|
||||
// Returns the current mixer state serial. With timeoutMs > 0 the call
|
||||
// blocks until the serial differs from `prevSerial` or the timeout
|
||||
// elapses. With timeoutMs == 0 it returns immediately (cheap snapshot).
|
||||
inline uint64_t audio_wait(uint64_t prevSerial, uint64_t timeoutMs) {
|
||||
return syscall2(Montauk::SYS_AUDIOWAIT, prevSerial, timeoutMs);
|
||||
}
|
||||
|
||||
// Bluetooth
|
||||
inline int bt_scan(Montauk::BtScanResult* buf, int maxCount, uint32_t timeoutMs) {
|
||||
|
||||
Reference in New Issue
Block a user