# HG changeset patch # User Eric Wing # Date 1288258366 25200 # Node ID 4b1048af7e55e0dc7fa3b14606e0a009a7518c22 # Parent 8cb13d89451af0c6d1dc3427959c16198a18825d Disabled some of the debugging printfs diff -r 8cb13d89451a -r 4b1048af7e55 ALmixer.c --- a/ALmixer.c Thu Oct 28 01:26:11 2010 -0700 +++ b/ALmixer.c Thu Oct 28 02:32:46 2010 -0700 @@ -506,19 +506,18 @@ alGetString(error)); } + /* fprintf(stderr, "For source: %d, buffers_queued=%d, buffers_processed=%d\n", source, buffers_queued, buffers_processed); - +*/ } static void Init_Channel(ALint channel) { - -fprintf(stderr, "Init channel %d\n", channel); ALmixer_Channel_List[channel].channel_in_use = 0; ALmixer_Channel_List[channel].callback_update = 0; ALmixer_Channel_List[channel].needs_stream = 0; @@ -1124,7 +1123,7 @@ ); } -/* From SDL_Sound's playsound. Converts milliseconds to byte positions. +/* Converts milliseconds to byte positions. * This is needed for seeking on predecoded samples */ static ALuint Convert_Msec_To_Byte_Pos(Sound_AudioInfo *info, ALuint ms) @@ -1132,26 +1131,17 @@ float frames_per_ms; ALuint frame_offset; ALuint frame_size; - fprintf(stderr, "In convert\n" ); if(info == NULL) { fprintf(stderr, "Error, info is NULL\n"); } - else - { - fprintf(stderr, "Not an error: info is not NULL\n"); - } - fprintf(stderr, "The rate=%d\n", info->rate); /* "frames" == "sample frames" */ frames_per_ms = ((float) info->rate) / 1000.0f; - fprintf(stderr, "%f\n", frames_per_ms); frame_offset = (ALuint) (frames_per_ms * ((float) ms)); - fprintf(stderr, "%d\n", frame_offset); frame_size = (ALuint) ((info->format & 0xFF) / 8) * info->channels; - fprintf(stderr, "%d\n", frame_size); - return(frame_offset * frame_size); -} /* cvtMsToBytePos */ + return frame_offset * frame_size; +} static ALint Set_Predecoded_Seek_Position(ALmixer_Data* data, ALuint byte_position) { @@ -1163,8 +1153,10 @@ if(byte_position > data->total_bytes) { /* We can't go past the end, so set to end? */ + /* fprintf(stderr, "Error, can't seek past end\n"); - + */ + /* In case the below thing doesn't work, * just rewind the whole thing. * @@ -1244,7 +1236,9 @@ index = LookUpBuffer(buffer, data->buffer_map_list, data->max_queue_buffers); if(-1 == index) { + /* fprintf(stderr, ">>>>>>>CopyData catch, albuffer=%d\n",buffer); +*/ return -1; } /* Copy the data to the access buffer */ @@ -1382,7 +1376,9 @@ /* Now reset the bytes_decoded to reflect the entire * buffer to tell alBufferData what our full size is. */ + /* fprintf(stderr, "ALTERED bytes decoded for silence: Original end was %d\n", bytes_decoded); + */ bytes_decoded = data->sample->buffer_size; } /*********** END EXPERIMENT ******************************/ @@ -1690,7 +1686,6 @@ /* If the user specified a specific channel */ if(channel >= 0) { - fprintf(stderr, "Halt on channel %d\n", channel); /* only need to process channel if in use */ if(ALmixer_Channel_List[channel].channel_in_use) { @@ -1712,7 +1707,6 @@ * remove the processed buffers and force remove the * still-queued buffers. */ - fprintf(stderr, "Halt on channel %d, channel in use\n", channel); alGetSourcei( ALmixer_Channel_List[channel].alsource, AL_BUFFERS_QUEUED, &buffers_still_queued @@ -1770,12 +1764,9 @@ ALint i; for(i=0; inum_buffers_in_use = 0; - fprintf(stderr, "Clean channel %d\n", i); Clean_Channel(i); Is_Playing_global--; /* Launch callback for consistency? */ - fprintf(stderr, "Callback%d\n", i); Invoke_Channel_Done_Callback(i, did_finish_naturally); /* Increment the counter */ @@ -2046,7 +2034,9 @@ */ if(data->in_use) { + /* fprintf(stderr, "Warning sample is in use. May not be able to rewind\n"); + */ /* ALmixer_SetError("Data is in use. Cannot rewind unless all sources using the data are halted\n"); return -1; @@ -2100,7 +2090,6 @@ /* Remaining stuff for streamed data */ -fprintf(stderr, "Rewinding for stream\n"); data->eof = 0; retval = Sound_Rewind(data->sample); if(0 == retval) @@ -2108,8 +2097,6 @@ ALmixer_SetError( Sound_GetError() ); return -1; } -fprintf(stderr, "Rewinding succeeded\n"); -fprintf(stderr, "calling GetMoreData for Rewinding for stream\n"); #if 0 /* Clear error */ alGetError(); @@ -2130,7 +2117,6 @@ #endif -fprintf(stderr, "end Rewinding for stream\n"); return retval; } @@ -2238,7 +2224,6 @@ ALint i; for(i=0; ibuffer[0]); + */ for(j=1; jnum_startup_buffers; j++) { + /* fprintf(stderr, "Filling buffer #%d (AL id is %d)\n", j, data->buffer[j]); - /* fprintf(stderr, ">>>>>>>>>>>>>>>>>>HACK for GetMoreData2\n"); */ bytes_returned = GetMoreData( @@ -2591,7 +2578,9 @@ /* Check for loops */ if( ALmixer_Channel_List[channel].loops != 0 ) { + /* fprintf(stderr, "Need to rewind. In RAMPUP, handling loop\n"); +*/ if(0 == Sound_Rewind(data->sample)) { fprintf(stderr, "error in rewind\n"); @@ -2606,7 +2595,9 @@ if(ALmixer_Channel_List[channel].loops > 0) { ALmixer_Channel_List[channel].loops--; + /* fprintf(stderr, "Inside 000 >>>>>>>>>>Loops=%d\n", ALmixer_Channel_List[channel].loops); +*/ } /* Would like to redo the loop, but due to * Sound_Rewind() bugs, we would risk falling @@ -2781,7 +2772,6 @@ /* If the user specified a specific channel */ if(channel >= 0) { - fprintf(stderr, "Pause on channel %d\n", channel); /* only need to process channel if in use */ if(ALmixer_Channel_List[channel].channel_in_use) { @@ -2865,8 +2855,6 @@ ALint i; for(i=0; i= 0) { - fprintf(stderr, "Pause on channel %d\n", channel); /* only need to process channel if in use */ if(ALmixer_Channel_List[channel].channel_in_use) { @@ -3034,7 +3020,6 @@ retval = -1; } } - fprintf(stderr, "Pause on channel %d, channel in use\n", channel); } } /* The user wants to halt all channels */ @@ -3043,12 +3028,9 @@ ALint i; for(i=0; isample->desired, msec); - fprintf(stderr, "Calling Set_Predecoded_Seek...%d\n", byte_position); return( Set_Predecoded_Seek_Position(data, byte_position) ); } else @@ -3268,7 +3248,6 @@ alGetString(error)); } ALmixer_Channel_List[channel].fade_start_volume = value; - fprintf(stderr, "MIN gain: %f\n", value); /* Set the actual volume */ alSourcef(ALmixer_Channel_List[channel].alsource, @@ -3325,7 +3304,6 @@ /* Set fade start time */ ALmixer_Channel_List[channel].fade_start_time = ALmixer_Channel_List[channel].start_time; - fprintf(stderr, "Current time =%d\n", current_time); /* Set the fade expire ticks */ ALmixer_Channel_List[channel].fade_expire_ticks = fade_ticks; @@ -3424,7 +3402,6 @@ alGetString(error)); } ALmixer_Channel_List[channel].fade_end_volume = value; - fprintf(stderr, "MIN gain: %f\n", value); /* Set expire start time */ ALmixer_Channel_List[channel].start_time = current_time; @@ -3470,7 +3447,6 @@ alGetString(error)); } ALmixer_Channel_List[i].fade_end_volume = value; - fprintf(stderr, "MIN gain: %f\n", value); /* Set expire start time */ ALmixer_Channel_List[i].start_time = current_time; @@ -5438,14 +5414,18 @@ #endif if(0 == bytes_returned) { + /* fprintf(stderr, "We got 0 bytes from reading. Checking for loops\n"); + */ /* Check for loops */ if( ALmixer_Channel_List[i].loops != 0 ) { /* We have to loop, so rewind * and fetch more data */ + /* fprintf(stderr, "Rewinding data\n"); + */ if(0 == Sound_Rewind( ALmixer_Channel_List[i].almixer_data->sample)) { @@ -5469,24 +5449,32 @@ if(ALmixer_Channel_List[i].almixer_data->num_buffers_in_use < ALmixer_Channel_List[i].almixer_data->max_queue_buffers) { + /* fprintf(stderr, "We got %d bytes from reading loop. Filling unused packet\n", bytes_returned); + */ /* Grab next packet */ bytes_returned = GetMoreData( ALmixer_Channel_List[i].almixer_data, ALmixer_Channel_List[i].almixer_data->buffer[ ALmixer_Channel_List[i].almixer_data->num_buffers_in_use] ); + /* fprintf(stderr, "We reread %d bytes into unused packet\n", bytes_returned); + */ } /* Refilling unqueued packet */ else { + /* fprintf(stderr, "We got %d bytes from reading loop. Filling unqueued packet\n", bytes_returned); + */ /* Grab next packet */ bytes_returned = GetMoreData( ALmixer_Channel_List[i].almixer_data, unqueued_buffer_id); + /* fprintf(stderr, "We reread %d bytes into unqueued packet\n", bytes_returned); + */ } /* Another error check */ /* @@ -5747,7 +5735,9 @@ */ for(temp_count=0; temp_countflags & SOUND_SAMPLEFLAG_EOF) { + /* fprintf(stderr, "We got LUCKY! File is predecoded even though STREAM was requested\n"); - +*/ ret_data->decoded_all = 1; /* Need to keep this information around for * seek and rewind abilities. @@ -7554,7 +7530,9 @@ * create multple buffers for queuing */ else { + /* fprintf(stderr, "Loading streamed data (not lucky)\n"); + */ ret_data->decoded_all = 0; /* This information is for predecoded. @@ -7694,7 +7672,7 @@ /* User requested decode all (easy, nothing to figure out) */ else if(AL_TRUE == decode_mode_is_predecoded) { -#ifndef ALMIXER_DISABLE_PREDECODED_PRECOMPUTE_BUFFER_SIZE_OPTIMIZATION +#ifdef ALMIXER_DISABLE_PREDECODED_PRECOMPUTE_BUFFER_SIZE_OPTIMIZATION /* SDL_sound (behind the scenes) seems to loop on buffer_size chunks * until the buffer is filled. It seems like we can * do much better and precompute the size of the buffer @@ -7777,8 +7755,9 @@ free(ret_data); return NULL; } + /* fprintf(stderr, "Actual rate=%d, desired=%d\n", sample->actual.rate, sample->desired.rate); - +*/ /* Now copy the data to the OpenAL buffer */ /* We can't just set a pointer because the API needs * its own copy to assist hardware acceleration */ @@ -7837,7 +7816,6 @@ #endif #endif -fprintf(stderr, "Made it\n"); /* okay we're done here */ } else @@ -7849,7 +7827,6 @@ return NULL; } -fprintf(stderr, "Returning data\n"); return ret_data; } @@ -8000,8 +7977,9 @@ return NULL; } + /* fprintf(stderr, "Correction test: Actual rate=%d, desired=%d, actual format=%d, desired format=%d\n", sample->actual.rate, sample->desired.rate, sample->actual.format, sample->desired.format); - +*/ return( DoLoad(sample, buffersize, decode_mode_is_predecoded, max_queue_buffers, num_startup_buffers, access_data)); }