Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

Commit ef1e3f5

Browse files
committed
Merge pull request #11 from n8fr8/master
fixes for sox and ffmpeg
2 parents dfe7215 + 7afe5dd commit ef1e3f5

File tree

4 files changed

+201
-69
lines changed

4 files changed

+201
-69
lines changed

src/net/sourceforge/sox/CrossfadeCat.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.sourceforge.sox;
22

33
import java.io.File;
4+
import java.io.IOException;
45
import java.util.ArrayList;
56

67
import android.util.Log;
@@ -36,7 +37,7 @@ public CrossfadeCat(SoxController controller, String firstFile, String secondFil
3637
mFinalMix = outFile;
3738
}
3839

39-
public boolean start() {
40+
public boolean start() throws IOException {
4041
// find length of first file
4142
double length = mController.getLength(mFirstFile);
4243

@@ -73,7 +74,7 @@ public boolean start() {
7374
files.add(fadedOne);
7475
files.add(fadedTwo);
7576

76-
String crossfaded = new File(mFirstFile).getAbsolutePath() + "-x-" + new File(mSecondFile).getName() +".wav";
77+
String crossfaded = new File(mFirstFile).getCanonicalPath() + "-x-" + new File(mSecondFile).getName() +".wav";
7778
crossfaded = mController.combineMix(files, crossfaded);
7879
if( crossfaded == null )
7980
return abort();

src/net/sourceforge/sox/SoxController.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
import java.io.InputStream;
88
import java.io.InputStreamReader;
99
import java.text.DecimalFormat;
10+
import java.text.DecimalFormatSymbols;
1011
import java.util.ArrayList;
1112
import java.util.Arrays;
1213
import java.util.List;
14+
import java.util.Locale;
1315

1416
import org.ffmpeg.android.BinaryInstaller;
1517
import org.ffmpeg.android.ShellUtils.ShellCallback;
@@ -34,7 +36,7 @@ public SoxController(Context _context) throws FileNotFoundException, IOException
3436
bi.installFromRaw();
3537
}
3638

37-
soxBin = new File(fileBinDir,"sox").getAbsolutePath();
39+
soxBin = new File(fileBinDir,"sox").getCanonicalPath();
3840

3941
}
4042

@@ -112,11 +114,11 @@ public double getLength(String path) {
112114
* @param length (optional)
113115
* @return path to trimmed audio
114116
*/
115-
public String trimAudio(String path, String start, String length) {
117+
public String trimAudio(String path, String start, String length) throws IOException {
116118
ArrayList<String> cmd = new ArrayList<String>();
117119

118120
File file = new File(path);
119-
String outFile = file.getAbsolutePath() + "_trimmed.wav";
121+
String outFile = file.getCanonicalPath() + "_trimmed.wav";
120122
cmd.add(soxBin);
121123
cmd.add(path);
122124
cmd.add("-e");
@@ -156,7 +158,7 @@ public String trimAudio(String path, String start, String length) {
156158
* @param fadeOutLength (optional)
157159
* @return
158160
*/
159-
public String fadeAudio(String path, String type, String fadeInLength, String stopTime, String fadeOutLength ) {
161+
public String fadeAudio(String path, String type, String fadeInLength, String stopTime, String fadeOutLength ) throws IOException {
160162

161163
final List<String> curves = Arrays.asList( new String[]{ "q", "h", "t", "l", "p"} );
162164

@@ -166,7 +168,7 @@ public String fadeAudio(String path, String type, String fadeInLength, String st
166168
}
167169

168170
File file = new File(path);
169-
String outFile = file.getAbsolutePath() + "_faded.wav";
171+
String outFile = file.getCanonicalPath() + "_faded.wav";
170172

171173
ArrayList<String> cmd = new ArrayList<String>();
172174
cmd.add(soxBin);
@@ -269,14 +271,16 @@ public String combine(List<String> files, String outFile) {
269271
* @param seconds
270272
*/
271273
public String formatTimePeriod(double seconds) {
272-
String seconds_frac = new DecimalFormat("#.##").format(seconds);
273-
return String.format("0:0:%s", seconds_frac);
274+
DecimalFormat df = new DecimalFormat("#.##");
275+
df.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));
276+
String seconds_frac = df.format(seconds);
277+
return String.format(Locale.US, "0:0:%s", seconds_frac);
274278
}
275279

276-
private int execSox(List<String> cmd, ShellCallback sc) throws IOException,
280+
public int execSox(List<String> cmd, ShellCallback sc) throws IOException,
277281
InterruptedException {
278282

279-
String soxBin = new File(fileBinDir, "sox").getAbsolutePath();
283+
String soxBin = new File(fileBinDir, "sox").getCanonicalPath();
280284
Runtime.getRuntime().exec("chmod 700 " + soxBin);
281285
return execProcess(cmd, sc);
282286
}

src/org/ffmpeg/android/BinaryInstaller.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private static boolean streamToFile(InputStream stm, File outFile, boolean appen
105105
stmOut.close();
106106
stm.close();
107107

108-
Runtime.getRuntime().exec("chmod "+mode+" "+outFile.getAbsolutePath());
108+
Runtime.getRuntime().exec("chmod "+mode+" "+outFile.getCanonicalPath());
109109

110110

111111
return true;
@@ -184,7 +184,7 @@ private static boolean isARMv6() {
184184
*/
185185
private static void copyRawFile(Context ctx, int resid, File file, String mode, boolean isZipd) throws IOException, InterruptedException
186186
{
187-
final String abspath = file.getAbsolutePath();
187+
final String abspath = file.getCanonicalPath();
188188
// Write the iptables binary
189189
final FileOutputStream out = new FileOutputStream(file);
190190
InputStream is = ctx.getResources().openRawResource(resid);

0 commit comments

Comments
 (0)