Commit 29eeff9f by aquilescanta Committed by bachinger

Assign error codes to FileDataSourceExceptions

PiperOrigin-RevId: 377481210
parent 536f7c8d
...@@ -46,6 +46,7 @@ import com.google.android.exoplayer2.trackselection.ExoTrackSelection; ...@@ -46,6 +46,7 @@ import com.google.android.exoplayer2.trackselection.ExoTrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelector; import com.google.android.exoplayer2.trackselection.TrackSelector;
import com.google.android.exoplayer2.trackselection.TrackSelectorResult; import com.google.android.exoplayer2.trackselection.TrackSelectorResult;
import com.google.android.exoplayer2.upstream.BandwidthMeter; import com.google.android.exoplayer2.upstream.BandwidthMeter;
import com.google.android.exoplayer2.upstream.FileDataSource;
import com.google.android.exoplayer2.upstream.HttpDataSource; import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Clock; import com.google.android.exoplayer2.util.Clock;
...@@ -55,6 +56,7 @@ import com.google.android.exoplayer2.util.TraceUtil; ...@@ -55,6 +56,7 @@ import com.google.android.exoplayer2.util.TraceUtil;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
...@@ -572,6 +574,15 @@ import java.util.concurrent.atomic.AtomicBoolean; ...@@ -572,6 +574,15 @@ import java.util.concurrent.atomic.AtomicBoolean;
stopInternal(/* forceResetRenderers= */ true, /* acknowledgeStop= */ false); stopInternal(/* forceResetRenderers= */ true, /* acknowledgeStop= */ false);
playbackInfo = playbackInfo.copyWithPlaybackError(e); playbackInfo = playbackInfo.copyWithPlaybackError(e);
} }
} catch (FileDataSource.FileDataSourceException e) {
@Nullable Throwable cause = e.getCause();
int errorCode = PlaybackException.ERROR_CODE_IO_UNSPECIFIED;
if (cause instanceof FileNotFoundException) {
errorCode = PlaybackException.ERROR_CODE_IO_FILE_NOT_FOUND;
} else if (cause instanceof SecurityException) {
errorCode = PlaybackException.ERROR_CODE_IO_NO_PERMISSION;
}
handleIoException(e, errorCode);
} catch (ParserException e) { } catch (ParserException e) {
int errorCode = PlaybackException.ERROR_CODE_UNSPECIFIED; int errorCode = PlaybackException.ERROR_CODE_UNSPECIFIED;
if (e.dataType == C.DATA_TYPE_MEDIA) { if (e.dataType == C.DATA_TYPE_MEDIA) {
......
...@@ -33,7 +33,7 @@ public final class FileDataSource extends BaseDataSource { ...@@ -33,7 +33,7 @@ public final class FileDataSource extends BaseDataSource {
/** Thrown when a {@link FileDataSource} encounters an error reading a file. */ /** Thrown when a {@link FileDataSource} encounters an error reading a file. */
public static class FileDataSourceException extends IOException { public static class FileDataSourceException extends IOException {
public FileDataSourceException(IOException cause) { public FileDataSourceException(Exception cause) {
super(cause); super(cause);
} }
...@@ -94,7 +94,7 @@ public final class FileDataSource extends BaseDataSource { ...@@ -94,7 +94,7 @@ public final class FileDataSource extends BaseDataSource {
} }
} catch (FileDataSourceException e) { } catch (FileDataSourceException e) {
throw e; throw e;
} catch (IOException e) { } catch (Exception e) {
throw new FileDataSourceException(e); throw new FileDataSourceException(e);
} }
......
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