-
Notifications
You must be signed in to change notification settings - Fork 324
Description
flac/src/libFLAC/stream_encoder.c
Lines 2160 to 2161 in 4c57829
if(value > FLAC__STREAM_ENCODER_MAX_THREADS) | |
return FLAC__STREAM_ENCODER_SET_NUM_THREADS_TOO_MANY_THREADS; |
FLAC__stream_encoder_set_num_threads()
ignores the set value when value > FLAC__STREAM_ENCODER_MAX_THREADS
and returns FLAC__STREAM_ENCODER_SET_NUM_THREADS_TOO_MANY_THREADS
.
The value of FLAC__STREAM_ENCODER_MAX_THREADS
is not exposed in the API, thus a client application that is setting a value that is too high has no way of knowing the maximum value that would be settable.
I think the intention of client applications setting a high value is probably "use as many threads as possible", so the behavior of returning an error instead of applying the maximum value possible probably goes against that intention. I would also guess that, in absence of any concrete reason to use another value, most applications might just put the number of threads available in the system there - and CPUs with more than 64 hardware threads do exist.
I am not sure what the best solution would be. Some possibilities:
- Leave it as it is, and expect client applications to do a retry loop.
- Apply the maximum value and still return
FLAC__STREAM_ENCODER_SET_NUM_THREADS_TOO_MANY_THREADS
. - Apply the maximum value and return
FLAC__STREAM_ENCODER_SET_NUM_THREADS_OK
. - Provide an explicit API to query
FLAC__STREAM_ENCODER_MAX_THREADS
. - Deprecate
FLAC__stream_encoder_set_num_threads()
and addFLAC__stream_encoder_set_num_threads2()
which applies the maximum value and returnsFLAC__STREAM_ENCODER_SET_NUM_THREADS_OK
. - Deprecate
FLAC__stream_encoder_set_num_threads()
and addFLAC__stream_encoder_set_num_threads2()
which applies the maximum value and returns a new return valueFLAC__STREAM_ENCODER_SET_NUM_THREADS_MAX_THREADS
.