This file is part of polypaudio.
polypaudio is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
+ it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU Lesser General Public License
along with polypaudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
i->kill = NULL;
i->get_latency = NULL;
i->userdata = NULL;
+ i->underrun = NULL;
i->volume = PA_VOLUME_NORM;
+ i->playing = 0;
i->resampled_chunk.memblock = NULL;
i->resampled_chunk.index = i->resampled_chunk.length = 0;
}
int pa_sink_input_peek(struct pa_sink_input *i, struct pa_memchunk *chunk) {
- int ret = 0;
+ int ret = -1;
assert(i && chunk && i->ref >= 1);
- if (!i->peek || !i->drop)
- return -1;
-
- if (i->state == PA_SINK_INPUT_CORKED)
- return -1;
-
- if (!i->resampler)
- return i->peek(i, chunk);
-
pa_sink_input_ref(i);
+ if (!i->peek || !i->drop || i->state == PA_SINK_INPUT_CORKED)
+ goto finish;
+
+ if (!i->resampler) {
+ ret = i->peek(i, chunk);
+ goto finish;
+ }
+
while (!i->resampled_chunk.memblock) {
struct pa_memchunk tchunk;
size_t l;
finish:
+ if (ret < 0 && i->playing && i->underrun)
+ i->underrun(i);
+
+ i->playing = ret >= 0;
+
pa_sink_input_unref(i);
return ret;