Skip to content

Commit

Permalink
Moved the adata buffer into the object itself, fill with 0. Rename to…
Browse files Browse the repository at this point in the history
… buffer.
  • Loading branch information
davidmoreno committed Oct 17, 2024
1 parent 8d0231a commit 060866f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/local_rawmidi_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ using namespace rtpmididns;
local_rawmidi_peer_t::local_rawmidi_peer_t(const std::string &name_,
const std::string &device_)
: device(device_), name(name_) {
buffer.fill(0);
INFO("Creating rawmidi peer=\"{}\", device={}", name, device);
fd = open(device.c_str(), O_RDWR | O_NONBLOCK);
if (fd < 0) {
Expand Down Expand Up @@ -89,13 +90,12 @@ void local_rawmidi_peer_t::read_midi() {
if (fd < 0) {
return;
}
std::array<uint8_t, 1024> adata;
ssize_t count = read(fd, adata.data(), adata.size());
ssize_t count = read(fd, buffer.data(), buffer.size());

if (count <= 0) {
return;
}
rtpmidid::packet_t packet(adata.begin(), (uint32_t)count);
rtpmidid::packet_t packet(buffer.begin(), (uint32_t)count);

// FIXME: Even if received several message in the stream, send one by one.
// Maybe would be better send full packets, but would need some stack space or
Expand Down
1 change: 1 addition & 0 deletions src/local_rawmidi_peer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class local_rawmidi_peer_t : public midipeer_t {
int fd = -1;
rtpmidid::poller_t::listener_t fd_listener;
midi_normalizer_t midi_normalizer;
std::array<uint8_t, 1024> buffer;

local_rawmidi_peer_t(const std::string &name, const std::string &device);
~local_rawmidi_peer_t() override;
Expand Down

0 comments on commit 060866f

Please sign in to comment.