[polypaudio-commits] r787 - in /trunk/src/polypcore: core-scache.c core-scache.h pstream.c sound-file.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sun Apr 23 13:59:10 PDT 2006


Author: lennart
Date: Sun Apr 23 22:59:09 2006
New Revision: 787

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=787&root=polypaudio&view=rev
Log:
enforce maximum sample size in sample cache

Modified:
    trunk/src/polypcore/core-scache.c
    trunk/src/polypcore/core-scache.h
    trunk/src/polypcore/pstream.c
    trunk/src/polypcore/sound-file.c

Modified: trunk/src/polypcore/core-scache.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/core-scache.c?rev=787&root=polypaudio&r1=786&r2=787&view=diff
==============================================================================
--- trunk/src/polypcore/core-scache.c (original)
+++ trunk/src/polypcore/core-scache.c Sun Apr 23 22:59:09 2006
@@ -133,6 +133,9 @@
     pa_scache_entry *e;
     assert(c && name);
 
+    if (chunk->length > PA_SCACHE_ENTRY_SIZE_MAX)
+        return -1;
+
     if (!(e = scache_add_item(c, name)))
         return -1;
 

Modified: trunk/src/polypcore/core-scache.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/core-scache.h?rev=787&root=polypaudio&r1=786&r2=787&view=diff
==============================================================================
--- trunk/src/polypcore/core-scache.h (original)
+++ trunk/src/polypcore/core-scache.h Sun Apr 23 22:59:09 2006
@@ -25,6 +25,8 @@
 #include <polypcore/core.h>
 #include <polypcore/memchunk.h>
 #include <polypcore/sink.h>
+
+#define PA_SCACHE_ENTRY_SIZE_MAX (1024*1024*2)
 
 typedef struct pa_scache_entry {
     pa_core *core;

Modified: trunk/src/polypcore/pstream.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/pstream.c?rev=787&root=polypaudio&r1=786&r2=787&view=diff
==============================================================================
--- trunk/src/polypcore/pstream.c (original)
+++ trunk/src/polypcore/pstream.c Sun Apr 23 22:59:09 2006
@@ -37,6 +37,7 @@
 #include <polypcore/queue.h>
 #include <polypcore/xmalloc.h>
 #include <polypcore/log.h>
+#include <polypcore/core-scache.h>
 
 #include "pstream.h"
 
@@ -52,7 +53,7 @@
 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 (1024*500) /* half a megabyte */
+#define FRAME_SIZE_MAX PA_SCACHE_ENTRY_SIZE_MAX /* allow uploading a single sample in one frame at max */
 
 struct item_info {
     enum { PA_PSTREAM_ITEM_PACKET, PA_PSTREAM_ITEM_MEMBLOCK } type;
@@ -419,7 +420,7 @@
 
         /* Frame size too large */
         if (ntohl(p->read.descriptor[PA_PSTREAM_DESCRIPTOR_LENGTH]) > FRAME_SIZE_MAX) {
-            pa_log_warn(__FILE__": Frame size too large");
+            pa_log_warn(__FILE__": Frame size too large: %lu > %lu", (unsigned long) ntohl(p->read.descriptor[PA_PSTREAM_DESCRIPTOR_LENGTH]), (unsigned long) FRAME_SIZE_MAX);
             return -1;
         }
         

Modified: trunk/src/polypcore/sound-file.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/sound-file.c?rev=787&root=polypaudio&r1=786&r2=787&view=diff
==============================================================================
--- trunk/src/polypcore/sound-file.c (original)
+++ trunk/src/polypcore/sound-file.c Sun Apr 23 22:59:09 2006
@@ -32,8 +32,7 @@
 #include <polypcore/log.h>
 
 #include "sound-file.h"
-
-#define MAX_FILE_SIZE (1024*1024)
+#include "core-scache.h"
 
 int pa_sound_file_load(const char *fname, pa_sample_spec *ss, pa_channel_map *map, pa_memchunk *chunk, pa_memblock_stat *s) {
     SNDFILE*sf = NULL;
@@ -78,7 +77,7 @@
     if (map)
         pa_channel_map_init_auto(map, ss->channels);
     
-    if ((l = pa_frame_size(ss)*sfinfo.frames) > MAX_FILE_SIZE) {
+    if ((l = pa_frame_size(ss)*sfinfo.frames) > PA_SCACHE_ENTRY_SIZE_MAX) {
         pa_log(__FILE__": File too large");
         goto finish;
     }
@@ -134,7 +133,7 @@
     ss.rate = sfinfo.samplerate;
     ss.channels = sfinfo.channels;
 
-    if ((pa_frame_size(&ss) * sfinfo.frames) > MAX_FILE_SIZE) {
+    if ((pa_frame_size(&ss) * sfinfo.frames) > PA_SCACHE_ENTRY_SIZE_MAX) {
         pa_log(__FILE__": File too large %s", fname);
         return 1;
     }




More information about the pulseaudio-commits mailing list