changeset 19502:9161b7653392

compile audio file utilities even when sndfile is not present * audioinfo.cc, audioread.cc, audiowrite.cc: disable compiling parts that require sndfile if it is not present
author Vytautas Jančauskas <unaudio@gmail.com>
date Wed, 11 Sep 2013 19:53:17 +0300
parents e30c88336ee9
children ea5c156aa804
files libinterp/dldfcn/audioinfo.cc libinterp/dldfcn/audioread.cc libinterp/dldfcn/audiowrite.cc
diffstat 3 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/dldfcn/audioinfo.cc	Wed Sep 11 19:14:50 2013 +0300
+++ b/libinterp/dldfcn/audioinfo.cc	Wed Sep 11 19:53:17 2013 +0300
@@ -12,6 +12,7 @@
 )
 {
   octave_scalar_map retval;
+#ifdef HAVE_SNDFILE
   Matrix audio;
   SNDFILE *file;
   SF_INFO info;
@@ -54,5 +55,8 @@
   retval.assign ("Title", sf_get_string (file, SF_STR_TITLE));
   retval.assign ("Artist", sf_get_string (file, SF_STR_ARTIST));
   retval.assign ("Comment", sf_get_string (file, SF_STR_COMMENT));
+#else
+  error("sndfile not found on your system and thus audioinfo is not functional")
+#endif
   return octave_value(retval);
 }
--- a/libinterp/dldfcn/audioread.cc	Wed Sep 11 19:14:50 2013 +0300
+++ b/libinterp/dldfcn/audioread.cc	Wed Sep 11 19:53:17 2013 +0300
@@ -30,6 +30,7 @@
 )
 {
   octave_value_list retval;
+#ifdef HAVE_SNDFILE
   Matrix audio;
   octave_value ret_audio;
   SNDFILE *file;
@@ -105,5 +106,8 @@
     }
   retval(0) = ret_audio;
   retval(1) = info.samplerate;
+#else
+  error("sndfile not found on your system and thus audioread is not functional")
+#endif
   return octave_value(retval);
 }
--- a/libinterp/dldfcn/audiowrite.cc	Wed Sep 11 19:14:50 2013 +0300
+++ b/libinterp/dldfcn/audiowrite.cc	Wed Sep 11 19:53:17 2013 +0300
@@ -61,12 +61,13 @@
 @end deftypefn"
 )
 {
+  octave_scalar_map retval;
+#ifdef HAVE_SNDFILE
   std::map<std::string, int> extension_to_format;
   fill_extension_table(extension_to_format);
   std::string filename = args(0).string_value ();
   std::string extension = filename.substr(filename.find_last_of(".") + 1);
   std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
-  octave_scalar_map retval;
   Matrix audio = args(1).matrix_value ();
   SNDFILE *file;
   SF_INFO info;
@@ -160,5 +161,8 @@
   sf_write_float (file, data, audio.rows () * audio.cols ());
   sf_close (file);
   free (data);
+#else
+  error("sndfile not found on your system and thus audiowrite is not functional")
+#endif
   return octave_value(retval);
 }