Skip to content

Commit

Permalink
feat(scrcpy): add audioSource option to v2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
yume-chan committed Nov 30, 2024
1 parent 9e828ff commit c4831e4
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 4 deletions.
40 changes: 39 additions & 1 deletion libraries/adb-daemon-webusb/src/manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,45 @@ class MockUsb implements USB {

getDevices = mock.fn(async () => []);
requestDevice = mock.fn(
async () => ({ serialNumber: "abcdefgh" }) as never,
async (options?: USBDeviceRequestOptions) =>
({
serialNumber: options?.filters?.[0]?.serialNumber ?? "abcdefgh",
vendorId: options?.filters?.[0]?.vendorId ?? 0x18d1,
productId: options?.filters?.[0]?.productId ?? 0x4e49,
configurations: [
{
configurationValue: 1,
interfaces: [
{
interfaceNumber: 0,
claimed: false,
alternate: {
alternateSetting: 0,
interfaceClass:
AdbDefaultInterfaceFilter.classCode,
interfaceSubclass:
AdbDefaultInterfaceFilter.subclassCode,
interfaceProtocol:
AdbDefaultInterfaceFilter.protocolCode,
endpoints: [],
},
alternates: [
{
alternateSetting: 0,
interfaceClass:
AdbDefaultInterfaceFilter.classCode,
interfaceSubclass:
AdbDefaultInterfaceFilter.subclassCode,
interfaceProtocol:
AdbDefaultInterfaceFilter.protocolCode,
endpoints: [],
},
],
},
],
},
],
}) satisfies Partial<USBDevice> as never,
);

addEventListener(
Expand Down
2 changes: 1 addition & 1 deletion libraries/scrcpy/src/2_3/impl/init.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PrevImpl } from "./prev.js";

export interface Init extends Omit<PrevImpl.Init, "audioCodec"> {
audioCodec?: "raw" | "opus" | "aac" | "flac";
audioCodec?: PrevImpl.Init["audioCodec"] | "flac";
}
3 changes: 2 additions & 1 deletion libraries/scrcpy/src/2_6/impl/init.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { PrevImpl } from "./prev.js";

export interface Init extends PrevImpl.Init {
export interface Init extends Omit<PrevImpl.Init, "audioSource"> {
audioSource?: PrevImpl.Init["audioSource"] | "playback";
audioDup?: boolean;
}
4 changes: 4 additions & 0 deletions libraries/scrcpy/src/2_6/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export class ScrcpyOptions2_6 implements ScrcpyOptions<Init> {
this.value.control = false;
}

if (this.value.audioDup) {
this.value.audioSource = "playback";
}

if (this.value.control) {
if (this.value.clipboardAutosync) {
this.#clipboard = new ClipboardStream();
Expand Down
4 changes: 4 additions & 0 deletions libraries/scrcpy/src/2_7/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export class ScrcpyOptions2_7 implements ScrcpyOptions<Init> {
this.value.control = false;
}

if (this.value.audioDup) {
this.value.audioSource = "playback";
}

if (this.value.control) {
if (this.value.clipboardAutosync) {
this.#clipboard = new ClipboardStream();
Expand Down
4 changes: 4 additions & 0 deletions libraries/scrcpy/src/3_0/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export class ScrcpyOptions3_0 implements ScrcpyOptions<Init> {
this.value.control = false;
}

if (this.value.audioDup) {
this.value.audioSource = "playback";
}

if (this.value.control) {
if (this.value.clipboardAutosync) {
this.#clipboard = new ClipboardStream();
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion toolchain/side-effect-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"dependencies": {
"@yume-chan/adb": "workspace:^",
"@yume-chan/struct": "workspace:^"
"@yume-chan/struct": "workspace:^",
"@yume-chan/scrcpy": "workspace:^"
}
}
1 change: 1 addition & 0 deletions toolchain/side-effect-test/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ u64(1);
u8(1);
struct({}, {});

export * from "@yume-chan/scrcpy";
export * from "@yume-chan/struct";

0 comments on commit c4831e4

Please sign in to comment.