RF64 tweaks 28/162528/1
authorErik de Castro Lopo <erikd@mega-nerd.com>
Tue, 18 Apr 2017 10:07:03 +0000 (20:07 +1000)
committerSeungbae Shin <seungbae.shin@samsung.com>
Thu, 30 Nov 2017 06:08:58 +0000 (15:08 +0900)
* Comments.
* Improve the `rf64_long_file_downgrade_test` test.

Change-Id: I53f2562db1bd450b8e449aa7a6a87e9febfeaaad

src/rf64.c
tests/misc_test.c

index 02dd904..60a3309 100644 (file)
@@ -339,6 +339,7 @@ rf64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
                                        } ;
                                break ;
 
+                       case JUNK_MARKER :
                        case PAD_MARKER :
                                psf_log_printf (psf, "%M : %d\n", marker, chunk_size) ;
                                psf_binheader_readf (psf, "j", chunk_size) ;
@@ -740,6 +741,7 @@ rf64_write_header (SF_PRIVATE *psf, int calc_length)
 
 #endif
 
+       /* Padding may be needed if string data sizes change. */
        pad_size = psf->dataoffset - 16 - psf->header.indx ;
        if (pad_size >= 0)
                psf_binheader_writef (psf, "m4z", PAD_MARKER, (unsigned int) pad_size, make_size_t (pad_size)) ;
index 7352ada..be9dcbf 100644 (file)
@@ -479,17 +479,18 @@ rf64_downgrade_test (const char *filename)
 static void
 rf64_long_file_downgrade_test (const char *filename)
 {      static int      output  [BUFFER_LEN] ;
+       static int      input   [1] = { 0 } ;
 
        SNDFILE         *file ;
        SF_INFO         sfinfo ;
-       sf_count_t      k, output_frames = 0 ;
+       sf_count_t      output_frames = 0 ;
 
        print_test_name (__func__, filename) ;
 
        sf_info_clear (&sfinfo) ;
 
-       for (k = 0 ; k < BUFFER_LEN ; k++)
-               output [k] = 0x1020304 ;
+       memset (output, 0, sizeof (output)) ;
+       output [0] = 0x1020304 ;
 
        sfinfo.samplerate       = 44100 ;
        sfinfo.frames           = ARRAY_LEN (output) ;
@@ -515,6 +516,10 @@ rf64_long_file_downgrade_test (const char *filename)
        exit_if_true (sfinfo.channels != 1, "\n\nLine %d: Incorrect number of channels in file.\n", __LINE__) ;
        exit_if_true (sfinfo.frames != output_frames, "\n\nLine %d: Incorrect number of frames in file (%d should be %d).\n", __LINE__, (int) sfinfo.frames, (int) output_frames) ;
 
+       /* Check that the first sample read is the same as the first written. */
+       test_read_int_or_die (file, 0, input, ARRAY_LEN (input), __LINE__) ;
+       exit_if_true (input [0] != output [0], "\n\nLine %d: Bad first sample (0x%08x).\n", __LINE__, input [0]) ;
+
        check_log_buffer_or_die (file, __LINE__) ;
 
        sf_close (file) ;