@@ -172,10 +172,10 @@ enum obs_module_load_state obs_source_load_state(const char *id)
172172
173173static void allocate_audio_output_buffer (struct obs_source * source )
174174{
175- size_t size = sizeof (float ) * AUDIO_OUTPUT_FRAMES * MAX_AUDIO_CHANNELS * MAX_AUDIO_MIXES ;
175+ size_t size = sizeof (float ) * AUDIO_OUTPUT_FRAMES * MAX_AUDIO_CHANNELS * MAX_AUDIO_MIXES_NEW ;
176176 float * ptr = bzalloc (size );
177177
178- for (size_t mix = 0 ; mix < MAX_AUDIO_MIXES ; mix ++ ) {
178+ for (size_t mix = 0 ; mix < MAX_AUDIO_MIXES_NEW ; mix ++ ) {
179179 size_t mix_pos = mix * AUDIO_OUTPUT_FRAMES * MAX_AUDIO_CHANNELS ;
180180
181181 for (size_t i = 0 ; i < MAX_AUDIO_CHANNELS ; i ++ ) {
@@ -5224,7 +5224,7 @@ static void apply_audio_actions(obs_source_t *source, size_t channels, size_t sa
52245224
52255225 pthread_mutex_unlock (& source -> audio_actions_mutex );
52265226
5227- for (size_t mix = 0 ; mix < MAX_AUDIO_MIXES ; mix ++ ) {
5227+ for (size_t mix = 0 ; mix < MAX_AUDIO_MIXES_NEW ; mix ++ ) {
52285228 if ((source -> audio_mixers & (1 << mix )) != 0 )
52295229 multiply_vol_data (source , mix , channels , vol_data );
52305230 }
@@ -5259,11 +5259,11 @@ static void apply_audio_volume(obs_source_t *source, uint32_t mixers, size_t cha
52595259
52605260 if (vol == 0.0f || mixers == 0 ) {
52615261 memset (source -> audio_output_buf [0 ][0 ], 0 ,
5262- AUDIO_OUTPUT_FRAMES * sizeof (float ) * MAX_AUDIO_CHANNELS * MAX_AUDIO_MIXES );
5262+ AUDIO_OUTPUT_FRAMES * sizeof (float ) * MAX_AUDIO_CHANNELS * MAX_AUDIO_MIXES_NEW );
52635263 return ;
52645264 }
52655265
5266- for (size_t mix = 0 ; mix < MAX_AUDIO_MIXES ; mix ++ ) {
5266+ for (size_t mix = 0 ; mix < MAX_AUDIO_MIXES_NEW ; mix ++ ) {
52675267 uint32_t mix_and_val = (1 << mix );
52685268 if ((source -> audio_mixers & mix_and_val ) != 0 && (mixers & mix_and_val ) != 0 )
52695269 multiply_output_audio (source , mix , channels , vol );
@@ -5276,7 +5276,7 @@ static void custom_audio_render(obs_source_t *source, uint32_t mixers, size_t ch
52765276 bool success ;
52775277 uint64_t ts ;
52785278
5279- for (size_t mix = 0 ; mix < MAX_AUDIO_MIXES ; mix ++ ) {
5279+ for (size_t mix = 0 ; mix < MAX_AUDIO_MIXES_NEW ; mix ++ ) {
52805280 for (size_t ch = 0 ; ch < channels ; ch ++ ) {
52815281 audio_data .output [mix ].data [ch ] = source -> audio_output_buf [mix ][ch ];
52825282 }
@@ -5293,7 +5293,7 @@ static void custom_audio_render(obs_source_t *source, uint32_t mixers, size_t ch
52935293 if (!success || !source -> audio_ts || !mixers )
52945294 return ;
52955295
5296- for (size_t mix = 0 ; mix < MAX_AUDIO_MIXES ; mix ++ ) {
5296+ for (size_t mix = 0 ; mix < MAX_AUDIO_MIXES_NEW ; mix ++ ) {
52975297 uint32_t mix_bit = 1 << mix ;
52985298
52995299 if ((mixers & mix_bit ) == 0 )
@@ -5355,7 +5355,7 @@ static inline void process_audio_source_tick(obs_source_t *source, uint32_t mixe
53555355
53565356 pthread_mutex_unlock (& source -> audio_buf_mutex );
53575357
5358- for (size_t mix = 1 ; mix < MAX_AUDIO_MIXES ; mix ++ ) {
5358+ for (size_t mix = 1 ; mix < MAX_AUDIO_MIXES_NEW ; mix ++ ) {
53595359 uint32_t mix_and_val = (1 << mix );
53605360
53615361 if (audio_submix ) {
@@ -5435,7 +5435,7 @@ void obs_source_get_audio_mix(const obs_source_t *source, struct obs_source_audi
54355435 if (!obs_ptr_valid (audio , "audio" ))
54365436 return ;
54375437
5438- for (size_t mix = 0 ; mix < MAX_AUDIO_MIXES ; mix ++ ) {
5438+ for (size_t mix = 0 ; mix < MAX_AUDIO_MIXES_NEW ; mix ++ ) {
54395439 for (size_t ch = 0 ; ch < MAX_AUDIO_CHANNELS ; ch ++ ) {
54405440 audio -> output [mix ].data [ch ] = source -> audio_output_buf [mix ][ch ];
54415441 }
@@ -5519,10 +5519,31 @@ void obs_source_set_monitoring_type(obs_source_t *source, enum obs_monitoring_ty
55195519 }
55205520
55215521 source -> monitoring_type = type ;
5522+
5523+ #ifdef _WIN32
5524+ // On windows, assign to the extra asio monitoring track (track 7) all sources which have not type
5525+ // OBS_MONITORING_TYPE_NONE.
5526+ if (type != OBS_MONITORING_TYPE_NONE ) {
5527+ source -> audio_mixers |= 1 << (MAX_AUDIO_MIXES_NEW - 1 );
5528+ } else {
5529+ source -> audio_mixers &= ~(1 << (MAX_AUDIO_MIXES_NEW - 1 ));
5530+ }
5531+ #endif
55225532}
55235533
55245534enum obs_monitoring_type obs_source_get_monitoring_type (const obs_source_t * source )
55255535{
5536+ #ifdef _WIN32
5537+ // If type is not OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT, unselect the extra asio monitoring track (track 7) on
5538+ // windows.
5539+ uint32_t mixers = obs_source_get_audio_mixers (source );
5540+ if (source -> monitoring_type != OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT && mixers ) {
5541+ if (mixers & 1 << (MAX_AUDIO_MIXES_NEW - 1 )) {
5542+ mixers &= ~(1 << (MAX_AUDIO_MIXES_NEW - 1 ));
5543+ obs_source_set_audio_mixers ((obs_source_t * )source , mixers );
5544+ }
5545+ }
5546+ #endif
55265547 return obs_source_valid (source , "obs_source_get_monitoring_type" ) ? source -> monitoring_type
55275548 : OBS_MONITORING_TYPE_NONE ;
55285549}
0 commit comments