Re: [AD] ALSA RawMIDI fixes

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Fri, 2007-02-02 at 02:12 +1100, Peter Wang wrote:
> Hi,
> 
> I noticed some behaviour in the ALSA rawmidi driver, which I think is wrong.
> The alsa_rawmidi_output() method currently puts a detailed error message into
> allegro_error when the call to snd_rawmidi_write() fails.  However, this
> method is probably most often called from a timer interrupt, due to
> play_midi().  The user might call some Allegro function and expect an error
> message to be put in allegro_error, only to have it clobbered by the MIDI
> playback running in the background.  Therefore I think it's best not to
> modify allegro_error in alsa_rawmidi_output().
> 
> Also, if the ALSA MIDI driver is active but the user hasn't configured ALSA
> properly, then the snd_rawmidi_write() will fail constantly.  The code that
> sets allegro_error was non-trivial and causes the timer thread take up more
> and more CPU time, eventually choking the main thread.  I've added code that
> counts the number of times that snd_rawmidi_write() fails.  Once it fails
> more than three times, we don't bother calling it any more.  It probably
> not necessary after the previous change, but it saves some useless system
> calls.
> 
> Okay?
> 

Sounds good to me.

I also noticed how oprofile always has an entry like this quite far up:

5.6421 libasound.so.2.0.0

So about 5% of my Allegro programs are spent in libasound. I guess this
is normal though. (And I always use MIDI_NONE or DIGMID for the midi
parameter, so likely it's completely unrelated.)

-- 
Elias Pschernig





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/