Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pulseaudio: Make use of suggestedLatency stream parameter. #849

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/hostapi/pulseaudio/pa_linux_pulseaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,16 @@ PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,

stream->inputDevice = inputParameters->device;

/* Convert positive suggestedLatency from seconds to microseconds, otherwise default to zero. */
if (inputParameters->suggestedLatency >= 0)
{
stream->suggestedLatencyUSecs = (unsigned int) (inputParameters->suggestedLatency * 1e6 + 1.0f);
}
else
{
stream->suggestedLatencyUSecs = 0;
}

/*
* This is too much as most of the time there is not much
* stuff in buffer but it's enough if we are doing blocked
Expand Down Expand Up @@ -1227,6 +1237,16 @@ PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
}

stream->outputDevice = outputParameters->device;

/* Convert positive suggestedLatency from seconds to microseconds, otherwise default to zero. */
if (outputParameters->suggestedLatency >= 0)
{
stream->suggestedLatencyUSecs = (unsigned int) (outputParameters->suggestedLatency * 1e6 + 1.0f);
}
else
{
stream->suggestedLatencyUSecs = 0;
}
}

else
Expand Down
2 changes: 1 addition & 1 deletion src/hostapi/pulseaudio/pa_linux_pulseaudio_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ PaError PaPulseAudio_StartStreamCb( PaStream * s )
const char *pulseaudioName = NULL;
pa_operation *pulseaudioOperation = NULL;
int waitLoop = 0;
unsigned int pulseaudioReqFrameSize = (1024 * 2);
unsigned int pulseaudioReqFrameSize = stream->suggestedLatencyUSecs;

stream->isActive = 0;
stream->isStopped = 1;
Expand Down
1 change: 1 addition & 0 deletions src/hostapi/pulseaudio/pa_linux_pulseaudio_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ typedef struct PaPulseAudio_Stream
pa_stream *inputStream;
pa_buffer_attr outputBufferAttr;
pa_buffer_attr inputBufferAttr;
unsigned int suggestedLatencyUSecs;
int outputUnderflows;
int outputChannelCount;
int inputChannelCount;
Expand Down
Loading