It can be simplified, but then it wouldn't be as extensible It is customary in callback interfaces to be able to provide both a function pointer and a context, which is how I implemented it
The logging callback interface does not. Provide callback-specific context and so is less extensible Sent from my iPhone On 22 בספט 2011, at 20:45, Luca Barbato <[email protected]> wrote: > On 9/22/11 8:01 AM, Aviad Rozenhek wrote: > >> +static AVIOInterruptContext avio_interrupt_context_default = { >> + .should_interrupt = 0, >> + .interrupt_check = avio_interrupt_check_default, >> + .interrupt_mark = avio_interrupt_mark_default, >> + .interrupt_mark_all = avio_interrupt_mark_all_default, >> + .interrupt_close = NULL, >> +}; >> + >> +static AVIOInterruptContext* avio_interrupt_context >> =&avio_interrupt_context_default; >> + >> + >> +void avio_interrupt_set(AVIOInterruptContext* ctx) >> +{ >> + AVIOInterruptContext* old = avio_interrupt_context; >> + avio_interrupt_context = ctx? ctx :&avio_interrupt_context_default; >> + if(old->interrupt_close) >> + old->interrupt_close(old); >> +} >> + >> +int avio_interrupt_check(URLContext* h) >> +{ >> + return avio_interrupt_context->interrupt_check(avio_interrupt_context, >> h); >> +} >> + >> +void avio_interrupt_mark(URLContext* h) >> +{ >> + avio_interrupt_context->interrupt_mark(avio_interrupt_context, h); >> +} >> + >> +void avio_interrupt_mark_all(void) >> +{ >> + avio_interrupt_context->interrupt_mark_all(avio_interrupt_context); >> +} >> + > > looks a bit complex. what about doing the same way logging is done instead? > _______________________________________________ > libav-devel mailing list > [email protected] > https://lists.libav.org/mailman/listinfo/libav-devel _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
