Added more error messages.

This commit is contained in:
Gonzalo Exequiel Pedone 2020-10-02 17:20:08 -03:00
parent bd5e1d4e94
commit d96eb195b6
No known key found for this signature in database
GPG key ID: B8B09E63E9B85BAF
2 changed files with 18 additions and 4 deletions

View file

@ -577,15 +577,21 @@ bool AkVCam::IpcBridge::deviceStart(const std::string &deviceId,
UNUSED(format); UNUSED(format);
AkLogFunction(); AkLogFunction();
if (!this->d->m_serverMessagePort) if (!this->d->m_serverMessagePort) {
AkLogError() << "Service not ready." << std::endl;
return false; return false;
}
auto it = std::find(this->d->m_broadcasting.begin(), auto it = std::find(this->d->m_broadcasting.begin(),
this->d->m_broadcasting.end(), this->d->m_broadcasting.end(),
deviceId); deviceId);
if (it != this->d->m_broadcasting.end()) if (it != this->d->m_broadcasting.end()) {
AkLogError() << '\'' << deviceId << "' is busy." << std::endl;
return false; return false;
}
auto dictionary = xpc_dictionary_create(nullptr, nullptr, 0); auto dictionary = xpc_dictionary_create(nullptr, nullptr, 0);
xpc_dictionary_set_int64(dictionary, "message", AKVCAM_ASSISTANT_MSG_DEVICE_SETBROADCASTING); xpc_dictionary_set_int64(dictionary, "message", AKVCAM_ASSISTANT_MSG_DEVICE_SETBROADCASTING);
@ -597,6 +603,7 @@ bool AkVCam::IpcBridge::deviceStart(const std::string &deviceId,
auto replyType = xpc_get_type(reply); auto replyType = xpc_get_type(reply);
if (replyType != XPC_TYPE_DICTIONARY) { if (replyType != XPC_TYPE_DICTIONARY) {
AkLogError() << "Invalid reply received." << std::endl;
xpc_release(reply); xpc_release(reply);
return false; return false;

View file

@ -598,8 +598,11 @@ bool AkVCam::IpcBridge::deviceStart(const std::string &deviceId,
this->d->m_broadcasting.end(), this->d->m_broadcasting.end(),
deviceId); deviceId);
if (it != this->d->m_broadcasting.end()) if (it != this->d->m_broadcasting.end()) {
AkLogError() << '\'' << deviceId << "' is busy." << std::endl;
return false; return false;
}
std::wstring portName(this->d->m_portName.begin(), std::wstring portName(this->d->m_portName.begin(),
this->d->m_portName.end()); this->d->m_portName.end());
@ -607,8 +610,11 @@ bool AkVCam::IpcBridge::deviceStart(const std::string &deviceId,
this->d->m_globalMutex = Mutex(portName + L".mutex"); this->d->m_globalMutex = Mutex(portName + L".mutex");
if (!this->d->m_sharedMemory.open(maxBufferSize, if (!this->d->m_sharedMemory.open(maxBufferSize,
SharedMemory::OpenModeWrite)) SharedMemory::OpenModeWrite)) {
AkLogError() << "Can't open shared memory for writing." << std::endl;
return false; return false;
}
Message message; Message message;
message.messageId = AKVCAM_ASSISTANT_MSG_DEVICE_SETBROADCASTING; message.messageId = AKVCAM_ASSISTANT_MSG_DEVICE_SETBROADCASTING;
@ -622,6 +628,7 @@ bool AkVCam::IpcBridge::deviceStart(const std::string &deviceId,
(std::min<size_t>)(this->d->m_portName.size(), MAX_STRING)); (std::min<size_t>)(this->d->m_portName.size(), MAX_STRING));
if (!this->d->m_mainServer.sendMessage(&message)) { if (!this->d->m_mainServer.sendMessage(&message)) {
AkLogError() << "Error sending message." << std::endl;
this->d->m_sharedMemory.close(); this->d->m_sharedMemory.close();
return false; return false;