Friday, January 6, 2012

about WIFI Lock

WIFI lock is required to keep a handle to turn off the WIFI connection in sleep.
Specifically, the code will look like this:

void freeWifi() {
    if (mWifiLock.isHeld()){
        mWifiLock.release();
    }
}

void lockWifi(final MediaData track){
    File cacheFile = StreamCacherServer.getCacheFile(this, track.data);
    if ((cacheFile == null && track.data.startsWith("http")) || (streamcacheserv!=null && streamcacheserv.isRunning())){
        mWifiLock.acquire();
    }
    else if (mWifiLock.isHeld()){
        mWifiLock.release();
    }
}

Lock before to play songs using this code, you may be stopped during playback Release.
However, it seems there is a problem that does this JustPlayer.
The JustPlayer, has a prefetch process of reading music.
Play the song and that which must be applied for the Lock at another location.
I think it was so seemingly went well, the following error occurred.

java.lang.UnsupportedOperationException: Exceeded maximum number of wifi locks
at android.net.wifi.WifiManager$WifiLock.acquire(WifiManager.java:968)
at jp.co.kayo.android.localplayer.service.MediaPlayerService.g(Unknown Source)
at jp.co.kayo.android.localplayer.service.MediaPlayerService.onPrepared(Unknown Source)
at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1442)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)

I'm sorry. It is an error to obtain multiple locks too. I'll fix in the next release.

3 comments:

  1. Bonjour à tous ! sur mon site vous trouverez des codes Free Wifi privé et qui ne ce désactive jamais ou du moin pour longtemps !

    ︻̷̿┻̿═━一 code free wifi

    ReplyDelete
  2. Bonjour à tous je partage mes dernier code Free Wifi ︻̷̿┻̿═━一 https://code-freewifi.com/

    CODE FREE WIFI 2016 ID 494

    ReplyDelete
  3. bonjour Je vous partage mon site ou je partage des codes free wifi pour tous et fonctionnel code free wifi

    ReplyDelete