Skip to content

Commit

Permalink
Merge pull request #825 from daschuer/midioverflow
Browse files Browse the repository at this point in the history
gracefull handle Midi overflow
  • Loading branch information
Be-ing committed Mar 3, 2021
2 parents b822174 + da870f0 commit 6a56345
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 57 deletions.
10 changes: 0 additions & 10 deletions src/controllers/midi/portmidicontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,6 @@ bool PortMidiController::poll() {
return false;
}

// Returns true if events are available or an error code.
PmError gotEvents = m_pInputDevice->poll();
if (gotEvents == FALSE) {
return false;
}
if (gotEvents < 0) {
qWarning() << "PortMidi error:" << Pm_GetErrorText(gotEvents);
return false;
}

int numEvents = m_pInputDevice->read(m_midiBuffer, MIXXX_PORTMIDI_BUFFER_LEN);

//qDebug() << "PortMidiController::poll()" << numEvents;
Expand Down
47 changes: 0 additions & 47 deletions src/test/portmidicontroller_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,23 +196,6 @@ TEST_F(PortMidiControllerTest, WriteSysex_Malformed) {
m_pController->sendSysexMsg(sysex, sysex.length());
};

TEST_F(PortMidiControllerTest, Poll_Read_NoInput) {
Sequence poll;
EXPECT_CALL(*m_mockInput, isOpen())
.WillRepeatedly(Return(true));
EXPECT_CALL(*m_mockInput, poll())
.InSequence(poll)
.WillOnce(Return((PmError)FALSE));
EXPECT_CALL(*m_mockInput, poll())
.InSequence(poll)
.WillOnce(Return((PmError)TRUE));
EXPECT_CALL(*m_mockInput, read(_, _))
.InSequence(poll)
.WillOnce(Return(0));

pollDevice();
pollDevice();
};

TEST_F(PortMidiControllerTest, Poll_Read_Basic) {
std::vector<PmEvent> messages;
Expand All @@ -222,9 +205,6 @@ TEST_F(PortMidiControllerTest, Poll_Read_Basic) {
Sequence read;
EXPECT_CALL(*m_mockInput, isOpen())
.WillRepeatedly(Return(true));
EXPECT_CALL(*m_mockInput, poll())
.InSequence(read)
.WillOnce(Return((PmError)TRUE));
EXPECT_CALL(*m_mockInput, read(NotNull(), _))
.InSequence(read)
.WillOnce(DoAll(SetArrayArgument<0>(messages.begin(), messages.end()),
Expand Down Expand Up @@ -260,9 +240,6 @@ TEST_F(PortMidiControllerTest, Poll_Read_SysExWithRealtime) {
Sequence read;
EXPECT_CALL(*m_mockInput, isOpen())
.WillRepeatedly(Return(true));
EXPECT_CALL(*m_mockInput, poll())
.InSequence(read)
.WillOnce(Return((PmError)TRUE));
EXPECT_CALL(*m_mockInput, read(NotNull(), _))
.InSequence(read)
.WillOnce(DoAll(SetArrayArgument<0>(messages.begin(), messages.end()),
Expand Down Expand Up @@ -295,9 +272,6 @@ TEST_F(PortMidiControllerTest, Poll_Read_SysEx) {
Sequence read;
EXPECT_CALL(*m_mockInput, isOpen())
.WillRepeatedly(Return(true));
EXPECT_CALL(*m_mockInput, poll())
.InSequence(read)
.WillOnce(Return((PmError)TRUE));
EXPECT_CALL(*m_mockInput, read(NotNull(), _))
.InSequence(read)
.WillOnce(DoAll(SetArrayArgument<0>(messages.begin(), messages.end()),
Expand Down Expand Up @@ -332,9 +306,6 @@ TEST_F(PortMidiControllerTest,
Sequence read;
EXPECT_CALL(*m_mockInput, isOpen())
.WillRepeatedly(Return(true));
EXPECT_CALL(*m_mockInput, poll())
.InSequence(read)
.WillOnce(Return((PmError)TRUE));
EXPECT_CALL(*m_mockInput, read(NotNull(), _))
.InSequence(read)
.WillOnce(DoAll(SetArrayArgument<0>(messages.begin(), messages.end()),
Expand All @@ -358,9 +329,6 @@ TEST_F(PortMidiControllerTest, Poll_Read_SysExInterrupted_FollowedByNormalMessag
Sequence read;
EXPECT_CALL(*m_mockInput, isOpen())
.WillRepeatedly(Return(true));
EXPECT_CALL(*m_mockInput, poll())
.InSequence(read)
.WillOnce(Return((PmError)TRUE));
EXPECT_CALL(*m_mockInput, read(NotNull(), _))
.InSequence(read)
.WillOnce(DoAll(SetArrayArgument<0>(messages.begin(), messages.end()),
Expand Down Expand Up @@ -396,9 +364,6 @@ TEST_F(PortMidiControllerTest, Poll_Read_SysExInterrupted_FollowedBySysExMessage
Sequence read;
EXPECT_CALL(*m_mockInput, isOpen())
.WillRepeatedly(Return(true));
EXPECT_CALL(*m_mockInput, poll())
.InSequence(read)
.WillOnce(Return((PmError)TRUE));
EXPECT_CALL(*m_mockInput, read(NotNull(), _))
.InSequence(read)
.WillOnce(DoAll(SetArrayArgument<0>(messages.begin(), messages.end()),
Expand Down Expand Up @@ -441,35 +406,23 @@ TEST_F(PortMidiControllerTest, Poll_Read_SysEx_BufferOverflow) {
.WillRepeatedly(Return(true));

// Poll 1 -- returns messages1.
EXPECT_CALL(*m_mockInput, poll())
.InSequence(read)
.WillOnce(Return((PmError)TRUE));
EXPECT_CALL(*m_mockInput, read(NotNull(), _))
.InSequence(read)
.WillOnce(DoAll(SetArrayArgument<0>(messages1.begin(), messages1.end()),
Return(messages1.size())));

// Poll 2 -- buffer overflow.
EXPECT_CALL(*m_mockInput, poll())
.InSequence(read)
.WillOnce(Return((PmError)TRUE));
EXPECT_CALL(*m_mockInput, read(NotNull(), _))
.InSequence(read)
.WillOnce(Return(pmBufferOverflow));

// Poll 3 -- returns messages2.
EXPECT_CALL(*m_mockInput, poll())
.InSequence(read)
.WillOnce(Return((PmError)TRUE));
EXPECT_CALL(*m_mockInput, read(NotNull(), _))
.InSequence(read)
.WillOnce(DoAll(SetArrayArgument<0>(messages2.begin(), messages2.end()),
Return(messages2.size())));

// Poll 4 -- returns messages3.
EXPECT_CALL(*m_mockInput, poll())
.InSequence(read)
.WillOnce(Return((PmError)TRUE));
EXPECT_CALL(*m_mockInput, read(NotNull(), _))
.InSequence(read)
.WillOnce(DoAll(SetArrayArgument<0>(messages3.begin(), messages3.end()),
Expand Down

0 comments on commit 6a56345

Please sign in to comment.