[pulseaudio-commits] r1300 - /trunk/src/pulsecore/pstream.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sat Aug 19 11:57:41 PDT 2006
Author: lennart
Date: Sat Aug 19 20:57:33 2006
New Revision: 1300
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1300&root=pulseaudio&view=rev
Log:
when transferring large memory chunks of a pa_pstream, split them up
Modified:
trunk/src/pulsecore/pstream.c
Modified: trunk/src/pulsecore/pstream.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/pstream.c?rev=1300&root=pulseaudio&r1=1299&r2=1300&view=diff
==============================================================================
--- trunk/src/pulsecore/pstream.c (original)
+++ trunk/src/pulsecore/pstream.c Sat Aug 19 20:57:33 2006
@@ -78,7 +78,8 @@
typedef uint32_t pa_pstream_descriptor[PA_PSTREAM_DESCRIPTOR_MAX];
#define PA_PSTREAM_DESCRIPTOR_SIZE (PA_PSTREAM_DESCRIPTOR_MAX*sizeof(uint32_t))
-#define FRAME_SIZE_MAX PA_SCACHE_ENTRY_SIZE_MAX /* allow uploading a single sample in one frame at max */
+#define FRAME_SIZE_MAX_ALLOW PA_SCACHE_ENTRY_SIZE_MAX /* allow uploading a single sample in one frame at max */
+#define FRAME_SIZE_MAX_USE (1024*64)
struct item_info {
enum {
@@ -323,7 +324,7 @@
}
void pa_pstream_send_memblock(pa_pstream*p, uint32_t channel, int64_t offset, pa_seek_mode_t seek_mode, const pa_memchunk *chunk) {
- struct item_info *i;
+ size_t length, idx;
assert(p);
assert(p->ref >= 1);
@@ -333,19 +334,34 @@
if (p->dead)
return;
- i = pa_xnew(struct item_info, 1);
- i->type = PA_PSTREAM_ITEM_MEMBLOCK;
- i->chunk = *chunk;
- i->channel = channel;
- i->offset = offset;
- i->seek_mode = seek_mode;
-#ifdef HAVE_CREDS
- i->with_creds = 0;
-#endif
-
- pa_memblock_ref(i->chunk.memblock);
-
- pa_queue_push(p->send_queue, i);
+ length = chunk->length;
+ idx = 0;
+
+ while (length > 0) {
+ struct item_info *i;
+ size_t n;
+
+ i = pa_xnew(struct item_info, 1);
+ i->type = PA_PSTREAM_ITEM_MEMBLOCK;
+
+ n = length < FRAME_SIZE_MAX_USE ? length : FRAME_SIZE_MAX_USE;
+ i->chunk.index = chunk->index + idx;
+ i->chunk.length = n;
+ i->chunk.memblock = pa_memblock_ref(chunk->memblock);
+
+ i->channel = channel;
+ i->offset = offset;
+ i->seek_mode = seek_mode;
+#ifdef HAVE_CREDS
+ i->with_creds = 0;
+#endif
+
+ pa_queue_push(p->send_queue, i);
+
+ idx += n;
+ length -= n;
+ }
+
p->mainloop->defer_enable(p->defer_event, 1);
}
@@ -599,7 +615,7 @@
length = ntohl(p->read.descriptor[PA_PSTREAM_DESCRIPTOR_LENGTH]);
- if (length > FRAME_SIZE_MAX) {
+ if (length > FRAME_SIZE_MAX_ALLOW) {
pa_log_warn("Recieved invalid frame size : %lu", (unsigned long) length);
return -1;
}
More information about the pulseaudio-commits
mailing list