2

I am trying to increase the volume of my Audio Output using the speakHere example from Apple. The volume is already set to max with :

// set the volume of the queue XThrowIfError (AudioQueueSetParameter(mQueue, kAudioQueueParam_Volume, 1.0), "set queue volume");

However, the output is directed to the ear-piece speaker, which is not as loud as the bottom-left-speaker on the iPhone. An example of this can be seen nicely in the 'Voice Memos' that comes with the iPhone. They provide a 'Speaker-Button' that toggles between the two speakers. Does anybody have an idea how that is done? What do I need to output my Audio to the bottom speaker? Any tips, hints, answers will be much appreciated. Thanks you in advance Al

Alan
  • 796
  • 9
  • 26

3 Answers3

3

Take a look at AudioSessionSetProperty, the kAudioSessionProperty_OverrideCategoryDefaultToSpeaker property in particular.

Neil Mix
  • 826
  • 6
  • 6
3

You need to set Player to Speaker Mode.

Add this code in AQPlayer.mm:

OSStatus error;
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; 
error = AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, sizeof (audioRouteOverride), &audioRouteOverride);
if (error) printf("couldn't set audio speaker!");

Before this code:

XThrowIfError (AudioQueueSetParameter(mQueue, kAudioQueueParam_Volume, 1.0), "set queue volume");

I hope it helps.

Xavi
  • 46
  • 1
2

look at the kAudioSessionProperty_OverrideAudioRoute property

anon
  • 21
  • 1