mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
fix an assert when runnig module-oss in record only-mode. optimize allocation of memblocks on playback
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1777 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
d60940dbe4
commit
b41dbfd28d
3 changed files with 56 additions and 23 deletions
|
|
@ -210,7 +210,7 @@ static int unix_read(struct userdata *u) {
|
|||
|
||||
for (;;) {
|
||||
void *p;
|
||||
snd_pcm_sframes_t t;
|
||||
snd_pcm_sframes_t t, k;
|
||||
ssize_t l;
|
||||
int err;
|
||||
pa_memchunk chunk;
|
||||
|
|
@ -228,10 +228,17 @@ static int unix_read(struct userdata *u) {
|
|||
if (l <= 0)
|
||||
return work_done;
|
||||
|
||||
chunk.memblock = pa_memblock_new(u->core->mempool, l);
|
||||
chunk.memblock = pa_memblock_new(u->core->mempool, (size_t) -1);
|
||||
|
||||
k = pa_memblock_get_length(chunk.memblock);
|
||||
|
||||
if (k > l)
|
||||
k = l;
|
||||
|
||||
k = (k/u->frame_size)*u->frame_size;
|
||||
|
||||
p = pa_memblock_acquire(chunk.memblock);
|
||||
t = snd_pcm_readi(u->pcm_handle, (uint8_t*) p, l / u->frame_size);
|
||||
t = snd_pcm_readi(u->pcm_handle, (uint8_t*) p, k / u->frame_size);
|
||||
pa_memblock_release(chunk.memblock);
|
||||
|
||||
/* pa_log("wrote %i bytes of %u (%u)", t*u->frame_size, u->memchunk.length, l); */
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ struct userdata {
|
|||
|
||||
pa_memchunk memchunk;
|
||||
|
||||
size_t frame_size;
|
||||
uint32_t in_fragment_size, out_fragment_size, in_nfrags, out_nfrags, in_hwbuf_size, out_hwbuf_size;
|
||||
int use_getospace, use_getispace;
|
||||
int use_getodelay;
|
||||
|
|
@ -941,14 +942,21 @@ static void thread_func(void *userdata) {
|
|||
}
|
||||
|
||||
do {
|
||||
ssize_t t;
|
||||
ssize_t t, k;
|
||||
|
||||
pa_assert(l > 0);
|
||||
|
||||
memchunk.memblock = pa_memblock_new(u->core->mempool, l);
|
||||
memchunk.memblock = pa_memblock_new(u->core->mempool, (size_t) -1);
|
||||
|
||||
k = pa_memblock_get_length(memchunk.memblock);
|
||||
|
||||
if (k > l)
|
||||
k = l;
|
||||
|
||||
k = (k/u->frame_size)*u->frame_size;
|
||||
|
||||
p = pa_memblock_acquire(memchunk.memblock);
|
||||
t = pa_read(u->fd, p, l, &read_type);
|
||||
t = pa_read(u->fd, p, k, &read_type);
|
||||
pa_memblock_release(memchunk.memblock);
|
||||
|
||||
pa_assert(t != 0); /* EOF cannot happen */
|
||||
|
|
@ -992,16 +1000,20 @@ static void thread_func(void *userdata) {
|
|||
/* pa_log("loop2"); */
|
||||
|
||||
/* Now give the sink inputs some to time to process their data */
|
||||
if ((ret = pa_sink_process_inputs(u->sink)) < 0)
|
||||
goto fail;
|
||||
if (ret > 0)
|
||||
continue;
|
||||
if (u->sink) {
|
||||
if ((ret = pa_sink_process_inputs(u->sink)) < 0)
|
||||
goto fail;
|
||||
if (ret > 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Now give the source outputs some to time to process their data */
|
||||
if ((ret = pa_source_process_outputs(u->source)) < 0)
|
||||
goto fail;
|
||||
if (ret > 0)
|
||||
continue;
|
||||
if (u->source) {
|
||||
if ((ret = pa_source_process_outputs(u->source)) < 0)
|
||||
goto fail;
|
||||
if (ret > 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check whether there is a message for us to process */
|
||||
if ((ret = pa_thread_mq_process(&u->thread_mq) < 0))
|
||||
|
|
@ -1148,6 +1160,7 @@ int pa__init(pa_module*m) {
|
|||
u->use_getodelay = 1;
|
||||
u->use_input_volume = u->use_pcm_volume = 1;
|
||||
u->mode = mode;
|
||||
u->frame_size = pa_frame_size(&ss);
|
||||
u->device_name = pa_xstrdup(dev);
|
||||
u->in_nfrags = u->out_nfrags = u->nfrags = nfrags;
|
||||
u->out_fragment_size = u->in_fragment_size = u->frag_size = frag_size;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue