Commit 9372426f authored by Geoffrey Métais's avatar Geoffrey Métais

Specific threadpool to queue ML processing

parent a359b84f
......@@ -28,6 +28,9 @@ import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.Util;
import java.io.File;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class MediaParsingService extends Service implements DevicesDiscoveryCb {
public final static String TAG = "VLC/MediaParsingService";
......@@ -52,6 +55,9 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
private String mCurrentDiscovery = null;
private long mLastNotificationTime = 0L;
private final ThreadPoolExecutor mThreadPool = new ThreadPoolExecutor(1, 1, 30, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(), VLCApplication.THREAD_FACTORY);
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
......@@ -119,19 +125,29 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
return START_NOT_STICKY;
}
private void discoverStorage(String path, String uuid) {
if (!TextUtils.isEmpty(uuid))
mMedialibrary.addDevice(uuid, path, true);
for (String folder : Medialibrary.getBlackList())
mMedialibrary.banFolder(path + folder);
mMedialibrary.discover(path);
private void discoverStorage(final String path, final String uuid) {
mThreadPool.execute(new Runnable() {
@Override
public void run() {
if (!TextUtils.isEmpty(uuid))
mMedialibrary.addDevice(uuid, path, true);
for (String folder : Medialibrary.getBlackList())
mMedialibrary.banFolder(path + folder);
mMedialibrary.discover(path);
}
});
}
private void discover(String path) {
private void discover(final String path) {
if (TextUtils.isEmpty(path))
return;
addDeviceIfNeeded(path);
mMedialibrary.discover(path);
mThreadPool.execute(new Runnable() {
@Override
public void run() {
addDeviceIfNeeded(path);
mMedialibrary.discover(path);
}
});
}
private void addDeviceIfNeeded(String path) {
......@@ -157,7 +173,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
if (mMedialibrary.isInitiated())
mMedialibrary.resumeBackgroundOperations();
else
VLCApplication.runBackground(new Runnable() {
mThreadPool.execute(new Runnable() {
@Override
public void run() {
mMedialibrary.setup();
......
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