# Routing changes, hopefully the last time

**URL:** <https://forum.juce.com/t/routing-changes-hopefully-the-last-time/9502>\
**Category:** MacOSX and iOS\
**Created:** [November 6, 2012, 7:32pm UTC](https://forum.juce.com/t/routing-changes-hopefully-the-last-time/9502 "2012-11-06T19:32:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![P4tr3ck](https://avatars.discourse-cdn.com/v4/letter/p/e79b87/32.png) [@P4tr3ck](https://forum.juce.com/u/P4tr3ck)\
**Post date:** [November 6, 2012, 7:32pm UTC](https://forum.juce.com/t/routing-changes-hopefully-the-last-time/9502/1 "2012-11-06T19:32:23Z")

</div>

It feels like an endless story but it seems iOS users want us to nail the exact standard behavior of other iOS apps like the stock music app. So here we go again…

Imagine the following use case: Listen to app with headphones. Pull headphones.

The music app pauses playback in that case. A JUCE app continue with playback using the iPhone/iPad speaker.

There are more combinations possible with bluetooth headset and headphones plugged in and out but everything seems to come down to the following simple change in juce\_ios\_Audio.cpp, routingChanged method:

[code]if (routeChangeReason == kAudioSessionRouteChangeReason\_OldDeviceUnavailable)  
{  
{  
const ScopedLock sl (callbackLock);

```
	if (callback != nullptr)
		callback->audioDeviceError ("iOS routing changed, old device unavailable");
}

// fixAudioRouteIfSetToReceiver();

```

}  
[/code]

This would make a JUCE app behave exactly the same as regular iOS apps like the music app. What do you think, is it a good idea to make this change?

Patrick

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 6, 2012, 9:05pm UTC](https://forum.juce.com/t/routing-changes-hopefully-the-last-time/9502/2 "2012-11-06T21:05:49Z")

</div>

I’d give this a tentative “yes”, but would welcome other opinions too…

---

<div class="post-metadata">

**Author:** ![valley](https://avatars.discourse-cdn.com/v4/letter/v/67e7ee/32.png) [@valley](https://forum.juce.com/u/valley)\
**Post date:** [November 7, 2012, 12:44am UTC](https://forum.juce.com/t/routing-changes-hopefully-the-last-time/9502/3 "2012-11-07T00:44:28Z")

</div>

FWIW: I have no interest in this as a dev, but as a user, I would absolutely prefer that patch.

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [November 7, 2012, 12:49am UTC](https://forum.juce.com/t/routing-changes-hopefully-the-last-time/9502/4 "2012-11-07T00:49:06Z")

</div>

Well even with the patch, if you want the old behavior can’t you simply not pause on the routing change?

---

<div class="post-metadata">

**Author:** ![P4tr3ck](https://avatars.discourse-cdn.com/v4/letter/p/e79b87/32.png) [@P4tr3ck](https://forum.juce.com/u/P4tr3ck)\
**Post date:** [November 7, 2012, 8:00am UTC](https://forum.juce.com/t/routing-changes-hopefully-the-last-time/9502/5 "2012-11-07T08:00:25Z")

</div>

> [@TheVinn](#):
>
> Well even with the patch, if you want the old behavior can’t you simply not pause on the routing change?

Yes you could. It depends on what you are doing in the audioDeviceError callback. My implementation updates the ui to a paused state. Alternatively you could try to recover and continue playback on whatever output is available.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 7, 2012, 9:17am UTC](https://forum.juce.com/t/routing-changes-hopefully-the-last-time/9502/6 "2012-11-07T09:17:30Z")

</div>

Yes, I think this makes a lot of sense. Thanks!
