Skip to content

Commit

Permalink
Bug192 (#194)
Browse files Browse the repository at this point in the history
* fix Visual Studio builds (bug #192):

invent a new enum _event_type, add a new enum _event_type evtype member
to struct _event. do all the event type comparisons using the new evtype
member instead of do_event function pointer.

* added enum _event_type:ev_null (for bug #192)

* fix build (typo.)

* updated changelog for 0.4.3.

Note: Bug #192 happened because Visual Studio, as observed with version
2005 to 2017, optimized several identical empty functions into one, but
the code used function pointer comparisons which led to false positives
and crashes.
  • Loading branch information
sezero authored May 15, 2018
1 parent 6bcce33 commit da69848
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 73 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Requirements:
CHANGELOG

0.4.3
* Fixed Visual Studio optimized builds. (Bug #192, function pointer
issue.)
* Fixed a thinko in one of the buffer size checks added in v0.4.2.
* Fix possible out of bounds reads in sysex commands. (Bug #190).

Expand Down
49 changes: 49 additions & 0 deletions include/internal_midi.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,56 @@ struct _note {

struct _mdi;

enum _event_type {
ev_null = -1,
ev_midi_divisions,
ev_note_off,
ev_note_on,
ev_aftertouch,
ev_control_bank_select,
ev_control_data_entry_course,
ev_control_channel_volume,
ev_control_channel_balance,
ev_control_channel_pan,
ev_control_channel_expression,
ev_control_data_entry_fine,
ev_control_channel_hold,
ev_control_data_increment,
ev_control_data_decrement,
ev_control_non_registered_param_fine,
ev_control_non_registered_param_course,
ev_control_registered_param_fine,
ev_control_registered_param_course,
ev_control_channel_sound_off,
ev_control_channel_controllers_off,
ev_control_channel_notes_off,
ev_control_dummy,
ev_patch,
ev_channel_pressure,
ev_pitch,
ev_sysex_roland_drum_track,
ev_sysex_gm_reset,
ev_sysex_roland_reset,
ev_sysex_yamaha_reset,
ev_meta_endoftrack,
ev_meta_tempo,
ev_meta_timesignature,
ev_meta_keysignature,
ev_meta_sequenceno,
ev_meta_channelprefix,
ev_meta_portprefix,
ev_meta_smpteoffset,
ev_meta_text,
ev_meta_copyright,
ev_meta_trackname,
ev_meta_instrumentname,
ev_meta_lyric,
ev_meta_marker,
ev_meta_cuepoint
};

struct _event {
enum _event_type evtype;
void (*do_event)(struct _mdi *mdi, struct _event_data *data);
struct _event_data event_data;
uint32_t samples_to_next;
Expand Down
Loading

0 comments on commit da69848

Please sign in to comment.