Merge remote-tracking branch 'origin/develop_liyi' into develop_liyi

This commit is contained in:
liyi 2025-02-25 15:18:51 +08:00
commit 567b85f03d
2 changed files with 30 additions and 24 deletions

View File

@ -676,8 +676,8 @@ class TalkViewLogic extends BaseGetXController {
// } // }
List<int> adjustVolume(List<int> pcmList, double volume) { List<int> adjustVolume(List<int> pcmList, double volume) {
final List<int> adjustedPcmList = []; final List<int> adjustedPcmList = <int>[];
for (int pcmVal in pcmList) { for (final int pcmVal in pcmList) {
// //
int adjustedPcmVal = (pcmVal * volume).round(); int adjustedPcmVal = (pcmVal * volume).round();
@ -698,8 +698,8 @@ class TalkViewLogic extends BaseGetXController {
final List<int> adjustedPcmList = adjustVolume(pcmList, 5.0); final List<int> adjustedPcmList = adjustVolume(pcmList, 5.0);
// A-law // A-law
final List<int> aLawList = []; final List<int> aLawList = <int>[];
for (int pcmVal in adjustedPcmList) { for (final int pcmVal in adjustedPcmList) {
final int aLawVal = linearToALaw(pcmVal); final int aLawVal = linearToALaw(pcmVal);
aLawList.add(aLawVal); aLawList.add(aLawVal);
} }
@ -707,8 +707,8 @@ class TalkViewLogic extends BaseGetXController {
} }
int linearToALaw(int pcmVal) { int linearToALaw(int pcmVal) {
const int ALAW_MAX = 0x7FFF; // 32767 const int alawMax = 0x7FFF; // 32767
const int ALAW_BIAS = 0x84; // 132 const int alawBias = 0x84; // 132
int mask; int mask;
int seg; int seg;
@ -723,9 +723,9 @@ class TalkViewLogic extends BaseGetXController {
} }
// Add bias and clamp to ALAW_MAX // Add bias and clamp to ALAW_MAX
pcmVal += ALAW_BIAS; pcmVal += alawBias;
if (pcmVal > ALAW_MAX) { if (pcmVal > alawMax) {
pcmVal = ALAW_MAX; pcmVal = alawMax;
} }
// Determine segment // Determine segment
@ -735,7 +735,7 @@ class TalkViewLogic extends BaseGetXController {
if (seg >= 8) { if (seg >= 8) {
aLawVal = 0x7F ^ mask; // Clamp to maximum value aLawVal = 0x7F ^ mask; // Clamp to maximum value
} else { } else {
int quantized = (pcmVal >> (seg + 3)) & 0xF; final int quantized = (pcmVal >> (seg + 3)) & 0xF;
aLawVal = (seg << 4) | quantized; aLawVal = (seg << 4) | quantized;
aLawVal ^= 0xD5; // XOR with 0xD5 to match standard A-law table aLawVal ^= 0xD5; // XOR with 0xD5 to match standard A-law table
} }
@ -744,7 +744,7 @@ class TalkViewLogic extends BaseGetXController {
} }
int search(int val) { int search(int val) {
final List<int> table = [ final List<int> table = <int>[
0xFF, // Segment 0 0xFF, // Segment 0
0x1FF, // Segment 1 0x1FF, // Segment 1
0x3FF, // Segment 2 0x3FF, // Segment 2

View File

@ -83,12 +83,16 @@ class XSJPushProvider {
final int cmdCode = data['cmd']; final int cmdCode = data['cmd'];
switch (cmdCode) { switch (cmdCode) {
case CMD_GET_REGISTRATION_ID: case CMD_GET_REGISTRATION_ID:
await Storage.setString(pushDeviceID, data['message']); if (!_jpushRegistrationIdCompleter.isCompleted &&
AppLog.log('flutter get registration id : ${data['message']}'); data['message'] != null) {
_jpushRegistrationIdCompleter.complete(<String, dynamic>{ await Storage.setString(pushDeviceID, data['message']);
'channel': 'jiguang', AppLog.log('flutter get registration id : ${data['message']}');
'channelToken': data['message'] _jpushRegistrationIdCompleter.complete(<String, dynamic>{
}); 'channel': 'jiguang',
'channelToken': data['message']
});
}
// final String? channel2TokenStr = // final String? channel2TokenStr =
// await Storage.getString(vendorPushChannelInfo); // await Storage.getString(vendorPushChannelInfo);
// if (Platform.isAndroid && channel2TokenStr != null) { // if (Platform.isAndroid && channel2TokenStr != null) {
@ -96,13 +100,15 @@ class XSJPushProvider {
// } // }
break; break;
case CMD_GET_TOKEN: case CMD_GET_TOKEN:
final Map<String, dynamic> channel2Token = <String, dynamic>{ if (!_vendorTokenCompleter.isCompleted && data['token'] != null) {
'channel': channelTypeMapping[data['platform']], final Map<String, dynamic> channel2Token = <String, dynamic>{
'channelToken': data['token'] 'channel': channelTypeMapping[data['platform']],
}; 'channelToken': data['token']
await Storage.setString( };
vendorPushChannelInfo, jsonEncode(channel2Token)); await Storage.setString(
_vendorTokenCompleter.complete(channel2Token); vendorPushChannelInfo, jsonEncode(channel2Token));
_vendorTokenCompleter.complete(channel2Token);
}
break; break;
} }
}, },