Merge remote-tracking branch 'origin/develop_liyi' into develop_liyi
This commit is contained in:
commit
567b85f03d
@ -676,8 +676,8 @@ class TalkViewLogic extends BaseGetXController {
|
||||
// }
|
||||
|
||||
List<int> adjustVolume(List<int> pcmList, double volume) {
|
||||
final List<int> adjustedPcmList = [];
|
||||
for (int pcmVal in pcmList) {
|
||||
final List<int> adjustedPcmList = <int>[];
|
||||
for (final int pcmVal in pcmList) {
|
||||
// 调整音量
|
||||
int adjustedPcmVal = (pcmVal * volume).round();
|
||||
|
||||
@ -698,8 +698,8 @@ class TalkViewLogic extends BaseGetXController {
|
||||
final List<int> adjustedPcmList = adjustVolume(pcmList, 5.0);
|
||||
|
||||
// 再进行 A-law 编码
|
||||
final List<int> aLawList = [];
|
||||
for (int pcmVal in adjustedPcmList) {
|
||||
final List<int> aLawList = <int>[];
|
||||
for (final int pcmVal in adjustedPcmList) {
|
||||
final int aLawVal = linearToALaw(pcmVal);
|
||||
aLawList.add(aLawVal);
|
||||
}
|
||||
@ -707,8 +707,8 @@ class TalkViewLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
int linearToALaw(int pcmVal) {
|
||||
const int ALAW_MAX = 0x7FFF; // 32767
|
||||
const int ALAW_BIAS = 0x84; // 132
|
||||
const int alawMax = 0x7FFF; // 32767
|
||||
const int alawBias = 0x84; // 132
|
||||
|
||||
int mask;
|
||||
int seg;
|
||||
@ -723,9 +723,9 @@ class TalkViewLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// Add bias and clamp to ALAW_MAX
|
||||
pcmVal += ALAW_BIAS;
|
||||
if (pcmVal > ALAW_MAX) {
|
||||
pcmVal = ALAW_MAX;
|
||||
pcmVal += alawBias;
|
||||
if (pcmVal > alawMax) {
|
||||
pcmVal = alawMax;
|
||||
}
|
||||
|
||||
// Determine segment
|
||||
@ -735,7 +735,7 @@ class TalkViewLogic extends BaseGetXController {
|
||||
if (seg >= 8) {
|
||||
aLawVal = 0x7F ^ mask; // Clamp to maximum value
|
||||
} else {
|
||||
int quantized = (pcmVal >> (seg + 3)) & 0xF;
|
||||
final int quantized = (pcmVal >> (seg + 3)) & 0xF;
|
||||
aLawVal = (seg << 4) | quantized;
|
||||
aLawVal ^= 0xD5; // XOR with 0xD5 to match standard A-law table
|
||||
}
|
||||
@ -744,7 +744,7 @@ class TalkViewLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
int search(int val) {
|
||||
final List<int> table = [
|
||||
final List<int> table = <int>[
|
||||
0xFF, // Segment 0
|
||||
0x1FF, // Segment 1
|
||||
0x3FF, // Segment 2
|
||||
|
||||
@ -83,12 +83,16 @@ class XSJPushProvider {
|
||||
final int cmdCode = data['cmd'];
|
||||
switch (cmdCode) {
|
||||
case CMD_GET_REGISTRATION_ID:
|
||||
await Storage.setString(pushDeviceID, data['message']);
|
||||
AppLog.log('flutter get registration id : ${data['message']}');
|
||||
_jpushRegistrationIdCompleter.complete(<String, dynamic>{
|
||||
'channel': 'jiguang',
|
||||
'channelToken': data['message']
|
||||
});
|
||||
if (!_jpushRegistrationIdCompleter.isCompleted &&
|
||||
data['message'] != null) {
|
||||
await Storage.setString(pushDeviceID, data['message']);
|
||||
AppLog.log('flutter get registration id : ${data['message']}');
|
||||
_jpushRegistrationIdCompleter.complete(<String, dynamic>{
|
||||
'channel': 'jiguang',
|
||||
'channelToken': data['message']
|
||||
});
|
||||
}
|
||||
|
||||
// final String? channel2TokenStr =
|
||||
// await Storage.getString(vendorPushChannelInfo);
|
||||
// if (Platform.isAndroid && channel2TokenStr != null) {
|
||||
@ -96,13 +100,15 @@ class XSJPushProvider {
|
||||
// }
|
||||
break;
|
||||
case CMD_GET_TOKEN:
|
||||
final Map<String, dynamic> channel2Token = <String, dynamic>{
|
||||
'channel': channelTypeMapping[data['platform']],
|
||||
'channelToken': data['token']
|
||||
};
|
||||
await Storage.setString(
|
||||
vendorPushChannelInfo, jsonEncode(channel2Token));
|
||||
_vendorTokenCompleter.complete(channel2Token);
|
||||
if (!_vendorTokenCompleter.isCompleted && data['token'] != null) {
|
||||
final Map<String, dynamic> channel2Token = <String, dynamic>{
|
||||
'channel': channelTypeMapping[data['platform']],
|
||||
'channelToken': data['token']
|
||||
};
|
||||
await Storage.setString(
|
||||
vendorPushChannelInfo, jsonEncode(channel2Token));
|
||||
_vendorTokenCompleter.complete(channel2Token);
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user