|
@@ -170,15 +170,17 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
|
|
|
}
|
|
|
|
|
|
private void createHeader(String phone) throws IOException {
|
|
|
- if(Objects.isNull(userSoundInfoMap.get(phone).getAccessFile())){
|
|
|
+ if(!userSoundInfoMap.containsKey(phone)){
|
|
|
return;
|
|
|
}
|
|
|
- RandomAccessFile randomAccessFile = userSoundInfoMap.get(phone).getAccessFile();
|
|
|
- LOGGER.info("音频时长:{}", randomAccessFile.length()/(audioFormat.getFrameSize()*audioFormat.getFrameRate())*1000);
|
|
|
- randomAccessFile.seek(0);
|
|
|
- randomAccessFile.write(WavHeader.getWaveHeader(randomAccessFile.length(), (long) audioFormat.getFrameRate(), audioFormat.getSampleSizeInBits()));
|
|
|
- randomAccessFile.close();
|
|
|
- userSoundInfoMap.get(phone).setAccessFile(null);
|
|
|
+ if(Objects.nonNull(userSoundInfoMap.get(phone).getAccessFile())){
|
|
|
+ RandomAccessFile randomAccessFile = userSoundInfoMap.get(phone).getAccessFile();
|
|
|
+ LOGGER.info("音频时长:{}", randomAccessFile.length()/(audioFormat.getFrameSize()*audioFormat.getFrameRate())*1000);
|
|
|
+ randomAccessFile.seek(0);
|
|
|
+ randomAccessFile.write(WavHeader.getWaveHeader(randomAccessFile.length(), (long) audioFormat.getFrameRate(), audioFormat.getSampleSizeInBits()));
|
|
|
+ randomAccessFile.close();
|
|
|
+ userSoundInfoMap.get(phone).setAccessFile(null);
|
|
|
+ }
|
|
|
LOGGER.info("评分数据:{}", JSON.toJSONString(userSoundInfoMap.get(phone)));
|
|
|
userSoundInfoMap.remove(phone);
|
|
|
}
|