player: replaced buffered_before_play with buffering flag
buffered_before_play was copied to struct player because it was used to disable buffering when seeking. Instead of mainaining a copy of this number, move just the flag to the player struct.
This commit is contained in:
		@@ -35,10 +35,9 @@ enum xfade_state {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
struct player {
 | 
					struct player {
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * number of chunks which have to be decoded before playing
 | 
						 * are we waiting for buffered_before_play?
 | 
				
			||||||
	 * starts
 | 
					 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	unsigned int buffered_before_play;
 | 
						bool buffering;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * true if the decoder is starting and did not provide data
 | 
						 * true if the decoder is starting and did not provide data
 | 
				
			||||||
@@ -178,7 +177,10 @@ static void processDecodeInput(struct player *player)
 | 
				
			|||||||
		dropBufferedAudio();
 | 
							dropBufferedAudio();
 | 
				
			||||||
		if (decodeSeek(player) == 0) {
 | 
							if (decodeSeek(player) == 0) {
 | 
				
			||||||
			player->xfade = XFADE_UNKNOWN;
 | 
								player->xfade = XFADE_UNKNOWN;
 | 
				
			||||||
			player->buffered_before_play = 0;
 | 
					
 | 
				
			||||||
 | 
								/* abort buffering when the user has requested
 | 
				
			||||||
 | 
								   a seek */
 | 
				
			||||||
 | 
								player->buffering = false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -225,14 +227,13 @@ static int playChunk(ob_chunk * chunk,
 | 
				
			|||||||
static void do_play(void)
 | 
					static void do_play(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct player player = {
 | 
						struct player player = {
 | 
				
			||||||
		.buffered_before_play = pc.buffered_before_play,
 | 
							.buffering = true,
 | 
				
			||||||
		.decoder_starting = false,
 | 
							.decoder_starting = false,
 | 
				
			||||||
		.paused = false,
 | 
							.paused = false,
 | 
				
			||||||
		.queued = false,
 | 
							.queued = false,
 | 
				
			||||||
		.xfade = XFADE_UNKNOWN,
 | 
							.xfade = XFADE_UNKNOWN,
 | 
				
			||||||
		.next_song_chunk = -1,
 | 
							.next_song_chunk = -1,
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	int buffering = 1;
 | 
					 | 
				
			||||||
	unsigned int crossFadeChunks = 0;
 | 
						unsigned int crossFadeChunks = 0;
 | 
				
			||||||
	/** the position of the next cross-faded chunk in the next
 | 
						/** the position of the next cross-faded chunk in the next
 | 
				
			||||||
	    song */
 | 
						    song */
 | 
				
			||||||
@@ -262,14 +263,14 @@ static void do_play(void)
 | 
				
			|||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (buffering) {
 | 
							if (player.buffering) {
 | 
				
			||||||
			if (ob_available() < player.buffered_before_play) {
 | 
								if (ob_available() < pc.buffered_before_play) {
 | 
				
			||||||
				/* not enough decoded buffer space yet */
 | 
									/* not enough decoded buffer space yet */
 | 
				
			||||||
				notify_wait(&pc.notify);
 | 
									notify_wait(&pc.notify);
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				/* buffering is complete */
 | 
									/* buffering is complete */
 | 
				
			||||||
				buffering = 0;
 | 
									player.buffering = false;
 | 
				
			||||||
				ob_set_lazy(true);
 | 
									ob_set_lazy(true);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user