Fixed segfaults and many other bugs in device controls.

This commit is contained in:
Gonzalo Exequiel Pedone 2020-09-10 17:26:08 -03:00
parent 39c84d9788
commit db094901bc
No known key found for this signature in database
GPG key ID: B8B09E63E9B85BAF
5 changed files with 34 additions and 17 deletions

View file

@ -1287,7 +1287,7 @@ int AkVCam::CmdParserPrivate::readControl(const StringMap &flags,
}
for (auto &control: this->m_ipcBridge.controls(deviceId))
if (control.description == args[2]) {
if (control.id == args[2]) {
if (flags.empty()) {
std::cout << control.value << std::endl;
} else {

View file

@ -666,9 +666,9 @@ void AkVCam::AssistantPrivate::broadcasting(xpc_connection_t client,
void AkVCam::AssistantPrivate::controlsUpdated(xpc_connection_t client, xpc_object_t event)
{
UNUSED(client);
AkLogFunction();
std::string deviceId = xpc_dictionary_get_string(event, "device");
bool ok = false;
if (this->m_deviceConfigs.count(deviceId) > 0) {
auto notification = xpc_copy(event);
@ -677,13 +677,7 @@ void AkVCam::AssistantPrivate::controlsUpdated(xpc_connection_t client, xpc_obje
xpc_connection_send_message(client.second, notification);
xpc_release(notification);
ok = true;
}
auto reply = xpc_dictionary_create_reply(event);
xpc_dictionary_set_bool(reply, "status", ok);
xpc_connection_send_message(client, reply);
xpc_release(reply);
}
void AkVCam::AssistantPrivate::listenerAdd(xpc_connection_t client,

View file

@ -511,10 +511,8 @@ void AkVCam::IpcBridge::setControls(const std::string &deviceId,
auto dictionary = xpc_dictionary_create(nullptr, nullptr, 0);
xpc_dictionary_set_int64(dictionary, "message", AKVCAM_ASSISTANT_MSG_DEVICE_CONTROLS_UPDATED);
xpc_dictionary_set_string(dictionary, "device", deviceId.c_str());
auto reply = xpc_connection_send_message_with_reply_sync(this->d->m_serverMessagePort,
dictionary);
xpc_connection_send_message(this->d->m_serverMessagePort, dictionary);
xpc_release(dictionary);
xpc_release(reply);
}
std::vector<std::string> AkVCam::IpcBridge::listeners(const std::string &deviceId)
@ -1040,11 +1038,6 @@ void AkVCam::IpcBridgePrivate::controlsUpdated(xpc_connection_t client,
ControlsChanged,
deviceId,
controls)
auto reply = xpc_dictionary_create_reply(event);
xpc_dictionary_set_bool(reply, "status", cameraIndex >= 0);
xpc_connection_send_message(client, reply);
xpc_release(reply);
}
void AkVCam::IpcBridgePrivate::listenerAdd(xpc_connection_t client,

View file

@ -354,7 +354,7 @@ void AkVCam::PluginInterface::controlsChanged(void *userData,
device->setHorizontalMirror(controls.at("hflip"));
if (controls.count("vflip"))
device->setHorizontalMirror(controls.at("vflip"));
device->setVerticalMirror(controls.at("vflip"));
if (controls.count("scaling"))
device->setScaling(Scaling(controls.at("scaling")));

View file

@ -333,6 +333,12 @@ void AkVCam::Stream::setHorizontalMirror(bool horizontalMirror)
this->d->m_horizontalMirror = horizontalMirror;
this->d->updateTestFrame();
this->d->m_mutex.lock();
if (this->d->m_broadcaster.empty())
this->d->m_currentFrame = this->d->m_testFrameAdapted;
this->d->m_mutex.unlock();
}
void AkVCam::Stream::setVerticalMirror(bool verticalMirror)
@ -344,6 +350,12 @@ void AkVCam::Stream::setVerticalMirror(bool verticalMirror)
this->d->m_verticalMirror = verticalMirror;
this->d->updateTestFrame();
this->d->m_mutex.lock();
if (this->d->m_broadcaster.empty())
this->d->m_currentFrame = this->d->m_testFrameAdapted;
this->d->m_mutex.unlock();
}
void AkVCam::Stream::setScaling(Scaling scaling)
@ -355,6 +367,12 @@ void AkVCam::Stream::setScaling(Scaling scaling)
this->d->m_scaling = scaling;
this->d->updateTestFrame();
this->d->m_mutex.lock();
if (this->d->m_broadcaster.empty())
this->d->m_currentFrame = this->d->m_testFrameAdapted;
this->d->m_mutex.unlock();
}
void AkVCam::Stream::setAspectRatio(AspectRatio aspectRatio)
@ -366,6 +384,12 @@ void AkVCam::Stream::setAspectRatio(AspectRatio aspectRatio)
this->d->m_aspectRatio = aspectRatio;
this->d->updateTestFrame();
this->d->m_mutex.lock();
if (this->d->m_broadcaster.empty())
this->d->m_currentFrame = this->d->m_testFrameAdapted;
this->d->m_mutex.unlock();
}
void AkVCam::Stream::setSwapRgb(bool swap)
@ -377,6 +401,12 @@ void AkVCam::Stream::setSwapRgb(bool swap)
this->d->m_swapRgb = swap;
this->d->updateTestFrame();
this->d->m_mutex.lock();
if (this->d->m_broadcaster.empty())
this->d->m_currentFrame = this->d->m_testFrameAdapted;
this->d->m_mutex.unlock();
}
OSStatus AkVCam::Stream::copyBufferQueue(CMIODeviceStreamQueueAlteredProc queueAlteredProc,