OSDN Git Service

tunerec: make buf malloc-ed instead of fixed array
[rec10/rec10-git.git] / tunerec / tunerec.c
index 8201f24..822200a 100755 (executable)
@@ -1,3 +1,5 @@
+#define _FILE_OFFSET_BITS 64
+
 #include <linux/dvb/frontend.h>
 #include <linux/dvb/dmx.h>
 #include <linux/dvb/audio.h>
@@ -233,7 +235,7 @@ void record(int adapter_nr, char* output, int rectime) {
 void * record_read(void * priv) {
        ssize_t rt;
        time_t start_time, current_time;
-       char buf[DVB_READ_BUFFER_SIZE];
+       char* buf = malloc(DVB_READ_BUFFER_SIZE);
        my_thread_arg* p = (my_thread_arg*)priv;
 
        start_time = time(NULL);
@@ -270,7 +272,7 @@ void * record_read(void * priv) {
 
 void * record_write(void * priv) {
        ssize_t rt = 0, wt, shift;
-       char buf[DVB_WRITE_BUFFER_SIZE];
+       char* buf = malloc(DVB_WRITE_BUFFER_SIZE);
        my_thread_arg* p = (my_thread_arg*)priv;
 
        while ( 1 ) {
@@ -300,7 +302,7 @@ void * record_write(void * priv) {
                }
                if ( rt > 0 ) {
                        // [buf] is not correctly written to [fout]
-                       printf("output file write failed\n");
+                       printf("output file write failed. err=%d\n", errno);
                        goto error;
                }
        }
@@ -318,7 +320,8 @@ int main(int argc, char *argv[]) {
        int rectime;
 
        if (argc != 6) {
-               fprintf(stderr, "Usage: %s adapter_nr freq tsid rectime output\n", argv[0]);
+               fprintf(stderr, "Usage  : %s adapter_nr freq tsid rectime output\n", argv[0]);
+               fprintf(stderr, "Version: 0.0.1\n");
                return 1;
        }
        adapter_nr = strtol(argv[1], NULL, 0);