Commit 2f3c7cb8 by olly Committed by Oliver Woodman

Revert pushing download thread interruption into the Downloader implementations

Issue: #5978
PiperOrigin-RevId: 314175257
parent 8b89a5ed
......@@ -1284,6 +1284,7 @@ public final class DownloadManager {
if (!isCanceled) {
isCanceled = true;
downloader.cancel();
interrupt();
}
}
......
......@@ -50,7 +50,10 @@ public interface Downloader {
*/
void download(@Nullable ProgressListener progressListener) throws IOException;
/** Cancels the download operation and prevents future download operations from running. */
/**
* Cancels the download operation and prevents future download operations from running. The caller
* should also interrupt the downloading thread immediately after calling this method.
*/
void cancel();
/** Removes the content. */
......
......@@ -22,7 +22,6 @@ import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.upstream.cache.CacheDataSource;
import com.google.android.exoplayer2.upstream.cache.CacheWriter;
import com.google.android.exoplayer2.upstream.cache.CacheWriter.ProgressListener;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.PriorityTaskManager;
import com.google.android.exoplayer2.util.PriorityTaskManager.PriorityTooLowException;
......@@ -37,8 +36,6 @@ public final class ProgressiveDownloader implements Downloader {
private final CacheDataSource dataSource;
private final AtomicBoolean isCanceled;
@Nullable private volatile Thread downloadThread;
/** @deprecated Use {@link #ProgressiveDownloader(MediaItem, CacheDataSource.Factory)} instead. */
@SuppressWarnings("deprecation")
@Deprecated
......@@ -100,11 +97,6 @@ public final class ProgressiveDownloader implements Downloader {
@Override
public void download(@Nullable ProgressListener progressListener) throws IOException {
downloadThread = Thread.currentThread();
if (isCanceled.get()) {
return;
}
CacheWriter cacheWriter =
new CacheWriter(
dataSource,
......@@ -143,10 +135,6 @@ public final class ProgressiveDownloader implements Downloader {
@Override
public void cancel() {
isCanceled.set(true);
@Nullable Thread downloadThread = this.downloadThread;
if (downloadThread != null) {
downloadThread.interrupt();
}
}
@Override
......
......@@ -80,8 +80,6 @@ public abstract class SegmentDownloader<M extends FilterableManifest<M>> impleme
private final Executor executor;
private final AtomicBoolean isCanceled;
@Nullable private volatile Thread downloadThread;
/**
* @param mediaItem The {@link MediaItem} to be downloaded.
* @param manifestParser A parser for the manifest.
......@@ -107,10 +105,6 @@ public abstract class SegmentDownloader<M extends FilterableManifest<M>> impleme
@Override
public final void download(@Nullable ProgressListener progressListener) throws IOException {
downloadThread = Thread.currentThread();
if (isCanceled.get()) {
return;
}
@Nullable
PriorityTaskManager priorityTaskManager =
cacheDataSourceFactory.getUpstreamPriorityTaskManager();
......@@ -212,10 +206,6 @@ public abstract class SegmentDownloader<M extends FilterableManifest<M>> impleme
@Override
public void cancel() {
isCanceled.set(true);
@Nullable Thread downloadThread = this.downloadThread;
if (downloadThread != null) {
downloadThread.interrupt();
}
}
@Override
......
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 sign in to comment