/[svn]/linuxsampler/trunk/src/drivers/audio/AudioOutputDeviceCoreAudio.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/drivers/audio/AudioOutputDeviceCoreAudio.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2426 by persson, Sat Jun 11 17:53:32 2011 UTC revision 2427 by persson, Sat Mar 2 07:03:04 2013 UTC
# Line 2  Line 2 
2   *                                                                         *   *                                                                         *
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2009 Grigor Iliev                                       *   *   Copyright (C) 2009 - 2013 Grigor Iliev                                *
6   *                                                                         *   *                                                                         *
7   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
8   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 143  namespace LinuxSampler { Line 143  namespace LinuxSampler {
143    
144      AudioOutputDeviceCoreAudio::~AudioOutputDeviceCoreAudio() {      AudioOutputDeviceCoreAudio::~AudioOutputDeviceCoreAudio() {
145          atomic_set(&(aqPlayerState.mIsRunning), 0);          atomic_set(&(aqPlayerState.mIsRunning), 0);
146          destroyMutex.Lock();          {
147          AudioQueueDispose(aqPlayerState.mQueue, true);              LockGuard lock(destroyMutex);
148          destroyMutex.Unlock();              AudioQueueDispose(aqPlayerState.mQueue, true);
149            }
150          delete [] aqPlayerState.mBuffers;          delete [] aqPlayerState.mBuffers;
151    
152          CurrentDevice.RemoveListener(this);          CurrentDevice.RemoveListener(this);
# Line 317  namespace LinuxSampler { Line 318  namespace LinuxSampler {
318              }              }
319          }          }
320    
321          destroyMutex.Lock();          {
322          do {              LockGuard lock(destroyMutex);
323              if(atomic_read(&pausedNew) != pausedOld) {              do {
324                  pausedOld = atomic_read(&pausedNew);                  if(atomic_read(&pausedNew) != pausedOld) {
325                        pausedOld = atomic_read(&pausedNew);
326                  if(pausedOld) {  
327                      res = AudioQueuePause(aqPlayerState.mQueue);                      if(pausedOld) {
328                      if(res) std::cerr << "AudioQueuePause: Error " << res << std::endl;                          res = AudioQueuePause(aqPlayerState.mQueue);
329                  } else {                          if(res) std::cerr << "AudioQueuePause: Error " << res << std::endl;
330                      res = AudioQueuePrime(aqPlayerState.mQueue, 0, NULL);                      } else {
331                      if(res) std::cerr << "AudioQueuePrime: Error " << res << std::endl;                          res = AudioQueuePrime(aqPlayerState.mQueue, 0, NULL);
332                      res = AudioQueueStart(aqPlayerState.mQueue, NULL);                          if(res) std::cerr << "AudioQueuePrime: Error " << res << std::endl;
333                      if(res) std::cerr << "AudioQueueStart: Error " << res << std::endl;                          res = AudioQueueStart(aqPlayerState.mQueue, NULL);
334                            if(res) std::cerr << "AudioQueueStart: Error " << res << std::endl;
335                        }
336                  }                  }
             }  
337    
338              if(atomic_read(&restartQueue)) {                  if(atomic_read(&restartQueue)) {
339                  DestroyAudioQueue();                      DestroyAudioQueue();
340                  try { CreateAndStartAudioQueue(); }                      CreateAndStartAudioQueue();
341                  catch(Exception e) {                      atomic_set(&restartQueue, 0);
342                      destroyMutex.Unlock();                      dmsg(1,("Audio queue restarted"));
                     throw e;  
343                  }                  }
                 atomic_set(&restartQueue, 0);  
                 dmsg(1,("Audio queue restarted"));  
             }  
344                            
345              CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.2, false);                  CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.2, false);
346          } while (atomic_read(&(aqPlayerState.mIsRunning)));              } while (atomic_read(&(aqPlayerState.mIsRunning)));
347          destroyMutex.Unlock();          }
348    
349          dmsg(2,("CoreAudio thread stopped\n"));          dmsg(2,("CoreAudio thread stopped\n"));
350    

Legend:
Removed from v.2426  
changed lines
  Added in v.2427

  ViewVC Help
Powered by ViewVC