diff --git a/app/src/main/java/com/dimowner/audiorecorder/app/DownloadService.java b/app/src/main/java/com/dimowner/audiorecorder/app/DownloadService.java index 75a09c44..177e426f 100644 --- a/app/src/main/java/com/dimowner/audiorecorder/app/DownloadService.java +++ b/app/src/main/java/com/dimowner/audiorecorder/app/DownloadService.java @@ -125,9 +125,13 @@ public int onStartCommand(Intent intent, int flags, int startId) { } public void startDownload(String name, String path) { - recordName = name; - copyFile(name, path); - startNotification(); + if (name == null || path == null) { + stopService(); + } else { + recordName = name; + copyFile(name, path); + startNotification(); + } } private void copyFile(final String name, final String path) { diff --git a/app/src/main/java/com/dimowner/audiorecorder/app/main/MainPresenter.java b/app/src/main/java/com/dimowner/audiorecorder/app/main/MainPresenter.java index f3bc6a36..9b70bb7b 100644 --- a/app/src/main/java/com/dimowner/audiorecorder/app/main/MainPresenter.java +++ b/app/src/main/java/com/dimowner/audiorecorder/app/main/MainPresenter.java @@ -596,6 +596,10 @@ public void run() { public void run() { if (view != null) { view.hideProgress(); + view.showWaveForm(new int[]{}, 0); + view.showName(""); + view.showDuration(TimeUtils.formatTimeIntervalHourMinSec2(0)); + view.hideOptionsMenu(); } } }); @@ -689,6 +693,7 @@ public void run() { view.showMessage(R.string.record_moved_into_trash); } view.hideOptionsMenu(); + view.onPlayProgress(0, 0, 0); view.hideProgress(); record = null; } @@ -783,6 +788,7 @@ public void run() { view.showDuration(TimeUtils.formatTimeIntervalHourMinSec2(songDuration / 1000)); view.hideProgress(); view.hideImportProgress(); + view.showOptionsMenu(); } } }); diff --git a/app/src/main/java/com/dimowner/audiorecorder/audio/AudioDecoder.java b/app/src/main/java/com/dimowner/audiorecorder/audio/AudioDecoder.java index 91a1b055..b421f000 100644 --- a/app/src/main/java/com/dimowner/audiorecorder/audio/AudioDecoder.java +++ b/app/src/main/java/com/dimowner/audiorecorder/audio/AudioDecoder.java @@ -49,7 +49,7 @@ public class AudioDecoder { private int frameIndex = 0; private long duration; - private static final String[] SUPPORTED_EXT = new String[]{"mp3", "wav", "3gpp", "3gp", "amr", "aac", "m4a", "mp4", "ogg"}; + private static final String[] SUPPORTED_EXT = new String[]{"mp3", "wav", "3gpp", "3gp", "amr", "aac", "m4a", "mp4", "ogg", "flac"}; private IntArrayList gains; @@ -125,6 +125,7 @@ private void decodeFile(@NonNull final File mInputFile, @NonNull final DecodeLis decoder.setCallback(new MediaCodec.Callback() { private boolean mOutputEOS = false; + private boolean mInputEOS = false; @Override public void onError(@NonNull MediaCodec codec, @NonNull MediaCodec.CodecException exception) { @@ -147,7 +148,7 @@ public void onOutputFormatChanged(@NonNull MediaCodec codec, @NonNull MediaForma @Override public void onInputBufferAvailable(@NonNull MediaCodec codec, int index) { - if (mOutputEOS) return; + if (mOutputEOS | mInputEOS) return; try { ByteBuffer inputBuffer; inputBuffer = codec.getInputBuffer(index); @@ -166,11 +167,12 @@ public void onInputBufferAvailable(@NonNull MediaCodec codec, int index) { advanced = extractor.advance(); maxresult = Math.max(maxresult, result); } - } while (result >= 0 && advanced && inputBuffer.capacity() - inputBuffer.limit() > maxresult*3);//3 it is just for insurance. When remove it crash happens. it is ok if replace it by 2 number. + } while (result >= 0 && total < maxresult * 5 && advanced && inputBuffer.capacity() - inputBuffer.limit() > maxresult*3);//3 it is just for insurance. When remove it crash happens. it is ok if replace it by 2 number. if (advanced) { codec.queueInputBuffer(index, 0, total, sampleTime, 0); } else { codec.queueInputBuffer(index, 0, 0, -1, MediaCodec.BUFFER_FLAG_END_OF_STREAM); + mInputEOS = true; } } else { //If QUEUE_INPUT_BUFFER_EFFECTIVE failed then trying this way. @@ -181,12 +183,11 @@ public void onInputBufferAvailable(@NonNull MediaCodec codec, int index) { extractor.advance(); } else { codec.queueInputBuffer(index, 0, 0, -1, MediaCodec.BUFFER_FLAG_END_OF_STREAM); + mInputEOS = true; } } } catch (IllegalStateException | IllegalArgumentException e) { Timber.e(e); - //When crash happens decoding failed. Then just finish decoding by sending END of stream flag. - codec.queueInputBuffer(index, 0, 0, -1, MediaCodec.BUFFER_FLAG_END_OF_STREAM); } } diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 22a249b2..d5cfb5cd 100644 Binary files a/app/src/main/res/values-bg/strings.xml and b/app/src/main/res/values-bg/strings.xml differ diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 4c901f6d..7ea21b70 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -48,7 +48,7 @@ Открыть с помощью̷ Скачать Скачивание: %s - %s скачано в паку Downloads + %s скачано в паку Download Ошибка при скачивания: %s Скачивание отменено Поделиться diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index d1bfb719..25a446a3 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -48,7 +48,7 @@ Відкрити з допомогою̷ Скачати Скачування: %s - %s скачано папку Downloads + %s скачано папку Download Помилка при скачувані: %s Скачування відмінено Поділитися diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 53634baf..5475469d 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -48,7 +48,7 @@ Open with̷ Download Downloading: %s - %s downloaded to the Downloads directory + %s downloaded to the Download directory Failed to download: %s Downloading canceled Share