Hi Fred (and list),

I encountered what I consider a mis-feature running Rivendell 2.0.2 on
Debian this evening.

This is a self-compiled instance of Rivendell from the distribution
2.0.2 tarball on Debian "wheezy" (aka "testing").

The problem was that attempting to import audio tracks either through
the rdlibrary GUI or through rdimport(1) was failing to import the
entire track for any tracks longer than a few minutes in duration.

The root cause of the problem was that Debian had kindly configured /tmp
as a RAM file system (tmpfs) and the file system size was only 790MB.
rdxport.cgi ran out of disk space in /tmp but did not "fail gracefully"
on receiving the ENOSPC error when writing (for example)
/tmp/rdaudioconvertbakGAJ/signed32_2.wav.

I've taken the liberty to create a suggested change, but I haven't
done more than recompile, install, and test rdxport.cgi from the
command line. The patch may not be at all in line with your coding
standards, but it suggests one possible way to deal with the issue.

Thanks for all your hard work on this most excellent system! It's been
running (1.7.2) rock solid on our one-year-old community radio station
in Wisconsin. We use it for overnights and for the few other times when
live announcers aren't in the studio.

Cheers!

  ~David Klann
   WDRT 91.9fm, Viroqua, WI, US
   Community Radio From the Ground Up
diff -u -r --exclude '*~' rivendell-2.0.2/lib/rdaudioconvert.cpp rivendell-2.0.2-patched/lib/rdaudioconvert.cpp
--- rivendell-2.0.2/lib/rdaudioconvert.cpp	2011-09-23 23:57:28.544459173 -0500
+++ rivendell-2.0.2-patched/lib/rdaudioconvert.cpp	2011-09-23 23:57:49.553405127 -0500
@@ -255,6 +255,10 @@
   case RDAudioConvert::ErrorInvalidSpeed:
     ret=tr("Invalid speed ratio");
     break;
+
+  case RDAudioConvert::ErrorNoSpace:
+    ret=tr("No Space on disk device");
+    break;
   }
   return ret;
 }
@@ -382,6 +386,7 @@
   sf_count_t start=0;
   sf_count_t end=wave->getSampleLength();
   sf_count_t total_frames=0;
+  sf_count_t frames_written=0;
 
   //
   // Open Destination
@@ -449,13 +454,17 @@
 	      if(total_frames>=start) {
 		if((total_frames+frames)<end) {    // Write entire buffer 
 		  UpdatePeak(pcmbuf,frames*wave->getChannels());
-		  sf_writef_float(sf_dst,pcmbuf,frames);
+		  if ((frames_written = sf_writef_float(sf_dst,pcmbuf,frames)) != frames) {
+		    return RDAudioConvert::ErrorNoSpace;
+		  }
 		}
 		else {
 		  if(total_frames<(total_frames+frames)) {  // Write start of buffer
 		    UpdatePeak(pcmbuf,
 			       (total_frames+frames-end)*wave->getChannels());
-		    sf_writef_float(sf_dst,pcmbuf,total_frames+frames-end);
+		    if ((frames_written = sf_writef_float(sf_dst,pcmbuf,total_frames+frames-end)) != total_frames+frames-end) {
+		      return RDAudioConvert::ErrorNoSpace;
+		    }
 		    //
 		    // Done -- no need to decode the rest
 		    //
@@ -478,7 +487,9 @@
 		int diff=total_frames+frames-start;
 		if(diff>0) {   // Write end of buffer
 		  UpdatePeak(pcmbuf+diff,(frames-diff)*wave->getChannels());
-		  sf_writef_float(sf_dst,pcmbuf+diff,frames-diff);
+		  if ((frames_written = sf_writef_float(sf_dst,pcmbuf+diff,frames-diff)) != frames-diff) {
+		    return RDAudioConvert::ErrorNoSpace;
+		  }
 		}
 	      }
 	      total_frames+=frames;
@@ -529,6 +540,7 @@
   sf_count_t start=0;
   sf_count_t end=wave->getSampleLength();
   sf_count_t frames=0;
+  sf_count_t frames_written=0;
 
   //
   // Load MAD
@@ -585,13 +597,17 @@
       if(frames>=start) {
 	if((frames+mad_synth.pcm.length)<end) {    // Write entire buffer 
 	  UpdatePeak(sf_buffer,mad_synth.pcm.length*wave->getChannels());
-	  sf_writef_float(sf_dst,sf_buffer,mad_synth.pcm.length);
+	  if ((frames_written = sf_writef_float(sf_dst,sf_buffer,mad_synth.pcm.length)) != mad_synth.pcm.length) {
+	    return RDAudioConvert::ErrorNoSpace;
+	  }
 	}
 	else {
 	  if(frames<(frames+mad_synth.pcm.length)) {  // Write start of buffer
 	    UpdatePeak(sf_buffer,
 		       (frames+mad_synth.pcm.length-end)*wave->getChannels());
-	    sf_writef_float(sf_dst,sf_buffer,frames+mad_synth.pcm.length-end);
+	    if ((frames_written = sf_writef_float(sf_dst,sf_buffer,frames+mad_synth.pcm.length-end)) != frames+mad_synth.pcm.length-end) {
+	      return RDAudioConvert::ErrorNoSpace;
+	    }
 	    //
 	    // Done -- no need to decode the rest
 	    //
@@ -609,7 +625,9 @@
 	if(diff>0) {   // Write end of buffer
 	  UpdatePeak(sf_buffer+diff,
 		     (mad_synth.pcm.length-diff)*wave->getChannels());
-	  sf_writef_float(sf_dst,sf_buffer+diff,mad_synth.pcm.length-diff);
+	  if ((frames_written = sf_writef_float(sf_dst,sf_buffer+diff,mad_synth.pcm.length-diff)) != mad_synth.pcm.length-diff) {
+	    return RDAudioConvert::ErrorNoSpace;
+	  }
 	}
       }
       frames+=mad_synth.pcm.length;
@@ -628,7 +646,9 @@
       }
     }
     UpdatePeak(sf_buffer,mad_synth.pcm.length*wave->getChannels());
-    sf_writef_float(sf_dst,sf_buffer,mad_synth.pcm.length);
+    if ((frames_written = sf_writef_float(sf_dst,sf_buffer,mad_synth.pcm.length)) != mad_synth.pcm.length) {
+      return RDAudioConvert::ErrorNoSpace;
+    }
   }
 
   //
@@ -656,6 +676,7 @@
   SF_INFO sf_dst_info;
   sf_count_t start=0;
   sf_count_t end=sf_src_info->frames;
+  sf_count_t frames_written=0;
 
   //
   // Open Destination
@@ -681,7 +702,9 @@
   }
   while((n=sf_readf_float(sf_src,buffer,buffer_size))>0) {
     UpdatePeak(buffer,n*sf_src_info->channels);
-    sf_writef_float(sf_dst,buffer,n);
+    if ((frames_written = sf_writef_float(sf_dst,buffer,n)) != n) {
+      return RDAudioConvert::ErrorNoSpace;
+    }
     start+=n;
     if((end-start)<buffer_size) {
       buffer_size=end-start;
@@ -708,6 +731,7 @@
   bool free_pcm[3]={false,false,false};
   int err;
   sf_count_t n;
+  sf_count_t frames_written=0;
   float ratio=1.0;
   unsigned max_chans=2;
 
@@ -861,7 +885,9 @@
     //
     // Write Output
     //
-    sf_writef_float(dst_sf,pcm[2],n);
+    if ((frames_written = sf_writef_float(dst_sf,pcm[2],n)) != n) {
+      return RDAudioConvert::ErrorNoSpace;
+    }
   }
 
   //
@@ -871,7 +897,9 @@
     st_conv->flush();
     while((n=st_conv->
 	   receiveSamples(pcm[2],STAGE2_BUFFER_SIZE/dst_info.channels))>0) {
-      sf_writef_float(dst_sf,pcm[2],n);
+      if ((frames_written = sf_writef_float(dst_sf,pcm[2],n)) != n) {
+	return RDAudioConvert::ErrorNoSpace;
+      }
     }
     delete st_conv;
   }
diff -u -r --exclude '*~' rivendell-2.0.2/lib/rdaudioconvert.h rivendell-2.0.2-patched/lib/rdaudioconvert.h
--- rivendell-2.0.2/lib/rdaudioconvert.h	2010-07-29 14:32:33.000000000 -0500
+++ rivendell-2.0.2-patched/lib/rdaudioconvert.h	2011-09-23 23:37:42.245481223 -0500
@@ -46,7 +46,7 @@
   enum ErrorCode {ErrorOk=0,ErrorInvalidSettings=1,ErrorNoSource=2,
 		  ErrorNoDestination=3,ErrorInvalidSource=4,ErrorInternal=5,
 		  ErrorFormatNotSupported=6,ErrorNoDisc=7,ErrorNoTrack=8,
-		  ErrorInvalidSpeed=9};
+		  ErrorInvalidSpeed=9,ErrorNoSpace=10};
   RDAudioConvert(const QString &station_name,
 		 QObject *parent=0,const char *name=0);
   ~RDAudioConvert();

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Rivendell-dev mailing list
[email protected]
http://lists.rivendellaudio.org/mailman/listinfo/rivendell-dev

Reply via email to