Mercurial > hg > dmlib
comparison mod2wav.c @ 83:6b42aed2745b
Cleanups and correct the dmf_create_stdio() issue here as well.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 02 Oct 2012 09:57:38 +0300 |
parents | 182e5fac93f5 |
children | 1f8f4d7cb33b |
comparison
equal
deleted
inserted
replaced
82:265ce3091d88 | 83:6b42aed2745b |
---|---|
239 | 239 |
240 // Initialize miniJSS | 240 // Initialize miniJSS |
241 jssInit(); | 241 jssInit(); |
242 | 242 |
243 // Open the source file | 243 // Open the source file |
244 if ((inFile = dmf_create_stdio(srcFilename)) == NULL) | 244 if ((inFile = dmf_create_stdio(srcFilename, "rb")) == NULL) |
245 { | 245 { |
246 fprintf(stderr, "Error opening input file '%s'. (%s)\n", srcFilename, strerror(errno)); | 246 dmError("Error opening input file '%s', %d: %s\n", |
247 srcFilename, errno, strerror(errno)); | |
247 return 1; | 248 return 1; |
248 } | 249 } |
249 | 250 |
250 // Read module file | 251 // Read module file |
251 fprintf(stderr, "Reading file: %s\n", srcFilename); | 252 fprintf(stderr, "Reading file: %s\n", srcFilename); |
271 } | 272 } |
272 #endif | 273 #endif |
273 dmf_close(inFile); | 274 dmf_close(inFile); |
274 if (result != DMERR_OK) | 275 if (result != DMERR_OK) |
275 { | 276 { |
276 fprintf(stderr, "Error loading module file, %d: %s\n", | 277 dmError("Error loading module file, %d: %s\n", |
277 result, dmErrorStr(result)); | 278 result, dmErrorStr(result)); |
278 return 3; | 279 return 3; |
279 } | 280 } |
280 | 281 |
281 // Try to convert it | 282 // Try to convert it |
282 if ((result = jssConvertModuleForPlaying(mod)) != DMERR_OK) | 283 if ((result = jssConvertModuleForPlaying(mod)) != DMERR_OK) |
283 { | 284 { |
284 fprintf(stderr, "Could not convert module for playing, %d: %s\n", | 285 dmError("Could not convert module for playing, %d: %s\n", |
285 result, dmErrorStr(result)); | 286 result, dmErrorStr(result)); |
286 return 3; | 287 return 3; |
287 } | 288 } |
288 | 289 |
289 // Open mixer | 290 // Open mixer |
290 dev = jvmInit(optOutFormat, optOutChannels, optOutFreq, JMIX_AUTO); | 291 dev = jvmInit(optOutFormat, optOutChannels, optOutFreq, JMIX_AUTO); |
291 if (dev == NULL) | 292 if (dev == NULL) |
292 { | 293 { |
293 fprintf(stderr, "jvmInit() returned NULL\n"); | 294 dmError("jvmInit() returned NULL\n"); |
294 return 4; | 295 return 4; |
295 } | 296 } |
296 | 297 |
297 sampSize = jvmGetSampleSize(dev); | 298 sampSize = jvmGetSampleSize(dev); |
298 mb = dmMalloc(bufLen * sampSize); | 299 if ((mb = dmMalloc(bufLen * sampSize)) == NULL) |
299 if (mb == NULL) | 300 { |
300 { | 301 dmError("Could not allocate mixing buffer\n"); |
301 fprintf(stderr, "Could not allocate mixing buffer\n"); | |
302 return 5; | 302 return 5; |
303 } | 303 } |
304 | 304 |
305 dmMsg(1, "Using fmt=%d, bits=%d, channels=%d, freq=%d [%d / sample]\n", | 305 dmMsg(1, "Using fmt=%d, bits=%d, channels=%d, freq=%d [%d / sample]\n", |
306 optOutFormat, jvmGetSampleRes(dev), optOutChannels, optOutFreq, | 306 optOutFormat, jvmGetSampleRes(dev), optOutChannels, optOutFreq, |
307 sampSize); | 307 sampSize); |
308 | 308 |
309 // Initialize player | 309 // Initialize player |
310 if ((plr = jmpInit(dev)) == NULL) | 310 if ((plr = jmpInit(dev)) == NULL) |
311 { | 311 { |
312 fprintf(stderr, "jmpInit() returned NULL\n"); | 312 dmError("jmpInit() returned NULL.\n"); |
313 return 6; | 313 return 6; |
314 } | 314 } |
315 | 315 |
316 // Set callback | 316 // Set callback |
317 jvmSetCallback(dev, jmpExec, plr); | 317 jvmSetCallback(dev, jmpExec, plr); |