/** *Registersourcesandworkitemstoaneventloop
*/ struct spa_loop_methods { /* the version of this structure. This can be used to expand this
* structure in the future */ #define SPA_VERSION_LOOP_METHODS 0
uint32_t version;
/** Add a source to the loop. Must be called from the loop's own thread. * *\param[in]objectThecallbacksdata. *\param[in]sourceThesource. *\return0onsuccess,negativeerrno-stylevalueonfailure.
*/ int (*add_source) (void *object, struct spa_source *source);
/** Update the source io mask. Must be called from the loop's own thread. * *\param[in]objectThecallbacksdata. *\param[in]sourceThesource. *\return0onsuccess,negativeerrno-stylevalueonfailure.
*/ int (*update_source) (void *object, struct spa_source *source);
/** Remove a source from the loop. Must be called from the loop's own thread. * *\param[in]objectThecallbacksdata. *\param[in]sourceThesource. *\return0onsuccess,negativeerrno-stylevalueonfailure.
*/ int (*remove_source) (void *object, struct spa_source *source);
/** Invoke a function in the context of this loop. *Maybecalledfromanythreadandmultiplethreadsatthesametime. *Ifcalledfromtheloop'sthread,allcallbackspreviouslyqueuedwith *invoke()willberunsynchronously,whichmightcauseunexpected *reentrancyproblems. * *\param[in]objectThecallbacksdata. *\paramfuncThefunctiontobeinvoked. *\paramseqAnopaquesequencenumber.Thiswillbemade *availabletofunc. *\param[in]dataDatathatwillbecopiedintotheinternalringbufferandmade *availabletofunc.Becausethisdataiscopied,itisokayto *passapointertoalocalvariable,butdonotpassapointerto *anobjectthathasidentity. *\paramsizeThesizeofdatatocopy. *\paramblockIf\true,donotreturnuntilfunchasbeencalled.Otherwise, *returnsimmediately.Passing\truedoesnotriskadeadlockbecause *thedatathreadisneverallowedtowaitonanyotherthread. *\paramuser_dataAnopaquepointerpassedtofunc. *\return`-EPIPE`iftheinternalringbufferfilledup, *ifblockis\false,0ifseqwasSPA_ID_INVALIDor *seqwiththeASYNCflagset
* or the return value of func otherwise. */ int (*invoke) (void *object,
spa_invoke_func_t func,
uint32_t seq, constvoid *data,
size_t size, bool block, void *user_data);
};
/** Control hooks. These hooks can't be removed from their *callbacksandmustberemovedfromasafeplace(whentheloop
* is not running or when it is locked). */ struct spa_loop_control_hooks { #define SPA_VERSION_LOOP_CONTROL_HOOKS 0
uint32_t version; /** Executed right before waiting for events. It is typically used to
* release locks. */ void (*before) (void *data); /** Executed right after waiting for events. It is typically used to
* reacquire locks. */ void (*after) (void *data);
};
/** *Controlaneventloop * *TheeventloopcontrolfunctionprovideAPItoruntheeventloop. * *Thebelow(pseudo)codeisaminimalexampleoutliningtheuseoftheloop *control: *\code{.c} *spa_loop_control_enter(loop); *while(running){ *spa_loop_control_iterate(loop,-1); *} *spa_loop_control_leave(loop); *\endcode * *Itisalsopossibletoaddthelooptoanexistingeventloopbyusingthe *spa_loop_control_get_fd()call.Thisfdwillbecomereadablewhenactivity *hasbeendetectedonthesourcesintheloop.spa_loop_control_iterate()with *a0timeoutshouldbecalledtoprocessthependingsources. * *spa_loop_control_enter()andspa_loop_control_leave()shouldbecalledonce *fromthethreadthatwillruntheiterate()function.
*/ struct spa_loop_control_methods { /* the version of this structure. This can be used to expand this
* structure in the future */ #define SPA_VERSION_LOOP_CONTROL_METHODS 1
uint32_t version;
/** get the loop fd *\paramobjectthecontroltoquery * *Getthefdofthisloopcontrol.Thisfdwillbereadablewhena *sourceintheloophasactivity.Theusershouldcalliterate() *witha0timeouttoscheduleoneiterationoftheloopanddispatch *thesources. *\returnthefdoftheloop
*/ int (*get_fd) (void *object);
/** Enter a loop *\paramobjectthecontrol * *Thisfunctionshouldbecalledbeforecallingiterateandis *typicallyusedtocapturethethreadthatthisloopwillrunin. *Itshouldideallybecalledoncefromthethreadthatwillrun *theloop.
*/ void (*enter) (void *object); /** Leave a loop *\paramobjectthecontrol * *Itshouldideallybecalledonceaftercallingiteratewhentheloop *willnolongerbeiteratedfromthethreadthatcalledenter().
*/ void (*leave) (void *object);
/** Perform one iteration of the loop. *\paramctrlthecontrol *\paramtimeoutanoptionaltimeoutinmilliseconds. *0fornotimeout,-1forinfinitetimeout. * *Thisfunctionwillblock *upto\atimeoutmillisecondsandthendispatchthefdswithactivity. *Thenumberofdispatchedfdsisreturned.
*/ int (*iterate) (void *object, int timeout);
/** Check context of the loop *\paramctrlthecontrol * *Thisfunctionwillcheckifthecurrentthreadiscurrentlythe *onethatdidtheentercall.Sinceversion1:1. * *returns1onsuccess,0ornegativeerrnovalueonerror.
*/ int (*check) (void *object);
};
/** *Createsourcesforaneventloop
*/ struct spa_loop_utils_methods { /* the version of this structure. This can be used to expand this
* structure in the future */ #define SPA_VERSION_LOOP_UTILS_METHODS 0
uint32_t version;
/** destroy a source allocated with this interface. This function *shouldonlybecalledwhentheloopisnotrunningorfromthe
* context of the running loop */ void (*destroy_source) (void *object, struct spa_source *source);
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.