Merge "[TIAF] Fix FD leak in AdBuffer" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c246ee42f1
@@ -22,6 +22,8 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.SharedMemory;
|
import android.os.SharedMemory;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Buffer for advertisement data.
|
* Buffer for advertisement data.
|
||||||
*/
|
*/
|
||||||
@@ -57,6 +59,16 @@ public final class AdBuffer implements Parcelable {
|
|||||||
this.mFlags = flags;
|
this.mFlags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide **/
|
||||||
|
public static AdBuffer dupAdBuffer(AdBuffer buffer) throws IOException {
|
||||||
|
if (buffer == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new AdBuffer(buffer.mId, buffer.mMimeType,
|
||||||
|
SharedMemory.fromFileDescriptor(buffer.mBuffer.getFdDup()), buffer.mOffset,
|
||||||
|
buffer.mLength, buffer.mPresentationTimeUs, buffer.mFlags);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets corresponding AD request ID.
|
* Gets corresponding AD request ID.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -72,6 +72,22 @@ public final class AdRequest implements Parcelable {
|
|||||||
private final Bundle mMetadata;
|
private final Bundle mMetadata;
|
||||||
private final Uri mUri;
|
private final Uri mUri;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The key for video metadata.
|
||||||
|
*
|
||||||
|
* @see #getMetadata()
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String KEY_VIDEO_METADATA = "key_video_metadata";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The key for audio metadata.
|
||||||
|
*
|
||||||
|
* @see #getMetadata()
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String KEY_AUDIO_METADATA = "key_audio_metadata";
|
||||||
|
|
||||||
public AdRequest(int id, @RequestType int requestType,
|
public AdRequest(int id, @RequestType int requestType,
|
||||||
@Nullable ParcelFileDescriptor fileDescriptor, long startTime, long stopTime,
|
@Nullable ParcelFileDescriptor fileDescriptor, long startTime, long stopTime,
|
||||||
long echoInterval, @Nullable String mediaFileType, @NonNull Bundle metadata) {
|
long echoInterval, @Nullable String mediaFileType, @NonNull Bundle metadata) {
|
||||||
|
|||||||
@@ -3737,6 +3737,10 @@ public final class TvInputManager {
|
|||||||
mService.notifyAdBufferReady(mToken, buffer, mUserId);
|
mService.notifyAdBufferReady(mToken, buffer, mUserId);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
|
} finally {
|
||||||
|
if (buffer != null) {
|
||||||
|
buffer.getSharedMemory().close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1608,6 +1608,10 @@ public final class TvInteractiveAppManager {
|
|||||||
mService.notifyAdBufferConsumed(mToken, buffer, mUserId);
|
mService.notifyAdBufferConsumed(mToken, buffer, mUserId);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
|
} finally {
|
||||||
|
if (buffer != null) {
|
||||||
|
buffer.getSharedMemory().close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ import android.widget.FrameLayout;
|
|||||||
|
|
||||||
import com.android.internal.os.SomeArgs;
|
import com.android.internal.os.SomeArgs;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -1973,9 +1974,9 @@ public abstract class TvInteractiveAppService extends Service {
|
|||||||
"notifyAdBufferReady(buffer=" + buffer + ")");
|
"notifyAdBufferReady(buffer=" + buffer + ")");
|
||||||
}
|
}
|
||||||
if (mSessionCallback != null) {
|
if (mSessionCallback != null) {
|
||||||
mSessionCallback.onAdBufferReady(buffer);
|
mSessionCallback.onAdBufferReady(AdBuffer.dupAdBuffer(buffer));
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException | IOException e) {
|
||||||
Log.w(TAG, "error in notifyAdBuffer", e);
|
Log.w(TAG, "error in notifyAdBuffer", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2629,6 +2629,10 @@ public final class TvInputManagerService extends SystemService {
|
|||||||
getSessionLocked(sessionState).notifyAdBufferReady(buffer);
|
getSessionLocked(sessionState).notifyAdBufferReady(buffer);
|
||||||
} catch (RemoteException | SessionNotFoundException e) {
|
} catch (RemoteException | SessionNotFoundException e) {
|
||||||
Slog.e(TAG, "error in notifyAdBuffer", e);
|
Slog.e(TAG, "error in notifyAdBuffer", e);
|
||||||
|
} finally {
|
||||||
|
if (buffer != null) {
|
||||||
|
buffer.getSharedMemory().close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -3891,10 +3895,13 @@ public final class TvInputManagerService extends SystemService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
mSessionState.client.onAdBufferConsumed(
|
mSessionState.client.onAdBufferConsumed(buffer, mSessionState.seq);
|
||||||
buffer, mSessionState.seq);
|
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.e(TAG, "error in onAdBufferConsumed", e);
|
Slog.e(TAG, "error in onAdBufferConsumed", e);
|
||||||
|
} finally {
|
||||||
|
if (buffer != null) {
|
||||||
|
buffer.getSharedMemory().close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2007,6 +2007,10 @@ public class TvInteractiveAppManagerService extends SystemService {
|
|||||||
getSessionLocked(sessionState).notifyAdBufferConsumed(buffer);
|
getSessionLocked(sessionState).notifyAdBufferConsumed(buffer);
|
||||||
} catch (RemoteException | SessionNotFoundException e) {
|
} catch (RemoteException | SessionNotFoundException e) {
|
||||||
Slogf.e(TAG, "error in notifyAdBufferConsumed", e);
|
Slogf.e(TAG, "error in notifyAdBufferConsumed", e);
|
||||||
|
} finally {
|
||||||
|
if (buffer != null) {
|
||||||
|
buffer.getSharedMemory().close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -3063,6 +3067,10 @@ public class TvInteractiveAppManagerService extends SystemService {
|
|||||||
mSessionState.mClient.onAdBufferReady(buffer, mSessionState.mSeq);
|
mSessionState.mClient.onAdBufferReady(buffer, mSessionState.mSeq);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slogf.e(TAG, "error in onAdBuffer", e);
|
Slogf.e(TAG, "error in onAdBuffer", e);
|
||||||
|
} finally {
|
||||||
|
if (buffer != null) {
|
||||||
|
buffer.getSharedMemory().close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user