Skip to content

Commit

Permalink
[midi] Check if ports exist before closing them
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Jun 11, 2024
1 parent 24aebeb commit 0cab2c9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/ossia/dataflow/audio_port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ struct audio_port
audio_buffer_pool::set_channels(m_samples, other.channels());
for(std::size_t c = 0; c < other.channels(); c++)
{
channel(c) = other.channel(c);
const auto& src = other.channel(c);
channel(c).assign(src.begin(), src.end());
}
return *this;
}
Expand Down
4 changes: 3 additions & 1 deletion src/ossia/dataflow/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ void mix(const audio_vector& src_vec, audio_vector& sink_vec)
audio_buffer_pool::set_channels(sink_vec, channels);
for(std::size_t c = 0; c < channels; c++)
{
sink_vec[c] = src_vec[c];
const auto& src = src_vec[c];
sink_vec[c].assign(src.begin(), src.end());
}
return;
}
Expand Down Expand Up @@ -215,6 +216,7 @@ void audio_buffer_pool::set_channels(audio_vector& samples, std::size_t channels
{
auto chan = std::move(samples.back());
chan.clear();

pool.release(std::move(chan));
samples.pop_back();
}
Expand Down
6 changes: 4 additions & 2 deletions src/ossia/protocols/midi/midi_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ bool midi_protocol::set_info(midi_info m)
// Close current ports
if(m_info.type == midi_info::Type::Input)
{
m_input->close_port();
if(m_input)
m_input->close_port();
}
else if(m_info.type == midi_info::Type::Output)
{
m_output->close_port();
if(m_output)
m_output->close_port();
}

m_info = m;
Expand Down

0 comments on commit 0cab2c9

Please sign in to comment.