projects
/
ardour.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into cairocanvas
[ardour.git]
/
libs
/
evoral
/
src
/
libsmf
/
smf_load.c
diff --git
a/libs/evoral/src/libsmf/smf_load.c
b/libs/evoral/src/libsmf/smf_load.c
index f27d092a8b52d1e038ee46b468eb0202860e46b0..d8168d0e6ada0edfea142a8471b9f14ed824e646 100644
(file)
--- a/
libs/evoral/src/libsmf/smf_load.c
+++ b/
libs/evoral/src/libsmf/smf_load.c
@@
-40,7
+40,11
@@
#include <math.h>
#include <errno.h>
#include <ctype.h>
#include <math.h>
#include <errno.h>
#include <ctype.h>
+#ifdef PLATFORM_WINDOWS
+#include <winsock2.h>
+#else
#include <arpa/inet.h>
#include <arpa/inet.h>
+#endif
#include "smf.h"
#include "smf_private.h"
#include "smf.h"
#include "smf_private.h"
@@
-119,7
+123,7
@@
parse_mthd_header(smf_t *smf)
return (-1);
}
return (-1);
}
- tmp_mthd = smf->file_buffer;
+ tmp_mthd =
(struct chunk_header_struct*)
smf->file_buffer;
if (!chunk_signature_matches(tmp_mthd, "MThd")) {
g_critical("SMF error: MThd signature not found, is that a MIDI file?");
if (!chunk_signature_matches(tmp_mthd, "MThd")) {
g_critical("SMF error: MThd signature not found, is that a MIDI file?");
@@
-278,7
+282,11
@@
expected_sysex_length(const unsigned char status, const unsigned char *second_by
uint32_t sysex_length = 0;
uint32_t len = 0;
uint32_t sysex_length = 0;
uint32_t len = 0;
+#ifndef NDEBUG
+ (void) status;
+#else
assert(status == 0xF0);
assert(status == 0xF0);
+#endif
if (buffer_length < 3) {
g_critical("SMF error: end of buffer in expected_sysex_length().");
if (buffer_length < 3) {
g_critical("SMF error: end of buffer in expected_sysex_length().");
@@
-405,7
+413,7
@@
extract_sysex_event(const unsigned char *buf, const size_t buffer_length, smf_ev
}
event->midi_buffer_length = message_length;
}
event->midi_buffer_length = message_length;
- event->midi_buffer = malloc(event->midi_buffer_length);
+ event->midi_buffer =
(uint8_t*)
malloc(event->midi_buffer_length);
if (event->midi_buffer == NULL) {
g_critical("Cannot allocate memory in extract_sysex_event(): %s", strerror(errno));
return (-4);
if (event->midi_buffer == NULL) {
g_critical("Cannot allocate memory in extract_sysex_event(): %s", strerror(errno));
return (-4);
@@
-448,7
+456,7
@@
extract_escaped_event(const unsigned char *buf, const size_t buffer_length, smf_
}
event->midi_buffer_length = message_length;
}
event->midi_buffer_length = message_length;
- event->midi_buffer = malloc(event->midi_buffer_length);
+ event->midi_buffer =
(uint8_t*)
malloc(event->midi_buffer_length);
if (event->midi_buffer == NULL) {
g_critical("Cannot allocate memory in extract_escaped_event(): %s", strerror(errno));
return (-4);
if (event->midi_buffer == NULL) {
g_critical("Cannot allocate memory in extract_escaped_event(): %s", strerror(errno));
return (-4);
@@
-518,7
+526,7
@@
extract_midi_event(const unsigned char *buf, const size_t buffer_length, smf_eve
}
event->midi_buffer_length = message_length;
}
event->midi_buffer_length = message_length;
- event->midi_buffer = malloc(event->midi_buffer_length);
+ event->midi_buffer =
(uint8_t*)
malloc(event->midi_buffer_length);
if (event->midi_buffer == NULL) {
g_critical("Cannot allocate memory in extract_midi_event(): %s", strerror(errno));
return (-4);
if (event->midi_buffer == NULL) {
g_critical("Cannot allocate memory in extract_midi_event(): %s", strerror(errno));
return (-4);
@@
-541,7
+549,7
@@
extract_midi_event(const unsigned char *buf, const size_t buffer_length, smf_eve
static smf_event_t *
parse_next_event(smf_track_t *track)
{
static smf_event_t *
parse_next_event(smf_track_t *track)
{
- uint32_t time = 0;
+ uint32_t
e
time = 0;
uint32_t len;
size_t buffer_length;
unsigned char *c, *start;
uint32_t len;
size_t buffer_length;
unsigned char *c, *start;
@@
-560,7
+568,7
@@
parse_next_event(smf_track_t *track)
assert(buffer_length > 0);
/* First, extract time offset from previous event. */
assert(buffer_length > 0);
/* First, extract time offset from previous event. */
- if (smf_extract_vlq(c, buffer_length, &time, &len))
+ if (smf_extract_vlq(c, buffer_length, &
e
time, &len))
goto error;
c += len;
goto error;
c += len;
@@
-578,7
+586,7
@@
parse_next_event(smf_track_t *track)
track->last_status = event->midi_buffer[0];
track->next_event_offset += c - start;
track->last_status = event->midi_buffer[0];
track->next_event_offset += c - start;
- smf_track_add_event_delta_pulses(track, event, time);
+ smf_track_add_event_delta_pulses(track, event,
e
time);
return (event);
return (event);
@@
-607,7
+615,7
@@
make_string(const unsigned char *buf, const size_t buffer_length, uint32_t len)
len = buffer_length;
}
len = buffer_length;
}
- str = malloc(len + 1);
+ str =
(char*)
malloc(len + 1);
if (str == NULL) {
g_critical("Cannot allocate memory in make_string().");
return (NULL);
if (str == NULL) {
g_critical("Cannot allocate memory in make_string().");
return (NULL);
@@
-658,14
+666,14
@@
smf_event_extract_text(const smf_event_t *event)
return (NULL);
}
return (NULL);
}
- smf_extract_vlq((void *)&(event->midi_buffer[2]), event->midi_buffer_length - 2, &string_length, &length_length);
+ smf_extract_vlq((
const unsigned char*)(
void *)&(event->midi_buffer[2]), event->midi_buffer_length - 2, &string_length, &length_length);
if (string_length <= 0) {
g_critical("smf_event_extract_text: truncated MIDI message.");
return (NULL);
}
if (string_length <= 0) {
g_critical("smf_event_extract_text: truncated MIDI message.");
return (NULL);
}
- return (make_string((void *)(&event->midi_buffer[2] + length_length), event->midi_buffer_length - 2 - length_length, string_length));
+ return (make_string((
const unsigned char*)(
void *)(&event->midi_buffer[2] + length_length), event->midi_buffer_length - 2 - length_length, string_length));
}
/**
}
/**