mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 17:24:03 +02:00
Revert 2 PulseAudio related commits.
This reverts the following commits:d46e19fb47"PulseAudio: Attempt to fix a deadlock."61586de203"PulseAudio: Default to a blocking main loop."
This commit is contained in:
+1
-48
@@ -7110,7 +7110,6 @@ struct ma_device_config
|
||||
const char* pStreamNamePlayback;
|
||||
const char* pStreamNameCapture;
|
||||
int channelMap;
|
||||
ma_bool32 blockingMainLoop;
|
||||
} pulse;
|
||||
struct
|
||||
{
|
||||
@@ -7904,7 +7903,6 @@ struct ma_device
|
||||
/*pa_context**/ ma_ptr pPulseContext;
|
||||
/*pa_stream**/ ma_ptr pStreamPlayback;
|
||||
/*pa_stream**/ ma_ptr pStreamCapture;
|
||||
ma_bool32 blockingMainLoop;
|
||||
} pulse;
|
||||
#endif
|
||||
#ifdef MA_SUPPORT_JACK
|
||||
@@ -30475,7 +30473,6 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi
|
||||
sampleRate = pDescriptorCapture->sampleRate;
|
||||
}
|
||||
|
||||
pDevice->pulse.blockingMainLoop = pConfig->pulse.blockingMainLoop;
|
||||
|
||||
|
||||
result = ma_init_pa_mainloop_and_pa_context__pulse(pDevice->pContext, pDevice->pContext->pulse.pApplicationName, pDevice->pContext->pulse.pServerName, MA_FALSE, &pDevice->pulse.pMainLoop, &pDevice->pulse.pPulseContext);
|
||||
@@ -30961,50 +30958,10 @@ static ma_result ma_device_data_loop__pulse(ma_device* pDevice)
|
||||
the callbacks deal with it.
|
||||
*/
|
||||
while (ma_device_get_state(pDevice) == ma_device_state_started) {
|
||||
int block = (pDevice->pulse.blockingMainLoop) ? 1 : 0;
|
||||
|
||||
resultPA = ((ma_pa_mainloop_iterate_proc)pDevice->pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pDevice->pulse.pMainLoop, block, NULL);
|
||||
resultPA = ((ma_pa_mainloop_iterate_proc)pDevice->pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pDevice->pulse.pMainLoop, 1, NULL);
|
||||
if (resultPA < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* If we're not blocking we need to sleep for a bit to prevent the CPU core being pinned at 100% usage. */
|
||||
if (!block) {
|
||||
ma_uint32 sleepTimeInMilliseconds;
|
||||
|
||||
/*
|
||||
My original idea was to sleep for an amount of time proportionate to the configured period size, but I
|
||||
wasn't able to figure out how to make this work without glitching. Instead I'm just going to hardcode
|
||||
it to 1ms and move on.
|
||||
*/
|
||||
#if 0
|
||||
{
|
||||
if (((ma_pa_stream_writable_size_proc)pDevice->pContext->pulse.pa_stream_writable_size)((ma_pa_stream*)pDevice->pulse.pStreamPlayback) == 0) {
|
||||
/* The amount of time we spend sleeping should be proportionate to the size of a period. */
|
||||
if (pDevice->type == ma_device_type_playback) {
|
||||
sleepTimeInMilliseconds = (pDevice->playback.internalPeriodSizeInFrames * pDevice->playback.internalSampleRate) / 1000;
|
||||
} else {
|
||||
sleepTimeInMilliseconds = (pDevice->capture.internalPeriodSizeInFrames * pDevice->capture.internalSampleRate) / 1000;
|
||||
}
|
||||
|
||||
/*
|
||||
At this point the sleep time is equal to the period size in milliseconds. I'm going to divide this by 2
|
||||
in an attempt to reduce latency as a result of sleeping.
|
||||
*/
|
||||
sleepTimeInMilliseconds /= 2;
|
||||
|
||||
/* Clamp the sleep time to within reasonable values just in case. */
|
||||
sleepTimeInMilliseconds = ma_clamp(sleepTimeInMilliseconds, 1, 10);
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
sleepTimeInMilliseconds = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
ma_sleep(sleepTimeInMilliseconds);
|
||||
}
|
||||
}
|
||||
|
||||
/* NOTE: Don't stop the device here. It'll be done at a higher level. */
|
||||
@@ -41874,14 +41831,10 @@ MA_API ma_bool32 ma_context_is_loopback_supported(ma_context* pContext)
|
||||
MA_API ma_device_config ma_device_config_init(ma_device_type deviceType)
|
||||
{
|
||||
ma_device_config config;
|
||||
|
||||
MA_ZERO_OBJECT(&config);
|
||||
config.deviceType = deviceType;
|
||||
config.resampling = ma_resampler_config_init(ma_format_unknown, 0, 0, 0, ma_resample_algorithm_linear); /* Format/channels/rate don't matter here. */
|
||||
|
||||
/* Use a blocking PulseAudio loop by default. Non-blocking currently results in glitches with low period sizes. */
|
||||
config.pulse.blockingMainLoop = MA_TRUE;
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user