-
Notifications
You must be signed in to change notification settings - Fork 28
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
using .defaultToSpeaker causes audio session initialization problems on iPhone. #14
Comments
Update: Afterward, pressing stop, then start, will cause a crash because the Tap() is not nil. This appears to be a problem with initialization. Adding a check for Tap() status, before resetting the engine and removing a non-existent tap is probably needed. If I come up with something that works, I will post it. |
Hi @DaveHineman , thank you for your feedback!! I tried to run example app by adding Xcode version: 13.4.1 run-example-with-defaultToSpeaker.mp4I'll try to update Xcode version to 14.x and run it on actual device later. |
Yes, it must be run on an actual iPhone.
… On Oct 8, 2022, at 2:09 AM, ymd ***@***.***> wrote:
Hi @DaveHineman , thank you for your feedback!! I tried to run example app by adding defaultToSpeaker option on line 21 as you explained but seems working on my simulator.
Xcode version: 13.4.1
device: iPhone 13 with iOS 15.5 (Simulator)
https://user-images.githubusercontent.com/5585662/194694687-062b5886-b3d9-443f-9aa4-dc3ba1848ad2.mp4
I'll try to update Xcode version to 14.x and run it on actual device later.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
Adding these code changes is allowing capture the first time I press Start, with .defaultToSpeaker as an option.
I will now test the code changes in my complete app and confirm that it functions as expected. I think a smarter solution is possible, but I was unable to find a useful query that would indicate if the Tap was in use and satisfy my IF statement. import Foundation class AudioCapture { deinit{
public func stopSession() throws { |
Update: In conclusion, my changes weren't a solution. Hopefully the changes will reveal something useful. |
In my environment, I can't reproduce it with my actual iPhone 12...Could you please try again with pulling #13 ? |
the '.defaultToSpeaker' option is not in your newest code. Update line 21 to include this option. |
I retested with #13 and the issue still exists when '.defaultToSpeaker' is added to line 21 of AudioCapture.swift |
Another update - I found the issue is present in the AudioKit Cookbook, so I will also open a problem report there. |
The AudioKit issue was different - the speaker routing was changing, but the mic continued to function. |
I have successfully resolved the .defaultToSpeaker problem. I have attached the improved AudioCapture.swift file that you can include with the next release. You may add the .allowBluetoothA2DP, .allowAirPlay, .allowBluetooth back to the options line, but I don't use them. Thanks! |
feel free to remove the print statements 'startSession' and 'stopSession' that I used for debugging. |
@DaveHineman nice work! BTW, do you have issues with the latest 1.1.1 version on iOS? I found that it did not work correctly, and I needed to fall back to 1.1.0: |
Thanks, Vlad!I used the 1.1.1 base and then modified the AudioCapture.swift file. It is working great for me. I have tested on iPhone 7S and iPhone 14 Pro. I need to verify on iPad and Android devices. Using the print statements in Start and Stop, I observed ‘start-stop-start’ in console when StartCapture was called, but it does not do this in my main app, just the example. I was not able to find the cause, but it did not affect my performance. Best,Dave. On Nov 30, 2022, at 6:04 AM, Vlad Sonkin ***@***.***> wrote:
@DaveHineman nice work! BTW, do you have issues with the latest 1.1.1 version on iOS? I found that it did not work correctly, and I needed to fall back to 1.1.0:
#16
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@DaveHineman, you see 'start-stop-start' because, in 1.1.1, we now have a temporary listener to check for sampleRate (I'm not sure why), so it's good. The issue is that 1.1.1 don't work in iOS with the example in this library. I'll try to add your fix and test #16 again. |
Hi, @DaveHineman nice work!! Thank you for your work!! btw, can you make Pull Request for it? I can implement also but I want you to send me the Pull Request because it leave your contribution! |
I've added my changes to 1.1.2 and the example runs properly. Will begin the pull request now. |
Pull request submitted. |
Hi @DaveHineman , @vladsonkin !! |
Excellent! I’ll check it out and let you know!
Thanks,
Dave.
… On Dec 17, 2022, at 7:37 PM, ymd ***@***.***> wrote:
Hi @DaveHineman <https:/DaveHineman> , @vladsonkin <https:/vladsonkin> !!
I published new version 1.1.3 with #17 <#17> that is mentioned in here. Could you please try to update package and resolve this issue?
#18 <#18>
—
Reply to this email directly, view it on GitHub <#14 (comment)>, or unsubscribe <https:/notifications/unsubscribe-auth/ALXQ4DFHSPUTXZAHEJ7R53TWNZTF7ANCNFSM6AAAAAAQ42RAKY>.
You are receiving this because you were mentioned.
|
Hello. |
Looks good indeed, but there is still an iOS issue #16 (tested with 1.1.1, 1.1.2, 1.1.3) |
I am using 1.1.6 and this original issue (.defaultToSpeaker causing initialization problems) is resolved. Thanks, everyone! |
Ah, Close with comment button... |
To make an iPhone play sound from the loudspeakers, not the receiver, it is necessary to add .defaultToSpeaker to the AVAudioSession options. This is causing the audio_capture session to not initialize.
Step 1:
Run the flutter_audio_capture Example without modification. Observe that the first press of Start correctly causes data to stream to the Console.
Step 2:
Modify line 21 of AudioCapture.swift as such:
options: [.defaultToSpeaker, .allowBluetoothA2DP, .allowAirPlay, .allowBluetooth])
Or change line 21 to read:
options: [.defaultToSpeaker])
Run the flutter_audio_capture Example again. Observe that nothing happens when Start is pressed.
Press Stop, then press Start again and the stream is finally seen in the Console.
Other observations:
When line 21 does not include .defaultToSpeaker, the sample rate is 44100. Adding .defaultToSpeaker changes this to 48000.
To see this, add a print statement before 'audioEngine.prepare()' .
print("Buffer: ", buffer.format, ")
I have not been able to reveal any error messages using Xcode or VScode.
Clue: The AudioKit Cookbook is able to correctly implement .defaultToSpeaker without causing iPhone problems. I am looking for differences in the code, but have not found anything that makes a difference when applied to the audio_capture plugin.
https:/AudioKit/Cookbook
Tested using Xcode 14.0.1 with iPhone 7S on iOS 15.7 and iPhone XR on iOS 16.0.2.
The text was updated successfully, but these errors were encountered: