changeset 144:bf96eac4dbb1

Changed to a variable length buffer of splitbuf_t
author Naoya OYAMA <naoya.oyama@gmail.com>
date Wed, 01 Aug 2012 23:23:24 +0900
parents e72dd5e8d53f
children 4e39ce051c57
files src/recpt1.c src/tssplitter_lite.h
diffstat 2 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/recpt1.c	Sun Jul 29 23:16:30 2012 +0900
+++ b/src/recpt1.c	Wed Aug 01 23:23:24 2012 +0900
@@ -418,6 +418,8 @@
     buf.size = 0;
     buf.data = NULL;
     splitbuf.size = 0;
+    splitbuf.buffer_length = 0;
+    splitbuf.buffer = NULL;
 
     if(wfd == -1)
         fileless = TRUE;
@@ -454,6 +456,15 @@
 
         if(use_splitter) {
             splitbuf.size = 0;
+            if(splitbuf.buffer_length < buf.size && buf.size > 0) {
+                splitbuf.buffer = realloc(splitbuf.buffer, buf.size);
+                if(NULL == splitbuf.buffer) {
+                    fprintf(stderr, "splitbuf.buffer realloc failed\n");
+                    use_splitter = FALSE;
+                    goto fin;
+                }
+                splitbuf.buffer_length = buf.size;
+            }
 
             while(buf.size) {
                 /* $BJ,N%BP>](BPID$B$NCj=P(B */
@@ -608,6 +619,11 @@
                         pthread_kill(signal_thread, SIGPIPE);
                 }
             }
+            if(use_splitter) {
+                free(splitbuf.buffer);
+                splitbuf.buffer = NULL;
+                splitbuf.buffer_length = 0;
+            }
 
             break;
         }
--- a/src/tssplitter_lite.h	Sun Jul 29 23:16:30 2012 +0900
+++ b/src/tssplitter_lite.h	Wed Aug 01 23:23:24 2012 +0900
@@ -107,7 +107,7 @@
 
 /*
  * PCR¤«¤éSTC¤òÀ¸À®¤¹¤ë½èÍýÊý¼°(°Æ)
- * 1. PCR¤òÆó¤Ä¼èÆÀ¤¹¤ë¤Þ¤Ç¥ë¡¼¥×(1.¢²4.¤Þ¤Ç¤Ï½é´ü½èÍý¤Ç¼Â»Ü¤¹¤ë¤³¤È)
+ * 1. PCR¤òÆó¤Ä¼èÆÀ¤¹¤ë¤Þ¤Ç¥ë¡¼¥×(1.¤«¤é4.¤Þ¤Ç¤Ï½é´ü½èÍý¤Ç¼Â»Ü¤¹¤ë¤³¤È)
  * 2. ¥ë¡¼¥×³«»Ï»þ¹ï(PCR)¤È¡¢¥ë¡¼¥×È´¤±¤¿»þ¹ï(PCR)¤Îº¹Ê¬¤ò¼è¤ë
  * 3. ¥ë¡¼¥×³«»Ï¡Á½ªÎ»¤Î´Ö¤Ë½èÍý¤·¤¿¥Ñ¥±¥Ã¥È¿ô¤ò¿ô¤¨¤ë
  * 4. (2.¤ÎPCR¤Î¿Ê¤ó¤À»þ´Ö/3.¤Î¥Ñ¥±¥Ã¥È¿ô)¡¡¤Î·×»»¤Ë¤è¤Ã¤Æ¡¢1¥Ñ¥±¥Ã¥È¤Ë¤è¤Ã¤Æ¿Ê¤àPCR¤òÁÛÄꤹ¤ë
@@ -205,7 +205,8 @@
 typedef struct _splitbuf_t
 {
     int size;
-    u_char buffer[1024*1024];
+    int buffer_length;
+    u_char *buffer;
 } splitbuf_t;
 
 splitter* split_startup(char *sid, char *filename, char *cue_time);