Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Custom Audio Driver to project with mute audio functionality #176

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
24 changes: 17 additions & 7 deletions Custom-Audio-Driver/Custom-Audio-Driver/DefaultAudioDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ extension DefaultAudioDevice: OTAudioDevice {
return recording
}
func estimatedRenderDelay() -> UInt16 {
//No problem with casting. plaoutDelay will never be bigger than 1000
return UInt16(playoutDelay)
}
func estimatedCaptureDelay() -> UInt16 {
Expand Down Expand Up @@ -630,20 +631,29 @@ func updatePlayoutDelay(withAudioDevice audioDevice: DefaultAudioDevice) {
audioDevice.playoutDelayMeasurementCounter += 1
if audioDevice.playoutDelayMeasurementCounter >= 100 {
// Update HW and OS delay every second, unlikely to change
audioDevice.playoutDelay = 0
var tempPlayoutDelay: UInt32 = 0
let session = AVAudioSession.sharedInstance()

// HW output latency
let interval = session.outputLatency
audioDevice.playoutDelay += UInt32(interval * 1000000)
tempPlayoutDelay += UInt32(interval * 1000000)
// HW buffer duration
let ioInterval = session.ioBufferDuration
audioDevice.playoutDelay += UInt32(ioInterval * 1000000)
audioDevice.playoutDelay += UInt32(audioDevice.playoutAudioUnitPropertyLatency * 1000000)
tempPlayoutDelay += UInt32(ioInterval * 1000000)
tempPlayoutDelay += UInt32(audioDevice.playoutAudioUnitPropertyLatency * 1000000)
// To ms
audioDevice.playoutDelay = (audioDevice.playoutDelay - 500) / 1000

audioDevice.playoutDelayMeasurementCounter = 0
tempPlayoutDelay = (audioDevice.playoutDelay - 500) / 1000

//playout valid interval [0 - 1000]ms
if(tempPlayoutDelay > 1000)
{
//input parameter error
audioDevice.playoutDelayMeasurementCounter = 100
} else
{
audioDevice.playoutDelay = tempPlayoutDelay
audioDevice.playoutDelayMeasurementCounter = 0
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Simple-Multiparty/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: ec3904194bdf3baef5bcfd4f642012ed6f5538c5

COCOAPODS: 1.10.1
COCOAPODS: 1.11.3
56 changes: 56 additions & 0 deletions Simple-Multiparty/Simple-Multiparty.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,26 @@
objects = {

/* Begin PBXBuildFile section */
2CF52467150362DAB76ED36F /* Pods_Simple_Multiparty.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A69F800D6C9AF74C79D9C435 /* Pods_Simple_Multiparty.framework */; };
A05375F91EB1637B00645696 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A05375F11EB1637B00645696 /* AppDelegate.swift */; };
A05375FA1EB1637B00645696 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A05375F21EB1637B00645696 /* Assets.xcassets */; };
A05375FB1EB1637B00645696 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A05375F31EB1637B00645696 /* LaunchScreen.storyboard */; };
A05375FC1EB1637B00645696 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A05375F51EB1637B00645696 /* Main.storyboard */; };
A05375FE1EB1637B00645696 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A05375F81EB1637B00645696 /* ViewController.swift */; };
AD96BCE728D33B8D007C8AE5 /* DefaultAudioDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD96BCE628D33B8D007C8AE5 /* DefaultAudioDevice.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
38A96086E7512E399DFF2ED7 /* Pods-Simple-Multiparty.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Simple-Multiparty.debug.xcconfig"; path = "Target Support Files/Pods-Simple-Multiparty/Pods-Simple-Multiparty.debug.xcconfig"; sourceTree = "<group>"; };
9E6A4CFD4E6D554D154FEF4E /* Pods-Simple-Multiparty.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Simple-Multiparty.release.xcconfig"; path = "Target Support Files/Pods-Simple-Multiparty/Pods-Simple-Multiparty.release.xcconfig"; sourceTree = "<group>"; };
A05375F11EB1637B00645696 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
A05375F21EB1637B00645696 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
A05375F41EB1637B00645696 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
A05375F61EB1637B00645696 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
A05375F71EB1637B00645696 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A05375F81EB1637B00645696 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
A69F800D6C9AF74C79D9C435 /* Pods_Simple_Multiparty.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Simple_Multiparty.framework; sourceTree = BUILT_PRODUCTS_DIR; };
AD96BCE628D33B8D007C8AE5 /* DefaultAudioDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultAudioDevice.swift; sourceTree = "<group>"; };
F829C8E51D9AB57700CDFBD5 /* Simple-Multiparty.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Simple-Multiparty.app"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

Expand All @@ -29,12 +35,30 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2CF52467150362DAB76ED36F /* Pods_Simple_Multiparty.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
095AFCE1F560C836B338FFFC /* Frameworks */ = {
isa = PBXGroup;
children = (
A69F800D6C9AF74C79D9C435 /* Pods_Simple_Multiparty.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
86D18B3A61C2DCD118F00945 /* Pods */ = {
isa = PBXGroup;
children = (
38A96086E7512E399DFF2ED7 /* Pods-Simple-Multiparty.debug.xcconfig */,
9E6A4CFD4E6D554D154FEF4E /* Pods-Simple-Multiparty.release.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
A05375F01EB1637B00645696 /* Simple-Multiparty */ = {
isa = PBXGroup;
children = (
Expand All @@ -44,6 +68,7 @@
A05375F51EB1637B00645696 /* Main.storyboard */,
A05375F71EB1637B00645696 /* Info.plist */,
A05375F81EB1637B00645696 /* ViewController.swift */,
AD96BCE628D33B8D007C8AE5 /* DefaultAudioDevice.swift */,
);
path = "Simple-Multiparty";
sourceTree = "<group>";
Expand All @@ -53,6 +78,8 @@
children = (
A05375F01EB1637B00645696 /* Simple-Multiparty */,
F829C8E61D9AB57700CDFBD5 /* Products */,
86D18B3A61C2DCD118F00945 /* Pods */,
095AFCE1F560C836B338FFFC /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -71,6 +98,7 @@
isa = PBXNativeTarget;
buildConfigurationList = F829C8F71D9AB57700CDFBD5 /* Build configuration list for PBXNativeTarget "Simple-Multiparty" */;
buildPhases = (
58E41DACD660DB613732DD44 /* [CP] Check Pods Manifest.lock */,
F829C8E11D9AB57700CDFBD5 /* Sources */,
F829C8E21D9AB57700CDFBD5 /* Frameworks */,
F829C8E31D9AB57700CDFBD5 /* Resources */,
Expand Down Expand Up @@ -133,12 +161,38 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
58E41DACD660DB613732DD44 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Simple-Multiparty-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
F829C8E11D9AB57700CDFBD5 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A05375FE1EB1637B00645696 /* ViewController.swift in Sources */,
AD96BCE728D33B8D007C8AE5 /* DefaultAudioDevice.swift in Sources */,
A05375F91EB1637B00645696 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -278,6 +332,7 @@
};
F829C8F81D9AB57700CDFBD5 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 38A96086E7512E399DFF2ED7 /* Pods-Simple-Multiparty.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
Expand All @@ -292,6 +347,7 @@
};
F829C8F91D9AB57700CDFBD5 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9E6A4CFD4E6D554D154FEF4E /* Pods-Simple-Multiparty.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
Expand Down
Loading