From ad4852c2041b810967b8dcc9deaee17a5ba1a165 Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandre.savard@savoirfairelinux.net> Date: Fri, 23 Oct 2009 15:06:36 -0400 Subject: [PATCH] [#2333] Fix Pulseaudio Capture Setting pulseaudio capture stream parameters using alsa realtime scheduling --- .../src/audio/pulseaudio/audiostream.cpp | 26 +++++-------------- .../src/audio/pulseaudio/pulselayer.cpp | 3 +++ .../src/audio/pulseaudio/pulselayer.h | 2 ++ 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/sflphone-common/src/audio/pulseaudio/audiostream.cpp b/sflphone-common/src/audio/pulseaudio/audiostream.cpp index f3a1f3bb0e..66f8445a54 100644 --- a/sflphone-common/src/audio/pulseaudio/audiostream.cpp +++ b/sflphone-common/src/audio/pulseaudio/audiostream.cpp @@ -184,36 +184,22 @@ AudioStream::createStream (pa_context* c) // parameters are defined as number of bytes // 2048 bytes (1024 int16) is 20 ms at 44100 Hz if (_streamType == PLAYBACK_STREAM) { - /* - attributes->maxlength = (uint32_t) -1; - attributes->tlength = 1024; - attributes->prebuf = (uint32_t) -1; - attributes->minreq = (uint32_t) -1; - attributes->fragsize = (uint32_t) -1; - */ attributes->maxlength = 88200; attributes->tlength = 44100; attributes->prebuf = 4096; attributes->minreq = 2048; attributes->fragsize = 4096; - - // pa_stream_connect_playback( s , NULL , attributes, PA_STREAM_NOFLAGS, &_volume, NULL); - // pa_stream_connect_playback (s , NULL , attributes, PA_STREAM_START_CORKED, &_volume, NULL); + pa_stream_connect_playback( s , NULL , attributes, PA_STREAM_ADJUST_LATENCY, &_volume, NULL); } else if (_streamType == CAPTURE_STREAM) { - // attributes->maxlength = 66500; - // attributes->fragsize = (uint32_t)-1; - - attributes->maxlength = (uint32_t) -1; - attributes->tlength = (uint32_t) -1; - attributes->prebuf = (uint32_t) -1; - attributes->minreq = (uint32_t) -1; - attributes->fragsize = 1024; + attributes->maxlength = 88200; + attributes->tlength = 44100; + attributes->prebuf = 4096; + attributes->minreq = 2048; + attributes->fragsize = 4096; - // pa_stream_connect_record (s , NULL , attributes , PA_STREAM_START_CORKED); - // pa_stream_connect_record( s , NULL , attributes , PA_STREAM_INTERPOLATE_TIMING ); pa_stream_connect_record( s, NULL, attributes, PA_STREAM_ADJUST_LATENCY); } else if (_streamType == UPLOAD_STREAM) { pa_stream_connect_upload (s , 1024); diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp index 7801582cb7..edcf2815a7 100644 --- a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp +++ b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp @@ -155,6 +155,9 @@ void PulseLayer::connectPulseAudioServer (void) { _debug ("PulseLayer::connectPulseAudioServer \n"); + + setenv("PULSE_PROP_media.role", "phone", 1); + pa_context_flags_t flag = PA_CONTEXT_NOAUTOSPAWN ; pa_threaded_mainloop_lock (m); diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.h b/sflphone-common/src/audio/pulseaudio/pulselayer.h index 4e7e30e816..eb25240831 100644 --- a/sflphone-common/src/audio/pulseaudio/pulselayer.h +++ b/sflphone-common/src/audio/pulseaudio/pulselayer.h @@ -28,6 +28,8 @@ #include <pulse/pulseaudio.h> #include <pulse/stream.h> +#include <stdlib.h> + #define PLAYBACK_STREAM_NAME "SFLphone out" #define CAPTURE_STREAM_NAME "SFLphone in" -- GitLab