comparison data/midi/rtmidi/RtMidi.cpp @ 1038:cc27f35aa75c cxx11

Introducing the signed 64-bit frame index type, and fixing build failures from inclusion of -Wconversion with -Werror. Not finished yet.
author Chris Cannam
date Tue, 03 Mar 2015 15:18:24 +0000
parents 59e7fe1b1003
children a68d407f9752
comparison
equal deleted inserted replaced
1037:bf0e5944289b 1038:cc27f35aa75c
833 time -= apiData->lastTime; 833 time -= apiData->lastTime;
834 apiData->lastTime = lastTime; 834 apiData->lastTime = lastTime;
835 if ( data->firstMessage == true ) 835 if ( data->firstMessage == true )
836 data->firstMessage = false; 836 data->firstMessage = false;
837 else 837 else
838 message.timeStamp = time * 0.000001; 838 message.timeStamp = double(time) * 0.000001;
839 } 839 }
840 840
841 snd_seq_free_event(ev); 841 snd_seq_free_event(ev);
842 if ( message.bytes.size() == 0 ) continue; 842 if ( message.bytes.size() == 0 ) continue;
843 843
945 error( RtError::INVALID_PARAMETER ); 945 error( RtError::INVALID_PARAMETER );
946 } 946 }
947 947
948 948
949 snd_seq_addr_t sender, receiver; 949 snd_seq_addr_t sender, receiver;
950 sender.client = snd_seq_port_info_get_client( pinfo ); 950 sender.client = (unsigned char)snd_seq_port_info_get_client( pinfo );
951 sender.port = snd_seq_port_info_get_port( pinfo ); 951 sender.port = (unsigned char)snd_seq_port_info_get_port( pinfo );
952 receiver.client = snd_seq_client_id( data->seq ); 952 receiver.client = (unsigned char)snd_seq_client_id( data->seq );
953 if ( data->vport < 0 ) { 953 if ( data->vport < 0 ) {
954 snd_seq_port_info_set_client( pinfo, 0 ); 954 snd_seq_port_info_set_client( pinfo, 0 );
955 snd_seq_port_info_set_port( pinfo, 0 ); 955 snd_seq_port_info_set_port( pinfo, 0 );
956 snd_seq_port_info_set_capability( pinfo, 956 snd_seq_port_info_set_capability( pinfo,
957 SND_SEQ_PORT_CAP_WRITE | 957 SND_SEQ_PORT_CAP_WRITE |
970 errorString_ = "RtMidiIn::openPort: ALSA error creating input port."; 970 errorString_ = "RtMidiIn::openPort: ALSA error creating input port.";
971 error( RtError::DRIVER_ERROR ); 971 error( RtError::DRIVER_ERROR );
972 } 972 }
973 } 973 }
974 974
975 receiver.port = data->vport; 975 receiver.port = (unsigned char)data->vport;
976 976
977 // Make subscription 977 // Make subscription
978 snd_seq_port_subscribe_malloc( &data->subscription ); 978 snd_seq_port_subscribe_malloc( &data->subscription );
979 snd_seq_port_subscribe_set_sender(data->subscription, &sender); 979 snd_seq_port_subscribe_set_sender(data->subscription, &sender);
980 snd_seq_port_subscribe_set_dest(data->subscription, &receiver); 980 snd_seq_port_subscribe_set_dest(data->subscription, &receiver);
1220 errorString_ = ost.str(); 1220 errorString_ = ost.str();
1221 error( RtError::INVALID_PARAMETER ); 1221 error( RtError::INVALID_PARAMETER );
1222 } 1222 }
1223 1223
1224 snd_seq_addr_t sender, receiver; 1224 snd_seq_addr_t sender, receiver;
1225 receiver.client = snd_seq_port_info_get_client( pinfo ); 1225 receiver.client = (unsigned char)snd_seq_port_info_get_client( pinfo );
1226 receiver.port = snd_seq_port_info_get_port( pinfo ); 1226 receiver.port = (unsigned char)snd_seq_port_info_get_port( pinfo );
1227 sender.client = snd_seq_client_id( data->seq ); 1227 sender.client = (unsigned char)snd_seq_client_id( data->seq );
1228 1228
1229 if ( data->vport < 0 ) { 1229 if ( data->vport < 0 ) {
1230 data->vport = snd_seq_create_simple_port( data->seq, portName.c_str(), 1230 data->vport = snd_seq_create_simple_port( data->seq, portName.c_str(),
1231 SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_SUBS_READ, 1231 SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_SUBS_READ,
1232 SND_SEQ_PORT_TYPE_MIDI_GENERIC ); 1232 SND_SEQ_PORT_TYPE_MIDI_GENERIC );
1234 errorString_ = "RtMidiOut::openPort: ALSA error creating output port."; 1234 errorString_ = "RtMidiOut::openPort: ALSA error creating output port.";
1235 error( RtError::DRIVER_ERROR ); 1235 error( RtError::DRIVER_ERROR );
1236 } 1236 }
1237 } 1237 }
1238 1238
1239 sender.port = data->vport; 1239 sender.port = (unsigned char)data->vport;
1240 1240
1241 // Make subscription 1241 // Make subscription
1242 snd_seq_port_subscribe_malloc( &data->subscription ); 1242 snd_seq_port_subscribe_malloc( &data->subscription );
1243 snd_seq_port_subscribe_set_sender(data->subscription, &sender); 1243 snd_seq_port_subscribe_set_sender(data->subscription, &sender);
1244 snd_seq_port_subscribe_set_dest(data->subscription, &receiver); 1244 snd_seq_port_subscribe_set_dest(data->subscription, &receiver);
1293 1293
1294 void RtMidiOut :: sendMessage( std::vector<unsigned char> *message ) 1294 void RtMidiOut :: sendMessage( std::vector<unsigned char> *message )
1295 { 1295 {
1296 int result; 1296 int result;
1297 AlsaMidiData *data = static_cast<AlsaMidiData *> (apiData_); 1297 AlsaMidiData *data = static_cast<AlsaMidiData *> (apiData_);
1298 unsigned int nBytes = message->size(); 1298 unsigned int nBytes = (unsigned int) message->size();
1299 if ( nBytes > data->bufferSize ) { 1299 if ( nBytes > data->bufferSize ) {
1300 data->bufferSize = nBytes; 1300 data->bufferSize = nBytes;
1301 result = snd_midi_event_resize_buffer ( data->coder, nBytes); 1301 result = snd_midi_event_resize_buffer ( data->coder, nBytes);
1302 if ( result != 0 ) { 1302 if ( result != 0 ) {
1303 errorString_ = "RtMidiOut::sendMessage: ALSA error resizing MIDI event buffer."; 1303 errorString_ = "RtMidiOut::sendMessage: ALSA error resizing MIDI event buffer.";
1311 } 1311 }
1312 } 1312 }
1313 1313
1314 snd_seq_event_t ev; 1314 snd_seq_event_t ev;
1315 snd_seq_ev_clear(&ev); 1315 snd_seq_ev_clear(&ev);
1316 snd_seq_ev_set_source(&ev, data->vport); 1316 snd_seq_ev_set_source(&ev, (unsigned char) data->vport);
1317 snd_seq_ev_set_subs(&ev); 1317 snd_seq_ev_set_subs(&ev);
1318 snd_seq_ev_set_direct(&ev); 1318 snd_seq_ev_set_direct(&ev);
1319 for ( unsigned int i=0; i<nBytes; i++ ) data->buffer[i] = message->at(i); 1319 for ( unsigned int i=0; i<nBytes; i++ ) data->buffer[i] = message->at(i);
1320 result = snd_midi_event_encode( data->coder, data->buffer, (long)nBytes, &ev ); 1320 result = (int) snd_midi_event_encode( data->coder, data->buffer, (long)nBytes, &ev );
1321 if ( result < (int)nBytes ) { 1321 if ( result < (int)nBytes ) {
1322 errorString_ = "RtMidiOut::sendMessage: event parsing error!"; 1322 errorString_ = "RtMidiOut::sendMessage: event parsing error!";
1323 error( RtError::WARNING ); 1323 error( RtError::WARNING );
1324 return; 1324 return;
1325 } 1325 }