GPS application gets killed on screen timeout

by sagar » Mon, 13 Apr 2009 12:03:54 GMT


Sponsored Links
 Hi ,

I can see on OMAP zoom2 platform, the moment screen timeout happens my
application is getting terminated. I have a Google map based LBS
application which is running on Zoom. I have implemented the
interfaces given in gps.h to libhardware_legacy/gps.cpp .

GPS application talks to android framework and Framework talks to
libhardware to get the GPS info. Now I can see that the moment screen
timeout happens and the display goes off, my application killed.
Actually from the framework the stop interface (hgps_stop() )  gets
called on screen timeout.

I am wondring why this is happening, as I am not sending any stop
request form my GPS application to the libhardware.

Is it something related to Android power manager, that android Power
manager does not know about my application is running?


Thanks and regards,
Saghar

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. how to show a dialog alert dialog when receive a broadcast

Probably you can't....so, simply start an Activity that will display just
your dialog.


On Fri, Jun 11, 2010 at 11:46 AM, Mohammad Siddiqui <siddiqui.m...@gmail.com



> 

2. Possible SoundPool bug in setLoop

I've experimented with SoundPool a bit and it seems that setLoop loops
only samples with framecount under 2048. I'd like to hear any comments
about this. Has anybody successfully looped a longer sample with
SoundPool? If this is indeed a bug and not some kind of "feature" that
I'm unaware of, this could be submitted into the official issue
tracker.

Following ERRORs will be produced if samples which have a size of over
2048 frames are set to loop:
06-05 17:32:50.279: ERROR/AudioTrack(399): setLoop invalid value:
loopStart 0, loopEnd 37485, loopCount -1, framecount 2048, user 0
06-05 17:32:50.289: ERROR/AudioTrack(399): setLoop invalid value:
loopStart 0, loopEnd 5856, loopCount -1, framecount 2048, user 0

Somehow it seems that framecount is capped at 2048.

SoundPool uses AudioTrack and in AudioTrack.cpp there's code like
this:

[code]if (loopStart >= loopEnd ||
        loopEnd - loopStart > mFrameCount) {
        LOGE("setLoop invalid value: loopStart %d, loopEnd %d,
loopCount %d, framecount %d, user %d", loopStart, loopEnd, loopCount,
mFrameCount, cblk->user);
        return BAD_VALUE;
    }[/code]

So, if loopend minus loopstart are larger than mFrameCount, looping
isn't set and BAD_VALUE is returned. If mFrameCount is capped at 2048
for some reason (AudioTrack limitation?), looping works only for very
very short samples. However, many applications may require longer
loops which are still classified as sound effects rather than
background music. For example rain ambience loops or similar.

However, classfications aside, if SoundPool has a limitation like this
and it's not a bug, it should be stated in the API reference.

To reproduce: Insert three wav samples that are of different size into
res/raw with names sample1.wav, sample2.wav, and shortsample.wav.
Shortsample.wav must be very small resulting in a framecount of 2048
or less. Then implement the following code. Also create a button into
the ui layout. Clicking a button plays the sounds and tries to set
them looping. This results in the error messages shown above and only
the shortsample.wav looping.

[code]package somepack.SoundPoolTest;
import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class SoundPoolTest extends Activity implements OnClickListener
{
    /** Called when the activity is first created. */

        SoundPool a;
        int soundid1;
        int soundid2;
        int soundid3;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        a = new SoundPool(16, AudioManager.STREAM_MUSIC,0);

        soundid1 = a.load(this.getBaseContext(),  R.raw.sample1, 1);
        soundid2 = a.load(this.getBaseContext(),  R.raw.sample2, 1);
        soundid3 = a.load(this.getBaseContext(),  R.raw.shortsample,
1);

        Button button = (Button)findViewById(R.id.Button01);
        button.setOnClickListener(this);
    }

    public void onClick(View v) {
                int k = v.getId();
                if(k == R.id.Button01)
                {
                        long chan1 = a.play(soundid1, 1.0f, 1.0f, 1, 0, 1.0f);
                a.setLoop((int) chan1, -1);

                long chan2 = a.play(soundid2, 1.0f, 1.0f, 1, 0, 1.0f);
                a.setLoop((int) chan2, -1);

                long chan3 = a.play(soundid3, 1.0f, 1.0f, 1, 0, 1.0f);
                a.setLoop((int) chan3, -1);
                }
    }
}[/code]

-- 

3. Graphics performance

4. OpenGL ES Canvas

5. VideoView continues to play in 2.1

6. How to mount/umount sdcard

7. Fwd: How to mount/umount sdcard