Skip to content

Commit

Permalink
Fix FLAC support
Browse files Browse the repository at this point in the history
  • Loading branch information
loafofpiecrust committed Jan 2, 2019
1 parent 43c9d35 commit 719bf51
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "exoplayer-flac/src/main/jni/flac"]
path = exoplayer-flac/src/main/jni/flac
url = https://github.com/xiph/flac
Expand Up @@ -225,7 +225,7 @@ object MusicBrainz: Repository {

// )
} catch (e: Exception) {
error { e.message }
Timber.e(e)
null
}
}.filterNotNull()
Expand Down Expand Up @@ -418,7 +418,7 @@ object MusicBrainz: Repository {
} else null
} else null
} catch (e: Exception) {
error { e.stackTrace }
Timber.e(e)
null
}

Expand Down
11 changes: 9 additions & 2 deletions exoplayer-flac/build.gradle
Expand Up @@ -22,16 +22,23 @@ android {
minSdkVersion 22
targetSdkVersion 28
consumerProguardFiles 'proguard-rules.txt'

}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

externalNativeBuild {
ndkBuild {
path "src/main/jni/Android.mk"
}
}

sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] // Disable the automatic ndk-build call by Android Studio.
// jniLibs.srcDir 'src/main/libs'
jni.srcDirs = ["src/main/jni"] // Disable the automatic ndk-build call by Android Studio.
}
}

Expand Down
1 change: 0 additions & 1 deletion exoplayer-flac/src/main/jni/.gitignore
@@ -1,2 +1 @@
flac/
flac*.tar.xz
4 changes: 2 additions & 2 deletions exoplayer-flac/src/main/jni/Application.mk
Expand Up @@ -15,6 +15,6 @@
#

APP_OPTIM := release
APP_STL := gnustl_static
APP_STL := c++_static
APP_CPPFLAGS := -frtti
APP_PLATFORM := android-14
APP_PLATFORM := android-16
1 change: 1 addition & 0 deletions exoplayer-flac/src/main/jni/flac
Submodule flac added at ac39d3
17 changes: 17 additions & 0 deletions exoplayer-flac/src/test/AndroidManifest.xml
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<manifest package="com.google.android.exoplayer2.ext.flac"/>
@@ -0,0 +1,74 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.ext.flac;

import static com.google.common.truth.Truth.assertThat;

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
import com.google.android.exoplayer2.extractor.Extractor;
import com.google.android.exoplayer2.extractor.amr.AmrExtractor;
import com.google.android.exoplayer2.extractor.flv.FlvExtractor;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
import com.google.android.exoplayer2.extractor.mp3.Mp3Extractor;
import com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor;
import com.google.android.exoplayer2.extractor.mp4.Mp4Extractor;
import com.google.android.exoplayer2.extractor.ogg.OggExtractor;
import com.google.android.exoplayer2.extractor.ts.Ac3Extractor;
import com.google.android.exoplayer2.extractor.ts.AdtsExtractor;
import com.google.android.exoplayer2.extractor.ts.PsExtractor;
import com.google.android.exoplayer2.extractor.ts.TsExtractor;
import com.google.android.exoplayer2.extractor.wav.WavExtractor;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;

/** Unit test for {@link DefaultExtractorsFactory}. */
@RunWith(RobolectricTestRunner.class)
public final class DefaultExtractorsFactoryTest {

@Test
public void testCreateExtractors_returnExpectedClasses() {
DefaultExtractorsFactory defaultExtractorsFactory = new DefaultExtractorsFactory();

Extractor[] extractors = defaultExtractorsFactory.createExtractors();
List<Class<?>> listCreatedExtractorClasses = new ArrayList<>();
for (Extractor extractor : extractors) {
listCreatedExtractorClasses.add(extractor.getClass());
}

Class<?>[] expectedExtractorClassses =
new Class<?>[] {
MatroskaExtractor.class,
FragmentedMp4Extractor.class,
Mp4Extractor.class,
Mp3Extractor.class,
AdtsExtractor.class,
Ac3Extractor.class,
TsExtractor.class,
FlvExtractor.class,
OggExtractor.class,
PsExtractor.class,
WavExtractor.class,
AmrExtractor.class,
FlacExtractor.class
};

assertThat(listCreatedExtractorClasses).containsNoDuplicates();
assertThat(listCreatedExtractorClasses).containsExactlyElementsIn(expectedExtractorClassses);
}
}
1 change: 1 addition & 0 deletions exoplayer-flac/src/test/resources/robolectric.properties
@@ -0,0 +1 @@
manifest=src/test/AndroidManifest.xml

0 comments on commit 719bf51

Please sign in to comment.