[DEV-only][WIP] ALSA BCM21553 Audio libs built from source - BroadcomCM

Search This thread

bieltv3

Senior Member
Jun 12, 2012
1,299
9,879
Barcelona
I've created this thread to join developers into the final audio fix for android 2.3.7. Although the prupose of this thread is to fix Audio on Android 4.0.4 we first need audio drivers source.
On all our based Android 2.3.7 ROMs we fixed audio using some AOSP Alcatel .so files (to remove Samsung lib dependency) and some Samsung .so libraries too, this is the whole list:

# Samsung audio libs
  • acoustics.default.so
  • alsa.default.so
  • libaudiopolicy.so

# Alcatel audio libs
  • libaudio.so
  • libaudioflinger.so
  • libaudioeffect_jni.so
  • libmediaplayerservice.so
Our device uses ALSA audio system, which is also used on stock ROM. This is related to software more than hardware, although we are not planning at the momnt to "change" this audio way. To activate ALSA audio some changes need to be done on kernel, that samsung provide to us on their kernel sources. Mostly we need to enable ALSA on device .config file:

Code:
CONFIG_BRCM_SOUND_ALSA=y
CONFIG_BRCM_SOUND_ATHENA_ALSA=y

That's not an issue as prebuilt alsa libs work, so new libs should work too. Ramdisk needs some edit too, as ALSA audio system is stored on dev/snd, and this is well defined too on our ramdisk, ueventd.rc

Code:
/dev/snd/*                0660   system     audio

We realised after that that actually CyanogenMod 7.2 Sources include ALSA lib sources, what we didn't know if those sources could work with our devices. This sources build the following libs, as releated to its Android.mk files:

We can found inside hardware/sound_alsa the following sources to build
  • libaudio
  • libaudioflinguer
  • hw/alsa.default
  • hw/acoustics.default

On external/alsa-lib we can found the sources of anoher lib
  • libasound

And apart from that, some other audio libs such as libaudiopolicy are built inside framework/base repository, but they doesn't make any conflict. Other libs are included on Android source files.

To enable the build of those libs, using ALSA software instead af "Android default (not sure about that)". I've enabled on Boardconfig.mk the following configs:

Code:
# Audio
BOARD_USES_GENERIC_AUDIO := false
BOARD_USES_ALSA_AUDIO := true
BOARD_PREBUILT_LIBAUDIO := false # even not writted. 
BUILD_WITH_ALSA_UTILS := true

This configs enable the building of those libs on their Android.mk files.

Also, I've added on device_cooperve.mk the following lines to build those hw modules releated to audio:
Code:
# Audio
PRODUCT_PACKAGES += \
    alsa.default \
    acoustics.default

After the build finished, and fixed some errors, AUDIO WAS WORKING, but not as expected. There were issues on Audio Routing:
  • Headphones are detected through system, but audio is not reproduced on headphones (speakers does)
  • When you make a call, sometimes you can't and phone freezes, or when you hangout the call, phone freezes.
Everything else apart from that seems to be working, even microphone, although this bugs are pretty weird, I took a look to logcat.

Code:
[COLOR="Gray"]D/AndroidRuntime( 1419): CheckJNI is OFF
I/        ( 1420): ServiceManager: 0xad50[/COLOR]
[COLOR="Red"]E/ALSALib ( 1420): external/alsa-lib/src/control/control.c:882:(snd_ctl_open_noupdate) Invalid CTL AndroidOut[/COLOR]
W/AudioHardwareALSA( 1420): Unable to attach mixer to device AndroidOut: No such file or directory
[COLOR="Red"]E/ALSALib ( 1420): external/alsa-lib/src/control/control.c:882:(snd_ctl_open_noupdate) Invalid CTL AndroidIn[/COLOR]
W/AudioHardwareALSA( 1420): Unable to attach mixer to device AndroidIn: No such file or directory
D/AudioHardwareALSA( 1420): openOutputStream called for devices: 0x00000002
D/ALSAModule( 1420): open called for devices 00000002 in mode 0...
I/ALSAModule( 1420): Initialized ALSA PLAYBACK device AndroidPlayback_Speaker_normal
I/AudioHardwareALSA( 1420): buffer size (bytes) to AF = 16384
D/AudioFlinger( 1420): setParameters(): io 1, keyvalue routing=2, tid 1593, calling tid 1420
I/AudioFlinger( 1420): AudioFlinger's thread 0x1d978 ready to run
D/ALSAModule( 1420): route called for devices 00000002 in mode 0...

I managed to fix those errors (E/) by moddifying asound.conf, found on system/etc, adding this lines on the top and deleting old ones:

Code:
ctl.AndroidOut {
        type hw
        card 0 # Can replace with drivers name from /proc/asound/cards
}

ctl.AndroidIn {
        type hw
        card 0
}

Now logcat shows this at the moment

Code:
[COLOR="Gray"]D/AndroidRuntime( 1425): CheckJNI is OFF
I/        ( 1426): ServiceManager: 0xad50[/COLOR]
D/AudioHardwareALSA( 1426): openOutputStream called for devices: 0x00000002
D/ALSAModule( 1426): open called for devices 00000002 in mode 0...
I/ALSAModule( 1426): Initialized ALSA PLAYBACK device AndroidPlayback_Speaker_normal
I/AudioHardwareALSA( 1426): buffer size (bytes) to AF = 16384
D/AudioFlinger( 1426): setParameters(): io 1, keyvalue routing=2, tid 1604, calling tid 1426
I/AudioFlinger( 1426): AudioFlinger's thread 0x1d960 ready to run
D/ALSAModule( 1426): route called for devices 00000002 in mode 0...

Actually that's the actual logcat, using headphones, and sound goes through speakers:

Code:
D/dalvikvm( 1926): GC_EXTERNAL_ALLOC freed 324K, 49% free 3317K/6471K, external 571K/579K, paused 58ms
V/HeadsetObserver( 1607): Headset UEVENT: {SUBSYSTEM=switch, SWITCH_STATE=2, DEVPATH=/devices/virtual/switch/h2w, SEQNUM=1335, ACTION=change, SWITCH_NAME=h2w}
W/Vold    ( 1415): Ignoring unknown switch 'h2w'
V/HeadsetObserver( 1607): Intent.ACTION_HEADSET_PLUG: state: 1 name: h2w mic: 0
I/HeadsetService( 1907): Headset plugged: true
I/Effect-DRC( 2115): Compression factor set to: 1.000000
I/Effect-BassBoost( 2115): New strength: 0
D/SurfaceFlinger( 1607): Layer[1c62e0] [2] non-RGB565 reloads
I/Effect-Equalizer( 2115): Setting band 2 to 0
I/Effect-Equalizer( 2115): Setting band 2 to 1
I/Effect-Equalizer( 2115): Setting band 2 to 2
I/Effect-Equalizer( 2115): Setting band 2 to 3
I/Effect-Equalizer( 2115): Setting band 2 to 4
I/Effect-Equalizer( 2115): Setting loudness correction reference to 100.000000 dB
D/AudioFlinger( 2115): setParameters(): io 1, keyvalue routing=8, tid 2117, calling tid 2115
D/ALSAModule( 2115): route called for devices 00000008 in mode 0...
D/ALSAModule( 2115): open called for devices 00000008 in mode 0...
I/ALSAModule( 2115): Initialized ALSA PLAYBACK device AndroidPlayback
D/dalvikvm( 1926): GC_EXTERNAL_ALLOC freed 323K, 49% free 3327K/6471K, external 571K/579K, paused 44ms

We must take a look if that is kernel relevant or not, as we really need this libs to work, to then start working on CyanogenMod 9.1 / Android 4.0.4 audio. Any suggestions are welcomed, although if they are from newbie or developer, don't want this thread to be spammed as others :p
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 44
    I've created this thread to join developers into the final audio fix for android 2.3.7. Although the prupose of this thread is to fix Audio on Android 4.0.4 we first need audio drivers source.
    On all our based Android 2.3.7 ROMs we fixed audio using some AOSP Alcatel .so files (to remove Samsung lib dependency) and some Samsung .so libraries too, this is the whole list:

    # Samsung audio libs
    • acoustics.default.so
    • alsa.default.so
    • libaudiopolicy.so

    # Alcatel audio libs
    • libaudio.so
    • libaudioflinger.so
    • libaudioeffect_jni.so
    • libmediaplayerservice.so
    Our device uses ALSA audio system, which is also used on stock ROM. This is related to software more than hardware, although we are not planning at the momnt to "change" this audio way. To activate ALSA audio some changes need to be done on kernel, that samsung provide to us on their kernel sources. Mostly we need to enable ALSA on device .config file:

    Code:
    CONFIG_BRCM_SOUND_ALSA=y
    CONFIG_BRCM_SOUND_ATHENA_ALSA=y

    That's not an issue as prebuilt alsa libs work, so new libs should work too. Ramdisk needs some edit too, as ALSA audio system is stored on dev/snd, and this is well defined too on our ramdisk, ueventd.rc

    Code:
    /dev/snd/*                0660   system     audio

    We realised after that that actually CyanogenMod 7.2 Sources include ALSA lib sources, what we didn't know if those sources could work with our devices. This sources build the following libs, as releated to its Android.mk files:

    We can found inside hardware/sound_alsa the following sources to build
    • libaudio
    • libaudioflinguer
    • hw/alsa.default
    • hw/acoustics.default

    On external/alsa-lib we can found the sources of anoher lib
    • libasound

    And apart from that, some other audio libs such as libaudiopolicy are built inside framework/base repository, but they doesn't make any conflict. Other libs are included on Android source files.

    To enable the build of those libs, using ALSA software instead af "Android default (not sure about that)". I've enabled on Boardconfig.mk the following configs:

    Code:
    # Audio
    BOARD_USES_GENERIC_AUDIO := false
    BOARD_USES_ALSA_AUDIO := true
    BOARD_PREBUILT_LIBAUDIO := false # even not writted. 
    BUILD_WITH_ALSA_UTILS := true

    This configs enable the building of those libs on their Android.mk files.

    Also, I've added on device_cooperve.mk the following lines to build those hw modules releated to audio:
    Code:
    # Audio
    PRODUCT_PACKAGES += \
        alsa.default \
        acoustics.default

    After the build finished, and fixed some errors, AUDIO WAS WORKING, but not as expected. There were issues on Audio Routing:
    • Headphones are detected through system, but audio is not reproduced on headphones (speakers does)
    • When you make a call, sometimes you can't and phone freezes, or when you hangout the call, phone freezes.
    Everything else apart from that seems to be working, even microphone, although this bugs are pretty weird, I took a look to logcat.

    Code:
    [COLOR="Gray"]D/AndroidRuntime( 1419): CheckJNI is OFF
    I/        ( 1420): ServiceManager: 0xad50[/COLOR]
    [COLOR="Red"]E/ALSALib ( 1420): external/alsa-lib/src/control/control.c:882:(snd_ctl_open_noupdate) Invalid CTL AndroidOut[/COLOR]
    W/AudioHardwareALSA( 1420): Unable to attach mixer to device AndroidOut: No such file or directory
    [COLOR="Red"]E/ALSALib ( 1420): external/alsa-lib/src/control/control.c:882:(snd_ctl_open_noupdate) Invalid CTL AndroidIn[/COLOR]
    W/AudioHardwareALSA( 1420): Unable to attach mixer to device AndroidIn: No such file or directory
    D/AudioHardwareALSA( 1420): openOutputStream called for devices: 0x00000002
    D/ALSAModule( 1420): open called for devices 00000002 in mode 0...
    I/ALSAModule( 1420): Initialized ALSA PLAYBACK device AndroidPlayback_Speaker_normal
    I/AudioHardwareALSA( 1420): buffer size (bytes) to AF = 16384
    D/AudioFlinger( 1420): setParameters(): io 1, keyvalue routing=2, tid 1593, calling tid 1420
    I/AudioFlinger( 1420): AudioFlinger's thread 0x1d978 ready to run
    D/ALSAModule( 1420): route called for devices 00000002 in mode 0...

    I managed to fix those errors (E/) by moddifying asound.conf, found on system/etc, adding this lines on the top and deleting old ones:

    Code:
    ctl.AndroidOut {
            type hw
            card 0 # Can replace with drivers name from /proc/asound/cards
    }
    
    ctl.AndroidIn {
            type hw
            card 0
    }

    Now logcat shows this at the moment

    Code:
    [COLOR="Gray"]D/AndroidRuntime( 1425): CheckJNI is OFF
    I/        ( 1426): ServiceManager: 0xad50[/COLOR]
    D/AudioHardwareALSA( 1426): openOutputStream called for devices: 0x00000002
    D/ALSAModule( 1426): open called for devices 00000002 in mode 0...
    I/ALSAModule( 1426): Initialized ALSA PLAYBACK device AndroidPlayback_Speaker_normal
    I/AudioHardwareALSA( 1426): buffer size (bytes) to AF = 16384
    D/AudioFlinger( 1426): setParameters(): io 1, keyvalue routing=2, tid 1604, calling tid 1426
    I/AudioFlinger( 1426): AudioFlinger's thread 0x1d960 ready to run
    D/ALSAModule( 1426): route called for devices 00000002 in mode 0...

    Actually that's the actual logcat, using headphones, and sound goes through speakers:

    Code:
    D/dalvikvm( 1926): GC_EXTERNAL_ALLOC freed 324K, 49% free 3317K/6471K, external 571K/579K, paused 58ms
    V/HeadsetObserver( 1607): Headset UEVENT: {SUBSYSTEM=switch, SWITCH_STATE=2, DEVPATH=/devices/virtual/switch/h2w, SEQNUM=1335, ACTION=change, SWITCH_NAME=h2w}
    W/Vold    ( 1415): Ignoring unknown switch 'h2w'
    V/HeadsetObserver( 1607): Intent.ACTION_HEADSET_PLUG: state: 1 name: h2w mic: 0
    I/HeadsetService( 1907): Headset plugged: true
    I/Effect-DRC( 2115): Compression factor set to: 1.000000
    I/Effect-BassBoost( 2115): New strength: 0
    D/SurfaceFlinger( 1607): Layer[1c62e0] [2] non-RGB565 reloads
    I/Effect-Equalizer( 2115): Setting band 2 to 0
    I/Effect-Equalizer( 2115): Setting band 2 to 1
    I/Effect-Equalizer( 2115): Setting band 2 to 2
    I/Effect-Equalizer( 2115): Setting band 2 to 3
    I/Effect-Equalizer( 2115): Setting band 2 to 4
    I/Effect-Equalizer( 2115): Setting loudness correction reference to 100.000000 dB
    D/AudioFlinger( 2115): setParameters(): io 1, keyvalue routing=8, tid 2117, calling tid 2115
    D/ALSAModule( 2115): route called for devices 00000008 in mode 0...
    D/ALSAModule( 2115): open called for devices 00000008 in mode 0...
    I/ALSAModule( 2115): Initialized ALSA PLAYBACK device AndroidPlayback
    D/dalvikvm( 1926): GC_EXTERNAL_ALLOC freed 323K, 49% free 3327K/6471K, external 571K/579K, paused 44ms

    We must take a look if that is kernel relevant or not, as we really need this libs to work, to then start working on CyanogenMod 9.1 / Android 4.0.4 audio. Any suggestions are welcomed, although if they are from newbie or developer, don't want this thread to be spammed as others :p
    27
    Some new discoverment has been made thanks to Nexus S ICS Audio Source. They are not working at the moment, but we are on a good way! I'll keep developing... :3
    27
    Some progress have been made so far on Audio regarind CyanogenMod 9.1! I've initialized Audio Policy and Audio Hardware basing my sources on Nexus S ALSA ICS sources that I discovered as I explain here.
    You can see how it performs on this page of my blog, although not everything is releated to Audio, there is a part releated to pèople that insulted me...

    I will keep developing my best :p
    12
    Why this is helpfull ?

    Currently we based it upon cm7.2 GB
    this is because our device uses to run GB as stock.
    When we figure the sources out and figure out what is part 1 or such we can adapt and try to port to CM9 so in that we can have new libs aswell.

    (W.I.P Post;P )
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone