[client] usb audio: emulate UAC2 playback

Add a fixed-format USB Audio Class 2 playback device for the
client-side USB redirection bridge.

Advertise stereo 48 kHz IEEE float audio and handle enumeration,
configuration, alternate settings, clock requests, and isochronous data.
This commit is contained in:
Geoffrey McRae
2026-08-09 21:30:20 +10:00
parent 6d1b0c3004
commit 6979b93da5
3 changed files with 691 additions and 0 deletions

50
client/src/usb_audio.h Normal file
View File

@@ -0,0 +1,50 @@
/**
* Looking Glass
* Copyright © 2017-2026 The Looking Glass Authors
* https://looking-glass.io
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _H_LG_CLIENT_USB_AUDIO_
#define _H_LG_CLIENT_USB_AUDIO_
#include "usbredir.h"
#include <stddef.h>
#define LG_USB_AUDIO_SAMPLE_RATE 48000
#define LG_USB_AUDIO_CHANNELS 2
typedef struct LG_USBAudio LG_USBAudio;
typedef struct LG_USBAudioEventOps
{
void (*start)(void * opaque);
void (*stop)(void * opaque);
/* Data is borrowed interleaved stereo 32-bit IEEE float, little endian. */
void (*data)(void * opaque, const void * data, size_t frames);
}
LG_USBAudioEventOps;
LG_USBAudio * lgUsbAudio_create(
const LG_USBAudioEventOps * events, void * eventOpaque);
/* Destroy the LG_USBRedir using this device before destroying the device. */
void lgUsbAudio_destroy(LG_USBAudio * audio);
const LG_USBRedirDeviceOps * lgUsbAudio_deviceOps(void);
#endif