Skip to content

max thread count is not directly settable or queryable #823

@manxorist

Description

@manxorist

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:

  1. Leave it as it is, and expect client applications to do a retry loop.
  2. Apply the maximum value and still return FLAC__STREAM_ENCODER_SET_NUM_THREADS_TOO_MANY_THREADS.
  3. Apply the maximum value and return FLAC__STREAM_ENCODER_SET_NUM_THREADS_OK.
  4. Provide an explicit API to query FLAC__STREAM_ENCODER_MAX_THREADS.
  5. Deprecate FLAC__stream_encoder_set_num_threads() and add FLAC__stream_encoder_set_num_threads2() which applies the maximum value and returns FLAC__STREAM_ENCODER_SET_NUM_THREADS_OK.
  6. Deprecate FLAC__stream_encoder_set_num_threads() and add FLAC__stream_encoder_set_num_threads2() which applies the maximum value and returns a new return value FLAC__STREAM_ENCODER_SET_NUM_THREADS_MAX_THREADS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions