Mercurial > hg > dmlib
comparison src/dmengine.c @ 958:985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 27 Feb 2015 03:58:25 +0200 |
parents | 2c6b092328be |
children | 6ca9c334f5cd |
comparison
equal
deleted
inserted
replaced
957:b66653c9acb3 | 958:985225a93aeb |
---|---|
30 { | 30 { |
31 nengineEffectsAlloc += 16; | 31 nengineEffectsAlloc += 16; |
32 engineEffects = dmRealloc(engineEffects, sizeof(DMEffect) * nengineEffectsAlloc); | 32 engineEffects = dmRealloc(engineEffects, sizeof(DMEffect) * nengineEffectsAlloc); |
33 if (engineEffects == NULL) | 33 if (engineEffects == NULL) |
34 { | 34 { |
35 dmError("Could not expand effects structure.\n"); | 35 return dmError(DMERR_INIT_FAIL, |
36 return DMERR_INIT_FAIL; | 36 "Could not expand effects structure.\n"); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 // Copy effects structure | 40 // Copy effects structure |
41 memcpy(engineEffects + nengineEffects, ef, sizeof(DMEffect)); | 41 memcpy(engineEffects + nengineEffects, ef, sizeof(DMEffect)); |
51 | 51 |
52 dmFree(engine->effectData); | 52 dmFree(engine->effectData); |
53 engine->effectData = dmCalloc(nengineEffectsAlloc, sizeof(void *)); | 53 engine->effectData = dmCalloc(nengineEffectsAlloc, sizeof(void *)); |
54 if (engine->effectData == NULL) | 54 if (engine->effectData == NULL) |
55 { | 55 { |
56 dmError("Could not expand effects data structure.\n"); | 56 return dmError(DMERR_INIT_FAIL, |
57 return DMERR_INIT_FAIL; | 57 "Could not expand effects data structure.\n"); |
58 } | 58 } |
59 | 59 |
60 for (i = 0; i < nengineEffects; i++) | 60 for (i = 0; i < nengineEffects; i++) |
61 { | 61 { |
62 DMEffect *eff = &engineEffects[i]; | 62 DMEffect *eff = &engineEffects[i]; |
333 (res = dmResourceFind(eng->resources, name)) != NULL && | 333 (res = dmResourceFind(eng->resources, name)) != NULL && |
334 res->resData != NULL) | 334 res->resData != NULL) |
335 return res->resData; | 335 return res->resData; |
336 else | 336 else |
337 { | 337 { |
338 dmError("Could not find resource '%s'.\n", name); | 338 dmError(DMERR_INTERNAL, |
339 "Could not find resource '%s'.\n", | |
340 name); | |
339 return NULL; | 341 return NULL; |
340 } | 342 } |
341 } | 343 } |
342 | 344 |
343 | 345 |
520 } | 522 } |
521 | 523 |
522 if (SDL_OpenAudio(&engine->optAfmt, NULL) < 0) | 524 if (SDL_OpenAudio(&engine->optAfmt, NULL) < 0) |
523 { | 525 { |
524 // We'll let this pass, as we want to support no-sound. | 526 // We'll let this pass, as we want to support no-sound. |
525 dmError("Couldn't open SDL audio, falling back to no sound: %s\n", SDL_GetError()); | 527 dmMsg(0, |
528 "Couldn't open SDL audio, falling back to no sound: %s\n", | |
529 SDL_GetError()); | |
526 | 530 |
527 // Set up simulated audio thread | 531 // Set up simulated audio thread |
528 engine->audioSimDelay = 1000 / 45; | 532 engine->audioSimDelay = 1000 / 45; |
529 engine->audioSimBufSize = (engine->optAfmt.freq / 45) * engine->audioSampleSize; | 533 engine->audioSimBufSize = (engine->optAfmt.freq / 45) * engine->audioSampleSize; |
530 engine->audioSimBuf = dmMalloc(engine->audioSimBufSize); | 534 engine->audioSimBuf = dmMalloc(engine->audioSimBufSize); |