some fixes for ogg_decode
git-svn-id: https://svn.musicpd.org/mpd/trunk@976 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
		| @@ -181,7 +181,8 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc) | |||||||
| 		int current_section; | 		int current_section; | ||||||
| 		int eof = 0; | 		int eof = 0; | ||||||
| 		long ret; | 		long ret; | ||||||
| 		char chunk[CHUNK_SIZE]; | #define OGG_CHUNK_SIZE	2048 | ||||||
|  | 		char chunk[OGG_CHUNK_SIZE]; | ||||||
| 		int chunkpos = 0; | 		int chunkpos = 0; | ||||||
| 		long bitRate = 0; | 		long bitRate = 0; | ||||||
| 		long test; | 		long test; | ||||||
| @@ -196,22 +197,35 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc) | |||||||
| 				ov_time_seek_page(&vf,dc->seekWhere); | 				ov_time_seek_page(&vf,dc->seekWhere); | ||||||
| 				dc->seek = 0; | 				dc->seek = 0; | ||||||
| 			} | 			} | ||||||
| 			ret = ov_read(&vf, chunk, CHUNK_SIZE, | 			ret = ov_read(&vf, chunk+chunkpos,  | ||||||
|  | 					OGG_CHUNK_SIZE-chunkpos, | ||||||
| 					OGG_DECODE_USE_BIGENDIAN, | 					OGG_DECODE_USE_BIGENDIAN, | ||||||
| 					2, 1, ¤t_section); | 					2, 1, ¤t_section); | ||||||
| 			if(ret<=0) eof = 1; | 			if(ret<=0) { | ||||||
| 			else { | 				eof = 1; | ||||||
|  | 				break; | ||||||
|  | 			} | ||||||
|  |  | ||||||
|  | 			chunkpos+=ret; | ||||||
|  |  | ||||||
|  | 			if(chunkpos >= OGG_CHUNK_SIZE) { | ||||||
| 				if((test = ov_bitrate_instant(&vf))>0) { | 				if((test = ov_bitrate_instant(&vf))>0) { | ||||||
| 					bitRate = test/1000; | 					bitRate = test/1000; | ||||||
| 				} | 				} | ||||||
|                                 doReplayGain(chunk,ret,&(dc->audioFormat), |                                 doReplayGain(chunk,ret,&(dc->audioFormat), | ||||||
|                                                 replayGainScale); |                                                 replayGainScale); | ||||||
| 				sendDataToOutputBuffer(cb,dc,chunk,ret, | 				sendDataToOutputBuffer(cb,dc,chunk,chunkpos, | ||||||
| 					ov_time_tell(&vf),bitRate); | 					ov_time_tell(&vf),bitRate); | ||||||
| 				if(dc->stop) break; | 				if(dc->stop) break; | ||||||
|  | 				chunkpos = 0; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		if(!dc->stop && chunkpos > 0) { | ||||||
|  | 			sendDataToOutputBuffer(cb,dc,chunk,chunkpos, | ||||||
|  | 					ov_time_tell(&vf),bitRate); | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		ov_clear(&vf); | 		ov_clear(&vf); | ||||||
|  |  | ||||||
| 		flushOutputBuffer(cb); | 		flushOutputBuffer(cb); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Warren Dukes
					Warren Dukes