[Spirit FM] mikereidis:
Hi, makes sense to me.

I've never built a ROM and there's plenty about Android audio I don't know, but let's start...

I would like to think you could just grab some existing code for a device that supports the CM FM app, assuming you'd prefer the CM FM app to the stock app. See BT Stack below.

I'd think you'd do best with code for a Broadcom device such as these HTC devices:

Bravo / Desire

Buzz / Wildfire

Glacier / T-Mobile myTouch 4G

Incredible

Leo / Touch

I'm not sure which of these might be closest to the Galaxy 5 hardware.

If I recall correctly, qdsp5v2 (/dev/msm_audio_dev_ctrl) and msm7x30 (/dev/msm_snd) seem to be usable on the same hardware and I'm not sure why one is chosen over the other on some ports. I think qsd8250 (/dev/msm_audio_ctl) is different but I may be mis-remembering.

Please be aware of the mediaserver issue I mentioned in post 763 above. I'm not sure why it's a problem on my LG P500 with an unofficial port of CM7. It's not a problem on my HTC Legend with official CM7 despite that they both are msm7x30.

--------------------

BT Stack:

Your choice of Bluetooth stack will affect which FM apps can work. For the stock FM app I believe you have to run the Broadcom proprietary BT stack. For the CM FM app you must run the open source Bluez BT stack.

My FM app can work like the CM app when BT is on, using the Bluez stack that supports hcitool or direct BT sockets via a daemon. When BT is off my app can write directly to the HCI UART for Broadcom devices. This allows it to work on devices with the proprietary stack, or with BT off.

--------------------

Volume control:

My FM app can set the volume via the Broadcom or TI FM registers through the hardware volume control buttons, without any assistance from the ROM.

The CM FM app, OTOH, requires framework support for this. Here you can see some of the FM volume code: https://github.com/CyanogenMod/andr...rbread/services/audioflinger/AudioFlinger.cpp

There's a AudioFlinger::setFmVolume() method. a define: USE_BROADCOM_FM_VOLUME_HACK, and set_volume_fm() runs some hcitool commands via system().

--------------------

Audio routing:

The stock app uses something different I think, but the CM app and my app use:

AudioSystem:setForceUse()

AudioSystem:setDeviceConnectionState()

FM definitions used for setDeviceConnectionState and getDeviceConnectionState. DEVICE_OUT_FM means the headset:

private static final int DEVICE_OUT_FM = 0x800;

private static final int DEVICE_OUT_FM_SPEAKER = 0x1000;

FM definitions used most commonly as the device number in the Ioctl:

static const uint32_t SND_DEVICE_FM_HEADSET = 9;

static const uint32_t SND_DEVICE_FM_SPEAKER = 11;

Last time I looked:

https://github.com/CyanogenMod/andr...erbread/src/com/android/fm/radio/FMRadio.java

private void switchToSpeaker() {

AudioSystem.setForceUse(AudioSystem.FOR_MEDIA, AudioSystem.FORCE_SPEAKER);

AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_FM, AudioSystem.DEVICE_STATE_UNAVAILABLE, "");

AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_FM, AudioSystem.DEVICE_STATE_AVAILABLE, "");

}

private void switchToHeadset() {

AudioSystem.setForceUse(AudioSystem.FOR_MEDIA, AudioSystem.FORCE_NONE);

AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_FM, AudioSystem.DEVICE_STATE_UNAVAILABLE, "");

AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_FM, AudioSystem.DEVICE_STATE_AVAILABLE, "");

}

Here are some of the files I've examined:

https://github.com/mik9/android_device_lge_thunderg/blob/gingerbread/libaudio/AudioHardware.cpp

https://github.com/CyanogenMod/andr.../gingerbread/libaudio-qsd8k/AudioHardware.cpp

https://github.com/CyanogenMod/andr...ingerbread/libaudio-msm7x30/AudioHardware.cpp

https://github.com/CyanogenMod/andr...bread/libaudio-msm7x30/AudioPolicyManager.cpp

https://github.com/CyanogenMod/andr.../services/audioflinger/AudioPolicyService.cpp

https://github.com/CyanogenMod/andr...rbread/services/audioflinger/AudioFlinger.cpp

I hope this is a useful start at least.