Skip to content

Commit

Permalink
Merge branch 'jointhejourney-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanheise committed Apr 4, 2024
2 parents c20db1d + 78c59ff commit 2c69fa0
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 29 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.1.19

* Run setActive in a thread on iOS to avoid jank (@jointhejourney).
* Update minimum iOS version to 12.0.

## 0.1.18

* Fix parameter type in AVAudioSessionCategoryOptions.contains (@kainosk).
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
9 changes: 5 additions & 4 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -237,6 +237,7 @@
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand Down Expand Up @@ -353,7 +354,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -435,7 +436,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -484,7 +485,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
7 changes: 2 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:math';

import 'package:audio_session/audio_session.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:just_audio/just_audio.dart' as ja;

Expand Down Expand Up @@ -153,15 +152,13 @@ class _MyAppState extends State<MyApp> {
style: Theme.of(context).textTheme.titleLarge),
for (var device
in devices.where((device) => device.isInput))
Text(
'${device.name} (${describeEnum(device.type)})'),
Text('${device.name} (${device.type.name})'),
SizedBox(height: 16),
Text("Output devices",
style: Theme.of(context).textTheme.titleLarge),
for (var device
in devices.where((device) => device.isOutput))
Text(
'${device.name} (${describeEnum(device.type)})'),
Text('${device.name} (${device.type.name})'),
],
);
},
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: Demonstrates how to use the audio_session plugin.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ">=2.17.0 <4.0.0"

dependencies:
flutter:
Expand Down
34 changes: 21 additions & 13 deletions ios/Classes/DarwinAudioSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,27 @@ - (void)getRouteSharingPolicy:(NSArray *)args result:(FlutterResult)result {
}

- (void)setActive:(NSArray *)args result:(FlutterResult)result {
NSError *error = nil;
BOOL active = [args[0] boolValue];
BOOL status;
if (args[1] != (id)[NSNull null]) {
status = [[AVAudioSession sharedInstance] setActive:active withOptions:[args[1] integerValue] error:&error];
} else {
status = [[AVAudioSession sharedInstance] setActive:active error:&error];
}
if (error) {
[self sendError:error result:result];
} else {
result(@(status));
}
// Dispatch this task to a background thread to avoid jank
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSError *error = nil;
BOOL active = [args[0] boolValue];
BOOL status;

if (args[1] != (id)[NSNull null]) {
status = [[AVAudioSession sharedInstance] setActive:active withOptions:[args[1] integerValue] error:&error];
} else {
status = [[AVAudioSession sharedInstance] setActive:active error:&error];
}

// Once the operation is done, switch back to the main thread to send the result
dispatch_async(dispatch_get_main_queue(), ^{
if (error) {
[self sendError:error result:result];
} else {
result(@(status));
}
});
});
}

- (void)getRecordPermission:(NSArray *)args result:(FlutterResult)result {
Expand Down
2 changes: 1 addition & 1 deletion ios/audio_session.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A new flutter plugin project.
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.platform = :ios, '8.0'
s.platform = :ios, '12.0'

# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: audio_session
description: Sets the iOS audio session category and Android audio attributes for your app, and manages your app's audio focus, mixing and ducking behaviour.
version: 0.1.18
version: 0.1.19
homepage: https:/ryanheise/audio_session
topics:
- audio
- audio-session

environment:
sdk: ">=2.14.0 <4.0.0"
sdk: ">=2.17.0 <4.0.0"
flutter: ">=3.0.0"

dependencies:
Expand Down

0 comments on commit 2c69fa0

Please sign in to comment.