decoder/mad: refactor local variables in FillBuffer()
This commit is contained in:
		@@ -223,26 +223,31 @@ MadDecoder::Seek(long offset)
 | 
				
			|||||||
inline bool
 | 
					inline bool
 | 
				
			||||||
MadDecoder::FillBuffer()
 | 
					MadDecoder::FillBuffer()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	size_t remaining = 0, length = sizeof(input_buffer);
 | 
						/* amount of rest data still residing in the buffer */
 | 
				
			||||||
 | 
						size_t rest_size = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						size_t max_read_size = sizeof(input_buffer);
 | 
				
			||||||
	unsigned char *dest = input_buffer;
 | 
						unsigned char *dest = input_buffer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (stream.next_frame != nullptr) {
 | 
						if (stream.next_frame != nullptr) {
 | 
				
			||||||
		remaining = stream.bufend - stream.next_frame;
 | 
							rest_size = stream.bufend - stream.next_frame;
 | 
				
			||||||
		memmove(input_buffer, stream.next_frame, remaining);
 | 
							memmove(input_buffer, stream.next_frame, rest_size);
 | 
				
			||||||
		dest += remaining;
 | 
							dest += rest_size;
 | 
				
			||||||
		length -= remaining;
 | 
							max_read_size -= rest_size;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* we've exhausted the read buffer, so give up!, these potential
 | 
						/* we've exhausted the read buffer, so give up!, these potential
 | 
				
			||||||
	 * mp3 frames are way too big, and thus unlikely to be mp3 frames */
 | 
						 * mp3 frames are way too big, and thus unlikely to be mp3 frames */
 | 
				
			||||||
	if (length == 0)
 | 
						if (max_read_size == 0)
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	length = decoder_read(client, input_stream, dest, length);
 | 
						size_t nbytes = decoder_read(client, input_stream,
 | 
				
			||||||
	if (length == 0)
 | 
									     dest, max_read_size);
 | 
				
			||||||
 | 
						if (nbytes == 0) {
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mad_stream_buffer(&stream, input_buffer, length + remaining);
 | 
						mad_stream_buffer(&stream, input_buffer, rest_size + nbytes);
 | 
				
			||||||
	stream.error = MAD_ERROR_NONE;
 | 
						stream.error = MAD_ERROR_NONE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return true;
 | 
						return true;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user