Post

Replies

Boosts

Views

Activity

Reply to CoreAudio custom property memory leak
There is also something weird happening in the Core Audio Server Plug-In sandbox process itself - it seems to leak memory with custom properties on macOS 12.5.1. It seems related to the issue mentioned above, although if I do release the CFDataRef Instruments still complains about the leak in +[NSPropertyListSerialization propertyListWithData:options:format:error:]
Topic: Media Technologies SubTopic: Audio Tags:
Oct ’22
Reply to AVAudioSession.outputVolume does not reflect system volume changes made while app is in background
I had the same problem even with "Audio, AirPlay and Picture in Picture" background mode enabled and with all the AVAudioSession.setActive(true) and AVAudioSession.setCategory(...) calls. We run some tests and it seems Apple made things more restrictive since iOS 18 (it was working on iOS 17.6). The only fix I found is to use the good old MPVolumeView as a substitute, but there's a catch - it's mandatory to add it to UI otherwise it will always return volume of 0. In SwiftUI it was as simple as creating a UI component: import MediaPlayer import SwiftUI struct VolumeSlider: UIViewRepresentable { private let volumeView: MPVolumeView = MPVolumeView() func makeUIView(context: Context) -> MPVolumeView { return volumeView } func updateUIView(_ view: MPVolumeView, context: Context) {} func getVolume() -> Float { if let slider = volumeView.subviews.first(where: { $0 is UISlider }) as? UISlider { return slider.value } return AVAudioSession.sharedInstance().outputVolume } } And then in your SwiftUI view you can add it like: struct YourView: View { private let volumeControl: VolumeSlider = VolumeSlider() @ViewBuilder var body: some View { //... your controls here ... // This is a hack to make volume control work, but be invisible volumeControl.frame(height: .zero).clipped() Spacer(minLength: .zero) } private func someMethodThatRelatesToVolumeControl() { let volume = volumeControl.getVolume() // use the actual volume value } }
Topic: Media Technologies SubTopic: Audio Tags:
1d