Skip to content

Commit

Permalink
try to fix initialization of variables
Browse files Browse the repository at this point in the history
  • Loading branch information
gisogrimm committed May 14, 2024
1 parent f98a2df commit 95b06e8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions libtascar/src/alsamidicc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ void TASCAR::midi_ctl_t::service()
snd_seq_drop_input_buffer(seq);
snd_seq_drop_output(seq);
snd_seq_drop_output_buffer(seq);
snd_seq_event_t* ev;
snd_seq_event_t* ev = NULL;
while(run_service) {
// while( snd_seq_event_input_pending(seq,0) ){
while(snd_seq_event_input(seq, &ev) >= 0) {
if(ev->type == SND_SEQ_EVENT_CONTROLLER) {
if(ev && (ev->type == SND_SEQ_EVENT_CONTROLLER)) {
emit_event(ev->data.control.channel, ev->data.control.param,
ev->data.control.value);
}
if((ev->type == SND_SEQ_EVENT_NOTE) ||
(ev->type == SND_SEQ_EVENT_NOTEON) ||
(ev->type == SND_SEQ_EVENT_NOTEOFF)) {
if(ev && ((ev->type == SND_SEQ_EVENT_NOTE) ||
(ev->type == SND_SEQ_EVENT_NOTEON) ||
(ev->type == SND_SEQ_EVENT_NOTEOFF))) {
emit_event_note(ev->data.note.channel, ev->data.note.note,
ev->data.note.velocity);
}
Expand All @@ -104,6 +104,7 @@ TASCAR::midi_ctl_t::~midi_ctl_t()
void TASCAR::midi_ctl_t::send_midi(int channel, int param, int value)
{
snd_seq_event_t ev;
memset(&ev, 0, sizeof(ev));
snd_seq_ev_clear(&ev);
snd_seq_ev_set_source(&ev, port_out.port);
snd_seq_ev_set_subs(&ev);
Expand All @@ -120,6 +121,7 @@ void TASCAR::midi_ctl_t::send_midi(int channel, int param, int value)
void TASCAR::midi_ctl_t::send_midi_note(int channel, int param, int value)
{
snd_seq_event_t ev;
memset(&ev, 0, sizeof(ev));
snd_seq_ev_clear(&ev);
snd_seq_ev_set_source(&ev, port_out.port);
snd_seq_ev_set_subs(&ev);
Expand All @@ -137,6 +139,7 @@ void TASCAR::midi_ctl_t::connect_input(const std::string& src,
bool warn_on_fail)
{
snd_seq_addr_t sender;
memset(&sender, 0, sizeof(sender));
if(snd_seq_parse_address(seq, &sender, src.c_str()) == 0)
connect_input(sender.client, sender.port);
else {
Expand All @@ -151,6 +154,7 @@ void TASCAR::midi_ctl_t::connect_output(const std::string& src,
bool warn_on_fail)
{
snd_seq_addr_t sender;
memset(&sender, 0, sizeof(sender));
if(snd_seq_parse_address(seq, &sender, src.c_str()) == 0)
connect_output(sender.client, sender.port);
else {
Expand Down

0 comments on commit 95b06e8

Please sign in to comment.