Commit 65c2b6c6 authored by Martin Storsjö's avatar Martin Storsjö
Browse files

Don't create a new libvlc instance in PhoneStateReceiver if one isn't active



This avoids creating new libvlc instances when phone calls are
received, if no libvlc instance exists.
Signed-off-by: Martin Storsjö's avatarMartin Storsjö <martin@martin.st>
parent 782929b0
......@@ -78,6 +78,11 @@ public class LibVLC {
return sInstance;
}
public static LibVLC getExistingInstance()
{
return sInstance;
}
public void reinit() throws LibVlcException
{
destroy();
......
......@@ -12,13 +12,9 @@ public class PhoneStateReceiver extends BroadcastReceiver {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (state == TelephonyManager.CALL_STATE_RINGING) {
try {
LibVLC libVLC = LibVLC.getInstance();
if (libVLC.isPlaying())
libVLC.pause();
} catch (LibVlcException e) {
return;
}
LibVLC libVLC = LibVLC.getExistingInstance();
if (libVLC != null && libVLC.isPlaying())
libVLC.pause();
}
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment