]>
code.delx.au - pulseaudio/blob - src/sourceoutput.c
5 #include "sourceoutput.h"
8 struct source_output
* source_output_new(struct source
*s
, const char *name
, const struct pa_sample_spec
*spec
) {
9 struct source_output
*o
;
10 struct resampler
*resampler
= NULL
;
14 if (!pa_sample_spec_equal(&s
->sample_spec
, spec
))
15 if (!(resampler
= resampler_new(&s
->sample_spec
, spec
)))
18 o
= malloc(sizeof(struct source_output
));
20 o
->name
= name
? strdup(name
) : NULL
;
22 o
->sample_spec
= *spec
;
27 o
->resampler
= resampler
;
30 r
= idxset_put(s
->core
->source_outputs
, o
, &o
->index
);
31 assert(r
== 0 && o
->index
!= IDXSET_INVALID
);
32 r
= idxset_put(s
->outputs
, o
, NULL
);
38 void source_output_free(struct source_output
* o
) {
41 assert(o
->source
&& o
->source
->core
);
42 idxset_remove_by_data(o
->source
->core
->source_outputs
, o
, NULL
);
43 idxset_remove_by_data(o
->source
->outputs
, o
, NULL
);
46 resampler_free(o
->resampler
);
52 void source_output_kill(struct source_output
*i
) {
59 char *source_output_list_to_string(struct core
*c
) {
61 struct source_output
*o
;
62 uint32_t index
= IDXSET_INVALID
;
68 strbuf_printf(s
, "%u source outputs(s) available.\n", idxset_ncontents(c
->source_outputs
));
70 for (o
= idxset_first(c
->source_outputs
, &index
); o
; o
= idxset_next(c
->source_outputs
, &index
)) {
72 strbuf_printf(s
, " %c index: %u, name: <%s>, source: <%u>\n",
78 return strbuf_tostring_free(s
);
81 void source_output_push(struct source_output
*o
, const struct memchunk
*chunk
) {
82 struct memchunk rchunk
;
83 assert(o
&& chunk
&& chunk
->length
&& o
->push
);
90 resampler_run(o
->resampler
, chunk
, &rchunk
);
94 assert(rchunk
.memblock
);
96 memblock_unref(rchunk
.memblock
);