genixia, you da man. Works great. I think we're almost ready to submit this one for inclusion in Hijack.

Mark did say he wanted someone to change the patch to hold off on allocating and initializing the overlay buffers until the device is first used, so I made that change. I'll attach a new patch which goes against a plain hijack v300 kernel and has your setsam changes and the delayed allocation of the overlay buffers, as well as some conditionally-compiled debug statements.

The one thing I'm a little unhappy with is that the PCM output seems really quiet. I understand why, I mean, it's only scaling down the volume of the background music, and not increasing the volume of the PCM sound. So in theory the PCM will output at a maximum to 50% of the Empeg's volume setting.

I'm nowhere near slick enough to mess with the ASM code he has in the patch to try to find some way of scaling the foreground sound... I tried just multiplying the sample values but I got clipping and no discernable volume increase. Clearly not the way to go.

So the logical solution seems to be to:
1) Fade the background down
2) After it's faded, increase the player's volume with an empeg_mixer_setvolume call.
3) Play the sample
4) Once the sample is done, bring the player's volume back to normal.
5) Fade the BG back up to it's original state.

And that's what Kim's code *looks* like it's doing... BUT... The weird thing is, when I enable AUDIO_OVERLAY_DEBUG, I notice that, while the "audio_overlay_bg_volume" scaling factor is being used, the Empeg's volume setting itself didn't seem to be getting changed anywhere. Setting MIXER_DEBUG in empeg_mixer.c confirms this. empeg_audio3.c has two flags "iSwitchToPCM" and "iFadeVolumeUp" which look like they should be doing something, but they don't appear to be doing anything at all. I don't follow how these flags get triggered.

So, any thoughts on how we can get PCM samples to play at a louder volume, particularly by controlling the player's volume setting? I'm not sure exactly why none of Kim's code for increasing/decreasing the mixer volume is getting called...

If we can find some way to have the mixer volume increased by a configurable level when PCM sounds are playing, I think we're ready to submit the patch for Hijack. Scaling down the PCM doesn't seem to be good enough. Whaddya think?
_________________________
- Tony C
my empeg stuff