comparison libinterp/dldfcn/audioread.cc @ 20613:647db46ad754

eliminate more simple uses of error_state * audioread.cc: Eliminate simple uses of error_state.
author John W. Eaton <jwe@octave.org>
date Thu, 08 Oct 2015 17:41:21 -0400
parents 00cf2847355d
children
comparison
equal deleted inserted replaced
20612:7374a3a6d594 20613:647db46ad754
82 return retval; 82 return retval;
83 } 83 }
84 84
85 std::string filename = args(0).string_value (); 85 std::string filename = args(0).string_value ();
86 86
87 if (error_state)
88 return retval;
89
90 SF_INFO info; 87 SF_INFO info;
91 info.format = 0; 88 info.format = 0;
92 SNDFILE *file = sf_open (filename.c_str (), SFM_READ, &info); 89 SNDFILE *file = sf_open (filename.c_str (), SFM_READ, &info);
93 90
94 if (! file) 91 if (! file)
109 sf_count_t end = info.frames; 106 sf_count_t end = info.frames;
110 107
111 if ((nargin == 2 && ! args(1).is_string ()) || nargin == 3) 108 if ((nargin == 2 && ! args(1).is_string ()) || nargin == 3)
112 { 109 {
113 RowVector range = args(1).row_vector_value (); 110 RowVector range = args(1).row_vector_value ();
114
115 if (error_state)
116 return retval;
117 111
118 if (range.numel () != 2) 112 if (range.numel () != 2)
119 { 113 {
120 error ("audioread: invalid specification for range of frames"); 114 error ("audioread: invalid specification for range of frames");
121 return retval; 115 return retval;
156 std::string type; 150 std::string type;
157 if (nargin == 3) 151 if (nargin == 3)
158 type = args(2).string_value (); 152 type = args(2).string_value ();
159 else 153 else
160 type = args(1).string_value (); 154 type = args(1).string_value ();
161
162 if (error_state)
163 return retval;
164 155
165 if (type == "native") 156 if (type == "native")
166 { 157 {
167 switch (info.format & SF_FORMAT_SUBMASK) 158 switch (info.format & SF_FORMAT_SUBMASK)
168 { 159 {
299 return retval; 290 return retval;
300 } 291 }
301 292
302 std::string filename = args(0).string_value (); 293 std::string filename = args(0).string_value ();
303 294
304 if (error_state)
305 return retval;
306
307 Matrix audio = args(1).matrix_value (); 295 Matrix audio = args(1).matrix_value ();
308
309 if (error_state)
310 return retval;
311 296
312 double bias = 0.0; 297 double bias = 0.0;
313 double scale = 1.0; 298 double scale = 1.0;
314 299
315 if (args(1).is_uint8_type ()) 300 if (args(1).is_uint8_type ())
323 gripe_wrong_type_arg ("audiowrite", args(1)); 308 gripe_wrong_type_arg ("audiowrite", args(1));
324 return retval; 309 return retval;
325 } 310 }
326 311
327 int samplerate = args(2).int_value (); 312 int samplerate = args(2).int_value ();
328
329 if (error_state)
330 return retval;
331 313
332 std::string ext; 314 std::string ext;
333 size_t dotpos = filename.find_last_of ("."); 315 size_t dotpos = filename.find_last_of (".");
334 if (dotpos != std::string::npos) 316 if (dotpos != std::string::npos)
335 ext = filename.substr (dotpos + 1); 317 ext = filename.substr (dotpos + 1);
496 return retval; 478 return retval;
497 } 479 }
498 480
499 std::string filename = args(0).string_value (); 481 std::string filename = args(0).string_value ();
500 482
501 if (error_state)
502 return retval;
503
504 SF_INFO info; 483 SF_INFO info;
505 info.format = 0; 484 info.format = 0;
506 SNDFILE *file = sf_open (filename.c_str (), SFM_READ, &info); 485 SNDFILE *file = sf_open (filename.c_str (), SFM_READ, &info);
507 486
508 if (! file) 487 if (! file)