浏览代码

backport click correction to BT

philippe44 5 年之前
父节点
当前提交
93568723fd
共有 3 个文件被更改,包括 8 次插入8 次删除
  1. 1 1
      components/raop/rtp.c
  2. 6 4
      components/squeezelite/output_bt.c
  3. 1 3
      components/squeezelite/output_i2s.c

+ 1 - 1
components/raop/rtp.c

@@ -375,7 +375,7 @@ static void alac_decode(rtp_t *ctx, s16_t *dest, char *buf, int len, int *outsiz
 	unsigned char iv[16];
 	int aeslen;
 	assert(len<=MAX_PACKET);
-	
+
 	if (ctx->decrypt) {
 		aeslen = len & ~0xf;
 		memcpy(iv, ctx->aesiv, sizeof(iv));

+ 6 - 4
components/squeezelite/output_bt.c

@@ -43,7 +43,8 @@ extern u8_t config_spdif_gpio;
 
 static log_level loglevel;
 static bool running = false;
-uint8_t * btout;
+static uint8_t *btout;
+static frames_t oframes;
 
 static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t gainR,
 								s32_t cross_gain_in, s32_t cross_gain_out, ISAMPLE_T **cross_ptr);
@@ -101,12 +102,12 @@ static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t g
 		}
 
 #if BYTES_PER_FRAME == 4
-		memcpy(btout, outputbuf->readp, out_frames * BYTES_PER_FRAME);
+		memcpy(btout + oframes * BYTES_PER_FRAME, outputbuf->readp, out_frames * BYTES_PER_FRAME);
 #else
 	{
 		frames_t count = out_frames;
 		s32_t *_iptr = (s32_t*) outputbuf->readp;
-		s16_t *_optr = (s16_t*) bt_optr;
+		s16_t *_optr = (s16_t*) (btout + oframes * BYTES_PER_FRAME);
 		while (count--) {
 			*_optr++ = *_iptr++ >> 16;
 			*_optr++ = *_iptr++ >> 16;
@@ -117,7 +118,7 @@ static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t g
 	} else {
 
 		u8_t *buf = silencebuf;
-		memcpy(btout, buf, out_frames * BYTES_PER_FRAME);
+		memcpy(btout + oframes * BYTES_PER_FRAME, buf, out_frames * BYTES_PER_FRAME);
 	}
 
 	return (int)out_frames;
@@ -131,6 +132,7 @@ int32_t output_bt_data(uint8_t *data, int32_t len) {
 	}
 	
 	btout = data;
+	oframes = 0;
 
 	// This is how the BTC layer calculates the number of bytes to
 	// for us to send. (BTC_SBC_DEC_PCM_DATA_LEN * sizeof(OI_INT16) - availPcmBytes

+ 1 - 3
components/squeezelite/output_i2s.c

@@ -457,6 +457,7 @@ static void *output_thread_i2s() {
 			synced = false;
 		}
 		
+		oframes = 0;
 		output.updated = gettime_ms();
 		output.frames_played_dmp = output.frames_played;
 		// try to estimate how much we have consumed from the DMA buffer (calculation is incorrect at the very beginning ...)
@@ -479,7 +480,6 @@ static void *output_thread_i2s() {
 		} else if (discard) {
 			discard -= oframes;
 			iframes = discard ? min(FRAME_BLOCK, discard) : FRAME_BLOCK;
-			oframes = 0;
 			UNLOCK;
 			continue;
 		}
@@ -527,8 +527,6 @@ static void *output_thread_i2s() {
 			LOG_WARN("I2S DMA Overflow! available bytes: %d, I2S wrote %d bytes", oframes * bytes_per_frame, bytes);
 		}
 		
-		oframes = 0;
-			
 		SET_MIN_MAX( TIME_MEASUREMENT_GET(timer_start),i2s_time);
 		
 	}