PulseAudio 16.1

stream.h
Go to the documentation of this file.
1#ifndef foostreamhfoo
2#define foostreamhfoo
3
4/***
5 This file is part of PulseAudio.
6
7 Copyright 2004-2006 Lennart Poettering
8 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
9
10 PulseAudio is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published
12 by the Free Software Foundation; either version 2.1 of the License,
13 or (at your option) any later version.
14
15 PulseAudio is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
22***/
23
24#include <sys/types.h>
25
26#include <pulse/sample.h>
27#include <pulse/format.h>
28#include <pulse/channelmap.h>
29#include <pulse/volume.h>
30#include <pulse/def.h>
31#include <pulse/cdecl.h>
32#include <pulse/operation.h>
33#include <pulse/context.h>
34#include <pulse/proplist.h>
35
286PA_C_DECL_BEGIN
287
289 typedef struct pa_stream pa_stream;
290
292 typedef void (*pa_stream_success_cb_t) (pa_stream*s, int success, void *userdata);
293
295 typedef void (*pa_stream_request_cb_t)(pa_stream *p, size_t nbytes, void *userdata);
296
298 typedef void (*pa_stream_notify_cb_t)(pa_stream *p, void *userdata);
299
306 typedef void (*pa_stream_event_cb_t)(pa_stream *p, const char *name, pa_proplist *pl, void *userdata);
307
311 pa_stream* pa_stream_new(
312 pa_context *c ,
313 const char *name ,
314 const pa_sample_spec *ss ,
315 const pa_channel_map *map );
316
320 pa_stream* pa_stream_new_with_proplist(
321 pa_context *c ,
322 const char *name ,
323 const pa_sample_spec *ss ,
324 const pa_channel_map *map ,
325 pa_proplist *p );
326
331 pa_stream *pa_stream_new_extended(
332 pa_context *c ,
333 const char *name ,
334 pa_format_info * const * formats ,
335 unsigned int n_formats ,
336 pa_proplist *p );
337
339 void pa_stream_unref(pa_stream *s);
340
342 pa_stream *pa_stream_ref(pa_stream *s);
343
345 pa_stream_state_t pa_stream_get_state(const pa_stream *p);
346
348 pa_context* pa_stream_get_context(const pa_stream *p);
349
355uint32_t pa_stream_get_index(const pa_stream *s);
356
366uint32_t pa_stream_get_device_index(const pa_stream *s);
367
377 const char *pa_stream_get_device_name(const pa_stream *s);
378
383 int pa_stream_is_suspended(const pa_stream *s);
384
387 int pa_stream_is_corked(const pa_stream *s);
388
415 int pa_stream_connect_playback(
416 pa_stream *s ,
417 const char *dev ,
418 const pa_buffer_attr *attr ,
419 pa_stream_flags_t flags ,
420 const pa_cvolume *volume ,
421 pa_stream *sync_stream );
422
424 int pa_stream_connect_record(
425 pa_stream *s ,
426 const char *dev ,
427 const pa_buffer_attr *attr ,
428 pa_stream_flags_t flags );
429
431 int pa_stream_disconnect(pa_stream *s);
432
472 int pa_stream_begin_write(
473 pa_stream *p,
474 void **data,
475 size_t *nbytes);
476
486 int pa_stream_cancel_write(
487 pa_stream *p);
488
513 int pa_stream_write(
514 pa_stream *p ,
515 const void *data ,
516 size_t nbytes ,
517 pa_free_cb_t free_cb ,
518 int64_t offset ,
519 pa_seek_mode_t seek );
520
523 int pa_stream_write_ext_free(
524 pa_stream *p ,
525 const void *data ,
526 size_t nbytes ,
527 pa_free_cb_t free_cb ,
528 void *free_cb_data ,
529 int64_t offset ,
530 pa_seek_mode_t seek );
531
550 int pa_stream_peek(
551 pa_stream *p ,
552 const void **data ,
553 size_t *nbytes );
554
557 int pa_stream_drop(pa_stream *p);
558
569 size_t pa_stream_writable_size(const pa_stream *p);
570
574 size_t pa_stream_readable_size(const pa_stream *p);
575
580 pa_operation* pa_stream_drain(pa_stream *s, pa_stream_success_cb_t cb, void *userdata);
581
586 pa_operation* pa_stream_update_timing_info(pa_stream *p, pa_stream_success_cb_t cb, void *userdata);
587
589 void pa_stream_set_state_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata);
590
593 void pa_stream_set_write_callback(pa_stream *p, pa_stream_request_cb_t cb, void *userdata);
594
596 void pa_stream_set_read_callback(pa_stream *p, pa_stream_request_cb_t cb, void *userdata);
597
599 void pa_stream_set_overflow_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata);
600
605int64_t pa_stream_get_underflow_index(const pa_stream *p);
606
608 void pa_stream_set_underflow_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata);
609
615 void pa_stream_set_started_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata);
616
620 void pa_stream_set_latency_update_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata);
621
627 void pa_stream_set_moved_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata);
628
637 void pa_stream_set_suspended_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata);
638
641 void pa_stream_set_event_callback(pa_stream *p, pa_stream_event_cb_t cb, void *userdata);
642
648 void pa_stream_set_buffer_attr_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata);
649
660 pa_operation* pa_stream_cork(pa_stream *s, int b, pa_stream_success_cb_t cb, void *userdata);
661
665 pa_operation* pa_stream_flush(pa_stream *s, pa_stream_success_cb_t cb, void *userdata);
666
669 pa_operation* pa_stream_prebuf(pa_stream *s, pa_stream_success_cb_t cb, void *userdata);
670
674 pa_operation* pa_stream_trigger(pa_stream *s, pa_stream_success_cb_t cb, void *userdata);
675
677 pa_operation* pa_stream_set_name(pa_stream *s, const char *name, pa_stream_success_cb_t cb, void *userdata);
678
714 int pa_stream_get_time(pa_stream *s, pa_usec_t *r_usec);
715
730 int pa_stream_get_latency(pa_stream *s, pa_usec_t *r_usec, int *negative);
731
745 const pa_timing_info* pa_stream_get_timing_info(pa_stream *s);
746
748 const pa_sample_spec* pa_stream_get_sample_spec(pa_stream *s);
749
751 const pa_channel_map* pa_stream_get_channel_map(pa_stream *s);
752
754 const pa_format_info* pa_stream_get_format_info(const pa_stream *s);
755
764 const pa_buffer_attr* pa_stream_get_buffer_attr(pa_stream *s);
765
774 pa_operation *pa_stream_set_buffer_attr(pa_stream *s, const pa_buffer_attr *attr, pa_stream_success_cb_t cb, void *userdata);
775
781 pa_operation *pa_stream_update_sample_rate(pa_stream *s, uint32_t rate, pa_stream_success_cb_t cb, void *userdata);
782
789 pa_operation *pa_stream_proplist_update(pa_stream *s, pa_update_mode_t mode, pa_proplist *p, pa_stream_success_cb_t cb, void *userdata);
790
793 pa_operation *pa_stream_proplist_remove(pa_stream *s, const char *const keys[], pa_stream_success_cb_t cb, void *userdata);
794
799 int pa_stream_set_monitor_stream(pa_stream *s, uint32_t sink_input_idx);
800
804uint32_t pa_stream_get_monitor_stream(const pa_stream *s);
805
806PA_C_DECL_END
807
808#endif
channelmap.h
Constants and routines for channel mapping handling.
context.h
Connection contexts for asynchronous communication with a server.
pa_context
struct pa_context pa_context
An opaque connection context to a daemon.
Definition: context.h:154
def.h
Global definitions.
pa_free_cb_t
void(* pa_free_cb_t)(void *p)
A generic free() like callback prototype.
Definition: def.h:1037
pa_stream_flags_t
enum pa_stream_flags pa_stream_flags_t
Some special flags for stream connections.
pa_stream_state_t
enum pa_stream_state pa_stream_state_t
The state of a stream.
pa_seek_mode_t
enum pa_seek_mode pa_seek_mode_t
Seek type for pa_stream_write().
format.h
Utility functions for handling a stream or sink format.
operation.h
Asynchronous operations.
pa_operation
struct pa_operation pa_operation
An asynchronous operation object.
Definition: operation.h:33
proplist.h
Property list constants and functions.
pa_update_mode_t
enum pa_update_mode pa_update_mode_t
Update mode enum for pa_proplist_update().
pa_proplist
struct pa_proplist pa_proplist
A property list object.
Definition: proplist.h:278
sample.h
Constants and routines for sample type handling.
pa_usec_t
uint64_t pa_usec_t
Type for usec specifications (unsigned).
Definition: sample.h:264
pa_stream_get_monitor_stream
uint32_t pa_stream_get_monitor_stream(const pa_stream *s)
Return the sink input index previously set with pa_stream_set_monitor_stream().
pa_stream_proplist_update
pa_operation * pa_stream_proplist_update(pa_stream *s, pa_update_mode_t mode, pa_proplist *p, pa_stream_success_cb_t cb, void *userdata)
Update the property list of the sink input/source output of this stream, adding new entries.
pa_stream_trigger
pa_operation * pa_stream_trigger(pa_stream *s, pa_stream_success_cb_t cb, void *userdata)
Request immediate start of playback on this stream.
pa_stream_get_timing_info
const pa_timing_info * pa_stream_get_timing_info(pa_stream *s)
Return the latest raw timing data structure.
pa_stream_update_sample_rate
pa_operation * pa_stream_update_sample_rate(pa_stream *s, uint32_t rate, pa_stream_success_cb_t cb, void *userdata)
Change the stream sampling rate during playback.
pa_stream_new
pa_stream * pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *ss, const pa_channel_map *map)
Create a new, unconnected stream with the specified name and sample type.
pa_stream_get_sample_spec
const pa_sample_spec * pa_stream_get_sample_spec(pa_stream *s)
Return a pointer to the stream's sample specification.
pa_stream_set_state_callback
void pa_stream_set_state_callback(pa_stream *s, pa_stream_notify_cb_t cb, void *userdata)
Set the callback function that is called whenever the state of the stream changes.
pa_stream_cancel_write
int pa_stream_cancel_write(pa_stream *p)
Reverses the effect of pa_stream_begin_write() dropping all data that has already been placed in the ...
pa_stream_set_monitor_stream
int pa_stream_set_monitor_stream(pa_stream *s, uint32_t sink_input_idx)
For record streams connected to a monitor source: monitor only a very specific sink input of the sink...
pa_stream_set_write_callback
void pa_stream_set_write_callback(pa_stream *p, pa_stream_request_cb_t cb, void *userdata)
Set the callback function that is called when new data may be written to the stream.
pa_stream_drop
int pa_stream_drop(pa_stream *p)
Remove the current fragment on record streams.
pa_stream_get_underflow_index
int64_t pa_stream_get_underflow_index(const pa_stream *p)
Return at what position the latest underflow occurred, or -1 if this information is not known (e....
pa_stream_get_buffer_attr
const pa_buffer_attr * pa_stream_get_buffer_attr(pa_stream *s)
Return the per-stream server-side buffer metrics of the stream.
pa_stream_drain
pa_operation * pa_stream_drain(pa_stream *s, pa_stream_success_cb_t cb, void *userdata)
Drain a playback stream.
pa_stream_update_timing_info
pa_operation * pa_stream_update_timing_info(pa_stream *p, pa_stream_success_cb_t cb, void *userdata)
Request a timing info structure update for a stream.
pa_stream_set_suspended_callback
void pa_stream_set_suspended_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata)
Set the callback function that is called whenever the sink/source this stream is connected to is susp...
pa_stream_write
int pa_stream_write(pa_stream *p, const void *data, size_t nbytes, pa_free_cb_t free_cb, int64_t offset, pa_seek_mode_t seek)
Write some data to the server (for playback streams).
pa_stream_new_with_proplist
pa_stream * pa_stream_new_with_proplist(pa_context *c, const char *name, const pa_sample_spec *ss, const pa_channel_map *map, pa_proplist *p)
Create a new, unconnected stream with the specified name and sample type, and specify the initial str...
pa_stream_set_event_callback
void pa_stream_set_event_callback(pa_stream *p, pa_stream_event_cb_t cb, void *userdata)
Set the callback function that is called whenever a meta/policy control event is received.
pa_stream_cork
pa_operation * pa_stream_cork(pa_stream *s, int b, pa_stream_success_cb_t cb, void *userdata)
Pause (or resume) playback of this stream temporarily.
pa_stream_proplist_remove
pa_operation * pa_stream_proplist_remove(pa_stream *s, const char *const keys[], pa_stream_success_cb_t cb, void *userdata)
Update the property list of the sink input/source output of this stream, remove entries.
pa_stream_set_underflow_callback
void pa_stream_set_underflow_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata)
Set the callback function that is called when a buffer underflow happens.
pa_stream_success_cb_t
void(* pa_stream_success_cb_t)(pa_stream *s, int success, void *userdata)
A generic callback for operation completion.
Definition: stream.h:292
pa_stream_set_buffer_attr_callback
void pa_stream_set_buffer_attr_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata)
Set the callback function that is called whenever the buffer attributes on the server side change.
pa_stream_get_context
pa_context * pa_stream_get_context(const pa_stream *p)
Return the context this stream is attached to.
pa_stream_begin_write
int pa_stream_begin_write(pa_stream *p, void **data, size_t *nbytes)
Prepare writing data to the server (for playback streams).
pa_stream_set_moved_callback
void pa_stream_set_moved_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata)
Set the callback function that is called whenever the stream is moved to a different sink/source.
pa_stream_set_name
pa_operation * pa_stream_set_name(pa_stream *s, const char *name, pa_stream_success_cb_t cb, void *userdata)
Rename the stream.
pa_stream_unref
void pa_stream_unref(pa_stream *s)
Decrease the reference counter by one.
pa_stream_event_cb_t
void(* pa_stream_event_cb_t)(pa_stream *p, const char *name, pa_proplist *pl, void *userdata)
A callback for asynchronous meta/policy event messages.
Definition: stream.h:306
pa_stream_is_corked
int pa_stream_is_corked(const pa_stream *s)
Return 1 if the this stream has been corked.
pa_stream_writable_size
size_t pa_stream_writable_size(const pa_stream *p)
Return the number of bytes requested by the server that have not yet been written.
pa_stream_get_channel_map
const pa_channel_map * pa_stream_get_channel_map(pa_stream *s)
Return a pointer to the stream's channel map.
pa_stream_get_device_index
uint32_t pa_stream_get_device_index(const pa_stream *s)
Return the index of the sink or source this stream is connected to in the server.
pa_stream
struct pa_stream pa_stream
An opaque stream for playback or recording.
Definition: stream.h:289
pa_stream_flush
pa_operation * pa_stream_flush(pa_stream *s, pa_stream_success_cb_t cb, void *userdata)
Flush the playback or record buffer of this stream.
pa_stream_get_time
int pa_stream_get_time(pa_stream *s, pa_usec_t *r_usec)
Return the current playback/recording time.
pa_stream_set_latency_update_callback
void pa_stream_set_latency_update_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata)
Set the callback function that is called whenever a latency information update happens.
pa_stream_get_index
uint32_t pa_stream_get_index(const pa_stream *s)
Return the sink input resp. source output index this stream is identified in the server with.
pa_stream_disconnect
int pa_stream_disconnect(pa_stream *s)
Disconnect a stream from a source/sink.
pa_stream_get_latency
int pa_stream_get_latency(pa_stream *s, pa_usec_t *r_usec, int *negative)
Determine the total stream latency.
pa_stream_readable_size
size_t pa_stream_readable_size(const pa_stream *p)
Return the number of bytes that may be read using pa_stream_peek().
pa_stream_set_started_callback
void pa_stream_set_started_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata)
Set the callback function that is called when the server starts playback after an underrun or on init...
pa_stream_write_ext_free
int pa_stream_write_ext_free(pa_stream *p, const void *data, size_t nbytes, pa_free_cb_t free_cb, void *free_cb_data, int64_t offset, pa_seek_mode_t seek)
Function does exactly the same as pa_stream_write() with the difference that free_cb_data is passed t...
pa_stream_connect_playback
int pa_stream_connect_playback(pa_stream *s, const char *dev, const pa_buffer_attr *attr, pa_stream_flags_t flags, const pa_cvolume *volume, pa_stream *sync_stream)
Connect the stream to a sink.
pa_stream_set_read_callback
void pa_stream_set_read_callback(pa_stream *p, pa_stream_request_cb_t cb, void *userdata)
Set the callback function that is called when new data is available from the stream.
pa_stream_request_cb_t
void(* pa_stream_request_cb_t)(pa_stream *p, size_t nbytes, void *userdata)
A generic request callback.
Definition: stream.h:295
pa_stream_connect_record
int pa_stream_connect_record(pa_stream *s, const char *dev, const pa_buffer_attr *attr, pa_stream_flags_t flags)
Connect the stream to a source.
pa_stream_set_buffer_attr
pa_operation * pa_stream_set_buffer_attr(pa_stream *s, const pa_buffer_attr *attr, pa_stream_success_cb_t cb, void *userdata)
Change the buffer metrics of the stream during playback.
pa_stream_get_device_name
const char * pa_stream_get_device_name(const pa_stream *s)
Return the name of the sink or source this stream is connected to in the server.
pa_stream_peek
int pa_stream_peek(pa_stream *p, const void **data, size_t *nbytes)
Read the next fragment from the buffer (for recording streams).
pa_stream_notify_cb_t
void(* pa_stream_notify_cb_t)(pa_stream *p, void *userdata)
A generic notification callback.
Definition: stream.h:298
pa_stream_prebuf
pa_operation * pa_stream_prebuf(pa_stream *s, pa_stream_success_cb_t cb, void *userdata)
Reenable prebuffering if specified in the pa_buffer_attr structure.
pa_stream_is_suspended
int pa_stream_is_suspended(const pa_stream *s)
Return 1 if the sink or source this stream is connected to has been suspended.
pa_stream_new_extended
pa_stream * pa_stream_new_extended(pa_context *c, const char *name, pa_format_info *const *formats, unsigned int n_formats, pa_proplist *p)
Create a new, unconnected stream with the specified name, the set of formats this client can provide,...
pa_stream_set_overflow_callback
void pa_stream_set_overflow_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata)
Set the callback function that is called when a buffer overflow happens.
pa_stream_ref
pa_stream * pa_stream_ref(pa_stream *s)
Increase the reference counter by one.
pa_stream_get_format_info
const pa_format_info * pa_stream_get_format_info(const pa_stream *s)
Return a pointer to the stream's format.
pa_stream_get_state
pa_stream_state_t pa_stream_get_state(const pa_stream *p)
Return the current state of the stream.
pa_buffer_attr
Playback and record buffer metrics.
Definition: def.h:389
pa_channel_map
A channel map which can be used to attach labels to specific channels of a stream.
Definition: channelmap.h:264
pa_cvolume
A structure encapsulating a per-channel volume.
Definition: volume.h:145
pa_format_info
Represents the format of data provided in a stream or processed by a sink.
Definition: format.h:98
pa_sample_spec
A sample format and attribute specification.
Definition: sample.h:252
pa_timing_info
A structure for all kinds of timing information of a stream.
Definition: def.h:680
volume.h
Constants and routines for volume handling.