# Multiple audio stream on iOS (multiRoute)

**URL:** <https://forum.juce.com/t/multiple-audio-stream-on-ios-multiroute/35607>\
**Category:** MacOSX and iOS\
**Created:** [October 9, 2019, 12:20pm UTC](https://forum.juce.com/t/multiple-audio-stream-on-ios-multiroute/35607 "2019-10-09T12:20:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lelepar](https://avatars.discourse-cdn.com/v4/letter/l/c68b51/32.png) [@lelepar](https://forum.juce.com/u/lelepar)\
**Post date:** [October 9, 2019, 12:20pm UTC](https://forum.juce.com/t/multiple-audio-stream-on-ios-multiroute/35607/1 "2019-10-09T12:20:14Z")

</div>

Hi JUCE team,

do you plan to implement to implement multiRoute for iOS?  
[https://developer.apple.com/documentation/avfoundation/avaudiosession/category/1616484-multiroute](https://developer.apple.com/documentation/avfoundation/avaudiosession/category/1616484-multiroute)

Best,  
Emanuele

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [October 10, 2019, 8:05am UTC](https://forum.juce.com/t/multiple-audio-stream-on-ios-multiroute/35607/2 "2019-10-10T08:05:57Z")

</div>

No immediate plans for this, although from reading the docs it looks like we have a lot of the foundations for this in place already in the iOS audio code.

Does it work if you make the following modification in `juce_ios_Audio.cpp` to `handleRouteChange()` to reconfigure the device on route change:

```auto
switch (reason)
{
case AVAudioSessionRouteChangeReasonCategoryChange:
case AVAudioSessionRouteChangeReasonOverride:
    break;
case AVAudioSessionRouteChangeReasonUnknown:
case AVAudioSessionRouteChangeReasonNewDeviceAvailable:
case AVAudioSessionRouteChangeReasonOldDeviceUnavailable:
case AVAudioSessionRouteChangeReasonWakeFromSleep:
case AVAudioSessionRouteChangeReasonNoSuitableRouteForCategory:
case AVAudioSessionRouteChangeReasonRouteConfigurationChange:
{
    hardwareInfoNeedsUpdating = true;
    triggerAsyncUpdate();
    break;
}
// No default so the code doesn't compile if this enum is extended.
}

```

As well as changing the call to `setAudioSessionCategory()` in `iOSAudioIODevice::Pimpl::open()` to use `AVAudioSessionCategoryMultiRoute`.

---

<div class="post-metadata">

**Author:** ![pffelix](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/pffelix/32/7228_2.png) [@pffelix](https://forum.juce.com/u/pffelix)\
**Post date:** [December 13, 2019, 7:07pm UTC](https://forum.juce.com/t/multiple-audio-stream-on-ios-multiroute/35607/3 "2019-12-13T19:07:27Z")

</div>

Hi Ed @ed95  
I just tested your suggestion. _setAudioSessionCategory()_ triggers with the adaption a semantic issue as _AVAudioSessionCategoryMultiRoute_ seems to deliver the wrong, non binary, return value. Do you see a possibility to add the _multiRoute_ category in one of the next JUCE releases? Would be a very valuable feature to have multi-device playback and output routing options on IOS

 ![Screenshot 2019-12-13 at 20.00.40](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/5/5a6e421703b41dfed4e9860928c27b42af87b96a.png)

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [December 16, 2019, 12:53pm UTC](https://forum.juce.com/t/multiple-audio-stream-on-ios-multiroute/35607/4 "2019-12-16T12:53:54Z")

</div>

Yes, you’re right that code is incorrect. I’ve modified my reply above so hopefully it won’t confuse anyone else. Does it work correctly with the modified changes above?

---

<div class="post-metadata">

**Author:** ![pffelix](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/pffelix/32/7228_2.png) [@pffelix](https://forum.juce.com/u/pffelix)\
**Post date:** [December 16, 2019, 2:40pm UTC](https://forum.juce.com/t/multiple-audio-stream-on-ios-multiroute/35607/5 "2019-12-16T14:40:25Z")

</div>

The updated code compiled well, great. I have not yet tested whether selecting the routing paths works correctly, however, will post an update in case any issues are occuring.
