[G1 Android Development] Bavilo:
Found something interesting in the source.

Maybe there is a way to increase the Volume range higher than 5, to boost the overall output to the speaker?

static status_t set_volume_rpc(uint32_t device,
uint32_t method,
uint32_t volume)
{
int fd;
#if LOG_SND_RPC
LOGD("rpc_snd_set_volume(%d, %d, %d)\n", device, method, volume);
#endif

if (device == -1UL) return NO_ERROR;

fd = open("/dev/msm_snd", O_RDWR);
if (fd < 0) {
LOGE("Can not open snd device");
return -EPERM;
}
/* rpc_snd_set_volume(
* device, # Any hardware device enum, including
* # SND_DEVICE_CURRENT
* method, # must be SND_METHOD_VOICE to do anything useful
* volume, # integer volume level, in range [0,5].
* # note that 0 is audible (not quite muted)
* )
* rpc_snd_set_volume only works for in-call sound volume.
*/
struct msm_snd_volume_config args;
args.device = device;
args.method = method;
args.volume = volume;

if (ioctl(fd, SND_SET_VOLUME, &args) < 0) {
LOGE("snd_set_volume error.");
close(fd);
return -EIO;
}
close(fd);
return NO_ERROR;
}

status_t AudioHardware::setVoiceVolume(float v)
{
if (v < 0.0) {
LOGW("setVoiceVolume(%f) under 0.0, assuming 0.0\n", v);
v = 0.0;
} else if (v > 1.0) {
LOGW("setVoiceVolume(%f) over 1.0, assuming 1.0\n", v);
v = 1.0;
}

int vol = lrint(v * 5.0);
LOGD("setVoiceVolume(%f)\n", v);
LOGI("Setting in-call volume to %d (available range is 0 to 5)\n", vol);

Mutex::Autolock lock(mLock);
set_volume_rpc(SND_DEVICE_CURRENT, SND_METHOD_VOICE, vol);
return NO_ERROR;
}

status_t AudioHardware::setMasterVolume(float v)
{
Mutex::Autolock lock(mLock);
int vol = ceil(v * 5.0);
LOGI("Set master volume to %d.\n", vol);
set_volume_rpc(SND_DEVICE_HANDSET, SND_METHOD_VOICE, vol);
set_volume_rpc(SND_DEVICE_SPEAKER, SND_METHOD_VOICE, vol);
set_volume_rpc(SND_DEVICE_BT, SND_METHOD_VOICE, vol);
set_volume_rpc(SND_DEVICE_HEADSET, SND_METHOD_VOICE, vol);
// We return an error code here to let the audioflinger do in-software
// volume on top of the maximum volume that we set through the SND API.
// return error - software mixer will handle it
return -1;
}

static status_t do_route_audio_rpc(uint32_t device,
bool ear_mute, bool mic_mute)
{
if (device == -1UL)
return NO_ERROR;

int fd;
#if LOG_SND_RPC
LOGD("rpc_snd_set_device(%d, %d, %d)\n", device, ear_mute, mic_mute);
#endif

fd = open("/dev/msm_snd", O_RDWR);
if (fd < 0) {
LOGE("Can not open snd device");
return -EPERM;
}
// RPC call to switch audio path
/* rpc_snd_set_device(
* device, # Hardware device enum to use
* ear_mute, # Set mute for outgoing voice audio
* # this should only be unmuted when in-call
* mic_mute, # Set mute for incoming voice audio
* # this should only be unmuted when in-call or
* # recording.
* )
*/
struct msm_snd_device_config args;
args.device = device;
args.ear_mute = ear_mute ? SND_MUTE_MUTED : SND_MUTE_UNMUTED;
args.mic_mute = mic_mute ? SND_MUTE_MUTED : SND_MUTE_UNMUTED;

if (ioctl(fd, SND_SET_DEVICE, &args) < 0) {
LOGE("snd_set_device error.");
close(fd);
return -EIO;
}

close(fd);
return NO_ERROR;
}

// always call with mutex held
status_t AudioHardware::doAudioRouteOrMute(uint32_t device)
{
if (device == (uint32_t)SND_DEVICE_BT) {
if (mBluetoothId) {
device = mBluetoothId;
} else if (!mBluetoothNrec) {
device = SND_DEVICE_BT_EC_OFF;
}
}
return do_route_audio_rpc(device,
mMode != AudioSystem::MODE_IN_CALL, mMicMute);
}