- Timestamp:
- Dec 15, 2018, 11:49:41 AM (6 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/crepe, fix/ffmpeg5, master
- Children:
- 40bdc14
- Parents:
- 7107ed9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/sink_vorbis.c
r7107ed9 r0850e54 110 110 111 111 s->fid = fopen((const char *)s->path, "wb"); 112 if (!s->fid) return AUBIO_FAIL; 112 if (!s->fid) { 113 AUBIO_ERR("sink_vorbis: Error opening file %s (%s)\n", 114 s->path, strerror(errno)); 115 return AUBIO_FAIL; 116 } 113 117 114 118 vorbis_info_init(&s->vi); … … 134 138 { 135 139 int ret = 0; 140 size_t wrote; 136 141 ogg_packet header; 137 142 ogg_packet header_comm; … … 150 155 ret = ogg_stream_flush(&s->os, &s->og); 151 156 if (ret==0) break; 152 fwrite(s->og.header, 1, s->og.header_len, s->fid); 153 fwrite(s->og.body, 1, s->og.body_len, s->fid); 157 wrote = fwrite(s->og.header, 1, s->og.header_len, s->fid); 158 ret = (wrote == (unsigned)s->og.header_len); 159 wrote = fwrite(s->og.body, 1, s->og.body_len, s->fid); 160 ret &= (wrote == (unsigned)s->og.body_len); 161 if (ret == 0) { 162 AUBIO_ERR("sink_vorbis: failed writing \'%s\' to disk (%s)\n", 163 s->path, strerror(errno)); 164 return AUBIO_FAIL; 165 } 154 166 } 155 167 } … … 195 207 void aubio_sink_vorbis_write(aubio_sink_vorbis_t *s) 196 208 { 209 int result; 210 size_t wrote; 197 211 // pre-analysis 198 212 while (vorbis_analysis_blockout(&s->vd, &s->vb) == 1) { … … 206 220 207 221 while (1) { 208 intresult = ogg_stream_pageout (&s->os, &s->og);222 result = ogg_stream_pageout (&s->os, &s->og); 209 223 if (result == 0) break; 210 fwrite(s->og.header, 1, s->og.header_len, s->fid); 211 fwrite(s->og.body, 1, s->og.body_len, s->fid); 224 wrote = fwrite(s->og.header, 1, s->og.header_len, s->fid); 225 result = (wrote == (unsigned)s->og.header_len); 226 wrote = fwrite(s->og.body, 1, s->og.body_len, s->fid); 227 result &= (wrote == (unsigned)s->og.body_len); 228 if (result == 0) { 229 AUBIO_WRN("sink_vorbis: failed writing \'%s\' to disk (%s)\n", 230 s->path, strerror(errno)); 231 } 212 232 if (ogg_page_eos(&s->og)) break; 213 233 }
Note: See TracChangeset
for help on using the changeset viewer.