forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwal_interfaces.dart
More file actions
140 lines (119 loc) · 4.64 KB
/
Copy pathwal_interfaces.dart
File metadata and controls
140 lines (119 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import 'package:omi/backend/schema/bt_device/bt_device.dart';
import 'package:omi/backend/schema/conversation.dart';
import 'package:omi/backend/schema/geolocation.dart';
import 'package:omi/models/sync_state.dart';
import 'package:omi/services/audio_sources/audio_source.dart';
import 'package:omi/services/wals/wal.dart';
// Re-export for convenience
export 'package:omi/backend/http/api/conversations.dart'
show
uploadLocalFilesV2,
UploadFilesResult,
fetchSyncJobStatus,
SyncJobFetch,
SyncJobFetchOutcome,
SyncRateLimitedException,
SyncRateLimitKind,
SyncRecoveryWindowExceededException;
abstract class IWalSyncProgressListener {
void onWalSyncedProgress(
double percentage, {
double? speedKBps,
SyncPhase? phase,
int? currentFile,
int? totalFiles,
int? uploadedBytes,
int? totalBytesToUpload,
});
}
abstract class IWalServiceListener extends IWalSyncListener {
void onStatusChanged(WalServiceStatus status);
}
abstract class IWalSyncListener {
void onWalUpdated();
void onWalSynced(Wal wal, {ServerConversation? conversation});
}
abstract class IWalSync {
Future<List<Wal>> getMissingWals();
Future deleteWal(Wal wal);
Future<SyncLocalFilesResponse?> syncAll({IWalSyncProgressListener? progress});
Future<SyncLocalFilesResponse?> syncWal({required Wal wal, IWalSyncProgressListener? progress});
void cancelSync();
void start();
Future stop();
}
abstract class IWalService {
void start();
Future stop();
void subscribe(IWalServiceListener subscription, Object context);
void unsubscribe(Object context);
/// Returns the WalSyncs instance for managing sync operations.
/// Returns dynamic to avoid circular imports - cast to WalSyncs at call site.
dynamic getSyncs();
}
enum WalServiceStatus { init, ready, stop }
// Forward declarations for sync types
abstract class LocalWalSync implements IWalSync {
Future<void> addExternalWal(Wal wal);
Future<List<Wal>> getAllWals();
Future<void> deleteAllSyncedWals();
Future<void> deleteAllPendingWals();
Future<void> deleteAllCorruptedWals();
/// Ingest a pre-processed audio frame from an AudioSource.
/// The frame contains headerless payload and a source-specific sync key.
void onFrameCaptured(WalFrame frame);
/// Mark a frame as synced (sent to server via WebSocket).
/// Matches frames by sync key (source-agnostic).
void markFrameSynced(FrameSyncKey key);
/// Notify WAL that the audio codec has changed (resets frame state).
Future onAudioCodecChanged(BleAudioCodec codec);
/// Set device metadata for WAL file naming.
void setDeviceInfo(String? deviceId, String? deviceModel);
/// Set the snapshot inherited by WALs created for the active session.
void setSessionGeolocation(Geolocation? geolocation);
}
abstract class SDCardWalSync implements IWalSync {
void setLocalSync(LocalWalSync localSync);
void setDevice(BtDevice? device);
Future<void> deleteAllSyncedWals();
Future<void> deleteAllPendingWals();
bool get isSyncing;
double get currentSpeedKBps;
}
abstract class StorageSync implements IWalSync {
void setLocalSync(LocalWalSync localSync);
void setDevice(BtDevice? device);
Future<void> deleteAllSyncedWals();
Future<void> deleteAllPendingWals();
bool get isSyncing;
double get currentSpeedKBps;
Future<bool> hasFilesToSync();
}
/// Ring-buffer storage sync (firmware 3.0.20+).
/// Mirrors StorageSync, with the ring as a single logical stream rather than a list of files.
abstract class RingStorageSync implements IWalSync {
void setLocalSync(LocalWalSync localSync);
void setDevice(BtDevice? device);
Future<void> deleteAllSyncedWals();
Future<void> deleteAllPendingWals();
bool get isSyncing;
double get currentSpeedKBps;
Future<bool> hasFilesToSync();
Future<void> refreshWalsFromDevice();
}
/// Why the most recent flash-page drain pass stopped before reaching the
/// newest page enumerated from the device. A stall with the newest-page
/// pointer still advancing means the pendant is recording (an open recording
/// session starves the drain). A stall with zero free capture pages means the
/// pendant is full: it halts recording but stays armed in recording mode, and
/// serves no flash pages until the user presses the button to stop recording.
enum FlashSyncStallReason { none, recordingSuspected, deviceFull, unknown }
abstract class FlashPageWalSync implements IWalSync {
void setDevice(BtDevice? device);
void setLocalSync(LocalWalSync localSync);
Future<void> deleteAllSyncedWals();
Future<void> deleteAllPendingWals();
bool get isSyncing;
Future<void> refreshWalsFromDevice();
FlashSyncStallReason get lastStallReason;
}