Merge "TIF: fix wrong config comparison & confusing method name" into lmp-mr1-dev
This commit is contained in:
@@ -33,7 +33,6 @@ public class TvStreamConfig implements Parcelable {
|
|||||||
|
|
||||||
private int mStreamId;
|
private int mStreamId;
|
||||||
private int mType;
|
private int mType;
|
||||||
// TODO: Revisit if max widht/height really make sense.
|
|
||||||
private int mMaxWidth;
|
private int mMaxWidth;
|
||||||
private int mMaxHeight;
|
private int mMaxHeight;
|
||||||
/**
|
/**
|
||||||
@@ -166,4 +165,17 @@ public class TvStreamConfig implements Parcelable {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj == null) return false;
|
||||||
|
if (!(obj instanceof TvStreamConfig)) return false;
|
||||||
|
|
||||||
|
TvStreamConfig config = (TvStreamConfig) obj;
|
||||||
|
return config.mGeneration == mGeneration
|
||||||
|
&& config.mStreamId == mStreamId
|
||||||
|
&& config.mType == mType
|
||||||
|
&& config.mMaxWidth == mMaxWidth
|
||||||
|
&& config.mMaxHeight == mMaxHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ final class TvInputHal implements Handler.Callback {
|
|||||||
|
|
||||||
private native long nativeOpen();
|
private native long nativeOpen();
|
||||||
|
|
||||||
private static native int nativeAddStream(long ptr, int deviceId, int streamId,
|
private static native int nativeAddOrUpdateStream(long ptr, int deviceId, int streamId,
|
||||||
Surface surface);
|
Surface surface);
|
||||||
private static native int nativeRemoveStream(long ptr, int deviceId, int streamId);
|
private static native int nativeRemoveStream(long ptr, int deviceId, int streamId);
|
||||||
private static native TvStreamConfig[] nativeGetStreamConfigs(long ptr, int deviceId,
|
private static native TvStreamConfig[] nativeGetStreamConfigs(long ptr, int deviceId,
|
||||||
@@ -80,7 +80,7 @@ final class TvInputHal implements Handler.Callback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int addStream(int deviceId, Surface surface, TvStreamConfig streamConfig) {
|
public int addOrUpdateStream(int deviceId, Surface surface, TvStreamConfig streamConfig) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mPtr == 0) {
|
if (mPtr == 0) {
|
||||||
return ERROR_NO_INIT;
|
return ERROR_NO_INIT;
|
||||||
@@ -89,7 +89,7 @@ final class TvInputHal implements Handler.Callback {
|
|||||||
if (generation != streamConfig.getGeneration()) {
|
if (generation != streamConfig.getGeneration()) {
|
||||||
return ERROR_STALE_CONFIG;
|
return ERROR_STALE_CONFIG;
|
||||||
}
|
}
|
||||||
if (nativeAddStream(mPtr, deviceId, streamConfig.getStreamId(), surface) == 0) {
|
if (nativeAddOrUpdateStream(mPtr, deviceId, streamConfig.getStreamId(), surface) == 0) {
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
return ERROR_UNKNOWN;
|
return ERROR_UNKNOWN;
|
||||||
|
|||||||
@@ -668,14 +668,14 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
|||||||
result = mHal.removeStream(mInfo.getDeviceId(), mActiveConfig);
|
result = mHal.removeStream(mInfo.getDeviceId(), mActiveConfig);
|
||||||
mActiveConfig = null;
|
mActiveConfig = null;
|
||||||
} else {
|
} else {
|
||||||
if (config != mActiveConfig && mActiveConfig != null) {
|
if (!config.equals(mActiveConfig)) {
|
||||||
result = mHal.removeStream(mInfo.getDeviceId(), mActiveConfig);
|
result = mHal.removeStream(mInfo.getDeviceId(), mActiveConfig);
|
||||||
if (result != TvInputHal.SUCCESS) {
|
if (result != TvInputHal.SUCCESS) {
|
||||||
mActiveConfig = null;
|
mActiveConfig = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = mHal.addStream(mInfo.getDeviceId(), surface, config);
|
result = mHal.addOrUpdateStream(mInfo.getDeviceId(), surface, config);
|
||||||
if (result == TvInputHal.SUCCESS) {
|
if (result == TvInputHal.SUCCESS) {
|
||||||
mActiveConfig = config;
|
mActiveConfig = config;
|
||||||
}
|
}
|
||||||
@@ -801,7 +801,7 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = mHal.addStream(mInfo.getDeviceId(), surface, config);
|
int result = mHal.addOrUpdateStream(mInfo.getDeviceId(), surface, config);
|
||||||
return result == TvInputHal.SUCCESS;
|
return result == TvInputHal.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ public:
|
|||||||
|
|
||||||
static JTvInputHal* createInstance(JNIEnv* env, jobject thiz);
|
static JTvInputHal* createInstance(JNIEnv* env, jobject thiz);
|
||||||
|
|
||||||
int addStream(int deviceId, int streamId, const sp<Surface>& surface);
|
int addOrUpdateStream(int deviceId, int streamId, const sp<Surface>& surface);
|
||||||
int removeStream(int deviceId, int streamId);
|
int removeStream(int deviceId, int streamId);
|
||||||
const tv_stream_config_t* getStreamConfigs(int deviceId, int* numConfigs);
|
const tv_stream_config_t* getStreamConfigs(int deviceId, int* numConfigs);
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ JTvInputHal* JTvInputHal::createInstance(JNIEnv* env, jobject thiz) {
|
|||||||
return new JTvInputHal(env, thiz, device);
|
return new JTvInputHal(env, thiz, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
int JTvInputHal::addStream(int deviceId, int streamId, const sp<Surface>& surface) {
|
int JTvInputHal::addOrUpdateStream(int deviceId, int streamId, const sp<Surface>& surface) {
|
||||||
KeyedVector<int, Connection>& connections = mConnections.editValueFor(deviceId);
|
KeyedVector<int, Connection>& connections = mConnections.editValueFor(deviceId);
|
||||||
if (connections.indexOfKey(streamId) < 0) {
|
if (connections.indexOfKey(streamId) < 0) {
|
||||||
connections.add(streamId, Connection());
|
connections.add(streamId, Connection());
|
||||||
@@ -555,14 +555,14 @@ static jlong nativeOpen(JNIEnv* env, jobject thiz) {
|
|||||||
return (jlong)JTvInputHal::createInstance(env, thiz);
|
return (jlong)JTvInputHal::createInstance(env, thiz);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nativeAddStream(JNIEnv* env, jclass clazz,
|
static int nativeAddOrUpdateStream(JNIEnv* env, jclass clazz,
|
||||||
jlong ptr, jint deviceId, jint streamId, jobject jsurface) {
|
jlong ptr, jint deviceId, jint streamId, jobject jsurface) {
|
||||||
JTvInputHal* tvInputHal = (JTvInputHal*)ptr;
|
JTvInputHal* tvInputHal = (JTvInputHal*)ptr;
|
||||||
if (!jsurface) {
|
if (!jsurface) {
|
||||||
return BAD_VALUE;
|
return BAD_VALUE;
|
||||||
}
|
}
|
||||||
sp<Surface> surface(android_view_Surface_getSurface(env, jsurface));
|
sp<Surface> surface(android_view_Surface_getSurface(env, jsurface));
|
||||||
return tvInputHal->addStream(deviceId, streamId, surface);
|
return tvInputHal->addOrUpdateStream(deviceId, streamId, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nativeRemoveStream(JNIEnv* env, jclass clazz,
|
static int nativeRemoveStream(JNIEnv* env, jclass clazz,
|
||||||
@@ -612,8 +612,8 @@ static JNINativeMethod gTvInputHalMethods[] = {
|
|||||||
/* name, signature, funcPtr */
|
/* name, signature, funcPtr */
|
||||||
{ "nativeOpen", "()J",
|
{ "nativeOpen", "()J",
|
||||||
(void*) nativeOpen },
|
(void*) nativeOpen },
|
||||||
{ "nativeAddStream", "(JIILandroid/view/Surface;)I",
|
{ "nativeAddOrUpdateStream", "(JIILandroid/view/Surface;)I",
|
||||||
(void*) nativeAddStream },
|
(void*) nativeAddOrUpdateStream },
|
||||||
{ "nativeRemoveStream", "(JII)I",
|
{ "nativeRemoveStream", "(JII)I",
|
||||||
(void*) nativeRemoveStream },
|
(void*) nativeRemoveStream },
|
||||||
{ "nativeGetStreamConfigs", "(JII)[Landroid/media/tv/TvStreamConfig;",
|
{ "nativeGetStreamConfigs", "(JII)[Landroid/media/tv/TvStreamConfig;",
|
||||||
|
|||||||
Reference in New Issue
Block a user