Fix conversion warnings after SDL2 transition
Detected by MSVC compiler; several warnings: "(…) conversion from 'Sint64' to '<type>', possible loss of data"
This commit is contained in:
		
							parent
							
								
									dc0d174824
								
							
						
					
					
						commit
						c3e7997f75
					
				
					 2 changed files with 7 additions and 7 deletions
				
			
		|  | @ -400,7 +400,7 @@ static int init_sample(const Sound_DecoderFunctions *funcs, | |||
| { | ||||
|     Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; | ||||
|     Sound_AudioInfo desired; | ||||
|     int pos = SDL_RWtell(internal->rw); | ||||
|     const Sint64 pos = SDL_RWtell(internal->rw); | ||||
| 
 | ||||
|         /* fill in the funcs for this decoder... */ | ||||
|     sample->decoder = &funcs->info; | ||||
|  |  | |||
|  | @ -126,20 +126,20 @@ Uint64 calculate_stream_hash(struct SDL_RWops* const context) { | |||
|     // Seek to the end of the file so we can calculate the stream size.
 | ||||
|     SDL_RWseek(context, 0, RW_SEEK_END); | ||||
| 
 | ||||
|     const Sint32 stream_size = SDL_RWtell(context); | ||||
|     const Sint64 stream_size = SDL_RWtell(context); | ||||
|     if (stream_size <= 0) { | ||||
|         // LOG_MSG("MP3: get_stream_size returned %d, but should be positive", stream_size);
 | ||||
|         return 0; | ||||
|     } | ||||
| 
 | ||||
|     // Seek to the middle of the file while taking into account version small files.
 | ||||
|     const Uint32 tail_size = (stream_size > 32768) ? 32768 : stream_size; | ||||
|     const Sint64 tail_size = (stream_size > 32768) ? 32768 : stream_size; | ||||
|     const Sint64 mid_pos = static_cast<Sint64>(stream_size/2.0) - tail_size; | ||||
|     SDL_RWseek(context, mid_pos >= 0 ? static_cast<int>(mid_pos) : 0, RW_SEEK_SET); | ||||
|     SDL_RWseek(context, mid_pos >= 0 ? mid_pos : 0, RW_SEEK_SET); | ||||
| 
 | ||||
|     // Prepare our read buffer and counter:
 | ||||
|     vector<char> buffer(1024, 0); | ||||
|     Uint32 total_bytes_read = 0; | ||||
|     size_t total_bytes_read = 0; | ||||
| 
 | ||||
|     // Initialize xxHash's state using the stream_size as our seed.
 | ||||
|     // Seeding with the stream_size provide a second level of uniqueness
 | ||||
|  | @ -150,7 +150,7 @@ Uint64 calculate_stream_hash(struct SDL_RWops* const context) { | |||
|     const Uint64 seed = stream_size; | ||||
|     XXH64_reset(state, seed); | ||||
| 
 | ||||
|     while (total_bytes_read < tail_size) { | ||||
|     while (total_bytes_read < static_cast<size_t>(tail_size)) { | ||||
|         // Read a chunk of data.
 | ||||
|         const size_t bytes_read = SDL_RWread(context, buffer.data(), 1, buffer.size()); | ||||
| 
 | ||||
|  | @ -164,7 +164,7 @@ Uint64 calculate_stream_hash(struct SDL_RWops* const context) { | |||
|     } | ||||
| 
 | ||||
|     // restore the stream position
 | ||||
|     SDL_RWseek(context, static_cast<int>(original_pos), RW_SEEK_SET); | ||||
|     SDL_RWseek(context, original_pos, RW_SEEK_SET); | ||||
| 
 | ||||
|     const Uint64 hash = XXH64_digest(state); | ||||
|     XXH64_freeState(state); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue