diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bluetooth/android/inputstreamthread.cpp | 10 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothsocket_bluez.cpp | 12 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothsocket_macos.mm | 16 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothsocket_winrt.cpp | 40 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothsocketbase_p.h | 2 |
5 files changed, 40 insertions, 40 deletions
diff --git a/src/bluetooth/android/inputstreamthread.cpp b/src/bluetooth/android/inputstreamthread.cpp index 5d20d5ed..2bdce684 100644 --- a/src/bluetooth/android/inputstreamthread.cpp +++ b/src/bluetooth/android/inputstreamthread.cpp @@ -74,21 +74,21 @@ bool InputStreamThread::run() qint64 InputStreamThread::bytesAvailable() const { QMutexLocker locker(&m_mutex); - return m_socket_p->buffer.size(); + return m_socket_p->rxBuffer.size(); } bool InputStreamThread::canReadLine() const { QMutexLocker locker(&m_mutex); - return m_socket_p->buffer.canReadLine(); + return m_socket_p->rxBuffer.canReadLine(); } qint64 InputStreamThread::readData(char *data, qint64 maxSize) { QMutexLocker locker(&m_mutex); - if (!m_socket_p->buffer.isEmpty()) - return m_socket_p->buffer.read(data, maxSize); + if (!m_socket_p->rxBuffer.isEmpty()) + return m_socket_p->rxBuffer.read(data, maxSize); return 0; } @@ -110,7 +110,7 @@ void InputStreamThread::javaReadyRead(jbyteArray buffer, int bufferLength) QJniEnvironment env; QMutexLocker lock(&m_mutex); - char *writePtr = m_socket_p->buffer.reserve(bufferLength); + char *writePtr = m_socket_p->rxBuffer.reserve(bufferLength); env->GetByteArrayRegion(buffer, 0, bufferLength, reinterpret_cast<jbyte*>(writePtr)); emit dataAvailable(); } diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp index 8b83442b..6110d25b 100644 --- a/src/bluetooth/qbluetoothsocket_bluez.cpp +++ b/src/bluetooth/qbluetoothsocket_bluez.cpp @@ -371,10 +371,10 @@ void QBluetoothSocketPrivateBluez::_q_writeNotify() void QBluetoothSocketPrivateBluez::_q_readNotify() { Q_Q(QBluetoothSocket); - char *writePointer = buffer.reserve(QPRIVATELINEARBUFFER_BUFFERSIZE); + char *writePointer = rxBuffer.reserve(QPRIVATELINEARBUFFER_BUFFERSIZE); // qint64 readFromDevice = q->readData(writePointer, QPRIVATELINEARBUFFER_BUFFERSIZE); int readFromDevice = ::read(socket, writePointer, QPRIVATELINEARBUFFER_BUFFERSIZE); - buffer.chop(QPRIVATELINEARBUFFER_BUFFERSIZE - (readFromDevice < 0 ? 0 : readFromDevice)); + rxBuffer.chop(QPRIVATELINEARBUFFER_BUFFERSIZE - (readFromDevice < 0 ? 0 : readFromDevice)); if(readFromDevice <= 0){ int errsv = errno; readNotifier->setEnabled(false); @@ -611,8 +611,8 @@ qint64 QBluetoothSocketPrivateBluez::readData(char *data, qint64 maxSize) return -1; } - if (!buffer.isEmpty()) { - int i = buffer.read(data, maxSize); + if (!rxBuffer.isEmpty()) { + int i = rxBuffer.read(data, maxSize); return i; } @@ -660,7 +660,7 @@ bool QBluetoothSocketPrivateBluez::setSocketDescriptor(int socketDescriptor, QBl qint64 QBluetoothSocketPrivateBluez::bytesAvailable() const { - return buffer.size(); + return rxBuffer.size(); } qint64 QBluetoothSocketPrivateBluez::bytesToWrite() const @@ -670,7 +670,7 @@ qint64 QBluetoothSocketPrivateBluez::bytesToWrite() const bool QBluetoothSocketPrivateBluez::canReadLine() const { - return buffer.canReadLine(); + return rxBuffer.canReadLine(); } QT_END_NAMESPACE diff --git a/src/bluetooth/qbluetoothsocket_macos.mm b/src/bluetooth/qbluetoothsocket_macos.mm index 993fc57f..89e7701e 100644 --- a/src/bluetooth/qbluetoothsocket_macos.mm +++ b/src/bluetooth/qbluetoothsocket_macos.mm @@ -214,20 +214,20 @@ qint64 QBluetoothSocketPrivate::readData(char *data, qint64 maxSize) return -1; } - if (!buffer.isEmpty()) - return buffer.read(data, int(maxSize)); + if (!rxBuffer.isEmpty()) + return rxBuffer.read(data, int(maxSize)); return 0; } qint64 QBluetoothSocketPrivate::bytesAvailable() const { - return buffer.size(); + return rxBuffer.size(); } bool QBluetoothSocketPrivate::canReadLine() const { - return buffer.canReadLine(); + return rxBuffer.canReadLine(); } qint64 QBluetoothSocketPrivate::bytesToWrite() const @@ -349,7 +349,7 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address, socketError = QBluetoothSocket::SocketError::NoSocketError; errorString.clear(); - buffer.clear(); + rxBuffer.clear(); txBuffer.clear(); IOReturn status = kIOReturnError; @@ -393,12 +393,12 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address, q_ptr->setOpenMode(openMode); q_ptr->setSocketState(QBluetoothSocket::SocketState::ConnectedState); emit q_ptr->connected(); - if (buffer.size()) // We also have some data already ... + if (rxBuffer.size()) // We also have some data already ... emit q_ptr->readyRead(); } else if (state == QBluetoothSocket::SocketState::UnconnectedState) { // Even if we have some data, we can not read it if // state != ConnectedState. - buffer.clear(); + rxBuffer.clear(); state = oldState; q_ptr->setSocketError(QBluetoothSocket::SocketError::UnknownSocketError); } else { @@ -553,7 +553,7 @@ void QBluetoothSocketPrivate::readChannelData(void *data, std::size_t size) Q_ASSERT_X(q_ptr, Q_FUNC_INFO, "invalid q_ptr (null)"); const char *src = static_cast<char *>(data); - char *dst = buffer.reserve(int(size)); + char *dst = rxBuffer.reserve(int(size)); std::copy(src, src + size, dst); if (!isConnecting) { diff --git a/src/bluetooth/qbluetoothsocket_winrt.cpp b/src/bluetooth/qbluetoothsocket_winrt.cpp index 8fcc3e2c..7fe6d91d 100644 --- a/src/bluetooth/qbluetoothsocket_winrt.cpp +++ b/src/bluetooth/qbluetoothsocket_winrt.cpp @@ -96,25 +96,25 @@ static inline QString qt_QStringFromHString(const HString &string) static qint64 writeIOStream(ComPtr<IOutputStream> stream, const char *data, qint64 len) { - ComPtr<IBuffer> buffer; + ComPtr<IBuffer> tempBuffer; if (len > UINT32_MAX) { qCWarning(QT_BT_WINDOWS) << "writeIOStream can only write up to" << UINT32_MAX << "bytes."; len = UINT32_MAX; } quint32 ulen = static_cast<quint32>(len); - HRESULT hr = g->bufferFactory->Create(ulen, &buffer); + HRESULT hr = g->bufferFactory->Create(ulen, &tempBuffer); Q_ASSERT_SUCCEEDED(hr); - hr = buffer->put_Length(ulen); + hr = tempBuffer->put_Length(ulen); Q_ASSERT_SUCCEEDED(hr); ComPtr<Windows::Storage::Streams::IBufferByteAccess> byteArrayAccess; - hr = buffer.As(&byteArrayAccess); + hr = tempBuffer.As(&byteArrayAccess); Q_ASSERT_SUCCEEDED(hr); byte *bytes; hr = byteArrayAccess->Buffer(&bytes); Q_ASSERT_SUCCEEDED(hr); memcpy(bytes, data, ulen); ComPtr<IAsyncOperationWithProgress<UINT32, UINT32>> op; - hr = stream->WriteAsync(buffer.Get(), &op); + hr = stream->WriteAsync(tempBuffer.Get(), &op); RETURN_IF_FAILED("Failed to write to stream", return -1); UINT32 bytesWritten; hr = QWinRTFunctions::await(op, &bytesWritten); @@ -181,13 +181,13 @@ public slots: public: void startReading() { - ComPtr<IBuffer> buffer; - HRESULT hr = g->bufferFactory->Create(READ_BUFFER_SIZE, &buffer); + ComPtr<IBuffer> tempBuffer; + HRESULT hr = g->bufferFactory->Create(READ_BUFFER_SIZE, &tempBuffer); Q_ASSERT_SUCCEEDED(hr); ComPtr<IInputStream> stream; hr = m_socket->get_InputStream(&stream); Q_ASSERT_SUCCEEDED(hr); - hr = stream->ReadAsync(buffer.Get(), READ_BUFFER_SIZE, InputStreamOptions_Partial, m_initialReadOp.GetAddressOf()); + hr = stream->ReadAsync(tempBuffer.Get(), READ_BUFFER_SIZE, InputStreamOptions_Partial, m_initialReadOp.GetAddressOf()); Q_ASSERT_SUCCEEDED(hr); hr = m_initialReadOp->put_Completed(Callback<SocketReadCompletedHandler>(this, &SocketWorker::onReadyRead).Get()); Q_ASSERT_SUCCEEDED(hr); @@ -214,8 +214,8 @@ public: return S_OK; } - ComPtr<IBuffer> buffer; - HRESULT hr = asyncInfo->GetResults(&buffer); + ComPtr<IBuffer> tempBuffer; + HRESULT hr = asyncInfo->GetResults(&tempBuffer); if (FAILED(hr)) { qErrnoWarning(hr, "Failed to get read results buffer"); emit socketErrorOccured(QBluetoothSocket::SocketError::UnknownSocketError); @@ -223,7 +223,7 @@ public: } UINT32 bufferLength; - hr = buffer->get_Length(&bufferLength); + hr = tempBuffer->get_Length(&bufferLength); if (FAILED(hr)) { qErrnoWarning(hr, "Failed to get buffer length"); emit socketErrorOccured(QBluetoothSocket::SocketError::UnknownSocketError); @@ -239,7 +239,7 @@ public: } ComPtr<Windows::Storage::Streams::IBufferByteAccess> byteArrayAccess; - hr = buffer.As(&byteArrayAccess); + hr = tempBuffer.As(&byteArrayAccess); if (FAILED(hr)) { qErrnoWarning(hr, "Failed to get cast buffer"); emit socketErrorOccured(QBluetoothSocket::SocketError::UnknownSocketError); @@ -270,20 +270,20 @@ public: } // Reuse the stream buffer - hr = buffer->get_Capacity(&readBufferLength); + hr = tempBuffer->get_Capacity(&readBufferLength); if (FAILED(hr)) { qErrnoWarning(hr, "Failed to get buffer capacity"); emit socketErrorOccured(QBluetoothSocket::SocketError::UnknownSocketError); return S_OK; } - hr = buffer->put_Length(0); + hr = tempBuffer->put_Length(0); if (FAILED(hr)) { qErrnoWarning(hr, "Failed to set buffer length"); emit socketErrorOccured(QBluetoothSocket::SocketError::UnknownSocketError); return S_OK; } - hr = stream->ReadAsync(buffer.Get(), readBufferLength, InputStreamOptions_Partial, &m_readOp); + hr = stream->ReadAsync(tempBuffer.Get(), readBufferLength, InputStreamOptions_Partial, &m_readOp); if (FAILED(hr)) { qErrnoWarning(hr, "onReadyRead(): Could not read into socket stream buffer."); emit socketErrorOccured(QBluetoothSocket::SocketError::UnknownSocketError); @@ -689,10 +689,10 @@ qint64 QBluetoothSocketPrivateWinRT::readData(char *data, qint64 maxSize) return -1; } - if (!buffer.isEmpty()) { + if (!rxBuffer.isEmpty()) { if (maxSize > INT_MAX) maxSize = INT_MAX; - return buffer.read(data, int(maxSize)); + return rxBuffer.read(data, int(maxSize)); } return 0; @@ -733,7 +733,7 @@ bool QBluetoothSocketPrivateWinRT::setSocketDescriptor(ComPtr<IStreamSocket> soc qint64 QBluetoothSocketPrivateWinRT::bytesAvailable() const { - return buffer.size(); + return rxBuffer.size(); } qint64 QBluetoothSocketPrivateWinRT::bytesToWrite() const @@ -743,7 +743,7 @@ qint64 QBluetoothSocketPrivateWinRT::bytesToWrite() const bool QBluetoothSocketPrivateWinRT::canReadLine() const { - return buffer.canReadLine(); + return rxBuffer.canReadLine(); } void QBluetoothSocketPrivateWinRT::handleNewData(const QList<QByteArray> &data) @@ -783,7 +783,7 @@ void QBluetoothSocketPrivateWinRT::addToPendingData(const QList<QByteArray> &dat QMutexLocker locker(&m_readMutex); m_pendingData.append(data); for (const QByteArray &newData : data) { - char *writePointer = buffer.reserve(newData.length()); + char *writePointer = rxBuffer.reserve(newData.length()); memcpy(writePointer, newData.data(), size_t(newData.length())); } locker.unlock(); diff --git a/src/bluetooth/qbluetoothsocketbase_p.h b/src/bluetooth/qbluetoothsocketbase_p.h index 80b905dc..b50f9437 100644 --- a/src/bluetooth/qbluetoothsocketbase_p.h +++ b/src/bluetooth/qbluetoothsocketbase_p.h @@ -148,7 +148,7 @@ public: #endif public: - QPrivateLinearBuffer buffer; + QPrivateLinearBuffer rxBuffer; QPrivateLinearBuffer txBuffer; int socket = -1; QBluetoothServiceInfo::Protocol socketType = QBluetoothServiceInfo::UnknownProtocol; |