mirror of
https://github.com/ndeadly/MissionControl
synced 2024-11-23 04:43:10 +00:00
btdrv-mitm: minor improvements to bluetooth::CircularBuffer
This commit is contained in:
parent
c5a5b1f456
commit
5519283cb3
2 changed files with 24 additions and 25 deletions
|
@ -22,7 +22,6 @@ namespace ams::bluetooth {
|
|||
std::strncpy(this->name, name, sizeof(this->name) - 1);
|
||||
this->_unk1 = 0;
|
||||
this->size = BLUETOOTH_CIRCBUFFER_SIZE;
|
||||
//os::InitializeSdkMutex(&this->mutex);
|
||||
this->isInitialized = true;
|
||||
}
|
||||
|
||||
|
@ -67,7 +66,7 @@ namespace ams::bluetooth {
|
|||
return -1;
|
||||
|
||||
std::scoped_lock lk(this->mutex);
|
||||
{
|
||||
|
||||
ON_SCOPE_EXIT {
|
||||
if (this->event)
|
||||
os::SignalEvent(this->event);
|
||||
|
@ -83,7 +82,6 @@ namespace ams::bluetooth {
|
|||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -113,7 +111,7 @@ namespace ams::bluetooth {
|
|||
}
|
||||
}
|
||||
|
||||
void *CircularBuffer::Read(void) {
|
||||
CircularBufferPacket *CircularBuffer::Read(void) {
|
||||
return this->_read();
|
||||
}
|
||||
|
||||
|
@ -124,7 +122,7 @@ namespace ams::bluetooth {
|
|||
if (this->readOffset == this->writeOffset)
|
||||
return -1;
|
||||
|
||||
CircularBufferPacket *packet = reinterpret_cast<CircularBufferPacket *>(&this->data[this->readOffset]);
|
||||
auto packet = reinterpret_cast<CircularBufferPacket *>(&this->data[this->readOffset]);
|
||||
u32 newOffset = this->readOffset + packet->header.size + sizeof(packet->header);
|
||||
|
||||
if (newOffset >= BLUETOOTH_CIRCBUFFER_SIZE)
|
||||
|
@ -161,7 +159,7 @@ namespace ams::bluetooth {
|
|||
}
|
||||
|
||||
u64 CircularBuffer::_write(u8 type, void *data, size_t size) {
|
||||
CircularBufferPacket *packet = reinterpret_cast<CircularBufferPacket *>(&this->data[this->writeOffset]);
|
||||
auto packet = reinterpret_cast<CircularBufferPacket *>(&this->data[this->writeOffset]);
|
||||
packet->header.type = type;
|
||||
packet->header.timestamp = os::GetSystemTick();
|
||||
packet->header.size = size;
|
||||
|
@ -192,7 +190,7 @@ namespace ams::bluetooth {
|
|||
this->size = newCapacity;
|
||||
}
|
||||
|
||||
void *CircularBuffer::_read(void) {
|
||||
CircularBufferPacket *CircularBuffer::_read(void) {
|
||||
if (this->isInitialized) {
|
||||
CircularBufferPacket *packet;
|
||||
u32 newOffset;
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
namespace ams::bluetooth {
|
||||
|
||||
enum CircularBufferType {
|
||||
CircularBufferType_HidReport = 0x1,
|
||||
CircularBufferType_Other,
|
||||
CircularBufferType_HidReport,
|
||||
CircularBufferType_Bluetooth,
|
||||
CircularBufferType_Ble,
|
||||
CircularBufferType_BleCore,
|
||||
|
@ -36,8 +37,8 @@ namespace ams::bluetooth {
|
|||
u64 GetWriteableSize(void);
|
||||
void SetWriteCompleteEvent(os::EventType *event);
|
||||
u64 Write(u8 type, void *data, size_t size);
|
||||
void DiscardOldPackets(u8 a1, u32 a2);
|
||||
void *Read(void);
|
||||
void DiscardOldPackets(u8 type, u32 ageLimit);
|
||||
CircularBufferPacket *Read(void);
|
||||
u64 Free(void);
|
||||
|
||||
private:
|
||||
|
@ -47,7 +48,7 @@ namespace ams::bluetooth {
|
|||
u32 _getReadOffset(void);
|
||||
u64 _write(u8 type, void *data, size_t size);
|
||||
void _updateUtilization(void);
|
||||
void *_read(void);
|
||||
CircularBufferPacket *_read(void);
|
||||
|
||||
os::SdkMutex mutex;
|
||||
os::EventType *event;
|
||||
|
|
Loading…
Reference in a new issue