mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-18 06:59:57 -05:00
if we fail to import a memblock fill in silence to guarantee stability of timing
This commit is contained in:
parent
1737a19c86
commit
be81a681ac
3 changed files with 29 additions and 21 deletions
|
|
@ -335,8 +335,7 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
|
|||
|
||||
pa_assert(p);
|
||||
pa_assert(chunk);
|
||||
pa_assert(chunk->memblock);
|
||||
pa_assert(chunk->length);
|
||||
pa_assert(chunk->length > 0);
|
||||
pa_assert(c);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
|
|
@ -344,11 +343,11 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
|
|||
|
||||
if ((s = pa_dynarray_get(c->record_streams, channel))) {
|
||||
|
||||
pa_assert(seek == PA_SEEK_RELATIVE);
|
||||
pa_assert(offset == 0);
|
||||
|
||||
pa_memblockq_seek(s->record_memblockq, offset, seek);
|
||||
pa_memblockq_push_align(s->record_memblockq, chunk);
|
||||
if (chunk->memblock) {
|
||||
pa_memblockq_seek(s->record_memblockq, offset, seek);
|
||||
pa_memblockq_push_align(s->record_memblockq, chunk);
|
||||
} else
|
||||
pa_memblockq_seek(s->record_memblockq, offset+chunk->length, seek);
|
||||
|
||||
if (s->read_callback) {
|
||||
size_t l;
|
||||
|
|
|
|||
|
|
@ -4144,17 +4144,20 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
|
|||
if (playback_stream_isinstance(stream)) {
|
||||
playback_stream *ps = PLAYBACK_STREAM(stream);
|
||||
|
||||
if (seek != PA_SEEK_RELATIVE || offset != 0)
|
||||
pa_asyncmsgq_post(ps->sink_input->sink->asyncmsgq, PA_MSGOBJECT(ps->sink_input), SINK_INPUT_MESSAGE_SEEK, PA_UINT_TO_PTR(seek), offset, NULL, NULL);
|
||||
if (chunk->memblock) {
|
||||
if (seek != PA_SEEK_RELATIVE || offset != 0)
|
||||
pa_asyncmsgq_post(ps->sink_input->sink->asyncmsgq, PA_MSGOBJECT(ps->sink_input), SINK_INPUT_MESSAGE_SEEK, PA_UINT_TO_PTR(seek), offset, NULL, NULL);
|
||||
|
||||
pa_asyncmsgq_post(ps->sink_input->sink->asyncmsgq, PA_MSGOBJECT(ps->sink_input), SINK_INPUT_MESSAGE_POST_DATA, NULL, 0, chunk, NULL);
|
||||
pa_asyncmsgq_post(ps->sink_input->sink->asyncmsgq, PA_MSGOBJECT(ps->sink_input), SINK_INPUT_MESSAGE_POST_DATA, NULL, 0, chunk, NULL);
|
||||
} else
|
||||
pa_asyncmsgq_post(ps->sink_input->sink->asyncmsgq, PA_MSGOBJECT(ps->sink_input), SINK_INPUT_MESSAGE_SEEK, PA_UINT_TO_PTR(seek), offset+chunk->length, NULL, NULL);
|
||||
|
||||
} else {
|
||||
upload_stream *u = UPLOAD_STREAM(stream);
|
||||
size_t l;
|
||||
|
||||
if (!u->memchunk.memblock) {
|
||||
if (u->length == chunk->length) {
|
||||
if (u->length == chunk->length && chunk->memblock) {
|
||||
u->memchunk = *chunk;
|
||||
pa_memblock_ref(u->memchunk.memblock);
|
||||
u->length = 0;
|
||||
|
|
@ -4170,17 +4173,22 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
|
|||
if (l > chunk->length)
|
||||
l = chunk->length;
|
||||
|
||||
|
||||
if (l > 0) {
|
||||
void *src, *dst;
|
||||
void *dst;
|
||||
dst = pa_memblock_acquire(u->memchunk.memblock);
|
||||
src = pa_memblock_acquire(chunk->memblock);
|
||||
|
||||
memcpy((uint8_t*) dst + u->memchunk.index + u->memchunk.length,
|
||||
(uint8_t*) src+chunk->index, l);
|
||||
if (chunk->memblock) {
|
||||
void *src;
|
||||
src = pa_memblock_acquire(chunk->memblock);
|
||||
|
||||
memcpy((uint8_t*) dst + u->memchunk.index + u->memchunk.length,
|
||||
(uint8_t*) src + chunk->index, l);
|
||||
|
||||
pa_memblock_release(chunk->memblock);
|
||||
} else
|
||||
pa_silence_memory((uint8_t*) dst + u->memchunk.index + u->memchunk.length, l, &u->sample_spec);
|
||||
|
||||
pa_memblock_release(u->memchunk.memblock);
|
||||
pa_memblock_release(chunk->memblock);
|
||||
|
||||
u->memchunk.length += l;
|
||||
u->length -= l;
|
||||
|
|
|
|||
|
|
@ -832,8 +832,8 @@ static int do_read(pa_pstream *p) {
|
|||
ntohl(p->read.shm_info[PA_PSTREAM_SHM_INDEX]),
|
||||
ntohl(p->read.shm_info[PA_PSTREAM_SHM_LENGTH])))) {
|
||||
|
||||
pa_log_warn("Failed to import memory block.");
|
||||
return -1;
|
||||
if (pa_log_ratelimit())
|
||||
pa_log_debug("Failed to import memory block.");
|
||||
}
|
||||
|
||||
if (p->recieve_memblock_callback) {
|
||||
|
|
@ -842,7 +842,7 @@ static int do_read(pa_pstream *p) {
|
|||
|
||||
chunk.memblock = b;
|
||||
chunk.index = 0;
|
||||
chunk.length = pa_memblock_get_length(b);
|
||||
chunk.length = b ? pa_memblock_get_length(b) : ntohl(p->read.shm_info[PA_PSTREAM_SHM_LENGTH]);
|
||||
|
||||
offset = (int64_t) (
|
||||
(((uint64_t) ntohl(p->read.descriptor[PA_PSTREAM_DESCRIPTOR_OFFSET_HI])) << 32) |
|
||||
|
|
@ -857,7 +857,8 @@ static int do_read(pa_pstream *p) {
|
|||
p->recieve_memblock_callback_userdata);
|
||||
}
|
||||
|
||||
pa_memblock_unref(b);
|
||||
if (b)
|
||||
pa_memblock_unref(b);
|
||||
}
|
||||
|
||||
goto frame_done;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue