Fixed #2153 FLA Export - sound streams were limited to first stream block

This commit is contained in:
Jindra Petřík
2023-12-30 18:06:08 +01:00
parent 01ac222331
commit 18c02a48a5
4 changed files with 25 additions and 11 deletions
@@ -149,6 +149,9 @@ public class SoundStreamHead2Tag extends SoundStreamHeadTypeTag {
@Override
public SoundExportFormat getExportFormat() {
if (streamSoundCompression == SoundFormat.FORMAT_MP3) {
if (getInitialLatency() > 0) {
return SoundExportFormat.WAV;
}
return SoundExportFormat.MP3;
}
if (streamSoundCompression == SoundFormat.FORMAT_ADPCM) {
@@ -293,6 +296,6 @@ public class SoundStreamHead2Tag extends SoundStreamHeadTypeTag {
@Override
public int getInitialLatency() {
return 0;
return latencySeek;
}
}
@@ -147,8 +147,11 @@ public class SoundStreamHeadTag extends SoundStreamHeadTypeTag {
}
@Override
public SoundExportFormat getExportFormat() {
public SoundExportFormat getExportFormat() {
if (streamSoundCompression == SoundFormat.FORMAT_MP3) {
if (getInitialLatency() > 0) {
return SoundExportFormat.WAV;
}
return SoundExportFormat.MP3;
}
if (streamSoundCompression == SoundFormat.FORMAT_ADPCM) {
@@ -302,6 +305,6 @@ public class SoundStreamHeadTag extends SoundStreamHeadTypeTag {
@Override
public int getInitialLatency() {
return 0;
return latencySeek;
}
}
@@ -1977,7 +1977,7 @@ public class XFLConverter {
soundRate = head.getSoundRate();
soundType = head.getSoundType();
soundSize = head.getSoundSize();
soundSampleCount = head.getSoundSampleCount();
soundSampleCount = 0; //head.getSoundSampleCount();
boolean found = false;
for (Tag t : tags) {
if (found && (t instanceof SoundStreamBlockTag)) {
@@ -2105,16 +2105,22 @@ public class XFLConverter {
logger.log(Level.SEVERE, null, ex);
}
byte[] decodedData = null;
try {
decodedData = st.getSoundFormat().decode(null, st.getRawSoundData(), seekSamples);
if (soundSampleCount == 0) {
soundSampleCount = decodedData.length / (2 * (st.getSoundType() ? 2 : 1));
}
} catch (IOException ex) {
logger.log(Level.SEVERE, null, ex);
}
String datFileName = null;
if (seekSamples > 0) {
if (seekSamples > 0 && decodedData != null) {
long ts = getTimestamp(swf);
datFileName = "M " + (datfiles.size() + 1) + " " + ts + ".dat";
try {
byte[] decodedData = st.getSoundFormat().decode(null, st.getRawSoundData(), seekSamples);
datfiles.put(datFileName, decodedData);
} catch (IOException ex) {
logger.log(Level.SEVERE, null, ex);
}
datfiles.put(datFileName, decodedData);
}
String symbolFile = symbol.getFlaExportName() + "." + exportFormat;