Author Topic: multi-threads on ogg/mp3 encoding  (Read 150 times)

mkllc

  • Posts: 45
multi-threads on ogg/mp3 encoding
« on: 1 Dec '21 - 11:33 »
Hi, I saw recently there is a BASS_ATTRIB_MIXER_THREADS attribute for mixers, very nice! but, there is any similar to be used with BASS_Encode_OGG_Start or BASS_Encode_MP3_Start functions? I think libvorbis is thread safe, don't know about mp3 encoder. Extra ball: what about BASS_RecordInit? Would be any device be at a charge of a different thread? And to not start a new topic, there is something applicable to Record device like BASS_DEVICE_REINIT? It's not a problem as I have my logic in a sync with BASS_SYNC_DEV_FAIL to reinit by hand, but just to know if it's possible to this be automatically managed by the lib. Thanks!

Ian @ un4seen

  • Administrator
  • Posts: 24054
Re: multi-threads on ogg/mp3 encoding
« Reply #1 on: 1 Dec '21 - 12:41 »
Hi, I saw recently there is a BASS_ATTRIB_MIXER_THREADS attribute for mixers, very nice! but, there is any similar to be used with BASS_Encode_OGG_Start or BASS_Encode_MP3_Start functions? I think libvorbis is thread safe, don't know about mp3 encoder.

The BASSenc_OGG and BASSenc_MP3 add-ons should already be thread-safe, but note the BASS_ATTRIB_MIXER_THREADS option isn't relating to thread-safety but rather spreading a mixer's workload over multiple threads. I don't think a similar option for OGG/MP3 encoding is currently possible because the Ogg Vorbis and LAME encoders (used by BASSenc_OGG and BASSenc_MP3) don't have that ability.

Extra ball: what about BASS_RecordInit? Would be any device be at a charge of a different thread?

I'm not sure I understand the question. Can you expand on it?

And to not start a new topic, there is something applicable to Record device like BASS_DEVICE_REINIT? It's not a problem as I have my logic in a sync with BASS_SYNC_DEV_FAIL to reinit by hand, but just to know if it's possible to this be automatically managed by the lib. Thanks!

It isn't currently possible to reinitialize a recording device and still keep its recording channels (like BASS_DEVICE_REINIT does for playback), but if the BASS_SYNC_DEV_FAIL syncs that you're currently getting are just due to the device's sample format changing then there is a recent BASS update that handles format changes automatically so that you don't need to restart the recording:

   www.un4seen.com/stuff/bass.zip

When the recording device's sample format changes with that, it should continue recording and trigger BASS_SYNC_DEV_FORMAT syncs instead of BASS_SYNC_DEV_FAIL syncs. Note this only applies when using WASAPI recording (which is the default since BASS 2.4.16).