Re: [AD] audio recording

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


On Sat, 7 Jan 2012 13:16:41 -0600, Matthew Leverton <meffer@xxxxxxxxxx> wrote:
> On Sat, Jan 7, 2012 at 8:07 AM, Elias Pschernig <allefant@xxxxxxxxxx> wrote:
> > keycode = ALLEGRO_KEYBOARD_EVENT(event).keycode;
> >
> That might be the best way. The main disadvantage that I see is it
> gets a little confusing having:
> 
> ALLEGRO_EVENT_FOO (enum) and ALLEGRO_FOO_EVENT (struct)
> 
> Obviously the enumerations are going to be slightly more verbose than
> the struct name, but the placement of the EVENT portion still feels
> arbitrary.
> 
> It could just be written as a function:
> 
> ALLEGRO_AUDIO_EVENT *audio = al_get_audio_event(&e);
> memcpy(foo, audio->buffer, audio->buffer_len);
> 
> Compilers should optimize it away to nothing, I would think. In debug
> mode, it could assert that the type is correct.

Unless you make it an inline function it won't be optimised away,
but it really doesn't matter.

So I agree with using the casting functions.  You can add
runtime assertions in debug modes, too.

> The same sort of thing could be added for the first class events,
> although I'd probably still just use event.keyboard.keycode out of
> convenience.

Yeah, I don't really see the point.

Peter




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