2
0

largefile_test.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. ** Copyright (C) 2006-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
  3. **
  4. ** This program is free software; you can redistribute it and/or modify
  5. ** it under the terms of the GNU General Public License as published by
  6. ** the Free Software Foundation; either version 2 of the License, or
  7. ** (at your option) any later version.
  8. **
  9. ** This program is distributed in the hope that it will be useful,
  10. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ** GNU General Public License for more details.
  13. **
  14. ** You should have received a copy of the GNU General Public License
  15. ** along with this program; if not, write to the Free Software
  16. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include "sfconfig.h"
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #if HAVE_UNISTD_H
  23. #include <unistd.h>
  24. #endif
  25. #include <sndfile.h>
  26. #include "utils.h"
  27. #define BUFFER_LEN (1024 * 1024)
  28. #define BUFFER_COUNT (768)
  29. static void largefile_test (int filetype, const char * filename) ;
  30. int
  31. main (void)
  32. {
  33. largefile_test (SF_FORMAT_WAV, "largefile.wav") ;
  34. largefile_test (SF_FORMAT_AIFF, "largefile.aiff") ;
  35. return 0 ;
  36. } /* main */
  37. static void
  38. largefile_test (int filetype, const char * filename)
  39. { static float data [BUFFER_LEN] ;
  40. SNDFILE *file ;
  41. SF_INFO sfinfo ;
  42. int k ;
  43. print_test_name ("largefile_test", filename) ;
  44. sfinfo.samplerate = 44100 ;
  45. sfinfo.channels = 2 ;
  46. sfinfo.frames = 0 ;
  47. sfinfo.format = (filetype | SF_FORMAT_PCM_32) ;
  48. file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
  49. for (k = 0 ; k < BUFFER_COUNT ; k++)
  50. test_write_float_or_die (file, k, data, BUFFER_LEN, __LINE__) ;
  51. sf_close (file) ;
  52. file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
  53. if ((sfinfo.frames * sfinfo.channels) / BUFFER_LEN != BUFFER_COUNT)
  54. { printf ("\n\nLine %d : bad frame count.\n", __LINE__) ;
  55. exit (1) ;
  56. } ;
  57. sf_close (file) ;
  58. unlink (filename) ;
  59. puts ("ok") ;
  60. return ;
  61. } /* largefile_test */