QAlsaAudioOutput remove async callback.
authorDyami Caliri <dyami@dragonframe.com>
Tue, 17 Jun 2014 14:45:34 +0000 (07:45 -0700)
committerYoann Lopes <yoann.lopes@digia.com>
Fri, 4 Jul 2014 14:14:48 +0000 (16:14 +0200)
The async callback mechanism in ALSA is prone to deadlock.
There was already a timer fallback mechanism that appears to be
sufficient.

Task-number: QTBUG-39677
Change-Id: I44b59e6b16eea1c9c4eeb6967335ce4f468cf3c4
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
src/plugins/alsa/qalsaaudiooutput.cpp
src/plugins/alsa/qalsaaudiooutput.h

index 192b635..c8d709c 100644 (file)
@@ -63,7 +63,6 @@ QAlsaAudioOutput::QAlsaAudioOutput(const QByteArray &device)
 {
     bytesAvailable = 0;
     handle = 0;
-    ahandler = 0;
     access = SND_PCM_ACCESS_RW_INTERLEAVED;
     pcmformat = SND_PCM_FORMAT_S16;
     buffer_frames = 0;
@@ -118,17 +117,6 @@ QAudio::State QAlsaAudioOutput::state() const
     return deviceState;
 }
 
-void QAlsaAudioOutput::async_callback(snd_async_handler_t *ahandler)
-{
-    QAlsaAudioOutput* audioOut;
-
-    audioOut = static_cast<QAlsaAudioOutput*>
-        (snd_async_handler_get_callback_private(ahandler));
-
-    if (audioOut && (audioOut->deviceState == QAudio::ActiveState || audioOut->resuming))
-        audioOut->feedback();
-}
-
 int QAlsaAudioOutput::xrun_recovery(int err)
 {
     int  count = 0;
@@ -512,8 +500,7 @@ bool QAlsaAudioOutput::open()
     snd_pcm_prepare( handle );
     snd_pcm_start(handle);
 
-    // Step 5: Setup callback and timer fallback
-    snd_async_add_pcm_handler(&ahandler, handle, async_callback, this);
+    // Step 5: Setup timer
     bytesAvailable = bytesFree();
 
     // Step 6: Start audio processing
@@ -715,21 +702,6 @@ void QAlsaAudioOutput::userFeed()
     deviceReady();
 }
 
-void QAlsaAudioOutput::feedback()
-{
-    updateAvailable();
-}
-
-
-void QAlsaAudioOutput::updateAvailable()
-{
-#ifdef DEBUG_AUDIO
-    QTime now(QTime::currentTime());
-    qDebug()<<now.second()<<"s "<<now.msec()<<"ms :updateAvailable()";
-#endif
-    bytesAvailable = bytesFree();
-}
-
 bool QAlsaAudioOutput::deviceReady()
 {
     if(pullMode) {
index 67976a5..274878d 100644 (file)
@@ -107,8 +107,6 @@ public:
 
 private slots:
     void userFeed();
-    void feedback();
-    void updateAvailable();
     bool deviceReady();
 
 signals:
@@ -126,7 +124,6 @@ private:
     unsigned int period_time;
     snd_pcm_uframes_t buffer_frames;
     snd_pcm_uframes_t period_frames;
-    static void async_callback(snd_async_handler_t *ahandler);
     int xrun_recovery(int err);
 
     int setFormat();
@@ -141,7 +138,6 @@ private:
     qint64 elapsedTimeOffset;
     char* audioBuffer;
     snd_pcm_t* handle;
-    snd_async_handler_t* ahandler;
     snd_pcm_access_t access;
     snd_pcm_format_t pcmformat;
     snd_timestamp_t* timestamp;