Unknown Selected Data Source for Port Speaker (Type: Speaker)

Unknown selected data source for Port Speaker (type: Speaker)?

The message Unknown selected data source for Port Speaker seems to be a problem with iOS 12. Apparently it's some warning that appears even if the code is working. Perhaps Apple will fix this soon, so maybe for now you can ignore this warning and once they find a solution you will be able to silence it.

Source: AVAudioSession errors in iOS 12

As for the background music playing on silent mode, it's because of the AVAudioSessionCategory you selected. According to AVAudioSessionCategoryPlayback documentation (source):

When using this category, your app audio continues with the Silent switch set to silent or when the screen locks.

Depending on the style of your app, maybe you could use AVAudioSessionCategorySoloAmbient (source):

Your audio is silenced by screen locking and by the Silent switch (called the Ring/Silent switch on iPhone).

Or maybe AVAudioSessionCategoryAmbient (source):

This category is also appropriate for “play along” style apps, such as a virtual piano that a user plays while the Music app is playing. When you use this category, audio from other apps mixes with your audio. Your audio is silenced by screen locking and by the Silent switch (called the Ring/Silent switch on iPhone).

ValidateRequiredFields: Unknown selected data source for Port Speaker (type: Speaker)

Dan from Chirp here. Unfortunately, this warning is a known issue in the current Chirp iOS SDK (3.4.3) on certain devices and it can't be remedied by code on the user side. It's scheduled to be fixed in the next release, due out in the next few weeks. It is benign, however, and won't affect functionality.

AVAudioSessionManager availableInputs Unknown selected data source for port iPhone Microphone

This problem seems not just happen to me... I will just share my understanding here..

My situation is.. I'm using pjsip library, which has a lower level control of audio resources. I've noticed that, the sound device has been closed before I call [[AVAudioSession sharedInstance] availableInputs];

Thus, (I guess) AVAudioSession, as a higher level control, couldn't find corresponding audio data source for its input - as the error indicated...

To further investigate the problem, you'd better check somewhere in your code that modify the audio source.. and make sure the audio source is activated before you call AVAudioSession

I can only go this far for now... Deeper understanding and better explanation of audio control is always appreciated!!

AudioKit 4.6 no sound

I posted the answer to this question in AudioKit's GitHub issues pages, but for the record here, it is just that AKOscillator was on by default in the past (bad) and has been fixed in the newest version. So, @WholeCheese has to add an osc.start() to his files. Next, I hope to do a screen share with him to solve the Audiobus issues.

setPreferredInput WithBlueTooth not working

I finally found the right answer.
AVAudioSession should be used to collect and record which is very important.

And then setCategory like this:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord 
withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:&error];

Set preferinput:

[[AVAudioSession sharedInstance] setPreferredInput:_bluetoothPort error:nil];

When you got current input like this:

inputs = (
"< AVAudioSessionPortDescription: 0x28185bf00, type = MicrophoneBuiltIn; name = iPhone \U9ea6\U514b\U98ce; UID = Built-In Microphone; selectedDataSource = \U524d >"
);

outputs = (
"< AVAudioSessionPortDescription: 0x28185bfb0, type = BluetoothA2DPOutput; name = h.ear (MDR-EX750BT); UID = 04:5D:4B:4A:4F:31-tacl; selectedDataSource = (null) >"
)>.

It works! But I still don't understand why Apple's input shows that the prefer inputs is 'iPhone MicrophoneBuiltIn' but 'Bluetooth headphones' works.Is it a bug?

AVSystemController_SystemVolumeDidChangeNotification triggers when device locked

Wound up manually keeping the volume constant and using the audio session method. Had to throw in a couple hacks. This is a bit convoluted, so I'm open to cleaner alternatives. No idea how Apple would react to this being submitted in an app, although it seems that they definitely accept apps that use the volume buttons for interacting with the cameras.

Inside a UIViewController subclass:

override func viewDidLoad() {
super.viewDidLoad()
// …
setupVolumeButton()
}

private let volumeView = MPVolumeView(frame: CGRect(x: 0, y: -100, width: 0, height: 0)) // override volume view

private func setupVolumeButton() {
view.addSubview(volumeView)

setVolume(0.5) { // in case app launches with volume at max/min already
// need to wait until initial volume setting is done
// so it doesn't get triggered on launch

let audioSession = AVAudioSession()
try? audioSession.setActive(true)
audioSession.addObserver(self, forKeyPath: "outputVolume", options: NSKeyValueObservingOptions.new, context: nil)
}
}

private func setVolume(_ volume: Float, completion: (() -> Void)? = nil) {
let slider = volumeView.subviews.first(where: { $0 is UISlider }) as? UISlider
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
slider?.value = volume

DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.01) {
// needed to wait a bit before completing so the observer doesn't pick up the manualq volume change
completion?()
}
}
}

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if keyPath == "outputVolume" {
setVolume(0.5) // keep from reaching max or min volume so button keeps working

doTheThingThatShouldHappenWhenTheVolumeButtonIsPressed()
}
}

Edit: Also I noticed that the audio session was deactivated when the app was closed, so I stored the audio session in a property, added an observer for when the app became active again, and in the associated method I set the audio session to be active again.



Related Topics



Leave a reply



Submit