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

Felipe Ferreri Tonello eu at felipetonello.com
Tue Aug 23 13:24:27 CEST 2016


Hi Clemens,

On 23/08/16 11:51, Clemens Ladisch wrote:
> Felipe Ferreri Tonello wrote:
>> On 23/08/16 11:37, Clemens Ladisch wrote:
>>> Felipe Ferreri Tonello wrote:
>>>> On 22/08/16 13:43, Clemens Ladisch wrote:
>>>>> Felipe F. Tonello wrote:
>>>>>> +				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()?
>>>
>>> This function not only drains the ALSA buffer, but also waits for the
>>> hardware FIFO to empty.  And most drivers do not implement this, in
>>> which case the framework just does a fixed wait of 50 ms, which would
>>> correspond to a FIFO size of 156 bytes.
>>
>> Ok, so does that mean that it is not safe to use drain()?
> 
> That additional 50 ms delay might be safe, but not what you want.

Ok.

BTW: Why 320 µs for any byte not yet sent?

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/a44be87f/attachment-0001.bin>


More information about the Alsa-devel mailing list