[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdemultimedia/akode/plugins/alsa_sink
From:       Allan Sandfeld Jensen <kde () carewolf ! com>
Date:       2004-12-22 17:48:28
Message-ID: 20041222174828.581071B49D () office ! kde ! org
[Download RAW message or body]

CVS commit by carewolf: 

More safe if dynamically changing format


  M +9 -7      alsa_sink.cpp   1.7


--- kdemultimedia/akode/plugins/alsa_sink/alsa_sink.cpp  #1.6:1.7
@@ -135,4 +135,5 @@ int ALSASink::setAudioConfiguration(cons
     m_data->buffer = new char[m_data->fragmentSize];
     m_data->filled = 0;
+    m_data->open = false;
 
     if (snd_pcm_hw_params(m_data->pcm_playback, hw) < 0)
@@ -178,4 +179,12 @@ void ALSASink::_writeFrame(AudioFrame* f
 bool ALSASink::writeFrame(AudioFrame* frame)
 {
+    if ( frame->sample_width != m_data->config.sample_width
+      || frame->channels != m_data->config.channels
+      || frame->sample_rate != m_data->config.sample_rate)
+    {
+        if (setAudioConfiguration(frame) < 0)
+            return false;
+    }
+
     if (!m_data->open) {
         snd_pcm_prepare(m_data->pcm_playback);
@@ -184,11 +193,4 @@ bool ALSASink::writeFrame(AudioFrame* fr
     }
     
-    if ( frame->sample_width != m_data->config.sample_width
-      || frame->channels != m_data->config.channels )
-    {
-        if (!setAudioConfiguration(frame))
-            return false;
-    }
-
     if (frame->sample_width<0)
         _writeFrame<float>(frame);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic