Advertisement
Guest User

Untitled

a guest
Jul 27th, 2013
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 7.54 KB | None | 0 0
  1. Index: cdparanoia.1
  2. ===================================================================
  3. --- cdparanoia.1    (revision 18965)
  4. +++ cdparanoia.1    (working copy)
  5. @@ -207,6 +207,11 @@
  6.  known user data area of the disc, probably causing read errors on most
  7.  drives and possibly even hard lockups on some buggy hardware.
  8.  
  9. +.TP
  10. +.BI "\-x --force-overread
  11. +Force overreading into the lead-out portion of the disc. This option is only applicable when using the
  12. +.B -O
  13. +option with a positive sample offset value. Many drives are not capable of reading into this portion of the disc and attempting to do so on those drives will produce read errors and possibly hard lockups.
  14.  
  15.  .TP
  16.  .B \-Z --disable-paranoia
  17. Index: main.c
  18. ===================================================================
  19. --- main.c  (revision 18965)
  20. +++ main.c  (working copy)
  21. @@ -260,6 +260,7 @@
  22.  "                                    correct\n"
  23.  "  -O --sample-offset <n>          : Add <n> samples to the offset when\n"
  24.  "                                    reading data.  May be negative.\n"
  25. +"  -x --force-overread             : Enable overreading into the lead-out.\n"
  26.  "  -z --never-skip[=n]             : never accept any less than perfect\n"
  27.  "                                    data reconstruction (don't allow 'V's)\n"
  28.  "                                    but if [n] is given, skip after [n]\n"
  29. @@ -607,7 +608,7 @@
  30.      memset(dispcache,' ',graph);
  31.  }
  32.  
  33. -const char *optstring = "escCn:o:O:d:g:k:S:prRwafvqVQhZz::YXWBi:Tt:l::L::A";
  34. +const char *optstring = "escCn:o:O:xd:g:k:S:prRwafvqVQhZz::YXWBi:Tt:l::L::A";
  35.  
  36.  struct option options [] = {
  37.     {"stderr-progress",no_argument,NULL,'e'},
  38. @@ -621,6 +622,7 @@
  39.     {"force-generic-device",required_argument,NULL,'g'},
  40.     {"force-read-speed",required_argument,NULL,'S'},
  41.     {"sample-offset",required_argument,NULL,'O'},
  42. +   {"force-overread",no_argument,NULL,'x'},
  43.     {"toc-offset",required_argument,NULL,'t'},
  44.     {"toc-bias",no_argument,NULL,'T'},
  45.     {"output-raw",no_argument,NULL,'p'},
  46. @@ -682,6 +684,7 @@
  47.    char *force_generic_device=NULL;
  48.    char *force_cooked_device=NULL;
  49.    int force_cdrom_speed=0;
  50. +  int force_overread=0;
  51.    int max_retries=20;
  52.    char *span=NULL;
  53.    int output_type=1; /* 0=raw, 1=wav, 2=aifc */
  54. @@ -856,6 +859,9 @@
  55.      case 'O':
  56.        sample_offset=atoi(optarg);
  57.        break;
  58. +    case 'x':
  59. +      force_overread=1;
  60. +      break;
  61.      default:
  62.        usage(stderr);
  63.        exit(1);
  64. @@ -1179,11 +1185,18 @@
  65.        
  66.      }
  67.  
  68. +   if (toc_offset && !force_overread) {
  69. +       d->disc_toc[d->tracks].dwStartSector -= toc_offset;
  70. +       if (last_sector > cdda_track_lastsector(d, d->tracks))
  71. +           last_sector -= toc_offset;
  72. +    }
  73. +
  74.      {
  75.        long cursor;
  76.        int16_t offset_buffer[1176];
  77.        int offset_buffer_used=0;
  78.        int offset_skip=sample_offset*4;
  79. +      off_t sectorlen;
  80.  
  81.        p=paranoia_init(d);
  82.        paranoia_modeset(p,paranoia_mode);
  83. @@ -1205,7 +1218,7 @@
  84.      need to set the disc length forward here so that the libs are
  85.      willing to read past, assuming that works on the hardware, of
  86.      course */
  87. -      if(sample_offset)
  88. +      if(sample_offset && force_overread)
  89.     d->disc_toc[d->tracks].dwStartSector++;
  90.  
  91.        while(cursor<=last_sector){
  92. @@ -1322,18 +1335,25 @@
  93.         fflush(logfile);
  94.       }
  95.     }
  96. -  
  97. +
  98. +   sectorlen = batch_last - batch_first + 1;
  99. +   if (cdda_sector_gettrack(d, cursor) == d->tracks &&
  100. +       toc_offset > 0 && !force_overread)
  101. +   {
  102. +       sectorlen += toc_offset;
  103. +   }
  104. +
  105.     switch(output_type){
  106.     case 0: /* raw */
  107.       break;
  108.     case 1: /* wav */
  109. -     WriteWav(out,(batch_last-batch_first+1)*CD_FRAMESIZE_RAW);
  110. +     WriteWav(out, sectorlen * CD_FRAMESIZE_RAW);
  111.       break;
  112.     case 2: /* aifc */
  113. -     WriteAifc(out,(batch_last-batch_first+1)*CD_FRAMESIZE_RAW);
  114. +     WriteAifc(out, sectorlen * CD_FRAMESIZE_RAW);
  115.       break;
  116.     case 3: /* aiff */
  117. -     WriteAiff(out,(batch_last-batch_first+1)*CD_FRAMESIZE_RAW);
  118. +     WriteAiff(out, sectorlen * CD_FRAMESIZE_RAW);
  119.       break;
  120.     }
  121.    
  122. @@ -1402,44 +1422,70 @@
  123.  
  124.       /* One last bit of silliness to deal with sample offsets */
  125.       if(sample_offset && cursor>batch_last){
  126. -       int i;
  127. -       /* read a sector and output the partial offset.  Save the
  128. -               rest for the next batch iteration */
  129. -       readbuf=paranoia_read_limited(p,callback,max_retries);
  130. -       err=cdda_errors(d);mes=cdda_messages(d);
  131. +       if (cdda_sector_gettrack(d, batch_last) < d->tracks || force_overread) {
  132. +           int i;
  133.  
  134. -       if(mes || err)
  135. -         fprintf(stderr,"\r                               "
  136. -             "                                           \r%s%s\n",
  137. -             mes?mes:"",err?err:"");
  138. -    
  139. -       if(err)free(err);if(mes)free(mes);
  140. -       if(readbuf==NULL){
  141. -         skipped_flag=1;
  142. -         report("\nparanoia_read: Unrecoverable error reading through "
  143. -            "sample_offset shift\n\tat end of track, bailing.\n");
  144. -         break;
  145. -       }
  146. -       if(skipped_flag && abort_on_skip)break;
  147. -       skipped_flag=0;
  148. -       /* do not move the cursor */
  149. -    
  150. -       if(output_endian!=bigendianp())
  151. -         for(i=0;i<CD_FRAMESIZE_RAW/2;i++)
  152. -       offset_buffer[i]=swap16(readbuf[i]);
  153. -       else
  154. -         memcpy(offset_buffer,readbuf,CD_FRAMESIZE_RAW);
  155. -       offset_buffer_used=sample_offset*4;
  156. -    
  157. -       callback(cursor*(CD_FRAMEWORDS),-2);
  158. +           /* Need to flush the buffer when overreading into the leadout */
  159. +           if (cdda_sector_gettrack(d, batch_last) == d->tracks)
  160. +               paranoia_seek(p, cursor, SEEK_SET);
  161.  
  162. -       if(buffering_write(out,(char *)offset_buffer,
  163. +           /* read a sector and output the partial offset.  Save the
  164. +                  rest for the next batch iteration */
  165. +           readbuf=paranoia_read_limited(p,callback,max_retries);
  166. +           err=cdda_errors(d);mes=cdda_messages(d);
  167. +  
  168. +           if(mes || err)
  169. +             fprintf(stderr,"\r                               "
  170. +                 "                                           \r%s%s\n",
  171. +                 mes?mes:"",err?err:"");
  172. +        
  173. +           if(err)free(err);if(mes)free(mes);
  174. +           if(readbuf==NULL){
  175. +             skipped_flag=1;
  176. +             report("\nparanoia_read: Unrecoverable error reading through "
  177. +                "sample_offset shift\n\tat end of track, bailing.\n");
  178. +             break;
  179. +           }
  180. +           if(skipped_flag && abort_on_skip)break;
  181. +           skipped_flag=0;
  182. +           /* do not move the cursor */
  183. +        
  184. +           if(output_endian!=bigendianp())
  185. +             for(i=0;i<CD_FRAMESIZE_RAW/2;i++)
  186. +           offset_buffer[i]=swap16(readbuf[i]);
  187. +           else
  188. +             memcpy(offset_buffer,readbuf,CD_FRAMESIZE_RAW);
  189. +           offset_buffer_used=sample_offset*4;
  190. +           callback(cursor*(CD_FRAMEWORDS),-2);
  191. +         } else {
  192. +           memset(offset_buffer, 0, sizeof(offset_buffer));
  193. +           offset_buffer_used = sample_offset * 4;
  194. +         }
  195. +
  196. +         if(buffering_write(out,(char *)offset_buffer,
  197.                    offset_buffer_used)){
  198. -         report("Error writing output: %s",strerror(errno));
  199. -         exit(1);
  200. -       }
  201. -     }
  202. +             report("Error writing output: %s",strerror(errno));
  203. +             exit(1);
  204. +         }
  205. +       }
  206.     }
  207. +
  208. +   /* Write sectors of silent audio to compensate for
  209. +       missing samples that would be in the leadout */
  210. +   if (cdda_sector_gettrack(d, batch_last) == d->tracks &&
  211. +       toc_offset > 0 && !force_overread)
  212. +   {
  213. +       char *silence;
  214. +       size_t missing_sector_bytes = CD_FRAMESIZE_RAW * toc_offset;
  215. +
  216. +       silence = calloc(toc_offset, CD_FRAMESIZE_RAW);
  217. +       if (!silence || buffering_write(out, silence, missing_sector_bytes)) {
  218. +             report("Error writing output: %s", strerror(errno));
  219. +             exit(1);
  220. +       }
  221. +       free(silence);
  222. +   }
  223. +
  224.     callback(cursor*(CD_FRAMESIZE_RAW/2)-1,-1);
  225.     buffering_close(out);
  226.     if(skipped_flag){
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement