@@ -18616,15 +18616,20 @@ static ma_pa_buffer_attr ma_device__pa_buffer_attr_new(ma_uint32 periodSizeInFra
1861618616static ma_pa_stream* ma_device__pa_stream_new__pulse(ma_device* pDevice, const char* pStreamName, const ma_pa_sample_spec* ss, const ma_pa_channel_map* cmap)
1861718617{
1861818618 static int g_StreamCounter = 0;
18619+ static ma_mutex g_StreamCounterMutex;
1861918620 char actualStreamName[256];
1862018621
18621- if (pStreamName != NULL) {
18622- ma_strncpy_s(actualStreamName, sizeof(actualStreamName), pStreamName, (size_t)-1);
18623- } else {
18624- ma_strcpy_s(actualStreamName, sizeof(actualStreamName), "miniaudio:");
18625- ma_itoa_s(g_StreamCounter, actualStreamName + 8, sizeof(actualStreamName)-8, 10); /* 8 = strlen("miniaudio:") */
18622+ ma_mutex_lock(&g_StreamCounterMutex);
18623+ {
18624+ if (pStreamName != NULL) {
18625+ ma_strncpy_s(actualStreamName, sizeof(actualStreamName), pStreamName, (size_t)-1);
18626+ } else {
18627+ ma_strcpy_s(actualStreamName, sizeof(actualStreamName), "miniaudio:");
18628+ ma_itoa_s(g_StreamCounter, actualStreamName + 8, sizeof(actualStreamName)-8, 10); /* 8 = strlen("miniaudio:") */
18629+ }
18630+ g_StreamCounter += 1;
1862618631 }
18627- g_StreamCounter += 1 ;
18632+ ma_mutex_unlock(&g_StreamCounterMutex) ;
1862818633
1862918634 return ((ma_pa_stream_new_proc)pDevice->pContext->pulse.pa_stream_new)((ma_pa_context*)pDevice->pulse.pPulseContext, actualStreamName, ss, cmap);
1863018635}
0 commit comments