mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-18 09:58:14 +00:00
Added #1917 Better error message for sound import on unsupported sampling rate
This commit is contained in:
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.SoundTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.UnsupportedSamplingRateException;
|
||||
import com.jpexs.decompiler.flash.types.BasicType;
|
||||
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
|
||||
import com.jpexs.decompiler.flash.types.annotations.SWFType;
|
||||
@@ -213,7 +214,7 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setSound(InputStream is, int newSoundFormat) {
|
||||
public boolean setSound(InputStream is, int newSoundFormat) throws UnsupportedSamplingRateException {
|
||||
int newSoundRate = -1;
|
||||
boolean newSoundSize = false;
|
||||
boolean newSoundType = false;
|
||||
@@ -242,7 +243,7 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
|
||||
newSoundRate = 3;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
throw new UnsupportedSamplingRateException(newSoundRate, new int[]{5512,11025,22050,44100});
|
||||
}
|
||||
} catch (UnsupportedAudioFileException | IOException ex) {
|
||||
return false;
|
||||
@@ -284,7 +285,7 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
|
||||
newSoundRate = 3;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
throw new UnsupportedSamplingRateException(newSoundRate, new int[]{11025,22050,44100});
|
||||
}
|
||||
|
||||
newSoundSize = true;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2022 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class SoundImportException extends Exception {
|
||||
|
||||
public SoundImportException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public interface SoundTag extends TreeItem {
|
||||
|
||||
public boolean importSupported();
|
||||
|
||||
public boolean setSound(InputStream is, int newSoundFormat);
|
||||
public boolean setSound(InputStream is, int newSoundFormat) throws SoundImportException;
|
||||
|
||||
public int getSoundRate();
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2022 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class UnsupportedSamplingRateException extends SoundImportException {
|
||||
private final int soundRate;
|
||||
private final int[] supportedRates;
|
||||
|
||||
public UnsupportedSamplingRateException(int soundRate, int[] supportedRates) {
|
||||
super("Unsupported sound rate: " + soundRate);
|
||||
this.soundRate = soundRate;
|
||||
this.supportedRates = supportedRates;
|
||||
}
|
||||
|
||||
public int[] getSupportedRates() {
|
||||
return supportedRates;
|
||||
}
|
||||
|
||||
public int getSoundRate() {
|
||||
return soundRate;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user