Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
320b0e05
Commit
320b0e05
authored
Feb 10, 2022
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PulseAudio: Use a bigger default buffer size.
Public issue
https://github.com/mackron/miniaudio/issues/427
parent
bcff6ac1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
2 deletions
+28
-2
miniaudio.h
miniaudio.h
+28
-2
No files found.
miniaudio.h
View file @
320b0e05
...
...
@@ -28777,6 +28777,32 @@ static void ma_device_on_rerouted__pulse(ma_pa_stream* pStream, void* pUserData)
ma_device__on_notification_rerouted(pDevice);
}
static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__pulse(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile)
{
/*
There have been reports from users where buffers of < ~20ms result glitches when running through
PipeWire. To work around this we're going to have to use a different default buffer size.
*/
const ma_uint32 defaultPeriodSizeInMilliseconds_LowLatency = 25;
const ma_uint32 defaultPeriodSizeInMilliseconds_Conservative = MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE;
MA_ASSERT(nativeSampleRate != 0);
if (pDescriptor->periodSizeInFrames == 0) {
if (pDescriptor->periodSizeInMilliseconds == 0) {
if (performanceProfile == ma_performance_profile_low_latency) {
return ma_calculate_buffer_size_in_frames_from_milliseconds(defaultPeriodSizeInMilliseconds_LowLatency, nativeSampleRate);
} else {
return ma_calculate_buffer_size_in_frames_from_milliseconds(defaultPeriodSizeInMilliseconds_Conservative, nativeSampleRate);
}
} else {
return ma_calculate_buffer_size_in_frames_from_milliseconds(pDescriptor->periodSizeInMilliseconds, nativeSampleRate);
}
} else {
return pDescriptor->periodSizeInFrames;
}
}
static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
{
/*
...
...
@@ -28882,7 +28908,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi
}
/* We now have enough information to calculate our actual period size in frames. */
pDescriptorCapture->periodSizeInFrames = ma_calculate_
buffer_size_in_frames_from_descriptor
(pDescriptorCapture, ss.rate, pConfig->performanceProfile);
pDescriptorCapture->periodSizeInFrames = ma_calculate_
period_size_in_frames_from_descriptor__pulse
(pDescriptorCapture, ss.rate, pConfig->performanceProfile);
attr = ma_device__pa_buffer_attr_new(pDescriptorCapture->periodSizeInFrames, pDescriptorCapture->periodCount, &ss);
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_INFO, "[PulseAudio] Capture attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; periodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorCapture->periodSizeInFrames);
...
...
@@ -29018,7 +29044,7 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi
}
/* We now have enough information to calculate the actual buffer size in frames. */
pDescriptorPlayback->periodSizeInFrames = ma_calculate_
buffer_size_in_frames_from_descriptor
(pDescriptorPlayback, ss.rate, pConfig->performanceProfile);
pDescriptorPlayback->periodSizeInFrames = ma_calculate_
period_size_in_frames_from_descriptor__pulse
(pDescriptorPlayback, ss.rate, pConfig->performanceProfile);
attr = ma_device__pa_buffer_attr_new(pDescriptorPlayback->periodSizeInFrames, pDescriptorPlayback->periodCount, &ss);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment