[Pkg-voip-commits] r7504 - in /mumble/branches/1.1.8: ./ debian/changelog debian/patches/backport-alsa-pulseaudio debian/patches/series
slicer-guest at alioth.debian.org
slicer-guest at alioth.debian.org
Sun Aug 16 15:59:55 UTC 2009
Author: slicer-guest
Date: Sun Aug 16 15:59:55 2009
New Revision: 7504
URL: http://svn.debian.org/wsvn/pkg-voip/?sc=1&rev=7504
Log:
Backport ALSA and PulseAudio modules from 1.2.0 git, makes them work with modern
releases of these sound systems.
Added:
mumble/branches/1.1.8/
- copied from r7467, mumble/tags/1.1.8-2/
mumble/branches/1.1.8/debian/patches/backport-alsa-pulseaudio
Modified:
mumble/branches/1.1.8/debian/changelog
mumble/branches/1.1.8/debian/patches/series
Modified: mumble/branches/1.1.8/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-voip/mumble/branches/1.1.8/debian/changelog?rev=7504&op=diff
==============================================================================
--- mumble/branches/1.1.8/debian/changelog (original)
+++ mumble/branches/1.1.8/debian/changelog Sun Aug 16 15:59:55 2009
@@ -1,3 +1,10 @@
+mumble (1.1.8-3) UNRELEASED; urgency=low
+
+ * Backport ALSA and PulseAudio modules from 1.2.0 git, makes them work with modern
+ releases of these sound systems.
+
+ -- Thorvald Natvig <slicer at users.sourceforge.net> Sun, 16 Aug 2009 17:52:43 +0200
+
mumble (1.1.8-2) unstable; urgency=low
[ Thorvald Natvig ]
Added: mumble/branches/1.1.8/debian/patches/backport-alsa-pulseaudio
URL: http://svn.debian.org/wsvn/pkg-voip/mumble/branches/1.1.8/debian/patches/backport-alsa-pulseaudio?rev=7504&op=file
==============================================================================
--- mumble/branches/1.1.8/debian/patches/backport-alsa-pulseaudio (added)
+++ mumble/branches/1.1.8/debian/patches/backport-alsa-pulseaudio Sun Aug 16 15:59:55 2009
@@ -1,0 +1,725 @@
+diff --git a/src/mumble/ALSAAudio.cpp b/src/mumble/ALSAAudio.cpp
+index 4bb5143..b776201 100644
+--- a/src/mumble/ALSAAudio.cpp
++++ b/src/mumble/ALSAAudio.cpp
+@@ -121,7 +121,7 @@ const QList<audioDevice> ALSAAudioInputRegistrar::getDeviceChoices() {
+ }
+
+ foreach(const QString &dev, qlInputDevs) {
+- QString t=QString::fromLatin1("[%1] %2").arg(dev).arg(cards->qhInput.value(dev));
++ QString t=QString::fromLatin1("[%1] %2").arg(dev, cards->qhInput.value(dev));
+ qlReturn << audioDevice(t, dev);
+ }
+
+@@ -155,7 +155,7 @@ const QList<audioDevice> ALSAAudioOutputRegistrar::getDeviceChoices() {
+ }
+
+ foreach(const QString &dev, qlOutputDevs) {
+- QString t=QString::fromLatin1("[%1] %2").arg(dev).arg(cards->qhOutput.value(dev));
++ QString t=QString::fromLatin1("[%1] %2").arg(dev, cards->qhOutput.value(dev));
+ qlReturn << audioDevice(t, dev);
+ }
+
+@@ -302,11 +302,12 @@ ALSAAudioInput::~ALSAAudioInput() {
+ wait();
+ }
+
+-#define ALSA_ERRBAIL(x) if (!bOk) {} else if ((err=(x)) != 0) { bOk = false; qWarning("ALSAAudio: %s: %s", #x, snd_strerror(err));}
++#define ALSA_ERRBAIL(x) if (!bOk) {} else if ((err=(x)) < 0) { bOk = false; qWarning("ALSAAudio: %s: %s", #x, snd_strerror(err));}
++#define ALSA_ERRCHECK(x) if (!bOk) {} else if ((err=(x)) < 0) {qWarning("ALSAAudio: Non-critical: %s: %s", #x, snd_strerror(err));}
+
+ void ALSAAudioInput::run() {
+ QMutexLocker qml(&qmALSA);
+- int readblapp;
++ snd_pcm_sframes_t readblapp;
+
+ QByteArray device_name = g.s.qsALSAInput.toLatin1();
+ snd_pcm_hw_params_t *hw_params = NULL;
+@@ -324,7 +325,7 @@ void ALSAAudioInput::run() {
+ snd_pcm_hw_params_alloca(&hw_params);
+
+ ALSA_ERRBAIL(snd_pcm_open(&capture_handle, device_name.data(), SND_PCM_STREAM_CAPTURE, 0));
+- ALSA_ERRBAIL(snd_pcm_hw_params_any(capture_handle, hw_params));
++ ALSA_ERRCHECK(snd_pcm_hw_params_any(capture_handle, hw_params));
+ ALSA_ERRBAIL(snd_pcm_hw_params_set_access(capture_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED));
+ ALSA_ERRBAIL(snd_pcm_hw_params_set_format(capture_handle, hw_params, SND_PCM_FORMAT_S16));
+ ALSA_ERRBAIL(snd_pcm_hw_params_set_rate_near(capture_handle, hw_params, &rrate, NULL));
+@@ -342,8 +343,6 @@ void ALSAAudioInput::run() {
+ ALSA_ERRBAIL(snd_pcm_hw_params_current(capture_handle, hw_params));
+ ALSA_ERRBAIL(snd_pcm_hw_params_get_channels(hw_params, &iMicChannels));
+ ALSA_ERRBAIL(snd_pcm_hw_params_get_rate(hw_params, &iMicFreq, NULL));
+- eMicFormat = SampleShort;
+- initializeMixer();
+
+ #ifdef ALSA_VERBOSE
+ snd_output_t *log;
+@@ -365,7 +364,10 @@ void ALSAAudioInput::run() {
+ return;
+ }
+
+- char inbuff[wantPeriod * iChannels * sizeof(float)];
++ eMicFormat = SampleShort;
++ initializeMixer();
++
++ char inbuff[wantPeriod * iChannels * sizeof(short)];
+
+ qml.unlock();
+
+@@ -376,18 +378,18 @@ void ALSAAudioInput::run() {
+ snd_pcm_status_dump(status, log);
+ snd_pcm_status_free(status);
+ #endif
+- readblapp = snd_pcm_readi(capture_handle, inbuff, wantPeriod);
++ readblapp = snd_pcm_readi(capture_handle, inbuff, static_cast<int>(wantPeriod));
+ if (readblapp == -ESTRPIPE) {
+ // suspend event - what to do?
+- qWarning("ALSAAudioInput: %s", snd_strerror(readblapp));
++ qWarning("ALSAAudioInput: %s", snd_strerror(static_cast<int>(readblapp)));
+ } else if (readblapp == -EPIPE) {
+ err = snd_pcm_prepare(capture_handle);
+- qWarning("ALSAAudioInput: %s: %s", snd_strerror(readblapp), snd_strerror(err));
++ qWarning("ALSAAudioInput: %s: %s", snd_strerror(static_cast<int>(readblapp)), snd_strerror(err));
+ } else if (readblapp < 0) {
+ err = snd_pcm_prepare(capture_handle);
+- qWarning("ALSAAudioInput: %s: %s", snd_strerror(readblapp), snd_strerror(err));
++ qWarning("ALSAAudioInput: %s: %s", snd_strerror(static_cast<int>(readblapp)), snd_strerror(err));
+ } else if (wantPeriod == static_cast<unsigned int>(readblapp)) {
+- addMic(inbuff, readblapp);
++ addMic(inbuff, static_cast<int>(readblapp));
+ }
+ }
+
+@@ -430,7 +432,7 @@ void ALSAAudioOutput::run() {
+ snd_pcm_sw_params_alloca(&sw_params);
+
+ ALSA_ERRBAIL(snd_pcm_open(&pcm_handle, device_name.data(), SND_PCM_STREAM_PLAYBACK, 0));
+- ALSA_ERRBAIL(snd_pcm_hw_params_any(pcm_handle, hw_params));
++ ALSA_ERRCHECK(snd_pcm_hw_params_any(pcm_handle, hw_params));
+
+ if (g.s.doPositionalAudio()) {
+ iChannels = 1;
+@@ -445,8 +447,8 @@ void ALSAAudioOutput::run() {
+
+ ALSA_ERRBAIL(snd_pcm_hw_params_set_access(pcm_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED));
+ ALSA_ERRBAIL(snd_pcm_hw_params_set_format(pcm_handle, hw_params, SND_PCM_FORMAT_S16));
+- ALSA_ERRBAIL(snd_pcm_hw_params_set_rate_near(pcm_handle, hw_params, &iMixerFreq, NULL));
+ ALSA_ERRBAIL(snd_pcm_hw_params_set_channels_near(pcm_handle, hw_params, &iChannels));
++ ALSA_ERRBAIL(snd_pcm_hw_params_set_rate_near(pcm_handle, hw_params, &iMixerFreq, NULL));
+
+ unsigned int iOutputSize = (iFrameSize * iMixerFreq) / SAMPLE_RATE;
+
+@@ -459,15 +461,20 @@ void ALSAAudioOutput::run() {
+ ALSA_ERRBAIL(snd_pcm_hw_params(pcm_handle, hw_params));
+ ALSA_ERRBAIL(snd_pcm_hw_params_current(pcm_handle, hw_params));
+
++ qWarning("ALSAAudioOutput: Actual buffer %d hz, %d channel %ld samples [%ld per period]",iMixerFreq,iChannels,buffer_size,period_size);
++
+ ALSA_ERRBAIL(snd_pcm_sw_params_current(pcm_handle, sw_params));
+- ALSA_ERRBAIL(snd_pcm_sw_params_set_start_threshold(pcm_handle, sw_params, 0));
+ ALSA_ERRBAIL(snd_pcm_sw_params_set_avail_min(pcm_handle, sw_params, period_size));
++ ALSA_ERRBAIL(snd_pcm_sw_params_set_start_threshold(pcm_handle, sw_params, buffer_size));
++ ALSA_ERRBAIL(snd_pcm_sw_params_set_stop_threshold(pcm_handle, sw_params, 0));
++ ALSA_ERRBAIL(snd_pcm_sw_params_set_silence_threshold(pcm_handle, sw_params, period_size));
++ ALSA_ERRBAIL(snd_pcm_sw_params_set_silence_size(pcm_handle, sw_params, period_size));
+
+ ALSA_ERRBAIL(snd_pcm_sw_params(pcm_handle, sw_params));
+
+ ALSA_ERRBAIL(snd_pcm_prepare(pcm_handle));
+
+- const unsigned int buffsize = period_size * iChannels;
++ const unsigned int buffsize = static_cast<unsigned int>(period_size * iChannels);
+
+ float zerobuff[buffsize];
+ float outbuff[buffsize];
+@@ -514,7 +521,7 @@ void ALSAAudioOutput::run() {
+
+ qml.unlock();
+
+- while (bRunning) {
++ while (bRunning && bOk) {
+ poll(fds, count, 20);
+ unsigned short revents;
+
+@@ -522,26 +529,35 @@ void ALSAAudioOutput::run() {
+ if (revents & POLLERR) {
+ snd_pcm_prepare(pcm_handle);
+ } else if (revents & POLLOUT) {
+- while (snd_pcm_avail_update(pcm_handle) >= static_cast<int>(period_size)) {
+- stillRun = mix(outbuff, period_size);
+- int w = 0;
+- if (stillRun)
+- w=snd_pcm_writei(pcm_handle, outbuff, period_size);
++ snd_pcm_sframes_t avail;
++ ALSA_ERRCHECK(avail = snd_pcm_avail_update(pcm_handle));
++ while (avail >= static_cast<int>(period_size)) {
++ stillRun = mix(outbuff, static_cast<int>(period_size));
++ snd_pcm_sframes_t w = 0;
++ if (stillRun) {
++ ALSA_ERRCHECK(w=snd_pcm_writei(pcm_handle, outbuff, period_size));
++ if (w < 0) {
++ avail = w;
++ break;
++ }
++ }
+ else
+ break;
+- if (w == -EPIPE) {
+- qWarning("ALSAAudioOutput: %s", snd_strerror(w));
+- snd_pcm_prepare(pcm_handle);
+- for (unsigned int i=0;i< buffer_size / period_size;i++)
+- snd_pcm_writei(pcm_handle, zerobuff, period_size);
+- }
++ ALSA_ERRCHECK(avail = snd_pcm_avail_update(pcm_handle));
++ }
++
++ if (avail == -EPIPE) {
++ ALSA_ERRCHECK(snd_pcm_prepare(pcm_handle));
++ for (unsigned int i=0;i< buffer_size / period_size;++i)
++ ALSA_ERRCHECK(snd_pcm_writei(pcm_handle, zerobuff, period_size));
+ }
+
+ if (! stillRun) {
+ snd_pcm_drain(pcm_handle);
+
+- while (bRunning && !mix(outbuff, period_size))
+- this->msleep(20);
++ while (bRunning && !mix(outbuff, period_size)) {
++ this->msleep(10);
++ }
+
+ if (! bRunning)
+ break;
+diff --git a/src/mumble/ALSAAudio.h b/src/mumble/ALSAAudio.h
+index 06dcb33..31be8af 100644
+--- a/src/mumble/ALSAAudio.h
++++ b/src/mumble/ALSAAudio.h
+@@ -33,7 +33,6 @@
+
+ #include "AudioInput.h"
+ #include "AudioOutput.h"
+-#include "ConfigDialog.h"
+ #include <alsa/asoundlib.h>
+
+ class ALSAAudioOutput;
+diff --git a/src/mumble/AudioOutput.cpp b/src/mumble/AudioOutput.cpp
+index 4db6927..d0ede6e 100644
+--- a/src/mumble/AudioOutput.cpp
++++ b/src/mumble/AudioOutput.cpp
+@@ -514,7 +514,9 @@ const float *AudioOutput::getSpeakerPos(unsigned int &speakers) {
+ }
+
+ AudioSine *AudioOutput::playSine(float hz, float i, unsigned int frames, float volume) {
+- while ((iMixerFreq == 0) && isRunning()) {}
++ while ((iMixerFreq == 0) && bRunning) {}
++ if (! iMixerFreq)
++ return NULL;
+
+ qrwlOutputs.lockForWrite();
+ AudioSine *as = new AudioSine(hz,i,frames, volume, iMixerFreq);
+@@ -528,7 +530,9 @@ AudioOutputSample *AudioOutput::playSample(const QString &filename, bool loop) {
+ if (packets.isEmpty())
+ return NULL;
+
+- while ((iMixerFreq == 0) && isRunning()) {}
++ while ((iMixerFreq == 0) && bRunning) {}
++ if (! iMixerFreq)
++ return NULL;
+
+ qrwlOutputs.lockForWrite();
+ AudioOutputSample *aos = new AudioOutputSample(filename, packets, loop, iMixerFreq);
+@@ -546,7 +550,9 @@ void AudioOutput::addFrameToBuffer(ClientPlayer *player, const QByteArray &qbaPa
+ if (! aop) {
+ qrwlOutputs.unlock();
+
+- while ((iMixerFreq == 0) && isRunning()) {}
++ while ((iMixerFreq == 0) && bRunning) {}
++ if (! iMixerFreq)
++ return;
+
+ qrwlOutputs.lockForWrite();
+ aop = new AudioOutputSpeech(player, iMixerFreq);
+diff --git a/src/mumble/AudioWizard.cpp b/src/mumble/AudioWizard.cpp
+index f00e72d..311a5ac 100644
+--- a/src/mumble/AudioWizard.cpp
++++ b/src/mumble/AudioWizard.cpp
+@@ -536,11 +536,11 @@ void AudioWizard::on_InputDevice_activated(int) {
+ if (! AudioInputRegistrar::qmNew)
+ return;
+
+- boost::weak_ptr<AudioInput> wai(g.ai);
++ AudioInputPtr ai = g.ai;
+ g.ai.reset();
+
+- while (! wai.expired()) {
+- }
++ while (! ai.unique()) {}
++ ai.reset();
+
+ AudioInputRegistrar *air = AudioInputRegistrar::qmNew->value(qcbInput->currentText());
+ int idx = qcbInputDevice->currentIndex();
+@@ -579,11 +579,13 @@ void AudioWizard::on_OutputDevice_activated(int) {
+ if (! AudioOutputRegistrar::qmNew)
+ return;
+
+- boost::weak_ptr<AudioOutput> wai(g.ao);
++ AudioOutputPtr ao = g.ao;
+ g.ao.reset();
+
+- while (! wai.expired()) {
+- }
++ while (! ao.unique()) {}
++ ao.reset();
++
++ aosSource = NULL;
+
+ AudioOutputRegistrar *aor = AudioOutputRegistrar::qmNew->value(qcbOutput->currentText());
+ int idx = qcbOutputDevice->currentIndex();
+@@ -604,8 +606,7 @@ void AudioWizard::on_OutputDelay_valueChanged(int v) {
+ g.s.iOutputDelay = v;
+ on_OutputDevice_activated(0);
+ if (! bInit) {
+- AudioOutputPtr ao = g.ao;
+- ao->playSine(0.0f, 0.0f, 0xfffffff, 0.5f);
++ playChord();
+ }
+ }
+
+@@ -657,24 +658,26 @@ int AudioWizard::nextId() const {
+ }
+
+ void AudioWizard::playChord() {
++ qWarning("RequestPlayChord");
+ AudioOutputPtr ao = g.ao;
++ qWarning("%p %p", ao.get(), aosSource);
+ if (! ao || aosSource)
+ return;
+ aosSource = ao->playSample(QLatin1String("skin:wb_male.spx"), true);
+ }
+
+ void AudioWizard::restartAudio() {
+- boost::weak_ptr<AudioInput> wai(g.ai);
+- boost::weak_ptr<AudioOutput> wao(g.ao);
++ AudioInputPtr ai = g.ai;
++ AudioOutputPtr ao = g.ao;
+
+ aosSource = NULL;
+
+ g.ai.reset();
+ g.ao.reset();
+-
+- while (! wai.expired() || ! wao.expired()) {
+- // Where is QThread::yield() ?
+- }
++
++ while (! ai.unique() || ! ao.unique()) {}
++ ai.reset();
++ ao.reset();
+
+ g.s.qsAudioInput = qcbInput->currentText();
+ g.s.qsAudioOutput = qcbOutput->currentText();
+diff --git a/src/mumble/ConfigDialog.cpp b/src/mumble/ConfigDialog.cpp
+index 66c2a69..8e92847 100644
+--- a/src/mumble/ConfigDialog.cpp
++++ b/src/mumble/ConfigDialog.cpp
+@@ -220,15 +220,16 @@ void ConfigDialog::apply() {
+ foreach(ConfigWidget *cw, qmWidgets)
+ cw->save();
+
+- boost::weak_ptr<AudioInput> wai(g.ai);
+- boost::weak_ptr<AudioOutput> wao(g.ao);
++ AudioInputPtr ai = g.ai;
++ AudioOutputPtr ao = g.ao;
+
+ g.ai.reset();
+ g.ao.reset();
+-
+- while (! wai.expired() || ! wao.expired()) {
+- // Where is QThread::yield() ?
+- }
++
++ while (! ai.unique() || ! ao.unique()) {}
++
++ ai.reset();
++ ao.reset();
+
+ g.s = s;
+
+diff --git a/src/mumble/OSS.cpp b/src/mumble/OSS.cpp
+index e309c46..2b77b94 100644
+--- a/src/mumble/OSS.cpp
++++ b/src/mumble/OSS.cpp
+@@ -245,10 +245,10 @@ void OSSInput::run() {
+ short buffer[iMicLength];
+
+ while (bRunning) {
+- int len = iMicLength * iMicChannels * sizeof(short);
++ int len = static_cast<int>(iMicLength * iMicChannels * sizeof(short));
+ ssize_t l = read(fd, buffer, len);
+ if (l != len) {
+- qWarning("OSSInput: Read %d", l);
++ qWarning("OSSInput: Read %ld", l);
+ break;
+ }
+ addMic(buffer, iMicLength);
+@@ -342,15 +342,15 @@ void OSSOutput::run() {
+
+ qWarning("OSSOutput: Staring audio playback to %s", device.constData());
+
+- const int blocklen = iOutputBlock * iChannels * sizeof(short);
++ ssize_t blocklen = iOutputBlock * iChannels * sizeof(short);
+ short mbuffer[iOutputBlock * iChannels];
+
+ while (bRunning) {
+ bool stillRun = mix(mbuffer, iOutputBlock);
+ if (stillRun) {
+- int l = write(fd, mbuffer, blocklen);
++ ssize_t l = write(fd, mbuffer, blocklen);
+ if (l != blocklen) {
+- qWarning("OSSOutput: Write %d != %d", l, blocklen);
++ qWarning("OSSOutput: Write %ld != %ld", l, blocklen);
+ break;
+ }
+ } else {
+diff --git a/src/mumble/OSS.h b/src/mumble/OSS.h
+index e1c22fc..84f5532 100644
+--- a/src/mumble/OSS.h
++++ b/src/mumble/OSS.h
+@@ -33,7 +33,6 @@
+
+ #include "AudioInput.h"
+ #include "AudioOutput.h"
+-#include "ConfigDialog.h"
+
+ class OSSInput : public AudioInput {
+ private:
+@@ -48,7 +47,7 @@ class OSSInput : public AudioInput {
+ };
+
+ class OSSOutput : public AudioOutput {
+- friend class OSSPlayer;
++ friend class OSSUser;
+ private:
+ Q_OBJECT
+ Q_DISABLE_COPY(OSSOutput)
+diff --git a/src/mumble/PulseAudio.cpp b/src/mumble/PulseAudio.cpp
+index 18a65d0..0ac2520 100644
+--- a/src/mumble/PulseAudio.cpp
++++ b/src/mumble/PulseAudio.cpp
+@@ -67,7 +67,6 @@ class PulseAudioInit : public DeferInit {
+ void initialize() {
+ pasys = new PulseAudioSystem();
+ pasys->qmWait.lock();
+- pasys->start(QThread::TimeCriticalPriority);
+ pasys->qwcWait.wait(&pasys->qmWait, 1000);
+ pasys->qmWait.unlock();
+ if (pasys->bPulseIsGood) {
+@@ -76,6 +75,8 @@ class PulseAudioInit : public DeferInit {
+ } else {
+ airPulseAudio = NULL;
+ aorPulseAudio = NULL;
++ delete pasys;
++ pasys = NULL;
+ }
+ };
+ void destroy() {
+@@ -83,8 +84,10 @@ class PulseAudioInit : public DeferInit {
+ delete airPulseAudio;
+ if (aorPulseAudio)
+ delete aorPulseAudio;
+- delete pasys;
+- pasys = NULL;
++ if (pasys) {
++ delete pasys;
++ pasys = NULL;
++ }
+ };
+ };
+
+@@ -97,8 +100,8 @@ PulseAudioSystem::PulseAudioSystem() {
+ bPositionalCache = false;
+ bPulseIsGood = false;
+
+- pam = pa_mainloop_new();
+- pa_mainloop_api *api = pa_mainloop_get_api(pam);
++ pam = pa_threaded_mainloop_new();
++ pa_mainloop_api *api = pa_threaded_mainloop_get_api(pam);
+
+ pacContext = pa_context_new(api, "Mumble");
+
+@@ -109,30 +112,27 @@ PulseAudioSystem::PulseAudioSystem() {
+
+ pade = api->defer_new(api, defer_event_callback, this);
+ api->defer_enable(pade, false);
++
++ pa_threaded_mainloop_start(pam);
+ }
+
+ PulseAudioSystem::~PulseAudioSystem() {
+- pa_mainloop_quit(pam, 0);
+- wait();
++ pa_threaded_mainloop_stop(pam);
+ pa_context_disconnect(pacContext);
+ pa_context_unref(pacContext);
+- pa_mainloop_free(pam);
++ pa_threaded_mainloop_free(pam);
+ }
+
+ void PulseAudioSystem::wakeup() {
+- pa_mainloop_api *api = pa_mainloop_get_api(pam);
++ pa_mainloop_api *api = pa_threaded_mainloop_get_api(pam);
+ api->defer_enable(pade, true);
+- pa_mainloop_wakeup(pam);
+ }
+
+-void PulseAudioSystem::run() {
+- // Make sure we don't exit too early.
+- qmWait.lock();
+- qmWait.unlock();
+- int rv;
+- pa_mainloop_run(pam, &rv);
+- if (rv != 0)
+- qWarning("PulseAudio: Mainloop quit with retval %d", rv);
++void PulseAudioSystem::wakeup_lock() {
++ pa_threaded_mainloop_lock(pam);
++ pa_mainloop_api *api = pa_threaded_mainloop_get_api(pam);
++ api->defer_enable(pade, true);
++ pa_threaded_mainloop_unlock(pam);
+ }
+
+ void PulseAudioSystem::defer_event_callback(pa_mainloop_api *a, pa_defer_event *e, void *userdata) {
+@@ -140,7 +140,6 @@ void PulseAudioSystem::defer_event_callback(pa_mainloop_api *a, pa_defer_event *
+ pas->eventCallback(a, e);
+ }
+
+-
+ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
+ api->defer_enable(pade, false);
+
+@@ -203,16 +202,17 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
+ pa_buffer_attr buff;
+ const pa_sample_spec *pss = pa_stream_get_sample_spec(pasOutput);
+ const unsigned int iBlockLen = ((pao->iFrameSize * pss->rate) / SAMPLE_RATE) * pss->channels * ((pss->format == PA_SAMPLE_FLOAT32NE) ? sizeof(float) : sizeof(short));
+- buff.maxlength = iBlockLen * NBLOCKS;
+- buff.tlength = g.s.iOutputDelay * iBlockLen;
+- buff.prebuf = buff.tlength;
++ buff.tlength = iBlockLen * (g.s.iOutputDelay+1);
+ buff.minreq = iBlockLen;
++ buff.maxlength = -1;
++ buff.prebuf = -1;
++ buff.fragsize = iBlockLen;
+
+ iDelayCache = g.s.iOutputDelay;
+ bPositionalCache = g.s.doPositionalAudio();
+ qsOutputCache = odev;
+
+- pa_stream_connect_playback(pasOutput, qPrintable(odev), &buff, PA_STREAM_INTERPOLATE_TIMING, NULL, NULL);
++ pa_stream_connect_playback(pasOutput, qPrintable(odev), &buff, PA_STREAM_ADJUST_LATENCY, NULL, NULL);
+ }
+ }
+
+@@ -237,7 +237,7 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
+ if ((pss.format != PA_SAMPLE_FLOAT32NE) && (pss.format != PA_SAMPLE_S16NE))
+ pss.format = PA_SAMPLE_FLOAT32NE;
+
+- pasInput = pa_stream_new(pacContext, "Mumble Microphone", &pss, NULL);
++ pasInput = pa_stream_new(pacContext, "Microphone", &pss, NULL);
+ pa_stream_set_state_callback(pasInput, stream_callback, this);
+ pa_stream_set_read_callback(pasInput, read_callback, this);
+ }
+@@ -262,12 +262,15 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
+ pa_buffer_attr buff;
+ const pa_sample_spec *pss = pa_stream_get_sample_spec(pasInput);
+ const unsigned int iBlockLen = ((pai->iFrameSize * pss->rate) / SAMPLE_RATE) * pss->channels * ((pss->format == PA_SAMPLE_FLOAT32NE) ? sizeof(float) : sizeof(short));
+- buff.maxlength = iBlockLen * NBLOCKS;
++ buff.tlength = iBlockLen;
++ buff.minreq = iBlockLen;
++ buff.maxlength = -1;
++ buff.prebuf = -1;
+ buff.fragsize = iBlockLen;
+
+ qsInputCache = idev;
+
+- pa_stream_connect_record(pasInput, qPrintable(idev), &buff, PA_STREAM_INTERPOLATE_TIMING);
++ pa_stream_connect_record(pasInput, qPrintable(idev), &buff, PA_STREAM_ADJUST_LATENCY);
+ }
+ }
+
+@@ -317,12 +320,15 @@ void PulseAudioSystem::eventCallback(pa_mainloop_api *api, pa_defer_event *) {
+ pa_buffer_attr buff;
+ const pa_sample_spec *pss = pa_stream_get_sample_spec(pasSpeaker);
+ const unsigned int iBlockLen = ((pai->iFrameSize * pss->rate) / SAMPLE_RATE) * pss->channels * ((pss->format == PA_SAMPLE_FLOAT32NE) ? sizeof(float) : sizeof(short));
+- buff.maxlength = iBlockLen * NBLOCKS;
++ buff.tlength = iBlockLen;
++ buff.minreq = iBlockLen;
++ buff.maxlength = -1;
++ buff.prebuf = -1;
+ buff.fragsize = iBlockLen;
+
+ qsEchoCache = edev;
+
+- pa_stream_connect_record(pasSpeaker, qPrintable(edev), &buff, PA_STREAM_INTERPOLATE_TIMING);
++ pa_stream_connect_record(pasSpeaker, qPrintable(edev), &buff, PA_STREAM_ADJUST_LATENCY);
+ }
+ }
+ }
+@@ -332,7 +338,21 @@ void PulseAudioSystem::context_state_callback(pa_context *c, void *userdata) {
+ pas->contextCallback(c);
+ }
+
+-void PulseAudioSystem::subscribe_callback(pa_context *, pa_subscription_event_type, unsigned int, void *userdata) {
++void PulseAudioSystem::subscribe_callback(pa_context *, pa_subscription_event_type evt, unsigned int, void *userdata) {
++ switch (evt & PA_SUBSCRIPTION_EVENT_TYPE_MASK) {
++ case PA_SUBSCRIPTION_EVENT_NEW:
++ case PA_SUBSCRIPTION_EVENT_REMOVE:
++ break;
++ default:
++ return;
++ }
++ switch (evt & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) {
++ case PA_SUBSCRIPTION_EVENT_SINK:
++ case PA_SUBSCRIPTION_EVENT_SOURCE:
++ break;
++ default:
++ return;
++ }
+ PulseAudioSystem *pas = reinterpret_cast<PulseAudioSystem *>(userdata);
+ qWarning("PulseAudio: Sinks or inputs changed (inserted or removed sound card)");
+ pas->query();
+@@ -446,8 +466,7 @@ void PulseAudioSystem::write_callback(pa_stream *s, size_t bytes, void *userdata
+ AudioOutputPtr ao = g.ao;
+ PulseAudioOutput *pao = dynamic_cast<PulseAudioOutput *>(ao.get());
+
+- int samples = bytes / sizeof(float);
+- float buffer[samples];
++ unsigned char buffer[bytes];
+
+ if (! pao) {
+ // Transitioning, but most likely transitions back, so just zero.
+@@ -514,12 +533,11 @@ void PulseAudioSystem::write_callback(pa_stream *s, size_t bytes, void *userdata
+ pao->initializeMixer(chanmasks);
+ }
+
+-
+ const unsigned int iSampleSize = pao->iSampleSize;
+- samples = bytes / iSampleSize;
++ const unsigned int samples = bytes / iSampleSize;
+
+ if (! pao->mix(buffer, samples))
+- memset(buffer, 0, samples * iSampleSize);
++ memset(buffer, 0, bytes);
+ pa_stream_write(s, buffer, iSampleSize * samples, NULL, 0, PA_SEEK_RELATIVE);
+ }
+
+@@ -554,7 +572,9 @@ void PulseAudioSystem::contextCallback(pa_context *c) {
+ default:
+ return;
+ }
++ qmWait.lock();
+ qwcWait.wakeAll();
++ qmWait.unlock();
+ }
+
+ PulseAudioInputRegistrar::PulseAudioInputRegistrar() : AudioInputRegistrar(QLatin1String("PulseAudio"), 10) {
+@@ -620,29 +640,29 @@ void PulseAudioOutputRegistrar::setDeviceChoice(const QVariant &choice, Settings
+ }
+
+ PulseAudioInput::PulseAudioInput() {
+- pssMic.rate = 0;
+- pssEcho.rate = 0;
++ memset(&pssMic, 0, sizeof(pssMic));
++ memset(&pssEcho, 0, sizeof(pssEcho));
+ bRunning = true;
+ if (pasys)
+- pasys->wakeup();
++ pasys->wakeup_lock();
+ };
+
+ PulseAudioInput::~PulseAudioInput() {
+ bRunning = false;
+ if (pasys)
+- pasys->wakeup();
++ pasys->wakeup_lock();
+ }
+
+ PulseAudioOutput::PulseAudioOutput() {
+- pss.rate = 0;
+- pcm.channels = 0;
++ memset(&pss, 0, sizeof(pss));
++ memset(&pcm, 0, sizeof(pcm));
+ bRunning = true;
+ if (pasys)
+- pasys->wakeup();
++ pasys->wakeup_lock();
+ }
+
+ PulseAudioOutput::~PulseAudioOutput() {
+ bRunning = false;
+ if (pasys)
+- pasys->wakeup();
++ pasys->wakeup_lock();
+ }
+diff --git a/src/mumble/PulseAudio.h b/src/mumble/PulseAudio.h
+index 3aef169..f3c0fe1 100644
+--- a/src/mumble/PulseAudio.h
++++ b/src/mumble/PulseAudio.h
+@@ -33,35 +33,29 @@
+
+ #include "AudioInput.h"
+ #include "AudioOutput.h"
+-#include "ConfigDialog.h"
+ #include <pulse/pulseaudio.h>
+
+ class PulseAudioInput;
+ class PulseAudioOutput;
+
+-class PulseAudioSystem : public QThread {
++class PulseAudioSystem : public QObject {
+ private:
+ Q_OBJECT
+ Q_DISABLE_COPY(PulseAudioSystem)
+- public:
++ protected:
++ void wakeup();
+ pa_context *pacContext;
+ pa_stream *pasInput, *pasOutput, *pasSpeaker;
+- pa_mainloop *pam;
++ pa_threaded_mainloop *pam;
+ pa_defer_event *pade;
+
+- QMutex qmWait;
+- QWaitCondition qwcWait;
+-
+ bool bSourceDone, bSinkDone, bServerDone;
+- bool bPulseIsGood;
+
+ QString qsDefaultInput, qsDefaultOutput;
+
+ int iDelayCache;
+ QString qsOutputCache, qsInputCache, qsEchoCache;
+ bool bPositionalCache;
+- QHash<QString, QString> qhInput;
+- QHash<QString, QString> qhOutput;
+ QHash<QString, QString> qhEchoMap;
+ QHash<QString, pa_sample_spec> qhSpecMap;
+ QHash<QString, int> qhIndexMap;
+@@ -79,11 +73,18 @@ class PulseAudioSystem : public QThread {
+ void eventCallback(pa_mainloop_api *a, pa_defer_event *e);
+
+ void query();
++
++ public:
++ QHash<QString, QString> qhInput;
++ QHash<QString, QString> qhOutput;
++ bool bPulseIsGood;
++ QMutex qmWait;
++ QWaitCondition qwcWait;
++
++ void wakeup_lock();
+
+ PulseAudioSystem();
+ ~PulseAudioSystem();
+- void run();
+- void wakeup();
+ };
+
+ class PulseAudioInput : public AudioInput {
Modified: mumble/branches/1.1.8/debian/patches/series
URL: http://svn.debian.org/wsvn/pkg-voip/mumble/branches/1.1.8/debian/patches/series?rev=7504&op=diff
==============================================================================
--- mumble/branches/1.1.8/debian/patches/series (original)
+++ mumble/branches/1.1.8/debian/patches/series Sun Aug 16 15:59:55 2009
@@ -1,1 +1,2 @@
logrotate-when-not-started
+backport-alsa-pulseaudio
More information about the Pkg-voip-commits
mailing list