Go to the documentation of this file.
   24 #include <pulse/rtclock.h> 
   25 #include <pulse/error.h> 
   38 #define DEFAULT_CODEC_ID AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE) 
   61 #define CHECK_SUCCESS_GOTO(rerror, expression, label)        \ 
   63         if (!(expression)) {                                    \ 
   64             rerror = AVERROR_EXTERNAL;                          \ 
   69 #define CHECK_DEAD_GOTO(p, rerror, label)                               \ 
   71         if (!(p)->context || !PA_CONTEXT_IS_GOOD(pa_context_get_state((p)->context)) || \ 
   72             !(p)->stream || !PA_STREAM_IS_GOOD(pa_stream_get_state((p)->stream))) { \ 
   73             rerror = AVERROR_EXTERNAL;                                  \ 
   81     switch (pa_context_get_state(
c)) {
 
   82         case PA_CONTEXT_READY:
 
   83         case PA_CONTEXT_TERMINATED:
 
   84         case PA_CONTEXT_FAILED:
 
   85             pa_threaded_mainloop_signal(
p->mainloop, 0);
 
   93     switch (pa_stream_get_state(
s)) {
 
   95         case PA_STREAM_FAILED:
 
   96         case PA_STREAM_TERMINATED:
 
   97             pa_threaded_mainloop_signal(
p->mainloop, 0);
 
  105     pa_threaded_mainloop_signal(
p->mainloop, 0);
 
  111     pa_threaded_mainloop_signal(
p->mainloop, 0);
 
  119         pa_threaded_mainloop_stop(pd->
mainloop);
 
  122         pa_stream_unref(pd->
stream);
 
  126         pa_context_disconnect(pd->
context);
 
  132         pa_threaded_mainloop_free(pd->
mainloop);
 
  153     pa_buffer_attr attr = { -1 };
 
  155     const pa_buffer_attr *queried_attr;
 
  157     pa_channel_map_init_extend(&cmap, pd->
channels, PA_CHANNEL_MAP_WAVEEX);
 
  173     if (
s->url[0] != 
'\0' && strcmp(
s->url, 
"default"))
 
  176     if (!(pd->
mainloop = pa_threaded_mainloop_new())) {
 
  181     if (!(pd->
context = pa_context_new(pa_threaded_mainloop_get_api(pd->
mainloop), pd->
name))) {
 
  193     pa_threaded_mainloop_lock(pd->
mainloop);
 
  195     if (pa_threaded_mainloop_start(pd->
mainloop) < 0) {
 
  197         goto unlock_and_fail;
 
  201         pa_context_state_t 
state;
 
  205         if (
state == PA_CONTEXT_READY)
 
  208         if (!PA_CONTEXT_IS_GOOD(
state)) {
 
  210             goto unlock_and_fail;
 
  214         pa_threaded_mainloop_wait(pd->
mainloop);
 
  219         goto unlock_and_fail;
 
  227     ret = pa_stream_connect_record(pd->
stream, device, &attr,
 
  228                                     PA_STREAM_INTERPOLATE_TIMING
 
  229                                     |PA_STREAM_ADJUST_LATENCY
 
  230                                     |PA_STREAM_AUTO_TIMING_UPDATE);
 
  234         goto unlock_and_fail;
 
  238         pa_stream_state_t 
state;
 
  242         if (
state == PA_STREAM_READY)
 
  245         if (!PA_STREAM_IS_GOOD(
state)) {
 
  247             goto unlock_and_fail;
 
  251         pa_threaded_mainloop_wait(pd->
mainloop);
 
  255     queried_attr = pa_stream_get_buffer_attr(pd->
stream);
 
  256     if (!queried_attr || queried_attr->fragsize > INT_MAX/100) {
 
  258         goto unlock_and_fail;
 
  263     pa_threaded_mainloop_unlock(pd->
mainloop);
 
  283     pa_threaded_mainloop_unlock(pd->
mainloop);
 
  300     pa_threaded_mainloop_lock(pd->
mainloop);
 
  304     while (pos < pd->fragment_size) {
 
  310         if (read_length <= 0) {
 
  311             pa_threaded_mainloop_wait(pd->
mainloop);
 
  316             r = pa_stream_drop(pd->
stream);
 
  322                     goto unlock_and_fail;
 
  326                 pa_operation_unref(pa_stream_update_timing_info(pd->
stream, 
NULL, 
NULL));
 
  328                 if (pa_stream_get_latency(pd->
stream, &latency, &negative) >= 0) {
 
  340                 pa_stream_drop(pd->
stream);
 
  343                 goto unlock_and_fail;
 
  347             pa_stream_drop(pd->
stream);
 
  351     pa_threaded_mainloop_unlock(pd->
mainloop);
 
  363     pa_threaded_mainloop_unlock(pd->
mainloop);
 
  373 #define OFFSET(a) offsetof(PulseData, a) 
  374 #define D AV_OPT_FLAG_DECODING_PARAM 
  375 #define DEPR AV_OPT_FLAG_DEPRECATED 
  381     { 
"sample_rate",   
"set sample rate in Hz",                             
OFFSET(sample_rate),   
AV_OPT_TYPE_INT,    {.i64 = 48000},    1, INT_MAX, 
D },
 
  384     { 
"fragment_size", 
"set buffering size, affects latency and cpu usage", 
OFFSET(fragment_size), 
AV_OPT_TYPE_INT,    {.i64 = -1},      -1, INT_MAX, 
D },
 
  385     { 
"wallclock",     
"set the initial pts using the current time",     
OFFSET(wallclock),     
AV_OPT_TYPE_INT,    {.i64 = 1},       -1, 1, 
D },
 
  
static const AVOption options[]
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Opaque type representing a time filter state.
#define AV_LOG_WARNING
Something somehow does not look correct.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
static int read_data(void *opaque, uint8_t *buf, int buf_size)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVMediaType codec_type
General type of the encoded data.
pa_threaded_mainloop * mainloop
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
static int pulse_get_device_list(AVFormatContext *h, AVDeviceInfoList *device_list)
static void stream_latency_update_cb(pa_stream *s, void *userdata)
pa_sample_format_t av_cold ff_codec_id_to_pulse_format(enum AVCodecID codec_id)
FFmpeg hosted at Telepoint in bulgaria ns2 avcodec org Replica Name server(provided by an ffmpeg developer, hosted at Hetzner in germany) ns3.avcodec.org Replica Name server(provided by an ffmpeg developer
int nb_channels
Number of channels in this layout.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
static av_cold int read_close(AVFormatContext *ctx)
#define ss(width, name, subs,...)
TimeFilter * ff_timefilter_new(double time_base, double period, double bandwidth)
Create a new Delay Locked Loop time filter.
static void stream_request_cb(pa_stream *s, size_t length, void *userdata)
@ AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
int ff_pulse_audio_get_devices(AVDeviceInfoList *devices, const char *server, int output)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static av_cold int pulse_close(AVFormatContext *s)
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
const char * av_default_item_name(void *ptr)
Return the context name.
AVChannelLayout ch_layout
Audio only.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int sample_rate
Audio only.
AVCodecID
Identify the syntax and semantics of the bitstream.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
const FFInputFormat ff_pulse_demuxer
#define CHECK_SUCCESS_GOTO(rerror, expression, label)
#define AVERROR_EXTERNAL
Generic error in an external library.
#define CHECK_DEAD_GOTO(p, rerror, label)
static int read_header(FFV1Context *f, RangeCoder *c)
static int pulse_read_packet(AVFormatContext *s, AVPacket *pkt)
static av_cold int pulse_read_header(AVFormatContext *s)
void ff_timefilter_destroy(TimeFilter *self)
Free all resources associated with the filter.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
double ff_timefilter_update(TimeFilter *self, double system_time, double period)
Update the filter.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
@ AV_OPT_TYPE_INT
Underlying C type is int.
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
int64_t av_gettime(void)
Get the current time in microseconds.
static void context_state_cb(pa_context *c, void *userdata)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
static void stream_state_cb(pa_stream *s, void *userdata)
static const AVClass pulse_demuxer_class
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...