Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fileprefix is not computed correctly on file-rotation #20

Open
DerOetzi opened this issue Jul 17, 2016 · 0 comments
Open

Fileprefix is not computed correctly on file-rotation #20

DerOetzi opened this issue Jul 17, 2016 · 0 comments

Comments

@DerOetzi
Copy link

DerOetzi commented Jul 17, 2016

I noticed an issue on filenames generated when the wave-file is rotated by jack_capture.

The file are looking like:

jack_capture.01.wav
jack_capture.01.wav.01.wav
...

I did the following local fix you may want to patch into your code:

diff --git a/jack_capture.c b/jack_capture.c
index ee03a8c..7266a82 100644
--- a/jack_capture.c
+++ b/jack_capture.c
@@ -1047,8 +1047,9 @@ static void hook_file_rotated(char *oldfn, char *newfn, int num, int xruns, int
 //////////////////////// DISK ///////////////////////////////////////
 /////////////////////////////////////////////////////////////////////

-// These four variables are used in case we break the 4GB barriere for standard wav files.
+// These five variables are used in case we break the 4GB barriere for standard wav files.
 static int num_files=1;
+static int seq=0;
 static int64_t disksize=0;
 static bool is_using_wav=true;
 static int bytes_per_frame;
@@ -1274,11 +1275,10 @@ static int rotate_file(size_t frames, int reset_totals){

   char *filename_new;
   filename_new=my_calloc(1,strlen(base_filename)+500);
-  sprintf(filename_new,"%s.%0*d.%s",base_filename,leading_zeros+1,num_files,soundfile_format);
+  sprintf(filename_new,"%s%0*d.%s",filename_prefix,leading_zeros+1,++seq,soundfile_format);
   print_message("Closing %s, and continue writing to %s.\n",filename,filename_new);
   num_files++;
-
-  hook_file_rotated(filename, filename_new, num_files, total_overruns + total_xruns, disk_errors);
+  hook_file_rotated(filename, filename_new, seq, total_overruns + total_xruns, disk_errors);

   free(filename);
   filename=filename_new;
@@ -2383,11 +2383,10 @@ void init_arguments(int argc, char *argv[]){
   // Find filename
   {
     if(base_filename==NULL){
-      int try=0;
       base_filename=my_calloc(1,5000);
       for(;;){
-       sprintf(base_filename,"%s%0*d.%s",filename_prefix,leading_zeros+1,++try,soundfile_format);
-       if(access(base_filename,F_OK)) break;
+               sprintf(base_filename,"%s%0*d.%s",filename_prefix,leading_zeros+1,++seq,soundfile_format);
+           if(access(base_filename,F_OK)) break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant