audio: only speaker on ipad for now

This commit is contained in:
Gautier Pelloux-Prayer 2016-01-25 10:06:07 +01:00
parent f4478d53c8
commit b15979637b
5 changed files with 60 additions and 40 deletions

View file

@ -147,18 +147,6 @@
<state key="selected" image="micro_selected.png"/>
<state key="highlighted" backgroundImage="color_E.png"/>
</button>
<button opaque="NO" tag="10" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="G7m-Av-QlR" userLabel="speakerButton" customClass="UISpeakerButton">
<rect key="frame" x="282" y="0.0" width="94" height="63"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES"/>
<accessibility key="accessibilityConfiguration" label="Accept"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" image="speaker_default.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="disabled" image="speaker_disabled.png"/>
<state key="selected" image="speaker_selected.png"/>
<state key="highlighted" backgroundImage="color_E.png"/>
</button>
<button hidden="YES" opaque="NO" tag="54" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="29K-Sd-aHF" userLabel="routesButton" customClass="UIToggleButton">
<rect key="frame" x="282" y="0.0" width="94" height="63"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
@ -174,6 +162,18 @@
<action selector="onRoutesClick:" destination="-1" eventType="touchUpInside" id="hXX-8a-7M4"/>
</connections>
</button>
<button opaque="NO" tag="10" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="G7m-Av-QlR" userLabel="speakerButton" customClass="UISpeakerButton">
<rect key="frame" x="282" y="0.0" width="94" height="63"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES"/>
<accessibility key="accessibilityConfiguration" label="Accept"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" image="speaker_default.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="disabled" image="speaker_disabled.png"/>
<state key="selected" image="speaker_selected.png"/>
<state key="highlighted" backgroundImage="color_E.png"/>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
@ -344,18 +344,6 @@
<state key="selected" image="micro_selected.png"/>
<state key="highlighted" backgroundImage="color_E.png"/>
</button>
<button opaque="NO" tag="10" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="5CY-aN-NLX" userLabel="speakerButton" customClass="UISpeakerButton">
<rect key="frame" x="501" y="0.0" width="167" height="63"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES"/>
<accessibility key="accessibilityConfiguration" label="Accept"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" image="speaker_default.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="disabled" image="speaker_disabled.png"/>
<state key="selected" image="speaker_selected.png"/>
<state key="highlighted" backgroundImage="color_E.png"/>
</button>
<button hidden="YES" opaque="NO" tag="54" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="61B-DK-jZ6" userLabel="routesButton" customClass="UIToggleButton">
<rect key="frame" x="501" y="0.0" width="167" height="63"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES"/>
@ -368,6 +356,18 @@
<state key="selected" image="routes_selected.png"/>
<state key="highlighted" backgroundImage="color_E.png"/>
</button>
<button opaque="NO" tag="10" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="5CY-aN-NLX" userLabel="speakerButton" customClass="UISpeakerButton">
<rect key="frame" x="501" y="0.0" width="167" height="63"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES"/>
<accessibility key="accessibilityConfiguration" label="Accept"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" image="speaker_default.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="disabled" image="speaker_disabled.png"/>
<state key="selected" image="speaker_selected.png"/>
<state key="highlighted" backgroundImage="color_E.png"/>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>

View file

@ -1775,19 +1775,25 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
#pragma mark - Audio route Functions
- (bool)allowSpeaker {
bool notallow = false;
if (IPAD)
return true;
bool allow = true;
CFStringRef lNewRoute = CFSTR("Unknown");
UInt32 lNewRouteSize = sizeof(lNewRoute);
OSStatus lStatus = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &lNewRouteSize, &lNewRoute);
if (!lStatus && lNewRouteSize > 0) {
NSString *route = (__bridge NSString *)lNewRoute;
notallow = [route containsString:@"Heads"] || [route isEqualToString:@"Lineout"];
allow = ![route containsString:@"Heads"] && ![route isEqualToString:@"Lineout"];
CFRelease(lNewRoute);
}
return !notallow;
return allow;
}
- (void)audioRouteChangeListenerCallback:(NSNotification *)notif {
if (IPAD)
return;
// there is at least one bug when you disconnect an audio bluetooth headset
// since we only get notification of route having changed, we cannot tell if that is due to:
// -bluetooth headset disconnected or
@ -1839,7 +1845,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
}
if (override != kAudioSessionNoError) {
if (enable && (IPAD || [self allowSpeaker])) {
if (enable && [self allowSpeaker]) {
override = kAudioSessionOverrideAudioRoute_Speaker;
ret = AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof(override), &override);
_bluetoothEnabled = FALSE;

View file

@ -57,8 +57,6 @@ INIT_WITH_COMMON_CF {
- (bool)onUpdate {
self.enabled = [LinphoneManager.instance allowSpeaker];
if (IPAD)
self.selected = !LinphoneManager.instance.bluetoothEnabled;
return [LinphoneManager.instance speakerEnabled];
}

View file

@ -23,12 +23,34 @@
#pragma mark - Lifecycle Functions
INIT_WITH_COMMON_CF {
- (void)initUIToggleButton {
[self update];
[self addTarget:self action:@selector(touchUp:) forControlEvents:UIControlEventTouchUpInside];
}
- (id)init {
self = [super init];
if (self) {
[self initUIToggleButton];
}
return self;
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initUIToggleButton];
}
return self;
}
- (id)initWithCoder:(NSCoder *)decoder {
self = [super initWithCoder:decoder];
if (self) {
[self initUIToggleButton];
}
return self;
}
#pragma mark -
- (void)touchUp:(id)sender {

View file

@ -100,21 +100,15 @@ typedef enum {
whatever is using it (xib, source code, etc., tableview cell) */
#define INIT_WITH_COMMON_C \
-(instancetype)init { \
self = [super init]; \
[self commonInit]; \
return self; \
return [[super init] commonInit]; \
} \
-(instancetype)initWithCoder : (NSCoder *)aDecoder { \
self = [super initWithCoder:aDecoder]; \
[self commonInit]; \
return self; \
return [[super initWithCoder:aDecoder] commonInit]; \
} \
-(instancetype)commonInit
#define INIT_WITH_COMMON_CF \
-(instancetype)initWithFrame : (CGRect)frame { \
self = [super initWithFrame:frame]; \
[self commonInit]; \
return self; \
return [[super initWithFrame:frame] commonInit]; \
} \
INIT_WITH_COMMON_C