mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-01 18:59:25 +00:00
Use AVAudioPlayer for sound play instead of PlaySystemSound. This allows to control the volume of the notifications from within the app.
This commit is contained in:
parent
d627212c9b
commit
b422185b7f
3 changed files with 24 additions and 30 deletions
|
|
@ -98,8 +98,6 @@ struct NetworkReachabilityContext {
|
|||
@end
|
||||
|
||||
typedef struct _LinphoneManagerSounds {
|
||||
SystemSoundID call;
|
||||
SystemSoundID message;
|
||||
SystemSoundID vibrate;
|
||||
} LinphoneManagerSounds;
|
||||
|
||||
|
|
@ -132,6 +130,7 @@ typedef struct _LinphoneManagerSounds {
|
|||
+ (NSString *)getUserAgent;
|
||||
+ (int)unreadMessageCount;
|
||||
|
||||
- (void)playMessageSound;
|
||||
- (void)resetLinphoneCore;
|
||||
- (void)startLibLinphone;
|
||||
- (void)destroyLibLinphone;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
#import "LinphoneIOSVersion.h"
|
||||
|
||||
#import <AVFoundation/AVAudioPlayer.h>
|
||||
|
||||
#define LINPHONE_LOGS_MAX_ENTRY 5000
|
||||
|
||||
static void audioRouteChangeListenerCallback (
|
||||
|
|
@ -99,6 +101,12 @@ NSString *const kLinphoneInternalChatDBFilename = @"linphone_chats.db";
|
|||
[super dealloc];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@interface LinphoneManager ()
|
||||
@property (retain, nonatomic) AVAudioPlayer* messagePlayer;
|
||||
@end
|
||||
|
||||
@implementation LinphoneManager
|
||||
|
||||
@synthesize connectivity;
|
||||
|
|
@ -247,26 +255,13 @@ struct codec_name_pref_table codec_pref_table[]={
|
|||
[LinphoneLogger logc:LinphoneLoggerError format:"cannot register route change handler [%ld]",lStatus];
|
||||
}
|
||||
|
||||
// Sounds
|
||||
{
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"ring" ofType:@"wav"];
|
||||
sounds.call = 0;
|
||||
OSStatus status = AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &sounds.call);
|
||||
if(status != 0){
|
||||
[LinphoneLogger log:LinphoneLoggerWarning format:@"Can't set \"call\" system sound"];
|
||||
}
|
||||
}
|
||||
{
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"msg" ofType:@"wav"];
|
||||
sounds.message = 0;
|
||||
OSStatus status = AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &sounds.message);
|
||||
if(status != 0){
|
||||
[LinphoneLogger log:LinphoneLoggerWarning format:@"Can't set \"message\" system sound"];
|
||||
}
|
||||
}
|
||||
sounds.vibrate = kSystemSoundID_Vibrate;
|
||||
|
||||
logs = [[NSMutableArray alloc] init];
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"msg" ofType:@"wav"];
|
||||
self.messagePlayer = [[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL URLWithString:path] error:nil] autorelease];
|
||||
|
||||
sounds.vibrate = kSystemSoundID_Vibrate;
|
||||
|
||||
logs = [[NSMutableArray alloc] init];
|
||||
database = NULL;
|
||||
speakerEnabled = FALSE;
|
||||
bluetoothEnabled = FALSE;
|
||||
|
|
@ -294,13 +289,6 @@ struct codec_name_pref_table codec_pref_table[]={
|
|||
}
|
||||
|
||||
- (void)dealloc {
|
||||
if(sounds.call) {
|
||||
AudioServicesDisposeSystemSoundID(sounds.call);
|
||||
}
|
||||
if(sounds.message) {
|
||||
AudioServicesDisposeSystemSoundID(sounds.message);
|
||||
}
|
||||
|
||||
[fastAddressBook release];
|
||||
[logs release];
|
||||
|
||||
|
|
@ -1521,6 +1509,14 @@ static int comp_call_id(const LinphoneCall* call , const char *callid) {
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (void)playMessageSound {
|
||||
BOOL success = [self.messagePlayer play];
|
||||
if( !success ){
|
||||
Linphone_err(@"Could not play the message sound");
|
||||
}
|
||||
AudioServicesPlaySystemSound([LinphoneManager instance].sounds.vibrate);
|
||||
}
|
||||
|
||||
static int comp_call_state_paused (const LinphoneCall* call, const void* param) {
|
||||
return linphone_call_get_state(call) != LinphoneCallPaused;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -675,8 +675,7 @@ static RootViewManager* rootViewManagerInstance = nil;
|
|||
- (void)playMessageSound {
|
||||
if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) {
|
||||
if(![self removeInhibitedEvent:kLinphoneTextReceived]) {
|
||||
AudioServicesPlaySystemSound([LinphoneManager instance].sounds.message);
|
||||
AudioServicesPlaySystemSound([LinphoneManager instance].sounds.vibrate);
|
||||
[[LinphoneManager instance] playMessageSound];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue