Defective playback of AIFC files on Xamarin.Android
Summary
Frequency and pitch drop randomly on Xamarin/Android apps when playing AIFF-C (IMA4) audio files.
Minimal project and steps to reproduce
- Clone https://github.com/videolan/libvlcsharp.git
- Modify
Samples/LibVLCSharp.Android.Sample/MainActivity.cs
: - Change the URL from
http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
tohttp://unjammit.com/samples/back.aifc
. - Run
LibVLCSharp.Android.Sample
, either on an emulator or a physical device. - Listen to the audio playback.
What is the current bug behavior?
Audio slows down and loses pitch intermittently, regardless of the device being used.
What is the expected correct behavior?
Audio plays correctly and continuously.
NOTES:
- The file is NOT corrupted. The behavior shows consistently with any AIFC/IMA4 audio file.
- For contrast, try playing URL http://unjammit.com/samples/back.m4a . This file was originated from back.aifc, but plays correctly and consistently.
- The does not appear to be a bug in the VLC codecs:
- A Xamarin.Gtk app will successfully play the AIFC files. It's only the Xamarin.Android app that fails.
- This is not exclusive to the LibVLCSharp.Android.Sample app. The problem was discovered while developing Unjammit! (https://play.google.com/store/apps/details?id=com.unjammit.player).
Relevant logs and/or screenshots
Sample file's technical info (obtained from macOS afinfo
command):
File: back.aifc
File type ID: AIFC
Num Tracks: 1
----
Data format: 2 ch, 44100 Hz, 'ima4' (0x00000000) 0 bits/channel, 68 bytes/packet, 64 frames/packet, 0 bytes/frame
no channel layout.
estimated duration: 322.686259 sec
audio bytes: 15119868
audio packets: 222351
bit rate: 374850 bits per second
packet size upper bound: 68
maximum packet size: 68
audio data file offset: 4096
optimized
----
afinfo
for the M4A file (which plays correctly):
File: back.m4a
File type ID: m4af
Num Tracks: 1
----
Data format: 2 ch, 44100 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
no channel layout.
estimated duration: 322.686259 sec
audio bytes: 5244131
audio packets: 13899
bit rate: 129992 bits per second
packet size upper bound: 798
maximum packet size: 798
audio data file offset: 61440
optimized
audio 14230464 valid frames + 2112 priming + 0 remainder = 14232576
format list:
[ 0] format: 2 ch, 44100 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
Channel layout: Stereo (L R)
----
Environment
- OS: Android
- Version 4.4 - 9.0
- Device: Emulator, Rinno R400, Galaxy S6
- LibVLC version and architecture 3.2.0 ARM
- LibVLCSharp version 3.3.1
Possible fixes
None found yet
[Update] For reference, the sample files (and any other AICF files) play correctly in the official VLC app for Android (https://play.google.com/store/apps/details?id=org.videolan.vlc).