ObjectAL
 All Classes Functions Variables Properties Pages
Instance Methods | Protected Member Functions | Protected Attributes | Properties | List of all members
OALAudioSession Class Reference

Handles the audio session and interrupts. More...

#import <OALAudioSession.h>

Inheritance diagram for OALAudioSession:
<OALSuspendManager> <OALSuspendListener>

Instance Methods

(void) - forceEndInterruption
 Force an interrupt end. More...
 
- Instance Methods inherited from <OALSuspendManager>
(void) - addSuspendListener:
 Add a listener that will receive manual suspend and interrupt events. More...
 
(void) - removeSuspendListener:
 Remove a registered listener. More...
 

Protected Member Functions

() - SYNTHESIZE_SINGLETON_FOR_CLASS_HEADER
 Singleton implementation providing "sharedInstance" and "purgeSharedInstance" methods. More...
 

Protected Attributes

bool handlingErrorNotification
 Flag signifying that we are currently handling an error notification. More...
 
bool audioSessionWasActive
 If true, the audio session was active when the interrupt occurred. More...
 
OALSuspendHandlersuspendHandler
 Handles suspending and interrupting for this object. More...
 
NSDate * lastResetTime
 Marks the last time the audio session was reset due to error. More...
 

Properties

NSString * audioSessionCategory
 The current audio session category. More...
 
bool allowIpod
 If YES, allow ipod music to continue playing (NOT SUPPORTED ON THE SIMULATOR). More...
 
bool ipodDucking
 If YES, ipod music will duck (lower in volume) when the audio session activates. More...
 
bool useHardwareIfAvailable
 Determines what to do if no other application is playing audio and allowIpod = YES (NOT SUPPORTED ON THE SIMULATOR). More...
 
bool honorSilentSwitch
 If true, mute when backgrounded, screen locked, or the ringer switch is turned off (NOT SUPPORTED ON THE SIMULATOR). More...
 
bool handleInterruptions
 If true, automatically handle interruptions. More...
 
float preferredIOBufferDuration
 The preferred I/O buffer duration, in seconds. More...
 
bool ipodPlaying
 If true, another application (usually iPod) is playing music. More...
 
bool audioSessionActive
 If true, the audio session is active. More...
 
float hardwareVolume
 Get the device's final hardware output volume, as controlled by the volume button on the side of the device. More...
 
bool hardwareMuted
 Check if the hardware mute switch is on (not supported on the simulator or iOS 5+). More...
 
NSString * audioRoute
 Check what hardware route the audio is taking, such as "Speaker" or "Headphone" (not supported on the simulator). More...
 
- Properties inherited from <OALSuspendManager>
bool suspended
 If YES, this object is suspended. More...
 
- Properties inherited from <OALSuspendListener>
bool manuallySuspended
 Set to YES to manually suspend. More...
 
bool interrupted
 If YES, this object is interrupted. More...
 

Detailed Description

Handles the audio session and interrupts.

Method Documentation

- (void) forceEndInterruption

Force an interrupt end.

This can be useful in cases where a buggy OS fails to end an interrupt.

Be VERY CAREFUL when using this!

- OALAudioSession: (OALAudioSession

Singleton implementation providing "sharedInstance" and "purgeSharedInstance" methods.

- (OALAudioSupport*) sharedInstance: Get the shared singleton instance.
- (void) purgeSharedInstance: Purge (deallocate) the shared instance.

Member Data Documentation

- (bool) audioSessionWasActive
protected

If true, the audio session was active when the interrupt occurred.

- (bool) handlingErrorNotification
protected

Flag signifying that we are currently handling an error notification.

This prevents onAudioError: from becoming reentrant due to self.manuallySuspended setting off a chain of calls that result in another error notification broadcast.

- (NSDate*) lastResetTime
protected

Marks the last time the audio session was reset due to error.

This is used to avoid getting stuck in a rapid-fire reset-error loop.

- (OALSuspendHandler*) suspendHandler
protected

Handles suspending and interrupting for this object.

Property Documentation

- (bool) allowIpod
readwritenonatomicassign

If YES, allow ipod music to continue playing (NOT SUPPORTED ON THE SIMULATOR).

Note: If this is enabled, and another app is playing music, background audio playback will use the SOFTWARE codecs, NOT hardware.

If allowIpod = NO, the application will ALWAYS use hardware decoding.

See Also
useHardwareIfAvailable

Default value: YES

- (NSString*) audioRoute
readnonatomicretain

Check what hardware route the audio is taking, such as "Speaker" or "Headphone" (not supported on the simulator).

- (bool) audioSessionActive
readwritenonatomicassign

If true, the audio session is active.

- (NSString *) audioSessionCategory
readwritenonatomicretain

The current audio session category.

If this value is explicitly set, the other session properties "allowIpod", "useHardwareIfAvailable", "honorSilentSwitch", and "ipodDucking" may be modified to remain compatible with the category.

See Also
AVAudioSessionCategory

Default value: nil

- (bool) handleInterruptions
readwritenonatomicassign

If true, automatically handle interruptions.


Default value: YES

- (bool) hardwareMuted
readnonatomicassign

Check if the hardware mute switch is on (not supported on the simulator or iOS 5+).

Note: If headphones are plugged in, hardwareMuted will always return FALSE regardless of the switch state.

Note: Please file a bug report with Apple to get this functionality restored in iOS 5!

- (float) hardwareVolume
readnonatomicassign

Get the device's final hardware output volume, as controlled by the volume button on the side of the device.

- (bool) honorSilentSwitch
readwritenonatomicassign

If true, mute when backgrounded, screen locked, or the ringer switch is turned off (NOT SUPPORTED ON THE SIMULATOR).


Default value: YES

- (bool) ipodDucking
readwritenonatomicassign

If YES, ipod music will duck (lower in volume) when the audio session activates.

Default value: NO

- (bool) ipodPlaying
readnonatomicassign

If true, another application (usually iPod) is playing music.

- (float) preferredIOBufferDuration
readwritenonatomicassign

The preferred I/O buffer duration, in seconds.

Lower values give less playback latencey, but use more CPU.

- (bool) useHardwareIfAvailable
readwritenonatomicassign

Determines what to do if no other application is playing audio and allowIpod = YES (NOT SUPPORTED ON THE SIMULATOR).


If NO, the application will ALWAYS use software decoding. The advantage to this is that the user can background your application and then start audio playing from another application. If useHardwareIfAvailable = YES, the user won't be able to do this.

If this is set to YES, the application will use hardware decoding if no other application is currently playing audio. However, no other application will be able to start playing audio if it wasn't playing already.

Note: This switch has no effect if allowIpod = NO.

See Also
allowIpod

Default value: YES


The documentation for this class was generated from the following files: