Camera: remove stream_configuration_counter from camera3.h
Handle the race issue in the wrapper HAL instead of letting HAL implementation handing it. Test: Pixel 3 + camera CTS + GCA Bug: 120986771 Change-Id: Iff97fcaa969bea6668679c57642e4322c4ca5c19
This commit is contained in:
parent
71e6298ea6
commit
9e3079b0de
3 changed files with 25 additions and 5 deletions
|
@ -128,7 +128,9 @@ void CameraDeviceSession::configureStreams_3_4_Impl(
|
||||||
}
|
}
|
||||||
|
|
||||||
camera3_stream_configuration_t stream_list{};
|
camera3_stream_configuration_t stream_list{};
|
||||||
stream_list.stream_configuration_counter = streamConfigCounter;
|
// Block reading mStreamConfigCounter until configureStream returns
|
||||||
|
Mutex::Autolock _sccl(mStreamConfigCounterLock);
|
||||||
|
mStreamConfigCounter = streamConfigCounter;
|
||||||
hidl_vec<camera3_stream_t*> streams;
|
hidl_vec<camera3_stream_t*> streams;
|
||||||
stream_list.session_parameters = paramBuffer;
|
stream_list.session_parameters = paramBuffer;
|
||||||
if (!preProcessConfigurationLocked_3_4(requestedConfiguration, &stream_list, &streams)) {
|
if (!preProcessConfigurationLocked_3_4(requestedConfiguration, &stream_list, &streams)) {
|
||||||
|
|
|
@ -123,6 +123,10 @@ protected:
|
||||||
// Physical camera ids for the logical multi-camera. Empty if this
|
// Physical camera ids for the logical multi-camera. Empty if this
|
||||||
// is not a logical multi-camera.
|
// is not a logical multi-camera.
|
||||||
std::unordered_set<std::string> mPhysicalCameraIds;
|
std::unordered_set<std::string> mPhysicalCameraIds;
|
||||||
|
|
||||||
|
Mutex mStreamConfigCounterLock;
|
||||||
|
uint32_t mStreamConfigCounter = 1;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct TrampolineSessionInterface_3_4 : public ICameraDeviceSession {
|
struct TrampolineSessionInterface_3_4 : public ICameraDeviceSession {
|
||||||
|
|
|
@ -72,6 +72,22 @@ Return<void> CameraDeviceSession::configureStreams_3_5(
|
||||||
|
|
||||||
Return<void> CameraDeviceSession::signalStreamFlush(
|
Return<void> CameraDeviceSession::signalStreamFlush(
|
||||||
const hidl_vec<int32_t>& streamIds, uint32_t streamConfigCounter) {
|
const hidl_vec<int32_t>& streamIds, uint32_t streamConfigCounter) {
|
||||||
|
if (mDevice->ops->signal_stream_flush == nullptr) {
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t currentCounter = 0;
|
||||||
|
{
|
||||||
|
Mutex::Autolock _l(mStreamConfigCounterLock);
|
||||||
|
currentCounter = mStreamConfigCounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (streamConfigCounter < currentCounter) {
|
||||||
|
ALOGV("%s: streamConfigCounter %d is stale (current %d), skipping signal_stream_flush call",
|
||||||
|
__FUNCTION__, streamConfigCounter, mStreamConfigCounter);
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<camera3_stream_t*> streams(streamIds.size());
|
std::vector<camera3_stream_t*> streams(streamIds.size());
|
||||||
{
|
{
|
||||||
Mutex::Autolock _l(mInflightLock);
|
Mutex::Autolock _l(mInflightLock);
|
||||||
|
@ -84,10 +100,8 @@ Return<void> CameraDeviceSession::signalStreamFlush(
|
||||||
streams[i] = &mStreamMap[id];
|
streams[i] = &mStreamMap[id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mDevice->ops->signal_stream_flush != nullptr) {
|
|
||||||
mDevice->ops->signal_stream_flush(mDevice,
|
mDevice->ops->signal_stream_flush(mDevice, streams.size(), streams.data());
|
||||||
streamConfigCounter, streams.size(), streams.data());
|
|
||||||
}
|
|
||||||
return Void();
|
return Void();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue