[alsa-devel] [PATCH v5 1/2] amidi: add delay option

Felipe Ferreri Tonello eu at felipetonello.com
Tue Aug 23 12:10:21 CEST 2016


Hi Clemens,

On 22/08/16 13:43, Clemens Ladisch wrote:
> Felipe F. Tonello wrote:
>> +.I \-D, \-\-delay=mseconds
>> +Adds a delay in between each SysEx message sent to a device.
> 
>> +			while (data < (send_data + send_data_length)) {
>> +				int len = send_data + send_data_length - data;
>> +				char *temp;
>> +
>> +				if (data > send_data)
>> +					usleep(delay * 1000);
> 
> The MIDI data is sent asynchonously, so this delay is not _between_ messages.
> You'd have to add 320 µs for any byte not yet sent (I guess you have to use
> snd_rawmidi_status_get_avail() to find out how many have been sent).

Right. Or I can just use snd_rawmidi_drain()? Otherwise it will add too
much complexity.
> 
> 
>> +				/* find end of SysEx */
>> +				if ((temp = memchr(data, 0xf7, len)))
> 
> This would be clearer with "!= NULL".

Ok.

> 
>> +					len = temp - data + 1;
>> +
>> +				if ((err = snd_rawmidi_write(output, data, len)) < 0) {
>> +					error("cannot send data: %s", snd_strerror(err));
>> +					return err;
>> +				}
>> +
>> +				data += len;
>> +			}
>>  		}
>>  	}
> 

Thanks

-- 
Felipe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0x92698E6A.asc
Type: application/pgp-keys
Size: 7195 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20160823/baddffa0/attachment.bin>


More information about the Alsa-devel mailing list