Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building flac extension #2352

Closed
PaulWoitaschek opened this issue Jan 20, 2017 · 6 comments
Closed

Building flac extension #2352

PaulWoitaschek opened this issue Jan 20, 2017 · 6 comments
Assignees
Labels

Comments

@PaulWoitaschek
Copy link

I closely followed your instrution on how to build the flac extension but at the last part it fails with missing
libncurses.so.5. How can I build the extension? I'm using the latest ExoPlayer version with an up-to-date Arch Linux

[ph1b@ph1b jni]$ cd "${FLAC_EXT_PATH}"/jni && ${NDK_PATH}/ndk-build APP_ABI=all -j4
[arm64-v8a] Compile++      : flacJNI <= flac_jni.cc
[arm64-v8a] Compile++      : flacJNI <= flac_parser.cc
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
make: *** [/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/arm64-v8a/objs/flacJNI/flac_jni.o] Error 127
make: *** Waiting for unfinished jobs....
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
make: *** [/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/arm64-v8a/objs/flacJNI/flac_parser.o] Error 127

@PaulWoitaschek
Copy link
Author

Apparently it is because exoplayer (or flac?) is using an outdated verison of libncurses.
I managed to fix that by installing ncurses5-compat-libs from the AUR repostiory.

Now it fails with an even more cryptic error. It would be so great if you could just upload the dependencies to maven.

[/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/armeabi-v7a/libflacJNI.so] Error 1
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/mips64/objs/flacJNI/flac/src/libFLAC/stream_decoder.o: In function `read_residual_partitioned_rice_':
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_decoder.c:2752: undefined reference to `flac_max'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/mips64/objs/flacJNI/flac/src/libFLAC/stream_encoder.o: In function `init_stream_internal_':
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:684: undefined reference to `flac_max'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:873: undefined reference to `flac_max'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/mips64/objs/flacJNI/flac/src/libFLAC/stream_encoder.o: In function `process_subframes_':
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:3102: undefined reference to `flac_min'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:3104: undefined reference to `flac_min'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/mips64/objs/flacJNI/flac/src/libFLAC/stream_encoder.o: In function `update_metadata_':
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:2686: undefined reference to `flac_max'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/mips64/objs/flacJNI/flac/src/libFLAC/stream_encoder.o: In function `FLAC__stream_encoder_process':
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:2137: undefined reference to `flac_min'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/mips64/objs/flacJNI/flac/src/libFLAC/stream_encoder.o: In function `FLAC__stream_encoder_process_interleaved':
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:2200: undefined reference to `flac_min'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:2235: undefined reference to `flac_min'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/mips64/objs/flacJNI/flac/src/libFLAC/stream_encoder.o: In function `write_frame_':
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:2675: undefined reference to `flac_max'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/mips64/objs/flacJNI/flac/src/libFLAC/stream_encoder.o: In function `write_bitbuffer_':
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:2583: undefined reference to `flac_min'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:2584: undefined reference to `flac_max'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/mips64/objs/flacJNI/flac/src/libFLAC/stream_encoder.o: In function `find_best_partition_order_':
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:3857: undefined reference to `flac_min'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/mips64/objs/flacJNI/flac/src/libFLAC/stream_encoder.o: In function `precompute_partition_info_escapes_':
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:4043: undefined reference to `flac_max'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/mips64/objs/flacJNI/flac/src/libFLAC/stream_encoder.o: In function `set_partitioned_rice_':
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:4121: undefined reference to `flac_max'
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/mips64/objs/flacJNI/flac/src/libFLAC/stream_encoder.o: In function `find_best_partition_order_':
/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/stream_encoder.c:3911: undefined reference to `flac_max'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/home/ph1b/Dev/ExoPlayer/extensions/flac/src/main/obj/local/mips64/libflacJNI.so] Error 1

@AndreiGorelov
Copy link

AndreiGorelov commented Feb 2, 2017

I had the same problem. There are 2 ways:

  1. Use an older version of the Android NDK with GCC compiler, instead of Clang.
  2. Find macros.h file (....extensions/flac/src/main/jni/flac/src/libFLAC/include/private/)and comment out two lines of code:

But, unfortunately, this extension does not work properly on all devices (on the Sony Xperia XA I hear something like white noise. On Samsung - OK).

@PaulWoitaschek
Copy link
Author

PaulWoitaschek commented Feb 5, 2017

What I dont get is that android supports flac itself.

There is even the MediaCodecAudioRenderer in ExoPlayer; why can't ExoPlayer just play flac if it's supported by the platform?

@erdemguven
Copy link
Contributor

There is a fix on the way which adds "-DHAVE_SYS_PARAM_H" to LOCAL_CFLAGS in extensions/flac/src/main/jni/Android.mk file.Until it arrives to github repository you can try to add it to your local copy manually.

@PaulWoitaschek, because of issues with FLAC format and the way android platform handles it we can't use native support.

@ojw28
Copy link
Contributor

ojw28 commented Feb 13, 2017

Right. Android doesn't currently expose a FLAC decoder through MediaCodec by default (individual OEMs may choose to add one). It instead extracts+decodes FLAC to PCM as a single step under MediaExtractor, which ExoPlayer doesn't use. It's the only format for which this unusual setup is used in the platform, as far as I know :(.

The "proper" fix would be for the platform to expose a FLAC decoder through MediaCodec in the same way as decoders are exposed for other format types. If anyone's sufficiently motivated, you could perhaps propose such a change via AOSP.

@ojw28 ojw28 added the bug label Feb 13, 2017
ojw28 pushed a commit that referenced this issue Feb 15, 2017
Issue: #2352

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=146469547
@ojw28 ojw28 closed this as completed Feb 15, 2017
@mirandole
Copy link

mirandole commented Jun 15, 2017

Hi !

Did you find an alternate way to play flac on devices that get white noise when playing a flac track ?

I have a device that play flac track but it's just white noise and I don't know how to detect if the device will play nicely flac file or if it won't.

I know that there is Vanilla Player on GIT that play flac nicely. Unfortunately, it's an GPL licence project, not an Apache2 one.


edit :

This code solve my issue with this device :

@Override public MediaCodecInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder) throws MediaCodecUtil.DecoderQueryException { if (mimeType.equals("audio/raw")) { return MediaCodecInfo.newInstance("OMX.google.raw.decoder", "audio/raw", null); } return MediaCodecUtil.getDecoderInfo(mimeType, requiresSecureDecoder); }

Source : #2873

Thank you

@google google locked and limited conversation to collaborators Jun 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants