/** \enum pw_stream_state The state of a stream */ enum pw_stream_state {
PW_STREAM_STATE_ERROR = -1, /**< the stream is in error */
PW_STREAM_STATE_UNCONNECTED = 0, /**< unconnected */
PW_STREAM_STATE_CONNECTING = 1, /**< connection is in progress */
PW_STREAM_STATE_PAUSED = 2, /**< paused */
PW_STREAM_STATE_STREAMING = 3/**< streaming */
};
/** a buffer structure obtained from pw_stream_dequeue_buffer(). The size of this
* structure can grow as more fields are added in the future */ struct pw_buffer { struct spa_buffer *buffer; /**< the spa buffer */ void *user_data; /**< user data attached to the buffer. The user of *thestreamcansetcustomdataassociatedwiththe *buffer,typicallyintheadd_bufferevent.Any *cleanupshouldbeperformedintheremove_buffer *event.Theuserdataisreturnedunmodifiedeach
* time a buffer is dequeued. */
uint64_t size; /**< This field is set by the user and the sum of *allqueuedbuffersisreturnedinthetimeinfo. *Foraudio,itisadvisedtousethenumberof
* frames in the buffer for this field. */
uint64_t requested; /**< For playback streams, this field contains the *suggestedamountofdatatoprovide.Foraudio *streamsthiswillbetheamountofframes *requiredbytheresampler.Thisfieldis0
* when no suggestion is provided. Since 0.3.49 */
uint64_t time; /**< For capture streams, this field contains the *cycletimeinnanosecondswhenthisbufferwas *queuedinthestream.Itcanbecomparedagainst *thepw_timevaluesorpw_stream_get_nsec()
* Since 1.0.5 */
};
struct pw_stream_control { constchar *name; /**< name of the control */
uint32_t flags; /**< extra flags (unused) */ float def; /**< default value */ float min; /**< min value */ float max; /**< max value */ float *values; /**< array of values */
uint32_t n_values; /**< number of values in array */
uint32_t max_values; /**< max values that can be set on this control */
};
/** A time structure. * *Usepw_stream_get_time_n()togetanupdatedtimesnapshotofthestream. *Thetimesnapshotcangiveinformationaboutthetimeinthedriverofthe *graph,thedelaytotheedgeofthegraphandtheinternalqueuinginthe *stream. * *pw_time.ticksgivesamonotonicincreasingcounterofthetimeinthegraph *driver.Icanbeusedtogenerateatimetimetoschedulesamplesaswell *asdetectdiscontinuitiesinthetimelinecausedbyxruns. * *pw_time.delayisexpressedaspw_time.rate,thetimedomainofthegraph.This *value,andpw_time.ticks,werecapturedatpw_time.nowandcanbeextrapolated *tothecurrenttimelikethis: * *\code{.c} *uint64_tnow=pw_stream_get_nsec(stream); *int64_tdiff=now-pw_time.now; *int64_telapsed=(pw_time.rate.denom*diff)/(pw_time.rate.num*SPA_NSEC_PER_SEC); *\endcode * *pw_time.delaycontainsthetotaldelaythatasignalwilltravelthroughthe *graph.Thisincludesthedelaycausedbyfiltersinthegraphaswellasdelays *causedbythehardware.Thedelayisusuallyquitestableandshouldonlychangewhen *thetopology,quantumorsamplerateofthegraphchanges. * *Thedelayrequirestheapplicationtosendthestreamearlyrelativetoothersynchronized *streamsinordertoarriveattheedgeofthegraphintime.Thisisusuallydoneby *delayingtheotherstreamswiththegivendelay. * *Notethatthedelaycanbenegative.Anegativedelaymeansthatthisstreamshouldbe *delayedwiththe(positive)delayrelativetootherstreams. * *pw_time.queuedandpw_time.bufferedisexpressedinthetimedomainofthestream, *ortheformatthatisusedforthebuffersofthisstream. * *pw_time.queuedisthesumofallthepw_buffer.sizefieldsofthebuffersthatare *currentlyqueuedinthestreambutnotyetprocessed.Theapplicationcanchoose *theunitsofthisvalue,forexample,time,samples,framesorbytes(below *expressedasapp.rate). * *pw_time.bufferedisformatdependent,foraudio/rawitcontainsthenumberofframes *thatarebufferedinsidetheresampler/converter. * *Thetotaldelayofdatainastreamisthesumofthequeuedandbuffereddata *(notyetprocesseddata)andthedelaytotheedgeofthegraph,usuallya *playbackorcapturedevice. * *Foranaudioplaybackstream,ifyouweretoqueueabuffer,thetotaldelay *inmillisecondsforthefirstsampleinthenewlyqueuedbuffertobeplayed *bythehardwarecanbecalculatedas: * *\code{.unparsed} *(pw_time.buffered*1000/stream.samplerate)+ *(pw_time.queued*1000/app.rate)+ *((pw_time.delay-elapsed)*1000*pw_time.rate.num/pw_time.rate.denom) *\endcode * *Thecurrentextrapolatedtime(inms)inthesourceorsinkcanbecalculatedas: * *\code{.unparsed} *(pw_time.ticks+elapsed)*1000*pw_time.rate.num/pw_time.rate.denom *\endcode * *Belowisanoverviewofthedifferenttimingvalues: * *\code{.unparsed} *streamtimedomaingraphtimedomain */-----------------------\/-----------------------------\ * *queue+-++-++-----------++--------+ *---->||||->|converter|->graph->|kernel|->speaker *<----+-++-++-----------++--------+ *dequeuebuffers\-------------------/\--------/ *graphinternal *latencylatency *\--------/\-------------/\-----------------------------/ *queuedbuffereddelay *\endcode
*/ struct pw_time {
int64_t now; /**< the time in nanoseconds. This is the time when this *timereportwasupdated.Itisusuallyupdatedevery *graphcycle.Youcanusepw_stream_get_nsec()to *calculatetheelapsedtimebetweenthisreportand *thecurrenttimeandcalculateupdatedticksanddelay
* values. */ struct spa_fraction rate; /**< the rate of \a ticks and delay. This is usually
* expressed in 1/<samplerate>. */
uint64_t ticks; /**< the ticks at \a now. This is the current time that *theremoteendisreading/writing.Thisismonotonicaly
* increasing. */
int64_t delay; /**< delay to device. This is the time it will take for *thenextoutputsampleofthestreamtobepresentedby *theplaybackdeviceorthetimeasampletraveled *fromthecapturedevice.Thisdelayincludesthe *delayintroducedbyallfiltersonthepathbetween *thestreamandthedevice.Thedelayisnormally *constantinagraphandcanchangewhenthetopology *ofthegraphorthequantumchanges.Thisdelaydoes
* not include the delay caused by queued buffers. */
uint64_t queued; /**< data queued in the stream, this is the sum *ofthesizefieldsinthepw_bufferthatare
* currently queued */
uint64_t buffered; /**< for audio/raw streams, this contains the extra *numberofframesbufferedintheresampler.
* Since 0.3.50. */
uint32_t queued_buffers; /**< the number of buffers that are queued. Since 0.3.50 */
uint32_t avail_buffers; /**< the number of buffers that can be dequeued. Since 0.3.50 */
uint64_t size; /**< for audio/raw playback streams, this contains the number of *samplesrequestedbytheresamplerforthecurrent *quantum.foraudio/rawcapturestreamsthiswillbethenumber
* of samples available for the current quantum. Since 1.1.0 */
};
#include <pipewire/port.h>
/** Events for a stream. These events are always called from the mainloop
* unless explicitly documented otherwise. */ struct pw_stream_events { #define PW_VERSION_STREAM_EVENTS 2
uint32_t version;
void (*destroy) (void *data); /** when the stream state changes. Since 1.4 this also sets errno when the
* new state is PW_STREAM_STATE_ERROR */ void (*state_changed) (void *data, enum pw_stream_state old, enum pw_stream_state state, constchar *error);
/** Notify information about a control. */ void (*control_info) (void *data, uint32_t id, conststruct pw_stream_control *control);
/** when io changed on the stream. */ void (*io_changed) (void *data, uint32_t id, void *area, uint32_t size); /** when a parameter changed */ void (*param_changed) (void *data, uint32_t id, conststruct spa_pod *param);
/** when a new buffer was created for this stream */ void (*add_buffer) (void *data, struct pw_buffer *buffer); /** when a buffer was destroyed for this stream */ void (*remove_buffer) (void *data, struct pw_buffer *buffer);
/** when a buffer can be queued (for playback streams) or *dequeued(forcapturestreams).Thisisnormallycalledfromthe *mainloopbutcanalsobecalleddirectlyfromtherealtimedata
* thread if the user is prepared to deal with this. */ void (*process) (void *data);
/** The stream is drained */ void (*drained) (void *data);
/** A command notify, Since 0.3.39:1 */ void (*command) (void *data, conststruct spa_command *command);
/** a trigger_process completed. Since version 0.3.40:2. *Thisisnormallycalledfromthemainloopbutsince1.1.0it *canalsobecalleddirectlyfromtherealtimedata
* thread if the user is prepared to deal with this. */ void (*trigger_done) (void *data);
};
/** Convert a stream state to a readable string */ constchar * pw_stream_state_as_string(enum pw_stream_state state);
/** \enum pw_stream_flags Extra flags that can be used in \ref pw_stream_connect() */ enum pw_stream_flags {
PW_STREAM_FLAG_NONE = 0, /**< no flags */
PW_STREAM_FLAG_AUTOCONNECT = (1 << 0), /**< try to automatically connect
* this stream */
PW_STREAM_FLAG_INACTIVE = (1 << 1), /**< start the stream inactive, *pw_stream_set_active()needstobe
* called explicitly */
PW_STREAM_FLAG_MAP_BUFFERS = (1 << 2), /**< mmap the buffers except DmaBuf that is not
* explicitly marked as mappable. */
PW_STREAM_FLAG_DRIVER = (1 << 3), /**< be a driver */
PW_STREAM_FLAG_RT_PROCESS = (1 << 4), /**< call process from the realtime *thread.YouMUSTuseRTsafefunctions
* in the process callback. */
PW_STREAM_FLAG_NO_CONVERT = (1 << 5), /**< don't convert format */
PW_STREAM_FLAG_EXCLUSIVE = (1 << 6), /**< require exclusive access to the
* device */
PW_STREAM_FLAG_DONT_RECONNECT = (1 << 7), /**< don't try to reconnect this stream
* when the sink/source is removed */
PW_STREAM_FLAG_ALLOC_BUFFERS = (1 << 8), /**< the application will allocate buffer *memory.Intheadd_bufferevent,the
* data of the buffer should be set */
PW_STREAM_FLAG_TRIGGER = (1 << 9), /**< the output stream will not be scheduled *automaticallybut_trigger_process() *needstobecalled.Thiscanbeused *whentheoutputofthestreamdepends
* on input from other streams. */
PW_STREAM_FLAG_ASYNC = (1 << 10), /**< Buffers will not be dequeued/queued from *therealtimeprocess()function.Thisis *assumedwhenRT_PROCESSisunsetbutcan *alsobethecasewhentheprocess()function *doesatrigger_process()thatwillthen *dequeue/queueabufferfromanotherprocess()
* function. since 0.3.73 */
PW_STREAM_FLAG_EARLY_PROCESS = (1 << 11), /**< Call process as soon as there is a buffer *todequeue.Thisisonlyrelevantfor *playbackandwhennotusingRT_PROCESS.It *canbeusedtokeepthemaximumnumberof
* buffers queued. Since 0.3.81 */
PW_STREAM_FLAG_RT_TRIGGER_DONE = (1 << 12), /**< Call trigger_done from the realtime *thread.YouMUSTuseRTsafefunctions
* in the trigger_done callback. Since 1.1.0 */
};
/** Create a new unconnected \ref pw_stream
* \return a newly allocated \ref pw_stream */ struct pw_stream *
pw_stream_new(struct pw_core *core, /**< a \ref pw_core */ constchar *name, /**< a stream media name */ struct pw_properties *props /**< stream properties, ownership is taken */);
struct pw_stream *
pw_stream_new_simple(struct pw_loop *loop, /**< a \ref pw_loop to use as the main loop */ constchar *name, /**< a stream media name */ struct pw_properties *props,/**< stream properties, ownership is taken */ conststruct pw_stream_events *events, /**< stream events */ void *data /**< data passed to events */);
/** Destroy a stream */ void pw_stream_destroy(struct pw_stream *stream);
/** Get the current stream state. Since 1.4 this also sets errno when the
* state is PW_STREAM_STATE_ERROR */ enum pw_stream_state pw_stream_get_state(struct pw_stream *stream, constchar **error);
int pw_stream_update_properties(struct pw_stream *stream, conststruct spa_dict *dict);
/** Connect a stream for input or output on \a port_path. *\return0onsuccess<0onerror. * *Youshouldconnecttotheprocesseventandusepw_stream_dequeue_buffer()
* to get the latest metadata and data. */ int
pw_stream_connect(struct pw_stream *stream, /**< a \ref pw_stream */ enum pw_direction direction, /**< the stream direction */
uint32_t target_id, /**< should have the value PW_ID_ANY. *Toselectaspecifictarget *node,specifythe *PW_KEY_OBJECT_SERIALorthe *PW_KEY_NODE_NAMEvalueofthetarget *nodeinthePW_KEY_TARGET_OBJECT *propertyofthestream. *Specifyingtargetnodesby *theiridisdeprecated.
*/ enum pw_stream_flags flags, /**< stream flags */ conststruct spa_pod **params, /**< an array with params. The params *shouldideallycontainsupported
* formats. */
uint32_t n_params /**< number of items in \a params */);
/** Get the node ID of the stream.
* \return node ID. */
uint32_t
pw_stream_get_node_id(struct pw_stream *stream);
/** Disconnect \a stream */ int pw_stream_disconnect(struct pw_stream *stream);
/** Set the stream in error state */ int pw_stream_set_error(struct pw_stream *stream, /**< a \ref pw_stream */ int res, /**< a result code */ constchar *error, /**< an error message */
...) SPA_PRINTF_FUNC(3, 4);
/** Update the param exposed on the stream. */ int
pw_stream_update_params(struct pw_stream *stream, /**< a \ref pw_stream */ conststruct spa_pod **params, /**< an array of params. */
uint32_t n_params /**< number of elements in \a params */);
/** *Setaparameteronthestream.Thisislikepw_stream_set_control()butwith *acompletespa_podparam.Itcanalsobecalledfromtheparam_changedeventhandler
* to intercept and modify the param for the adapter. Since 0.3.70 */ int pw_stream_set_param(struct pw_stream *stream, /**< a \ref pw_stream */
uint32_t id, /**< the id of the param */ conststruct spa_pod *param /**< the params to set */);
/** Get control values */ conststruct pw_stream_control *pw_stream_get_control(struct pw_stream *stream, uint32_t id);
/** Set control values */ int pw_stream_set_control(struct pw_stream *stream, uint32_t id, uint32_t n_values, float *values, ...);
/** Query the time on the stream, RT safe */ int pw_stream_get_time_n(struct pw_stream *stream, struct pw_time *time, size_t size);
/** Get the current time in nanoseconds. This value can be compared with
* the \ref pw_time.now value. RT safe. Since 1.1.0 */
uint64_t pw_stream_get_nsec(struct pw_stream *stream);
/** Get the data loop that is doing the processing of this stream. This loop
* is assigned after pw_stream_connect(). * Since 1.1.0 */ struct pw_loop *pw_stream_get_data_loop(struct pw_stream *stream);
/** Query the time on the stream, deprecated since 0.3.50,
* use pw_stream_get_time_n() to get the fields added since 0.3.50. RT safe. */
SPA_DEPRECATED int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time);
/** Get a buffer that can be filled for playback streams or consumed
* for capture streams. RT safe. */ struct pw_buffer *pw_stream_dequeue_buffer(struct pw_stream *stream);
/** Submit a buffer for playback or recycle a buffer for capture. RT safe. */ int pw_stream_queue_buffer(struct pw_stream *stream, struct pw_buffer *buffer);
/** Return a buffer to the queue without using it. This makes the buffer
* immediately available to dequeue again. RT safe. */ int pw_stream_return_buffer(struct pw_stream *stream, struct pw_buffer *buffer);
/** Activate or deactivate the stream */ int pw_stream_set_active(struct pw_stream *stream, bool active);
/** Flush a stream. When \a drain is true, the drained callback will *becalledwhenalldataisplayedorrecorded.Thestreamcanberesumed *afterthedrainbysettingitactiveagainwith *\refpw_stream_set_active().Aflushwithoutadrainismostlyusefulafer *astatechangetoPAUSED,toflushanyremainingdatafromthequeuesand
* the converters. RT safe. */ int pw_stream_flush(struct pw_stream *stream, bool drain);
/** Check if the stream is driving. The stream needs to have the *PW_STREAM_FLAG_DRIVERset.Whenthestreamisdriving, *pw_stream_trigger_process()needstobecalledwhendatais
* available (output) or needed (input). Since 0.3.34 */ bool pw_stream_is_driving(struct pw_stream *stream);
/** Check if the graph is using lazy scheduling. If the stream is *drivingaccordingto\refpw_stream_is_driving(),thenitshould *considertakingintoaccounttheRequestProcesscommandswhen *drivingthegraph. * *Ifthestreamisnotdriving,itshouldsendoutRequestProcess *eventswith\refpw_stream_emit_event()orindirectlywith *\refpw_stream_trigger_process()tosuggestanewgraphcycle *tothedriver. * *ItisnotarequirementthatallRequestProcessevents/commands *needtostartagraphcycle.
* Since 1.4.0 */ bool pw_stream_is_lazy(struct pw_stream *stream);
/** Trigger a push/pull on the stream. One iteration of the graph will *bescheduledwhenthestreamisdrivingaccordingto *\refpw_stream_is_driving().Ifitsuccessfullyfinishes,process() *willbecalledandthetrigger_doneeventwillbeemitted.Itis *possibleforthegraphiterationtonotfinish,so *pw_stream_trigger_process()needstobecalledagainevenifprocess() *andtrigger_doneisnotcalled. * *Ifthereisadeadlineafterwhichthestreamwillhavexrun, *pw_stream_trigger_process()shouldbecalledthen,whetherornot *process()/trigger_donehasbeencalled.Soundhardwarewillxrunif *thereisanydelayinaudioprocessing,sotheALSAplugintriggersthe *grapheveryquantumtoensureaudiokeepsflowing.Driversthat *donothaveadeadline,suchasthefreewheeldriver,should *useatimeouttoensurethatforwardprogresskeepsbeingmade. *Areasonablechoiceofdeadlineisthreetimesthequantum:if *thegraphistaking3xlongerthannormal,itislikelythatit *ishungandshouldberetriggered. * *Streamsthatarenotdriversaccordingto\refpw_stream_is_driving() *canalsocallthismethod.TheresultisthataRequestProcessevent *issenttothedriver.Ifthegraphislazyschedulingaccordingto *\refpw_stream_is_lazy(),thismightresultinagraphcyclebythe *driver.Ifthegraphisnotlazyschedulingandthestreamisnota *driver,thismethodwillhavenoeffect. * *RTsafe. *
* Since 0.3.34 */ int pw_stream_trigger_process(struct pw_stream *stream);
/** Emit an event from this stream. RT safe.
* Since 1.2.6 */ int pw_stream_emit_event(struct pw_stream *stream, conststruct spa_event *event);
/** Adjust the rate of the stream. *Whenthestreamisusinganadaptiveresampler,adjusttheresamplerrate. *Whenthereisnoresampler,-ENOTSUPisreturned.Activatingtheadaptive *resamplerwilladdasmallamountofdelaytothesamples,youcandeactivate *itagainbysettingavalue<=0.0.RTsafe.
* Since 1.4.0 */ int pw_stream_set_rate(struct pw_stream *stream, double rate);
/** *\}
*/
#ifdef __cplusplus
} #endif
#endif/* PIPEWIRE_STREAM_H */
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.30Angebot
¤
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.