mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Revert pushing download thread interruption into the Downloader implementations
Issue: #5978 PiperOrigin-RevId: 314175257
This commit is contained in:
parent
8b89a5ed6d
commit
2f3c7cb85f
4 changed files with 5 additions and 23 deletions
|
|
@ -1284,6 +1284,7 @@ public final class DownloadManager {
|
||||||
if (!isCanceled) {
|
if (!isCanceled) {
|
||||||
isCanceled = true;
|
isCanceled = true;
|
||||||
downloader.cancel();
|
downloader.cancel();
|
||||||
|
interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,10 @@ public interface Downloader {
|
||||||
*/
|
*/
|
||||||
void download(@Nullable ProgressListener progressListener) throws IOException;
|
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();
|
void cancel();
|
||||||
|
|
||||||
/** Removes the content. */
|
/** 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.DataSpec;
|
||||||
import com.google.android.exoplayer2.upstream.cache.CacheDataSource;
|
import com.google.android.exoplayer2.upstream.cache.CacheDataSource;
|
||||||
import com.google.android.exoplayer2.upstream.cache.CacheWriter;
|
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.Assertions;
|
||||||
import com.google.android.exoplayer2.util.PriorityTaskManager;
|
import com.google.android.exoplayer2.util.PriorityTaskManager;
|
||||||
import com.google.android.exoplayer2.util.PriorityTaskManager.PriorityTooLowException;
|
import com.google.android.exoplayer2.util.PriorityTaskManager.PriorityTooLowException;
|
||||||
|
|
@ -37,8 +36,6 @@ public final class ProgressiveDownloader implements Downloader {
|
||||||
private final CacheDataSource dataSource;
|
private final CacheDataSource dataSource;
|
||||||
private final AtomicBoolean isCanceled;
|
private final AtomicBoolean isCanceled;
|
||||||
|
|
||||||
@Nullable private volatile Thread downloadThread;
|
|
||||||
|
|
||||||
/** @deprecated Use {@link #ProgressiveDownloader(MediaItem, CacheDataSource.Factory)} instead. */
|
/** @deprecated Use {@link #ProgressiveDownloader(MediaItem, CacheDataSource.Factory)} instead. */
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|
@ -100,11 +97,6 @@ public final class ProgressiveDownloader implements Downloader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void download(@Nullable ProgressListener progressListener) throws IOException {
|
public void download(@Nullable ProgressListener progressListener) throws IOException {
|
||||||
downloadThread = Thread.currentThread();
|
|
||||||
if (isCanceled.get()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CacheWriter cacheWriter =
|
CacheWriter cacheWriter =
|
||||||
new CacheWriter(
|
new CacheWriter(
|
||||||
dataSource,
|
dataSource,
|
||||||
|
|
@ -143,10 +135,6 @@ public final class ProgressiveDownloader implements Downloader {
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
isCanceled.set(true);
|
isCanceled.set(true);
|
||||||
@Nullable Thread downloadThread = this.downloadThread;
|
|
||||||
if (downloadThread != null) {
|
|
||||||
downloadThread.interrupt();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,6 @@ public abstract class SegmentDownloader<M extends FilterableManifest<M>> impleme
|
||||||
private final Executor executor;
|
private final Executor executor;
|
||||||
private final AtomicBoolean isCanceled;
|
private final AtomicBoolean isCanceled;
|
||||||
|
|
||||||
@Nullable private volatile Thread downloadThread;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mediaItem The {@link MediaItem} to be downloaded.
|
* @param mediaItem The {@link MediaItem} to be downloaded.
|
||||||
* @param manifestParser A parser for the manifest.
|
* @param manifestParser A parser for the manifest.
|
||||||
|
|
@ -107,10 +105,6 @@ public abstract class SegmentDownloader<M extends FilterableManifest<M>> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void download(@Nullable ProgressListener progressListener) throws IOException {
|
public final void download(@Nullable ProgressListener progressListener) throws IOException {
|
||||||
downloadThread = Thread.currentThread();
|
|
||||||
if (isCanceled.get()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
@Nullable
|
@Nullable
|
||||||
PriorityTaskManager priorityTaskManager =
|
PriorityTaskManager priorityTaskManager =
|
||||||
cacheDataSourceFactory.getUpstreamPriorityTaskManager();
|
cacheDataSourceFactory.getUpstreamPriorityTaskManager();
|
||||||
|
|
@ -212,10 +206,6 @@ public abstract class SegmentDownloader<M extends FilterableManifest<M>> impleme
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
isCanceled.set(true);
|
isCanceled.set(true);
|
||||||
@Nullable Thread downloadThread = this.downloadThread;
|
|
||||||
if (downloadThread != null) {
|
|
||||||
downloadThread.interrupt();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue