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 mType;
|
||||
// TODO: Revisit if max widht/height really make sense.
|
||||
private int mMaxWidth;
|
||||
private int mMaxHeight;
|
||||
/**
|
||||
@@ -166,4 +165,17 @@ public class TvStreamConfig implements Parcelable {
|
||||
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 static native int nativeAddStream(long ptr, int deviceId, int streamId,
|
||||
private static native int nativeAddOrUpdateStream(long ptr, int deviceId, int streamId,
|
||||
Surface surface);
|
||||
private static native int nativeRemoveStream(long ptr, int deviceId, int streamId);
|
||||
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) {
|
||||
if (mPtr == 0) {
|
||||
return ERROR_NO_INIT;
|
||||
@@ -89,7 +89,7 @@ final class TvInputHal implements Handler.Callback {
|
||||
if (generation != streamConfig.getGeneration()) {
|
||||
return ERROR_STALE_CONFIG;
|
||||
}
|
||||
if (nativeAddStream(mPtr, deviceId, streamConfig.getStreamId(), surface) == 0) {
|
||||
if (nativeAddOrUpdateStream(mPtr, deviceId, streamConfig.getStreamId(), surface) == 0) {
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return ERROR_UNKNOWN;
|
||||
|
||||
@@ -668,14 +668,14 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
||||
result = mHal.removeStream(mInfo.getDeviceId(), mActiveConfig);
|
||||
mActiveConfig = null;
|
||||
} else {
|
||||
if (config != mActiveConfig && mActiveConfig != null) {
|
||||
if (!config.equals(mActiveConfig)) {
|
||||
result = mHal.removeStream(mInfo.getDeviceId(), mActiveConfig);
|
||||
if (result != TvInputHal.SUCCESS) {
|
||||
mActiveConfig = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
result = mHal.addStream(mInfo.getDeviceId(), surface, config);
|
||||
result = mHal.addOrUpdateStream(mInfo.getDeviceId(), surface, config);
|
||||
if (result == TvInputHal.SUCCESS) {
|
||||
mActiveConfig = config;
|
||||
}
|
||||
@@ -801,7 +801,7 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
||||
return false;
|
||||
}
|
||||
|
||||
int result = mHal.addStream(mInfo.getDeviceId(), surface, config);
|
||||
int result = mHal.addOrUpdateStream(mInfo.getDeviceId(), surface, config);
|
||||
return result == TvInputHal.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ public:
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (connections.indexOfKey(streamId) < 0) {
|
||||
connections.add(streamId, Connection());
|
||||
@@ -555,14 +555,14 @@ static jlong nativeOpen(JNIEnv* env, jobject 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) {
|
||||
JTvInputHal* tvInputHal = (JTvInputHal*)ptr;
|
||||
if (!jsurface) {
|
||||
return BAD_VALUE;
|
||||
}
|
||||
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,
|
||||
@@ -612,8 +612,8 @@ static JNINativeMethod gTvInputHalMethods[] = {
|
||||
/* name, signature, funcPtr */
|
||||
{ "nativeOpen", "()J",
|
||||
(void*) nativeOpen },
|
||||
{ "nativeAddStream", "(JIILandroid/view/Surface;)I",
|
||||
(void*) nativeAddStream },
|
||||
{ "nativeAddOrUpdateStream", "(JIILandroid/view/Surface;)I",
|
||||
(void*) nativeAddOrUpdateStream },
|
||||
{ "nativeRemoveStream", "(JII)I",
|
||||
(void*) nativeRemoveStream },
|
||||
{ "nativeGetStreamConfigs", "(JII)[Landroid/media/tv/TvStreamConfig;",
|
||||
|
||||
Reference in New Issue
Block a user