Skip to content

Number of audio input channels hardcoded in AUDIO_MIC descriptor #677

@mbruno-xmos

Description

@mbruno-xmos

TUD_AUDIO_DESC_CS_AS_INT(/*_termid*/ 0x03, /*_ctrl*/ AUDIO_CTRL_NONE, /*_formattype*/ AUDIO_FORMAT_TYPE_I, /*_formats*/ AUDIO_DATA_FORMAT_TYPE_I_PCM, /*_nchannelsphysical*/ 0x01, /*_channelcfg*/ AUDIO_CHANNEL_CONFIG_NON_PREDEFINED, /*_stridx*/ 0x00),\

I have created a two channel USB audio microphone application. I have set CFG_TUD_AUDIO_N_CHANNELS_TX to two, but I needed to modify the referenced line to set _nchannelsphysical to CFG_TUD_AUDIO_N_CHANNELS_TX rather than to 0x01.

I am wondering if I should not have used TUD_AUDIO_MIC_DESCRIPTOR in my application, but rather created my own similar macro to define exactly the descriptors that I need. Still, I think it would make sense for the number of channels set by TUD_AUDIO_MIC_DESCRIPTOR to be configurable and not hardcoded to 1.

I also needed to define CFG_TUD_AUDIO_TX_FIFO_COUNT to CFG_TUD_AUDIO_N_CHANNELS_TX in my application. By default it is defined to CFG_TUD_AUDIO_N_CHANNELS_TX inside audio_device.c, but to 1 inside audio_device.h. This results in a mismatch between the prototype and definition of tud_audio_n_write().

#ifndef CFG_TUD_AUDIO_TX_FIFO_COUNT
#define CFG_TUD_AUDIO_TX_FIFO_COUNT CFG_TUD_AUDIO_N_CHANNELS_TX
#endif

#if CFG_TUD_AUDIO_TX_FIFO_COUNT == 1
uint16_t tud_audio_n_write(uint8_t itf, void const* data, uint16_t len)
{
{
audiod_interface_t* audio = &_audiod_itf[itf];
if (audio->p_desc == NULL)
{
return 0;
}
return tu_fifo_write_n(&audio->tx_ff[0], data, len);
}
}
#else
uint16_t tud_audio_n_write(uint8_t itf, uint8_t channelId, const void * data, uint16_t len)
{
audiod_interface_t* audio = &_audiod_itf[itf];
if (audio->p_desc == NULL) {
return 0;
}
return tu_fifo_write_n(&audio->tx_ff[channelId], data, len);
}
#endif

#ifndef CFG_TUD_AUDIO_TX_FIFO_COUNT
#define CFG_TUD_AUDIO_TX_FIFO_COUNT 1
#endif
#if CFG_TUD_AUDIO_EPSIZE_IN && CFG_TUD_AUDIO_TX_FIFO_SIZE
#if CFG_TUD_AUDIO_TX_FIFO_COUNT > 1
uint16_t tud_audio_n_write (uint8_t itf, uint8_t channelId, const void * data, uint16_t len);
#else
uint16_t tud_audio_n_write (uint8_t itf, const void * data, uint16_t len);
#endif
uint16_t tud_audio_n_write_flush(uint8_t itf);
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions