diff options
author | Filippos Karapetis | 2009-02-20 20:39:02 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-02-20 20:39:02 +0000 |
commit | 2ddce51a56a73acaa2bc1170d6c6ab087e1170c4 (patch) | |
tree | a7247ed95e6e2a70c1b05e244509db4f2fb04d61 /engines/sci/sfx | |
parent | 1419024bd02aac9c7a3405f34d9cfd6bf38a8447 (diff) | |
download | scummvm-rg350-2ddce51a56a73acaa2bc1170d6c6ab087e1170c4.tar.gz scummvm-rg350-2ddce51a56a73acaa2bc1170d6c6ab087e1170c4.tar.bz2 scummvm-rg350-2ddce51a56a73acaa2bc1170d6c6ab087e1170c4.zip |
Changed more messages to warnings/errors
svn-id: r38621
Diffstat (limited to 'engines/sci/sfx')
-rw-r--r-- | engines/sci/sfx/core.cpp | 77 | ||||
-rw-r--r-- | engines/sci/sfx/device/devices.cpp | 4 | ||||
-rw-r--r-- | engines/sci/sfx/iterator.cpp | 98 | ||||
-rw-r--r-- | engines/sci/sfx/mixer/soft.cpp | 29 | ||||
-rw-r--r-- | engines/sci/sfx/player/polled.cpp | 9 | ||||
-rw-r--r-- | engines/sci/sfx/player/realtime.cpp | 11 | ||||
-rw-r--r-- | engines/sci/sfx/softseq/SN76496.cpp | 6 | ||||
-rw-r--r-- | engines/sci/sfx/softseq/opl2.cpp | 6 | ||||
-rw-r--r-- | engines/sci/sfx/softseq/pcspeaker.cpp | 4 | ||||
-rw-r--r-- | engines/sci/sfx/time.cpp | 3 |
10 files changed, 126 insertions, 121 deletions
diff --git a/engines/sci/sfx/core.cpp b/engines/sci/sfx/core.cpp index 47942bdbf4..6a2180d2ed 100644 --- a/engines/sci/sfx/core.cpp +++ b/engines/sci/sfx/core.cpp @@ -129,22 +129,22 @@ static void _dump_playing_list(sfx_state_t *self, char *msg) { song_t *song = self->song; - fprintf(stderr, "[] Song list : [ "); + warning("[] Song list : [ "); song = *(self->songlib.lib); while (song) { - fprintf(stderr, "%08lx:%d ", song->handle, song->status); + warning("%08lx:%d ", song->handle, song->status); song = song->next_playing; } - fprintf(stderr, "]\n"); + warning("]\n"); - fprintf(stderr, "[] Play list (%s) : [ " , msg); + warning("[] Play list (%s) : [ " , msg); while (song) { - fprintf(stderr, "%08lx ", song->handle); + warning("%08lx ", song->handle); song = song->next_playing; } - fprintf(stderr, "]\n"); + warning("]\n"); } #endif @@ -153,17 +153,17 @@ _dump_songs(sfx_state_t *self) { #if 0 song_t *song = self->song; - fprintf(stderr, "Cue iterators:\n"); + warning("Cue iterators:\n"); song = *(self->songlib.lib); while (song) { - fprintf(stderr, " **\tHandle %08x (p%d): status %d\n", + warning(" **\tHandle %08x (p%d): status %d\n", song->handle, song->priority, song->status); SIMSG_SEND(song->it, SIMSG_PRINT(1)); song = song->next; } if (player) { - fprintf(stderr, "Audio iterator:\n"); + warning("Audio iterator:\n"); player->iterator_message(songit_make_message(0, SIMSG_PRINT(1))); } #endif @@ -238,8 +238,8 @@ _sfx_set_song_status(sfx_state_t *self, song_t *song, int status) { break; default: - fprintf(stderr, "%s L%d: Attempt to set invalid song" - " state %d!\n", __FILE__, __LINE__, status); + warning("%s L%d: Attempt to set invalid song" + " state %d", __FILE__, __LINE__, status); return; } @@ -399,7 +399,7 @@ static int _sfx_timer_active = 0; /* Timer toggle */ int sfx_play_iterator_pcm(song_iterator_t *it, song_handle_t handle) { #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Playing PCM: %08lx\n", handle); + warning("[sfx-core] Playing PCM: %08lx\n", handle); #endif if (mixer) { sfx_pcm_feed_t *newfeed = it->get_pcm_feed(it); @@ -451,7 +451,7 @@ sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) { #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Initialising: flags=%x\n", flags); + warning("[sfx-core] Initialising: flags=%x\n", flags); #endif /*------------------*/ @@ -462,8 +462,8 @@ sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) { timer = &sfx_timer_scummvm; if (!timer) { - fprintf(stderr, "[SFX] " __FILE__": Could not find timing mechanism\n"); - fprintf(stderr, "[SFX] Disabled sound support\n"); + warning("[SFX] " __FILE__": Could not find timing mechanism\n"); + warning("[SFX] Disabled sound support\n"); pcm_device = NULL; player = NULL; mixer = NULL; @@ -471,8 +471,8 @@ sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) { } if (timer->init(_sfx_timer_callback, NULL)) { - fprintf(stderr, "[SFX] " __FILE__": Timer failed to initialize\n"); - fprintf(stderr, "[SFX] Disabled sound support\n"); + warning("[SFX] " __FILE__": Timer failed to initialize\n"); + warning("[SFX] Disabled sound support\n"); timer = NULL; pcm_device = NULL; player = NULL; @@ -527,7 +527,7 @@ sfx_exit(sfx_state_t *self) { callbackMutex->lock(); _sfx_timer_active = 0; #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Uninitialising\n"); + warning("[sfx-core] Uninitialising\n"); #endif song_lib_free(self->songlib); @@ -535,7 +535,7 @@ sfx_exit(sfx_state_t *self) { pcm_device = NULL; if (timer && timer->exit()) - fprintf(stderr, "[SFX] Timer reported error on exit\n"); + warning("[SFX] Timer reported error on exit\n"); /* WARNING: The mixer may hold feeds from the ** player, so we must stop the mixer BEFORE @@ -562,7 +562,7 @@ time_le(GTimeVal a, GTimeVal b) { void sfx_suspend(sfx_state_t *self, int suspend) { #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Suspending? = %d\n", suspend); + warning("[sfx-core] Suspending? = %d\n", suspend); #endif if (suspend && (!self->suspended)) { /* suspend */ @@ -599,7 +599,7 @@ sfx_poll(sfx_state_t *self, song_handle_t *handle, int *cue) *handle = self->song->handle; #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Polling any (%08lx)\n", *handle); + warning("[sfx-core] Polling any (%08lx)\n", *handle); #endif return sfx_poll_specific(self, *handle, cue); } @@ -618,7 +618,7 @@ sfx_poll_specific(sfx_state_t *self, song_handle_t handle, int *cue) { return 0; /* Song not playing */ if (self->debug & SFX_DEBUG_CUES) { - fprintf(stderr, "[SFX:CUE] Polled song %08lx ", handle); + warning("[SFX:CUE] Polled song %08lx ", handle); } while (1) { @@ -665,9 +665,6 @@ sfx_poll_specific(sfx_state_t *self, song_handle_t handle, int *cue) { break; } } - if (self->debug & SFX_DEBUG_CUES) { - fprintf(stderr, "\n"); - } } @@ -680,10 +677,10 @@ sfx_add_song(sfx_state_t *self, song_iterator_t *it, int priority, song_handle_t song_t *song = song_lib_find(self->songlib, handle); #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Adding song: %08lx at %d, it=%p\n", handle, priority, it); + warning("[sfx-core] Adding song: %08lx at %d, it=%p\n", handle, priority, it); #endif if (!it) { - fprintf(stderr, "[SFX] Attempt to add empty song with handle %08lx\n", handle); + warning("[SFX] Attempt to add empty song with handle %08lx\n", handle); return -1; } @@ -699,10 +696,10 @@ sfx_add_song(sfx_state_t *self, song_iterator_t *it, int priority, song_handle_t if (song) { _sfx_set_song_status(self, song, SOUND_STATUS_STOPPED); - fprintf(stderr, "Overwriting old song (%08lx) ...\n", handle); + warning("Overwriting old song (%08lx) ...\n", handle); if (song->status == SOUND_STATUS_PLAYING || song->status == SOUND_STATUS_SUSPENDED) { - fprintf(stderr, "Unexpected (error): Song %ld still playing/suspended (%d)\n", + warning("Unexpected (error): Song %ld still playing/suspended (%d)\n", handle, song->status); songit_free(it); return -1; @@ -727,7 +724,7 @@ sfx_add_song(sfx_state_t *self, song_iterator_t *it, int priority, song_handle_t void sfx_remove_song(sfx_state_t *self, song_handle_t handle) { #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Removing song: %08lx\n", handle); + warning("[sfx-core] Removing song: %08lx\n", handle); #endif if (self->song && self->song->handle == handle) self->song = NULL; @@ -742,14 +739,14 @@ sfx_remove_song(sfx_state_t *self, song_handle_t handle) { /* Song modifications */ /**********************/ -#define ASSERT_SONG(s) if (!(s)) { fprintf(stderr, "Looking up song handle %08lx failed in %s, L%d\n", handle, __FILE__, __LINE__); return; } +#define ASSERT_SONG(s) if (!(s)) { warning("Looking up song handle %08lx failed in %s, L%d\n", handle, __FILE__, __LINE__); return; } void sfx_song_set_status(sfx_state_t *self, song_handle_t handle, int status) { song_t *song = song_lib_find(self->songlib, handle); ASSERT_SONG(song); #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Setting song status to %d" + warning("[sfx-core] Setting song status to %d" " (0:stop, 1:play, 2:susp, 3:wait): %08lx\n", status, handle); #endif @@ -769,7 +766,7 @@ sfx_song_set_fade(sfx_state_t *self, song_handle_t handle, ASSERT_SONG(song); #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Setting fade params of %08lx to " + warning("[sfx-core] Setting fade params of %08lx to " "final volume %d in steps of %d per %d ticks. %s.\n", handle, fade->final_volume, fade->step_size, fade->ticks_per_step, stopmsg[fade->action]); @@ -785,7 +782,7 @@ sfx_song_renice(sfx_state_t *self, song_handle_t handle, int priority) { song_t *song = song_lib_find(self->songlib, handle); ASSERT_SONG(song); #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Renicing song %08lx to %d\n", + warning("[sfx-core] Renicing song %08lx to %d\n", handle, priority); #endif @@ -802,7 +799,7 @@ sfx_song_set_loops(sfx_state_t *self, song_handle_t handle, int loops) { ASSERT_SONG(song); #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Setting loops on %08lx to %d\n", + warning("[sfx-core] Setting loops on %08lx to %d\n", handle, loops); #endif songit_handle_message(&(song->it), msg); @@ -822,7 +819,7 @@ sfx_song_set_hold(sfx_state_t *self, song_handle_t handle, int hold) { song->hold = hold; #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] Setting hold on %08lx to %d\n", + warning("[sfx-core] Setting hold on %08lx to %d\n", handle, loops); #endif songit_handle_message(&(song->it), msg); @@ -852,7 +849,7 @@ sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel, if (command == 0xb0 && arg1 == SCI_MIDI_CHANNEL_MUTE) { - sciprintf("TODO: channel mute (channel %d %s)!\n", channel, + sciprintf("TODO: channel mute (channel %d %s)", channel, channel_state[arg2]); /* We need to have a GET_PLAYMASK interface to use here. SET_PLAYMASK we've got. @@ -888,19 +885,19 @@ sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel, int sfx_get_volume(sfx_state_t *self) { - fprintf(stderr, "FIXME: Implement volume\n"); + warning("FIXME: Implement volume\n"); return 0; } void sfx_set_volume(sfx_state_t *self, int volume) { - fprintf(stderr, "FIXME: Implement volume\n"); + warning("FIXME: Implement volume\n"); } void sfx_all_stop(sfx_state_t *self) { #ifdef DEBUG_SONG_API - fprintf(stderr, "[sfx-core] All stop\n"); + warning("[sfx-core] All stop\n"); #endif song_lib_free(self->songlib); diff --git a/engines/sci/sfx/device/devices.cpp b/engines/sci/sfx/device/devices.cpp index a735cdaf3d..42f5a89dbb 100644 --- a/engines/sci/sfx/device/devices.cpp +++ b/engines/sci/sfx/device/devices.cpp @@ -23,6 +23,8 @@ * */ +#include "common/util.h" + #ifdef HAVE_CONFIG_H # include <config.h> #endif @@ -72,7 +74,7 @@ sfx_find_device(int type, char *name) { if (dev) { if (dev->init(dev)) { - fprintf(stderr, "[SFX] Opening device '%s' failed\n", + error("[SFX] Opening device '%s' failed\n", dev->name); return NULL; } diff --git a/engines/sci/sfx/iterator.cpp b/engines/sci/sfx/iterator.cpp index 0dad4a48f4..cf1e6db059 100644 --- a/engines/sci/sfx/iterator.cpp +++ b/engines/sci/sfx/iterator.cpp @@ -25,6 +25,8 @@ /* Song iterators */ +#include "common/util.h" + #include <stdio.h> #include "sci/include/sfx_iterator_internal.h" #include "sci/include/sfx_player.h" @@ -41,9 +43,9 @@ static const int MIDI_cmdlen[16] = {0, 0, 0, 0, 0, 0, 0, 0, void print_tabs_id(int nr, songit_id_t id) { while (nr-- > 0) - fprintf(stderr, "\t"); + error("\t"); - fprintf(stderr, "[%08lx] ", id); + error("[%08lx] ", id); } #ifndef HAVE_MEMCHR @@ -85,14 +87,14 @@ _common_init(base_song_iterator_t *self) { #define CHECK_FOR_END_ABSOLUTE(offset) \ if (offset > self->size) { \ - fprintf(stderr, SIPFX "Reached end of song without terminator (%x/%x) at %d!\n", offset, self->size, __LINE__); \ + error(SIPFX "Reached end of song without terminator (%x/%x) at %d", offset, self->size, __LINE__); \ return SI_FINISHED; \ } #define CHECK_FOR_END(offset_augment) \ if ((channel->offset + (offset_augment)) > channel->end) { \ channel->state = SI_STATE_FINISHED; \ - fprintf(stderr, SIPFX "Reached end of track %d without terminator (%x+%x/%x) at %d!\n", channel->id, channel->offset, offset_augment, channel->end, __LINE__); \ + error(SIPFX "Reached end of track %d without terminator (%x+%x/%x) at %d", channel->id, channel->offset, offset_augment, channel->end, __LINE__); \ return SI_FINISHED; \ } @@ -170,7 +172,7 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res } if (cmd == 0xfe) { - fprintf(stderr, "song iterator subsystem: Corrupted sound resource detected.\n"); + error("song iterator subsystem: Corrupted sound resource detected.\n"); return SI_FINISHED; } @@ -181,9 +183,9 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res #if 0 if (1) { - fprintf(stderr, "[IT]: off=%x, cmd=%02x, takes %d args ", + error("[IT]: off=%x, cmd=%02x, takes %d args ", channel->offset - 1, cmd, paramsleft); - fprintf(stderr, "[%02x %02x <%02x> %02x %02x %02x]\n", + error("[%02x %02x <%02x> %02x %02x %02x]\n", self->data[channel->offset-3], self->data[channel->offset-2], self->data[channel->offset-1], @@ -221,19 +223,19 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res if (cmd == SCI_MIDI_EOT) { /* End of track? */ _reset_synth_channels(self, channel); - /* fprintf(stderr, "eot; loops = %d, notesplayed=%d\n", self->loops, channel->notes_played);*/ + /* error("eot; loops = %d, notesplayed=%d\n", self->loops, channel->notes_played);*/ if (self->loops > 1 /* && channel->notes_played*/) { /* If allowed, decrement the number of loops */ if (!(flags & PARSE_FLAG_LOOPS_UNLIMITED)) *result = --self->loops; #ifdef DEBUG_DECODING - fprintf(stderr, "%s L%d: (%p):%d Looping ", __FILE__, __LINE__, self, channel->id); + error("%s L%d: (%p):%d Looping ", __FILE__, __LINE__, self, channel->id); if (flags & PARSE_FLAG_LOOPS_UNLIMITED) - fprintf(stderr, "(indef.)"); + error("(indef.)"); else - fprintf(stderr, "(%d)", self->loops); - fprintf(stderr, " %x -> %x\n", + error("(%d)", self->loops); + error(" %x -> %x\n", channel->offset, channel->loop_offset); #endif channel->offset = channel->loop_offset; @@ -241,12 +243,12 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res channel->state = SI_STATE_DELTA_TIME; channel->total_timepos = channel->loop_timepos; channel->last_cmd = 0xfe; - fprintf(stderr, "Looping song iterator %08lx.\n", self->ID); + error("Looping song iterator %08lx.\n", self->ID); return SI_LOOP; } else { channel->state = SI_STATE_FINISHED; #ifdef DEBUG_DECODING - fprintf(stderr, "%s L%d: (%p):%d EOT because" + error("%s L%d: (%p):%d EOT because" " %d notes, %d loops\n", __FILE__, __LINE__, self, channel->id, channel->notes_played, self->loops); @@ -389,12 +391,12 @@ _sci_midi_process_state(base_song_iterator_t *self, unsigned char *buf, int *res channel->state = SI_STATE_FINISHED; delay = (size * 50 + format.rate - 1) / format.rate; /* number of ticks to completion*/ - fprintf(stderr, "delaying %d ticks\n", delay); + error("delaying %d ticks\n", delay); return delay; } case SI_STATE_UNINITIALISED: - fprintf(stderr, SIPFX "Attempt to read command from uninitialized iterator!\n"); + error(SIPFX "Attempt to read command from uninitialized iterator"); self->init((song_iterator_t *) self); return self->next((song_iterator_t *) self, buf, result); @@ -433,7 +435,7 @@ _sci_midi_process_state(base_song_iterator_t *self, unsigned char *buf, int *res if (self->active_channels) --(self->active_channels); #ifdef DEBUG_DECODING - fprintf(stderr, "%s L%d: (%p):%d Finished channel, %d channels left\n", + error("%s L%d: (%p):%d Finished channel, %d channels left\n", __FILE__, __LINE__, self, channel->id, self->active_channels); #endif @@ -450,7 +452,7 @@ _sci_midi_process_state(base_song_iterator_t *self, unsigned char *buf, int *res } default: - fprintf(stderr, SIPFX "Invalid iterator state %d!\n", + error(SIPFX "Invalid iterator state %d", channel->state); BREAKPOINT(); return SI_FINISHED; @@ -509,8 +511,8 @@ _sci0_get_pcm_data(sci0_song_iterator_t *self, self->size - offset); if (!fc) { - fprintf(stderr, SIPFX "Warning: Playing unterminated" - " song!\n"); + error(SIPFX "Warning: Playing unterminated" + " song"); return 1; } @@ -523,7 +525,7 @@ _sci0_get_pcm_data(sci0_song_iterator_t *self, } if (!found_it) { - fprintf(stderr, SIPFX + error(SIPFX "Warning: Song indicates presence of PCM, but" " none found (finally at offset %04x)\n", offset); @@ -542,9 +544,9 @@ _sci0_get_pcm_data(sci0_song_iterator_t *self, if (offset + SCI0_PCM_DATA_OFFSET + size != self->size) { int d = offset + SCI0_PCM_DATA_OFFSET + size - self->size; - fprintf(stderr, SIPFX + error(SIPFX "Warning: PCM advertizes %d bytes of data, but %d" - " bytes are trailing in the resource!\n", + " bytes are trailing in the resource", size, self->size - (offset + SCI0_PCM_DATA_OFFSET)); if (d > 0) @@ -581,7 +583,7 @@ _sci0_handle_message(sci0_song_iterator_t *self, song_iterator_message_t msg) { case _SIMSG_BASEMSG_PRINT: print_tabs_id(msg.args[0].i, self->ID); - fprintf(stderr, "SCI0: dev=%d, active-chan=%d, size=%d, loops=%d\n", + error("SCI0: dev=%d, active-chan=%d, size=%d, loops=%d\n", self->device_id, self->active_channels, self->size, self->loops); break; @@ -596,7 +598,7 @@ _sci0_handle_message(sci0_song_iterator_t *self, song_iterator_message_t msg) { memcpy(mem, self, tsize); sci_refcount_incref(mem->data); #ifdef DEBUG_VERBOSE - fprintf(stderr, "** CLONE INCREF for new %p from %p at %p\n", mem, self, mem->data); + error("** CLONE INCREF for new %p from %p at %p\n", mem, self, mem->data); #endif return (struct _song_iterator *) mem; /* Assume caller has another copy of this */ } @@ -692,7 +694,7 @@ _sci0_init(sci0_song_iterator_t *self) { static void _sci0_cleanup(sci0_song_iterator_t *self) { #ifdef DEBUG_VERBOSE - fprintf(stderr, "** FREEING it %p: data at %p\n", self, self->data); + error("** FREEING it %p: data at %p\n", self, self->data); #endif if (self->data) sci_refcount_decref(self->data); @@ -746,7 +748,7 @@ _sci1_sample_init(sci1_song_iterator_t *self, int offset) { sample->data = self->data + offset + 10; #ifdef DEBUG_VERBOSE - fprintf(stderr, "[SAMPLE] %x/%x/%x/%x l=%x\n", + error("[SAMPLE] %x/%x/%x/%x l=%x\n", offset + 10, begin, end, self->size, length); #endif @@ -1080,7 +1082,7 @@ _sci1_process_next_command(sci1_song_iterator_t *self, } } else if (retval == SI_FINISHED) { #ifdef DEBUG - fprintf(stderr, "FINISHED some channel\n"); + error("FINISHED some channel\n"); #endif } else if (retval > 0) { int sd ; @@ -1116,7 +1118,7 @@ static struct _song_iterator * playmask |= self->channels[i].playmask; print_tabs_id(msg.args[0].i, self->ID); - fprintf(stderr, "SCI1: chan-nr=%d, playmask=%04x\n", + error("SCI1: chan-nr=%d, playmask=%04x\n", self->channels_nr, playmask); } break; @@ -1230,7 +1232,7 @@ static struct _song_iterator * } default: - fprintf(stderr, SIPFX "Unsupported command %d to" + error(SIPFX "Unsupported command %d to" " SCI1 iterator", msg.type); } return (song_iterator_t *) self; @@ -1300,7 +1302,7 @@ _cleanup_iterator_handle_message(song_iterator_t *i, song_iterator_message_t msg if (msg.recipient == _SIMSG_BASEMSG_PRINT && msg.type == _SIMSG_BASEMSG_PRINT) { print_tabs_id(msg.args[0].i, i->ID); - fprintf(stderr, "CLEANUP\n"); + error("CLEANUP\n"); } return NULL; @@ -1403,7 +1405,7 @@ _ff_handle_message(fast_forward_song_iterator_t *self, case _SIMSG_BASEMSG_PRINT: print_tabs_id(msg.args[0].i, self->ID); - fprintf(stderr, "PLASTICWRAP:\n"); + error("PLASTICWRAP:\n"); msg.args[0].i++; songit_handle_message(&(self->delegate), msg); break; @@ -1476,7 +1478,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, int retid; #ifdef DEBUG_TEE_ITERATOR - fprintf(stderr, "[Tee] %02x\n", it->status); + error("[Tee] %02x\n", it->status); #endif if (!(it->status & (TEE_LEFT_ACTIVE | TEE_RIGHT_ACTIVE))) @@ -1491,7 +1493,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, /* Not all are is active? */ int which = 0; #ifdef DEBUG_TEE_ITERATOR - fprintf(stderr, "\tRequesting transformation...\n"); + error("\tRequesting transformation...\n"); #endif if (it->status & TEE_LEFT_ACTIVE) which = TEE_LEFT; @@ -1525,7 +1527,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, it->status |= ready_masks[i]; #ifdef DEBUG_TEE_ITERATOR - fprintf(stderr, "\t Must check %d: %d\n", i, + error("\t Must check %d: %d\n", i, it->children[i].retval); #endif @@ -1536,7 +1538,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, it->status &= ~active_masks[i]; /* Recurse to complete */ #ifdef DEBUG_TEE_ITERATOR - fprintf(stderr, "\t Child %d signalled completion, recursing w/ status %02x\n", i, it->status); + error("\t Child %d signalled completion, recursing w/ status %02x\n", i, it->status); #endif return _tee_read_next_command(it, buf, result); } else if (it->children[i].retval == SI_PCM) { @@ -1557,7 +1559,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, retid = TEE_RIGHT; #ifdef DEBUG_TEE_ITERATOR - fprintf(stderr, "\tl:%d / r:%d / chose %d\n", + error("\tl:%d / r:%d / chose %d\n", it->children[TEE_LEFT].retval, it->children[TEE_RIGHT].retval, retid); #endif #if 0 @@ -1621,7 +1623,7 @@ _tee_handle_message(tee_song_iterator_t *self, song_iterator_message_t msg) { case _SIMSG_BASEMSG_PRINT: print_tabs_id(msg.args[0].i, self->ID); - fprintf(stderr, "TEE:\n"); + error("TEE:\n"); msg.args[0].i++; break; /* And continue with our children */ @@ -1752,7 +1754,7 @@ songit_new_tee(song_iterator_t *left, song_iterator_t *right, int may_destroy) { if (firstfree == MIDI_CHANNELS) { incomplete_map = 1; - fprintf(stderr, "[songit-tee <%08lx,%08lx>] " + error("[songit-tee <%08lx,%08lx>] " "Could not remap right channel #%d:" " Out of channels\n", left->ID, right->ID, i); @@ -1766,14 +1768,14 @@ songit_new_tee(song_iterator_t *left, song_iterator_t *right, int may_destroy) { #ifdef DEBUG_TEE_ITERATOR if (incomplete_map) { int c; - fprintf(stderr, "[songit-tee <%08lx,%08lx>] Channels:" + error("[songit-tee <%08lx,%08lx>] Channels:" " %04x <- %04x | %04x\n", left->ID, right->ID, it->channel_mask, left->channel_mask, right->channel_mask); for (c = 0 ; c < 2; c++) for (i = 0 ; i < 16; i++) - fprintf(stderr, " map [%d][%d] -> %d\n", + error(" map [%d][%d] -> %d\n", c, i, it->children[c].channel_remap[i]); } #endif @@ -1821,14 +1823,14 @@ songit_next(song_iterator_t **it, unsigned char *buf, int *result, int mask) { do { retval = (*it)->next(*it, buf, result); if (retval == SI_MORPH) { - fprintf(stderr, " Morphing %p (stored at %p)\n", (void *)*it, (void *)it); + error(" Morphing %p (stored at %p)\n", (void *)*it, (void *)it); if (!SIMSG_SEND((*it), SIMSG_ACK_MORPH)) { BREAKPOINT(); - } else fprintf(stderr, "SI_MORPH successful\n"); + } else error("SI_MORPH successful\n"); } if (retval == SI_FINISHED) - fprintf(stderr, "[song-iterator] Song finished. mask = %04x, cm=%04x\n", + error("[song-iterator] Song finished. mask = %04x, cm=%04x\n", mask, (*it)->channel_mask); if (retval == SI_FINISHED && (mask & IT_READER_MAY_CLEAN) @@ -1871,7 +1873,7 @@ songit_new(unsigned char *data, unsigned int size, int type, songit_id_t id) { int i; if (!data || size < 22) { - fprintf(stderr, SIPFX "Attempt to instantiate song iterator for null" + error(SIPFX "Attempt to instantiate song iterator for null" " song data\n"); return NULL; } @@ -1921,7 +1923,7 @@ songit_new(unsigned char *data, unsigned int size, int type, songit_id_t id) { default: /**-- Invalid/unsupported sound resources --**/ - fprintf(stderr, SIPFX "Attempt to instantiate invalid/unknown" + error(SIPFX "Attempt to instantiate invalid/unknown" " song iterator type %d\n", type); return NULL; } @@ -2004,7 +2006,7 @@ song_iterator_add_death_listener(song_iterator_t *it, void *client, void (*notify)(void *self, void *notifier)) { if (it->death_listeners_nr >= SONGIT_MAX_LISTENERS) { - fprintf(stderr, "FATAL: Too many death listeners for song" + error("FATAL: Too many death listeners for song" " iterator\n"); BREAKPOINT(); exit(1); @@ -2033,7 +2035,7 @@ song_iterator_remove_death_listener(song_iterator_t *it, } } - fprintf(stderr, "FATAL: Could not remove death listener from " + error("FATAL: Could not remove death listener from " "song iterator\n"); BREAKPOINT(); exit(1); diff --git a/engines/sci/sfx/mixer/soft.cpp b/engines/sci/sfx/mixer/soft.cpp index 093a57e3e9..5aa80c11ae 100644 --- a/engines/sci/sfx/mixer/soft.cpp +++ b/engines/sci/sfx/mixer/soft.cpp @@ -23,6 +23,7 @@ * */ +#include "common/util.h" #include "../mixer.h" #include "sci/include/sci_memory.h" @@ -48,9 +49,9 @@ static volatile int mixer_lock = 0; /*#define DEBUG_LOCKS*/ #ifdef DEBUG_LOCKS -# define DEBUG_ACQUIRE fprintf(stderr, "[ -LOCK -] ACKQ %d: %d\n", __LINE__, mixer_lock) -# define DEBUG_WAIT fprintf(stderr, "[ -LOCK -] WAIT %d: %d\n", __LINE__, mixer_lock); -# define DEBUG_RELEASE ; fprintf(stderr, "[ -LOCK -] REL %d: %d\n", __LINE__, mixer_lock); +# define DEBUG_ACQUIRE error("[ -LOCK -] ACKQ %d: %d\n", __LINE__, mixer_lock) +# define DEBUG_WAIT error("[ -LOCK -] WAIT %d: %d\n", __LINE__, mixer_lock); +# define DEBUG_RELEASE ; error("[ -LOCK -] REL %d: %d\n", __LINE__, mixer_lock); #else # define DEBUG_ACQUIRE # define DEBUG_WAIT @@ -164,7 +165,7 @@ mix_subscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed) { fs->buf_size = 2 + /* Additional safety */ (self->dev->buf_size * (1 + (feed->conf.rate / self->dev->conf.rate))); - fprintf(stderr, " ---> %d/%d/%d/%d = %d\n", + warning(" ---> %d/%d/%d/%d = %d\n", self->dev->buf_size, feed->conf.rate, self->dev->conf.rate, @@ -172,7 +173,7 @@ mix_subscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed) { fs->buf_size); fs->buf = (byte*)sci_malloc(fs->buf_size * feed->frame_size); - fprintf(stderr, " ---> --> %d for %p at %p\n", fs->buf_size * feed->frame_size, (void *)fs, (void *)fs->buf); + warning(" ---> --> %d for %p at %p\n", fs->buf_size * feed->frame_size, (void *)fs, (void *)fs->buf); { int i; for (i = 0; i < fs->buf_size * feed->frame_size; i++) @@ -232,7 +233,7 @@ _mix_unsubscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed) { } for (i = 0; i < self->feeds_nr; i++) - fprintf(stderr, " Feed #%d: %s-%x\n", + warning(" Feed #%d: %s-%x\n", i, self->feeds[i].feed->debug_name, self->feeds[i].feed->debug_nr); @@ -240,7 +241,7 @@ _mix_unsubscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed) { } } - fprintf(stderr, "[sfx-mixer] Assertion failed: Deleting invalid feed %p out of %d\n", + error("[sfx-mixer] Assertion failed: Deleting invalid feed %p out of %d\n", (void *)feed, self->feeds_nr); BREAKPOINT(); @@ -412,7 +413,7 @@ mix_compute_buf_len(sfx_pcm_mixer_t *self, int *skip_frames) return self->dev->buf_size; } - /* fprintf(stderr, "[%d:%d]S%d ", secs, usecs, P->skew);*/ + /* error("[%d:%d]S%d ", secs, usecs, P->skew);*/ if (P->skew > usecs) { secs--; @@ -425,7 +426,7 @@ mix_compute_buf_len(sfx_pcm_mixer_t *self, int *skip_frames) played_frames = frame_pos - P->played_this_second + ((secs - P->lsec) * self->dev->conf.rate); /* - fprintf(stderr, "%d:%d - %d:%d => %d\n", secs, frame_pos, + error("%d:%d - %d:%d => %d\n", secs, frame_pos, P->lsec, P->played_this_second, played_frames); */ @@ -433,7 +434,7 @@ mix_compute_buf_len(sfx_pcm_mixer_t *self, int *skip_frames) played_frames = self->dev->buf_size; /* - fprintf(stderr, "Between %d:? offset=%d and %d:%d offset=%d: Played %d at %d\n", P->lsec, P->played_this_second, + error("Between %d:? offset=%d and %d:%d offset=%d: Played %d at %d\n", P->lsec, P->played_this_second, secs, usecs, frame_pos, played_frames, self->dev->conf.rate); */ @@ -489,7 +490,7 @@ mix_compute_buf_len(sfx_pcm_mixer_t *self, int *skip_frames) } if (result_frames > self->dev->buf_size) { - fprintf(stderr, "[soft-mixer] Internal assertion failed: frames-to-write %d > %d\n", + error("[soft-mixer] Internal assertion failed: frames-to-write %d > %d\n", result_frames, self->dev->buf_size); } return result_frames; @@ -584,7 +585,7 @@ mix_compute_input_linear(sfx_pcm_mixer_t *self, int add_result, ts->secs = -1; if (frames_nr > fs->buf_size) { - fprintf(stderr, "%d (%d*%d + somethign) bytes, but only %d allowed!!!!!\n", + error("%d (%d*%d + somethign) bytes, but only %d allowed!!!!", frames_nr * f->frame_size, fs->spd.val, len, fs->buf_size); @@ -635,7 +636,7 @@ mix_compute_input_linear(sfx_pcm_mixer_t *self, int add_result, return; default: - fprintf(stderr, "[soft-mixer] Fatal: Invalid mode returned by PCM feed %s-%d's get_timestamp(): %d\n", + error("[soft-mixer] Fatal: Invalid mode returned by PCM feed %s-%d's get_timestamp(): %d\n", f->debug_name, f->debug_nr, newmode); exit(1); } @@ -788,7 +789,7 @@ mix_compute_input_linear(sfx_pcm_mixer_t *self, int add_result, xx_size = frames_left * f->frame_size; if (xx_offset + xx_size >= fs->buf_size * f->frame_size) { - fprintf(stderr, "offset %d >= max %d!\n", + error("offset %d >= max %d", (xx_offset + xx_size), fs->buf_size * f->frame_size); BREAKPOINT(); } diff --git a/engines/sci/sfx/player/polled.cpp b/engines/sci/sfx/player/polled.cpp index b5b2eaf386..2274b0003a 100644 --- a/engines/sci/sfx/player/polled.cpp +++ b/engines/sci/sfx/player/polled.cpp @@ -25,12 +25,13 @@ /* Polled player, mostly for PCM-based thingies (which _can_ poll, after all) */ +#include "common/file.h" +#include "common/util.h" + #include "sci/include/sfx_player.h" #include "sci/sfx/softseq.h" #include "sci/sfx/mixer.h" -#include "common/file.h" - static song_iterator_t *play_it; static int play_paused = 0; static sfx_softseq_t *seq; @@ -237,7 +238,7 @@ pp_add_iterator(song_iterator_t *it, GTimeVal start_time) { static int pp_fade_out(void) { - fprintf(stderr, __FILE__": Attempt to fade out- not implemented yet\n"); + warning(__FILE__": Attempt to fade out- not implemented yet\n"); return SFX_ERROR; } @@ -246,7 +247,7 @@ pp_stop(void) { song_iterator_t *it = play_it; play_it = NULL; - fprintf(stderr, "[play] Now stopping it %p\n", (void *)it); + warning("[play] Now stopping it %p\n", (void *)it); if (it) songit_free(it); diff --git a/engines/sci/sfx/player/realtime.cpp b/engines/sci/sfx/player/realtime.cpp index 5821d0b59d..ab3abc1513 100644 --- a/engines/sci/sfx/player/realtime.cpp +++ b/engines/sci/sfx/player/realtime.cpp @@ -27,6 +27,7 @@ ** prays for some reasonable amount of soft real-time, but it's close ** enough, I guess. */ +#include "common/util.h" #include "sci/include/sfx_player.h" #include "sci/sfx/sequencer.h" @@ -158,7 +159,7 @@ find_patch(ResourceManager *resmgr, const char *seq_name, int patchfile) { if (patchfile != SFX_SEQ_PATCHFILE_NONE) { res = scir_find_resource(resmgr, sci_patch, patchfile, 0); if (!res) { - fprintf(stderr, "[SFX] " __FILE__": patch.%03d requested by sequencer (%s), but not found\n", + error("[SFX] " __FILE__": patch.%03d requested by sequencer (%s), but not found\n", patchfile, seq_name); } } @@ -182,7 +183,7 @@ rt_init(ResourceManager *resmgr, int expected_latency) { seq = sfx_find_sequencer(NULL); if (!seq) { - fprintf(stderr, "[SFX] " __FILE__": Could not find sequencer\n"); + error("[SFX] " __FILE__": Could not find sequencer\n"); return SFX_ERROR; } @@ -199,7 +200,7 @@ rt_init(ResourceManager *resmgr, int expected_latency) { res2 ? res2->size : 0, res2 ? res2->data : NULL, seq_dev)) { - fprintf(stderr, "[SFX] " __FILE__": Sequencer failed to initialize\n"); + error("[SFX] " __FILE__": Sequencer failed to initialize\n"); return SFX_ERROR; } @@ -233,7 +234,7 @@ rt_add_iterator(song_iterator_t *it, GTimeVal start_time) { static int rt_fade_out(void) { - fprintf(stderr, __FILE__": Attempt to fade out- not implemented yet\n"); + error(__FILE__": Attempt to fade out- not implemented yet\n"); return SFX_ERROR; } @@ -286,7 +287,7 @@ rt_exit(void) { int retval = SFX_OK; if (seq->close()) { - fprintf(stderr, "[SFX] Sequencer reported error on close\n"); + error("[SFX] Sequencer reported error on close\n"); retval = SFX_ERROR; } diff --git a/engines/sci/sfx/softseq/SN76496.cpp b/engines/sci/sfx/softseq/SN76496.cpp index 0f398180a9..8ec8eb89e4 100644 --- a/engines/sci/sfx/softseq/SN76496.cpp +++ b/engines/sci/sfx/softseq/SN76496.cpp @@ -64,7 +64,7 @@ SN76496_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { int i; int chan = -1; #if 0 - fprintf(stderr, "Note [%02x : %02x %02x]\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); + error("Note [%02x : %02x %02x]\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); #endif if ((command & 0xe0) == 0x80) { int chan_nr = command & 0xf; @@ -96,7 +96,7 @@ SN76496_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { } } #if 0 - fprintf(stderr, " --> %d [%04x], {%d,%d,%d}@%d\n", chan, + error(" --> %d [%04x], {%d,%d,%d}@%d\n", chan, channels_assigned, chan_nrs[0], chan_nrs[1], chan_nrs[2], channel_assigner); #endif @@ -125,7 +125,7 @@ SN76496_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { default: #if DEBUG - fprintf(stderr, "[SFX:PCM-PC] Unused MIDI command %02x %02x %02x\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); + error("[SFX:PCM-PC] Unused MIDI command %02x %02x %02x\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); #endif break; /* ignore */ } diff --git a/engines/sci/sfx/softseq/opl2.cpp b/engines/sci/sfx/softseq/opl2.cpp index 9dc9bf387b..d84a114158 100644 --- a/engines/sci/sfx/softseq/opl2.cpp +++ b/engines/sci/sfx/softseq/opl2.cpp @@ -473,12 +473,12 @@ opl2_poll(sfx_softseq_t *self, byte *dest, int count) { gint16 *ptr = buffer; if (!ready) { - fprintf(stderr, "synth_mixer(): !ready \n"); + error("synth_mixer(): !ready \n"); exit(1); } if (!buffer) { - fprintf(stderr, "synth_mixer(): !buffer \n"); + error("synth_mixer(): !buffer \n"); exit(1); } @@ -537,7 +537,7 @@ opl2_init(sfx_softseq_t *self, byte *data_ptr, int data_length, byte *data2_ptr, if (!(ym3812_L = OPLCreate(OPL_TYPE_YM3812, OPL_INTERNAL_FREQ, SAMPLE_RATE)) || !(ym3812_R = OPLCreate(OPL_TYPE_YM3812, OPL_INTERNAL_FREQ, SAMPLE_RATE))) { - sciprintf("[sfx:seq:opl2] Failure: Emulator init failed!\n"); + sciprintf("[sfx:seq:opl2] Failure: Emulator init failed"); return SFX_ERROR; } diff --git a/engines/sci/sfx/softseq/pcspeaker.cpp b/engines/sci/sfx/softseq/pcspeaker.cpp index ba4236a917..f0685914f1 100644 --- a/engines/sci/sfx/softseq/pcspeaker.cpp +++ b/engines/sci/sfx/softseq/pcspeaker.cpp @@ -56,7 +56,7 @@ sps_exit(sfx_softseq_t *self) { static void sps_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { #if 0 - fprintf(stderr, "Note [%02x : %02x %02x]\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); + error("Note [%02x : %02x %02x]\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); #endif switch (command & 0xf0) { @@ -82,7 +82,7 @@ sps_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { default: #if DEBUG - fprintf(stderr, "[SFX:PCM-PC] Unused MIDI command %02x %02x %02x\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); + error("[SFX:PCM-PC] Unused MIDI command %02x %02x %02x\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); #endif break; /* ignore */ } diff --git a/engines/sci/sfx/time.cpp b/engines/sci/sfx/time.cpp index f908525983..9e366ca4d9 100644 --- a/engines/sci/sfx/time.cpp +++ b/engines/sci/sfx/time.cpp @@ -23,6 +23,7 @@ * */ +#include "common/util.h" #include "sci/include/sfx_time.h" #include "sci/include/resource.h" @@ -60,7 +61,7 @@ sfx_timestamp_frame_diff(sfx_timestamp_t a, sfx_timestamp_t b) { long usecdelta = 0; if (a.frame_rate != b.frame_rate) { - fprintf(stderr, "Fatal: The semantics of subtracting two timestamps with a different base from each other is not defined!\n"); + error("Fatal: The semantics of subtracting two timestamps with a different base from each other is not defined"); BREAKPOINT(); } |