4 This file is part of polypaudio.
6 polypaudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
11 polypaudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with polypaudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
30 #include "source-output.h"
32 struct pa_source_output* pa_source_output_new(struct pa_source *s, const char *name, const struct pa_sample_spec *spec) {
33 struct pa_source_output *o;
34 struct pa_resampler *resampler = NULL;
38 if (!pa_sample_spec_equal(&s->sample_spec, spec))
39 if (!(resampler = pa_resampler_new(&s->sample_spec, spec)))
42 o = malloc(sizeof(struct pa_source_output));
44 o->name = name ? strdup(name) : NULL;
48 o->sample_spec = *spec;
53 o->resampler = resampler;
56 r = pa_idxset_put(s->core->source_outputs, o, &o->index);
57 assert(r == 0 && o->index != PA_IDXSET_INVALID);
58 r = pa_idxset_put(s->outputs, o, NULL);
64 void pa_source_output_free(struct pa_source_output* o) {
67 assert(o->source && o->source->core);
68 pa_idxset_remove_by_data(o->source->core->source_outputs, o, NULL);
69 pa_idxset_remove_by_data(o->source->outputs, o, NULL);
72 pa_resampler_free(o->resampler);
78 void pa_source_output_kill(struct pa_source_output*i) {
85 void pa_source_output_push(struct pa_source_output *o, const struct pa_memchunk *chunk) {
86 struct pa_memchunk rchunk;
87 assert(o && chunk && chunk->length && o->push);
94 pa_resampler_run(o->resampler, chunk, &rchunk);
98 assert(rchunk.memblock);
100 pa_memblock_unref(rchunk.memblock);