mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:12:45 +00:00 
			
		
		
		
	WavLoader: Search for DATA marker by reading single bytes
Previously 4 bytes at once were read and compared to the string "DATA". This worked when the DATA marker was aligned on a 32-bit boundary relative to the start of the file. However, this is not guranteed to always be the case, and for some files the loader would just keep searching for the marker.
This commit is contained in:
		
							parent
							
								
									c053537321
								
							
						
					
					
						commit
						072e6a6405
					
				
					 1 changed files with 19 additions and 8 deletions
				
			
		|  | @ -155,16 +155,27 @@ bool WavLoader::parse_header() | ||||||
|     // Read chunks until we find DATA
 |     // Read chunks until we find DATA
 | ||||||
|     bool found_data = false; |     bool found_data = false; | ||||||
|     u32 data_sz = 0; |     u32 data_sz = 0; | ||||||
|  |     u8 search_byte = 0; | ||||||
|     while (true) { |     while (true) { | ||||||
|         u32 chunk_id; |         stream >> search_byte; | ||||||
|         stream >> chunk_id; |         CHECK_OK("Reading byte searching for data"); | ||||||
|         CHECK_OK("Reading chunk ID searching for data"); |         if (search_byte != 0x64) //D
 | ||||||
|  |             continue; | ||||||
|  | 
 | ||||||
|  |         stream >> search_byte; | ||||||
|  |         CHECK_OK("Reading next byte searching for data"); | ||||||
|  |         if (search_byte != 0x61) //A
 | ||||||
|  |             continue; | ||||||
|  | 
 | ||||||
|  |         u16 search_remaining = 0; | ||||||
|  |         stream >> search_remaining; | ||||||
|  |         CHECK_OK("Reading remaining bytes searching for data"); | ||||||
|  |         if (search_remaining != 0x6174) //TA
 | ||||||
|  |             continue; | ||||||
|  | 
 | ||||||
|         stream >> data_sz; |         stream >> data_sz; | ||||||
|         CHECK_OK("Reading chunk size searching for data"); |         found_data = true; | ||||||
|         if (chunk_id == 0x61746164) { // DATA
 |         break; | ||||||
|             found_data = true; |  | ||||||
|             break; |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     ok = ok && found_data; |     ok = ok && found_data; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Till Mayer
						Till Mayer