Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rp2040 audio corrections #2845

Closed

Conversation

pschatzmann
Copy link
Contributor

@pschatzmann pschatzmann commented Oct 15, 2024

The following issues are addressed

  • Building all examples with cmake is giving compile errors mainy due to data conversion
  • uac2_spaker_fb is missing in the cmake file, gives compile errors and has missing c file in cmake

Many issues could be resolved by treating conversion not as error, but I did not find the place to change this.

Detailed changes

  • .gitignore to ignore .vscode
  • examples/device/CMakeLists.txt add missing uac_speaker_fb
  • examples/device/uac_speaker_fb/CMakeLists.txt add missing quirk_os_guessing.c
  • uac2_spaker_fb/src.main compile errors due to conversion
  • audio_device.c compile error due to format conversion
/home/pschatzmann/Development/tinyusb/src/class/audio/audio_device.c: In function 'audiod_set_interface':
/home/pschatzmann/Development/tinyusb/src/class/audio/audio_device.c:2069:64: error: conversion from 'long unsigned int' to 'uint16_t' {aka 'short unsigned int'} may change value [-Werror=conversion]
 2069 |             audio->feedback.compute.fifo_count.rate_const[0] = (audio->feedback.max_value - nominal) / fifo_lvl_thr;

/home/pschatzmann/Development/tinyusb/examples/device/uac2_speaker_fb/src/main.c:417:21: error: conversion from 'long unsigned int' to 'uint16_t' {aka 'short unsigned int'} may change value [-Werror=conversion]
  417 |   uint16_t length = current_sample_rate/1000 * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_RX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX;
      |                      
/home/pschatzmann/Development/tinyusb/examples/device/uac2_speaker_fb/src/main.c: In function 'audio_debug_task':
/home/pschatzmann/Development/tinyusb/examples/device/uac2_speaker_fb/src/main.c:468:31: error: conversion from 'uint32_t' {aka 'long unsigned int'} to 'uint16_t' {aka 'short unsigned int'} may change value [-Werror=conversion]
  468 |   debug_info.fifo_count_avg = fifo_count_avg >> 16;
      |                               ^~~~~~~~~~~~~~

/home/pschatzmann/Development/tinyusb/src/class/audio/audio_device.c: In function 'audiod_set_interface':
/home/pschatzmann/Development/tinyusb/src/class/audio/audio_device.c:2070:64: error: conversion from 'long unsigned int' to 'uint16_t' {aka 'short unsigned int'} may change value [-Werror=conversion]
 2070 |             audio->feedback.compute.fifo_count.rate_const[1] = (nominal - audio->feedback.min_value) / fifo_lvl_thr;
      |          
/home/pschatzmann/Development/tinyusb/src/class/audio/audio_device.c: In function 'audiod_set_interface':
/home/pschatzmann/Development/tinyusb/src/class/audio/audio_device.c:2070:64: error: conversion from 'long unsigned int' to 'uint16_t' {aka 'short unsigned int'} may change value [-Werror=conversion]
 2070 |             audio->feedback.compute.fifo_count.rate_const[1] = (nominal - audio->feedback.min_value) / fifo_lvl_thr;
      |      

/home/pschatzmann/Development/tinyusb/src/class/audio/audio_device.c: In function 'audiod_set_fb_params_freq':
/home/pschatzmann/Development/tinyusb/src/class/audio/audio_device.c:2379:42: error: conversion from 'int' to 'uint8_t' {aka 'unsigned char'} may change value [-Werror=conversion]
 2379 |     audio->feedback.compute.power_of_2 = 16 - (audio->feedback.frame_shift - 1) - tu_log2(mclk_freq / sample_freq);
      |    

/home/pschatzmann/Development/tinyusb/src/class/audio/audio_device.c: In function 'audiod_set_fb_params_freq':
/home/pschatzmann/Development/tinyusb/src/class/audio/audio_device.c:2379:42: error: conversion from 'int' to 'uint8_t' {aka 'unsigned char'} may change value [-Werror=conversion]
 2379 |     audio->feedback.compute.power_of_2 = 16 - (audio->feedback.frame_shift - 1) - tu_log2(mclk_freq / sample_freq);
      |    

/home/pschatzmann/Development/tinyusb/examples/device/uac2_speaker_fb/src/usb_descriptors.c:251: undefined reference to `quirk_os_guessing_desc_string_cb'
/home/pschatzmann/Development/tinyusb/src/class/audio/audio_device.c:2383:62: error: conversion from 'uint32_t' {aka 'long unsigned int'} to 'float' may change value [-Werror=conversion]
 2383 |     audio->feedback.compute.float_const = (float)sample_freq / mclk_freq * (1UL << (16 - (audio->feedback.frame_shift - 1)));
      |                   

@HiFiPhile
Copy link
Collaborator

I did some clean up to keep only the relevant commit.
Also I see you are trying to merge into testing branch, please use master branch, it's one of the reason why many unwanted files included.

@pschatzmann
Copy link
Contributor Author

Thanks. Could you give some recommendation how to avoid the issue with the many generated files
I tried to

  • branch from master and merge to master
  • branch from testing and merge into testing

Both options created a big mess. I tried to find some documentation about this, but I only found some generic description that when creating a branch, I can indicate the source...

@HiFiPhile
Copy link
Collaborator

Thanks. Could you give some recommendation how to avoid the issue with the many generated files I tried to

  • branch from master and merge to master
  • branch from testing and merge into testing

Both options created a big mess. I tried to find some documentation about this, but I only found some generic description that when creating a branch, I can indicate the source...

Your initial attempt with master branch is correct, except the commit 67e120b included unwanted files, I think when you did git commit you forgot to pick only relevant files. (Like clicked Stage All Files in vscode)
image

testing branch is only for test some not yet merged stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants