Navigation Menu

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

Use of deprecated fluid_synth_set_sample_rate #7885

Closed
LordAro opened this issue Dec 31, 2019 · 1 comment
Closed

Use of deprecated fluid_synth_set_sample_rate #7885

LordAro opened this issue Dec 31, 2019 · 1 comment
Assignees
Labels
OS: Linux Issues specific to Linux builds
Milestone

Comments

@LordAro
Copy link
Member

LordAro commented Dec 31, 2019

Version of OpenTTD

master

Expected result

Compiles without warnings

Actual result

/home/lordaro/dev/openttd/src/music/fluidsynth.cpp:85:53: warning: ‘void fluid_synth_set_sample_rate(fluid_synth_t*, float)’ is deprecated [-Wdeprecated-declarations]
   85 |  fluid_synth_set_sample_rate(_midi.synth, samplerate);
      |                                                     ^
In file included from /usr/include/fluidsynth.h:97,
                 from /home/lordaro/dev/openttd/src/music/fluidsynth.cpp:16:
/usr/include/fluidsynth/synth.h:179:38: note: declared here
  179 | FLUID_DEPRECATED FLUIDSYNTH_API void fluid_synth_set_sample_rate(fluid_synth_t *synth, float sample_rate);
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Steps to reproduce

Compile

From http://www.fluidsynth.org/api/synth_8h.html#ac89771633b393c807e5d5766f5a219b0 :

As of fluidsynth 2.1.0 this function has been deprecated. Changing the sample-rate is generally not considered to be a real-time use-case, as it always produces some audible artifact ("click", "pop") on the dry sound and effects (because LFOs for chorus and reverb need to be reinitialized). The sample-rate change may also require memory allocation deep down in the effect units. However, this memory allocation may fail and there is no way for the caller to know that, because the actual change of the sample-rate is executed during rendering. This function cannot (must not) do the sample-rate change itself, otherwise the synth needs to be locked down, causing rendering to block. Esp. do not use this function if this synth instance is used by an audio driver, because the audio driver cannot be notified by this sample-rate change. Long story short: don't use it.

@nielsmh nielsmh self-assigned this Jan 1, 2020
@nielsmh nielsmh added the OS: Linux Issues specific to Linux builds label Jan 1, 2020
@nielsmh nielsmh added this to the 1.10.0 milestone Jan 1, 2020
@nielsmh
Copy link
Contributor

nielsmh commented Feb 6, 2020

The annoying thing with this is that the setting needs to be set before creating the synthesizer, but the sample rate to use is only known after setting the music stream callback from the mixer. So the music callback needs to handle the situation where the synthesizer is not yet ready, which means a mutex and atomic flag are definitely needed.

nielsmh added a commit to nielsmh/OpenTTD that referenced this issue Feb 7, 2020
@nielsmh nielsmh closed this as completed in 04ce1f0 Feb 7, 2020
douiwby pushed a commit to douiwby/OpenTTD that referenced this issue Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: Linux Issues specific to Linux builds
Projects
None yet
Development

No branches or pull requests

2 participants