mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
Implement left and right justifications for 24 to 32 bit PCM encoding
This commit is contained in:
parent
681cfd0bf2
commit
c098da9803
@ -366,11 +366,15 @@ static bool audiod_decode_type_I_pcm(uint8_t rhport, audiod_interface_t* audio)
|
|||||||
// If this aborts then the target buffer is full
|
// If this aborts then the target buffer is full
|
||||||
TU_VERIFY(tu_fifo_read_n_into_other_fifo(&audio->ep_out_ff, &audio->rx_ff[cntChannel], 0, CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_RX));
|
TU_VERIFY(tu_fifo_read_n_into_other_fifo(&audio->ep_out_ff, &audio->rx_ff[cntChannel], 0, CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_RX));
|
||||||
#else
|
#else
|
||||||
// TODO: Implement a left and right justified 24 to 32 and vice versa copy process from FIFO to FIFO
|
|
||||||
uint32_t sample = 0;
|
uint32_t sample = 0;
|
||||||
|
|
||||||
// Get sample from buffer
|
// Get sample from buffer
|
||||||
TU_VERIFY(tu_fifo_read_n(&audio->ep_out_ff, &sample, CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_RX));
|
TU_VERIFY(tu_fifo_read_n(&audio->ep_out_ff, &sample, CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_RX));
|
||||||
|
|
||||||
|
#if CFG_TUD_AUDIO_JUSTIFICATION_RX == CFG_TUD_AUDIO_LEFT_JUSTIFIED
|
||||||
|
sample = sample << 8;
|
||||||
|
#endif
|
||||||
|
|
||||||
TU_VERIFY(tu_fifo_write_n(&audio->rx_ff[cntChannel], &sample, CFG_TUD_AUDIO_RX_ITEMSIZE));
|
TU_VERIFY(tu_fifo_write_n(&audio->rx_ff[cntChannel], &sample, CFG_TUD_AUDIO_RX_ITEMSIZE));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -584,12 +588,14 @@ static bool audiod_encode_type_I_pcm(uint8_t rhport, audiod_interface_t* audio)
|
|||||||
#if CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_TX == CFG_TUD_AUDIO_TX_ITEMSIZE
|
#if CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_TX == CFG_TUD_AUDIO_TX_ITEMSIZE
|
||||||
tu_fifo_read_n_into_other_fifo(&audio->tx_ff[cntChannel], &audio->ep_in_ff, 0, CFG_TUD_AUDIO_TX_ITEMSIZE);
|
tu_fifo_read_n_into_other_fifo(&audio->tx_ff[cntChannel], &audio->ep_in_ff, 0, CFG_TUD_AUDIO_TX_ITEMSIZE);
|
||||||
#else
|
#else
|
||||||
// TODO: Implement a left and right justified 24 to 32 and vice versa copy process from FIFO to FIFO
|
|
||||||
uint32_t sample = 0;
|
uint32_t sample = 0;
|
||||||
|
|
||||||
// Get sample from buffer
|
// Get sample from buffer
|
||||||
tu_fifo_read_n(&audio->tx_ff[cntChannel], &sample, CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_TX);
|
tu_fifo_read_n(&audio->tx_ff[cntChannel], &sample, CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_TX);
|
||||||
|
|
||||||
|
#if CFG_TUD_AUDIO_JUSTIFICATION_TX == CFG_TUD_AUDIO_LEFT_JUSTIFIED
|
||||||
|
sample = sample << 8;
|
||||||
|
#endif
|
||||||
tu_fifo_write_n(&audio->ep_in_ff, &sample, CFG_TUD_AUDIO_TX_ITEMSIZE);
|
tu_fifo_write_n(&audio->ep_in_ff, &sample, CFG_TUD_AUDIO_TX_ITEMSIZE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,18 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// In case PCM encoding/decoding of 24 into 32 bits, the adjustment needs to be defined
|
||||||
|
#define CFG_TUD_AUDIO_LEFT_JUSTIFIED
|
||||||
|
#define CFG_TUD_AUDIO_RIGHT_JUSTIFIED
|
||||||
|
|
||||||
|
#ifndef CFG_TUD_AUDIO_JUSTIFICATION_RX
|
||||||
|
#define CFG_TUD_AUDIO_JUSTIFICATION_RX CFG_TUD_AUDIO_LEFT_JUSTIFIED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CFG_TUD_AUDIO_JUSTIFICATION_TX
|
||||||
|
#define CFG_TUD_AUDIO_JUSTIFICATION_TX CFG_TUD_AUDIO_LEFT_JUSTIFIED
|
||||||
|
#endif
|
||||||
|
|
||||||
//static_assert(sizeof(tud_audio_desc_lengths) != CFG_TUD_AUDIO, "Supply audio function descriptor pack length!");
|
//static_assert(sizeof(tud_audio_desc_lengths) != CFG_TUD_AUDIO, "Supply audio function descriptor pack length!");
|
||||||
|
|
||||||
// Supported types of this driver:
|
// Supported types of this driver:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user