Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions apps/common-app/src/examples/Record/Record.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ const Record: FC = () => {
};

const onSelect = useCallback(
(uid: string) => {
const input = availableInputs.find((d) => d.uid === uid);
(id: string) => {
const input = availableInputs.find((d) => d.id === id);

if (input) {
onSelectInput(input);
Expand All @@ -224,9 +224,9 @@ const Record: FC = () => {
</View>
<View>
<Select
value={currentInput?.uid || ''}
value={currentInput?.id || ''}
onChange={onSelect}
options={availableInputs.map((d) => d.uid) || []}
options={availableInputs.map((d) => d.id) || []}
/>
</View>
<View style={{ alignItems: 'center', gap: 10 }}>
Expand Down
4 changes: 2 additions & 2 deletions packages/audiodocs/docs/react/select-input.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function AudioInputSelector() {

{availableInputs.map((input) => (
<Button
key={input.uid}
key={input.id}
title={`${input.name} (${input.category})`}
onPress={() => onSelectInput(input)}
/>
Expand All @@ -50,7 +50,7 @@ The hook returns an object with the following properties:
### `availableInputs: AudioDeviceInfo[]`

An array of all available audio input devices. Each device contains:
- `uid: string` - Unique device identifier
- `id: string` - Unique device identifier
- `name: string` - Human-readable device name
- `category: string` - Device category (e.g., "Built-In Microphone", "Bluetooth")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class AudioAPIModule(
) {
// TODO: noop for now, but it should be moved to upcoming
// audio engine implementation for android (duplex stream)
Promise.resolve(true)
promise?.resolve(true)
}

// Notification system methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ object MediaSessionManager {

for (inputDevice in this.audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS)) {
val deviceInfo = Arguments.createMap()
deviceInfo.putString("id", inputDevice.getId().toString())
deviceInfo.putString("name", inputDevice.productName.toString())
deviceInfo.putString("type", parseDeviceType(inputDevice))

Expand All @@ -217,6 +218,7 @@ object MediaSessionManager {

for (outputDevice in this.audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS)) {
val deviceInfo = Arguments.createMap()
deviceInfo.putString("id", outputDevice.getId().toString())
deviceInfo.putString("name", outputDevice.productName.toString())
deviceInfo.putString("type", parseDeviceType(outputDevice))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ - (void)getDevicesInfo:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectB
[deviceList addObject:@{
@"name" : device.portName,
@"category" : device.portType,
@"uid" : device.UID,
@"id" : device.UID,
}];
}

Expand Down
12 changes: 6 additions & 6 deletions packages/react-native-audio-api/src/hooks/useAudioInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export default function useAudioInput() {
const [currentInput, setCurrentInput] = useState<string | null>(null);

const onSelectInput = useCallback(async (device: AudioDeviceInfo) => {
const success = await AudioManager.setInputDevice(device.uid);
const success = await AudioManager.setInputDevice(device.id);

if (success) {
setCurrentInput(device.uid);
setCurrentInput(device.id);
}

const devicesInfo: AudioDevicesInfo = await AudioManager.getDevicesInfo();
Expand All @@ -43,12 +43,12 @@ export default function useAudioInput() {
useEffect(() => {
async function fetchAvailableInputs() {
const audioDevices = await AudioManager.getDevicesInfo();
const currentDeviceUid = audioDevices.currentInputs.length
? audioDevices.currentInputs[0].uid
const currentDeviceId = audioDevices.currentInputs.length
? audioDevices.currentInputs[0].id
: null;

setAvailableInputs(audioDevices.availableInputs);
setCurrentInput(currentDeviceUid);
setCurrentInput(currentDeviceId);
}

async function handleRouteChange(event: OnRouteChangeEventType) {
Expand Down Expand Up @@ -81,7 +81,7 @@ export default function useAudioInput() {
* The currently selected audio input device, or null if none is yet
* decided by the system.
*/
currentInput: availableInputs.find((d) => d.uid === currentInput) || null,
currentInput: availableInputs.find((d) => d.id === currentInput) || null,
/**
* Selects the given device as the current input. Returns true if
* successful, throws otherwise.
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-audio-api/src/system/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface SessionOptions {
export type PermissionStatus = 'Undetermined' | 'Denied' | 'Granted';

export interface AudioDeviceInfo {
uid: string;
id: string;
name: string;
category: string;
}
Expand Down