Skip to content

Commit c4ea8d1

Browse files
author
llfbandit
committed
chore: Rework Darwin package
1 parent 128380a commit c4ea8d1

20 files changed

+660
-481
lines changed

record/example/lib/audio_recorder.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ class _RecorderState extends State<Recorder> with AudioRecorderMixin {
4444
Future<void> _start() async {
4545
try {
4646
if (await _audioRecorder.hasPermission()) {
47-
const encoder = AudioEncoder.wav;
47+
const encoder = AudioEncoder.aacLc;
4848

4949
// We don't do anything with this but printing
5050
final isSupported = await _audioRecorder.isEncoderSupported(
5151
encoder,
5252
);
5353

54-
debugPrint('${encoder.name} supported: $isSupported');
54+
if (!isSupported) {
55+
debugPrint('${encoder.name} supported: $isSupported');
56+
}
5557

5658
final devs = await _audioRecorder.listInputDevices();
5759
debugPrint(devs.toString());

record/example/lib/platform/audio_recorder_io.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ mixin AudioRecorderMixin {
1313
}
1414

1515
Future<void> recordStream(AudioRecorder recorder, RecordConfig config) async {
16-
final file = File(await _getPath());
16+
final path = await _getPath();
17+
18+
final file = File(path);
1719

1820
final stream = await recorder.startStream(config);
1921

@@ -26,7 +28,10 @@ mixin AudioRecorderMixin {
2628
file.writeAsBytesSync(data, mode: FileMode.append);
2729
},
2830
// ignore: avoid_print
29-
onDone: () => print('End of stream'),
31+
onDone: () {
32+
// ignore: avoid_print
33+
print('End of stream. File written to $path.');
34+
},
3035
);
3136
}
3237

record/example/macos/Runner.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
isa = PBXProject;
203203
attributes = {
204204
LastSwiftUpdateCheck = 0920;
205-
LastUpgradeCheck = 1300;
205+
LastUpgradeCheck = 1430;
206206
ORGANIZATIONNAME = "";
207207
TargetAttributes = {
208208
33CC10EC2044A3C60003C045 = {

record/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1430"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

record_darwin/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.0.1-beta.1
2+
* chore: Reworked again implementations to be closer to previous versions:
3+
- iOS Simulator is now usable again.
4+
- streaming is now done via AudioEngine.
5+
16
## 1.0.0
27
* chore: Initial stable release.
38

record_darwin/darwin/Classes/RecordConfig.swift

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
enum AudioEncoder: String {
1+
public enum AudioEncoder: String {
22
case aacLc = "aacLc"
33
case aacEld = "aacEld"
44
case aacHe = "aacHe"
@@ -10,13 +10,12 @@ enum AudioEncoder: String {
1010
case wav = "wav"
1111
}
1212

13-
14-
class RecordConfig {
13+
public class RecordConfig {
1514
let encoder: String
1615
let bitRate: Int
1716
let sampleRate: Int
1817
let numChannels: Int
19-
let device: [String: Any]?
18+
let device: Device?
2019
let autoGain: Bool
2120
let echoCancel: Bool
2221
let noiseSuppress: Bool
@@ -25,7 +24,7 @@ class RecordConfig {
2524
bitRate: Int,
2625
sampleRate: Int,
2726
numChannels: Int,
28-
device: [String : Any]? = nil,
27+
device: Device? = nil,
2928
autoGain: Bool = false,
3029
echoCancel: Bool = false,
3130
noiseSuppress: Bool = false
@@ -40,3 +39,25 @@ class RecordConfig {
4039
self.noiseSuppress = noiseSuppress
4140
}
4241
}
42+
43+
public class Device {
44+
let id: String
45+
let label: String
46+
47+
init(id: String, label: String) {
48+
self.id = id
49+
self.label = label
50+
}
51+
52+
init(map: [String: Any]) {
53+
self.id = map["id"] as! String
54+
self.label = map["label"] as! String
55+
}
56+
57+
func toMap() -> [String: Any] {
58+
return [
59+
"id": id,
60+
"label": label
61+
]
62+
}
63+
}

0 commit comments

Comments
 (0)