Various updates in ALSA for probing while device is open and in Windows for thread...
authorGary Scavone <gary@music.mcgill.ca>
Thu, 24 Jan 2008 20:26:40 +0000 (20:26 +0000)
committerStephen Sinclair <sinclair@music.mcgill.ca>
Thu, 10 Oct 2013 23:38:22 +0000 (01:38 +0200)
Makefile.in
RtAudio.cpp
RtAudio.h
configure.ac
doc/release.txt
rtaudio-config.in
tests/Makefile.in

index 57df82b16cddb817501bb8951083ae769332f71a..23a444fd3782be04fe5a1eba6fa80728c9590b96 100644 (file)
@@ -13,7 +13,7 @@ RANLIB   = @RANLIB@
 
 DEFS     = @debug@
 DEFS    += @audio_apis@
-CFLAGS   = @cflags@ -Iinclude
+CFLAGS   = @CFLAGS@ -Iinclude
 CFLAGS  += @warn@
 
 all : $(LIBRARY)
index de7219fe842a4f55cec1efca52ca70d602a00732..f879244a7d7a07537ccb25afbc2e1474b30c9808 100644 (file)
@@ -3683,8 +3683,10 @@ bool RtApiDs :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned
     while ( dsPointerLeadTime * 2U > (DWORD) bufferBytes )
       bufferBytes *= 2;
 
-    // Set cooperative level to DSSCL_EXCLUSIVE
-    result = output->SetCooperativeLevel( hWnd, DSSCL_EXCLUSIVE );
+    // Set cooperative level to DSSCL_EXCLUSIVE ... sound stops when window focus changes.
+    //result = output->SetCooperativeLevel( hWnd, DSSCL_EXCLUSIVE );
+    // Set cooperative level to DSSCL_PRIORITY ... sound remains when window focus changes.
+    result = output->SetCooperativeLevel( hWnd, DSSCL_PRIORITY );
     if ( FAILED( result ) ) {
       output->Release();
       errorStream_ << "RtApiDs::probeDeviceOpen: error (" << getErrorString( result ) << ") setting cooperative level (" << dsinfo.name << ")!";
@@ -4938,6 +4940,18 @@ RtAudio::DeviceInfo RtApiAlsa :: getDeviceInfo( unsigned int device )
 
  foundDevice:
 
+  // If a stream is already open, we cannot probe the stream devices.
+  // Thus, use the saved results.
+  if ( stream_.state != STREAM_CLOSED &&
+       ( stream_.device[0] == device || stream_.device[1] == device ) ) {
+    if ( device >= devices_.size() ) {
+      errorText_ = "RtApiAlsa::getDeviceInfo: device ID was not present before stream was opened.";
+      error( RtError::WARNING );
+      return info;
+    }
+    return devices_[ device ];
+  }
+
   int openMode = SND_PCM_ASYNC;
   snd_pcm_stream_t stream;
        snd_pcm_info_t *pcminfo;
@@ -5132,6 +5146,16 @@ RtAudio::DeviceInfo RtApiAlsa :: getDeviceInfo( unsigned int device )
   return info;
 }
 
+void RtApiAlsa :: saveDeviceInfo( void )
+{
+  devices_.clear();
+
+  unsigned int nDevices = getDeviceCount();
+  devices_.resize( nDevices );
+  for ( unsigned int i=0; i<nDevices; i++ )
+    devices_[i] = getDeviceInfo( i );
+}
+
 bool RtApiAlsa :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
                                    unsigned int firstChannel, unsigned int sampleRate,
                                    RtAudioFormat format, unsigned int *bufferSize,
@@ -5191,6 +5215,12 @@ bool RtApiAlsa :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
 
  foundDevice:
 
+  // The getDeviceInfo() function will not work for a device that is
+  // already open.  Thus, we'll probe the system before opening a
+  // stream and save the results for use by getDeviceInfo().
+  if ( mode == OUTPUT || ( mode == INPUT && stream_.mode != OUTPUT ) ) // only do once
+    this->saveDeviceInfo();
+
   snd_pcm_stream_t stream;
   if ( mode == OUTPUT )
     stream = SND_PCM_STREAM_PLAYBACK;
@@ -6911,7 +6941,7 @@ void RtApi :: clearStreamInfo()
   stream_.callbackInfo.userData = 0;
   stream_.callbackInfo.isRunning = false;
   for ( int i=0; i<2; i++ ) {
-    stream_.device[i] = 0;
+    stream_.device[i] = 11111;
     stream_.doConvertBuffer[i] = false;
     stream_.deviceInterleaved[i] = true;
     stream_.doByteSwap[i] = false;
index 5e0666d7ae143cd395cd36146bec814fbe23ddd2..e7314c7673944caad5ee1eb93901a0bf63ef5095 100644 (file)
--- a/RtAudio.h
+++ b/RtAudio.h
@@ -10,7 +10,7 @@
     RtAudio WWW site: http://www.music.mcgill.ca/~gary/rtaudio/
 
     RtAudio: realtime audio i/o C++ classes
-    Copyright (c) 2001-2007 Gary P. Scavone
+    Copyright (c) 2001-2008 Gary P. Scavone
 
     Permission is hereby granted, free of charge, to any person
     obtaining a copy of this software and associated documentation files
@@ -617,7 +617,7 @@ protected:
 #endif
 
     RtApiStream()
-      :apiHandle(0), deviceBuffer(0) {}
+      :apiHandle(0), deviceBuffer(0) { device[0] = 11111; device[1] = 11111; }
   };
 
   typedef signed short Int16;
@@ -867,6 +867,8 @@ public:
 
   private:
 
+  std::vector<RtAudio::DeviceInfo> devices_;
+  void saveDeviceInfo( void );
   bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 
                         unsigned int firstChannel, unsigned int sampleRate,
                         RtAudioFormat format, unsigned int *bufferSize,
index 5949a5e0884a901d32f1f76863e737be0af59264..027dae045559face5bd88fc304316f5cc6cd00ac 100644 (file)
@@ -30,13 +30,15 @@ AC_ARG_ENABLE(debug,
   [AC_SUBST( debug, [] ) AC_SUBST( cflags, [-O2] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)])
 
 # Checks for functions
-AC_CHECK_FUNC(gettimeofday, [cflags=$cflags" -DHAVE_GETTIMEOFDAY"], )
+AC_CHECK_FUNC(gettimeofday, [CFLAGS=$CFLAGS" -DHAVE_GETTIMEOFDAY"], )
 
 # Check compiler and use -Wall if gnu.
 if [test $GXX = "yes" ;] then
   AC_SUBST( warn, [-Wall] )
 fi
 
+CFLAGS="$CFLAGS $cflags"
+
 # Checks for package options and external software
 AC_CANONICAL_HOST
 AC_MSG_CHECKING(for audio API)
@@ -45,7 +47,7 @@ case $host in
     AC_SUBST( sound_api, [-D__LINUX_OSS__] )
     AC_MSG_RESULT(using OSS)
     AC_SUBST( audio_apis, [-D__LINUX_OSS__] )
-    cflags=$cflags" -lossaudio"
+    CFLAGS=$CFLAGS" -lossaudio"
     AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
   ;;
 
@@ -56,7 +58,7 @@ case $host in
     TEMP_LIBS=$LIBS
     AC_CHECK_LIB(jack, jack_client_new, , AC_MSG_ERROR(JACK support requires the jack library!))
     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(Jack support also requires the asound library!))
-    LIBS="`pkg-config --cflags --libs jack` $TEMP_LIBS -lasound"
+    LIBS="`pkg-config --CFLAGS --libs jack` $TEMP_LIBS -lasound"
     audio_apis="-D__UNIX_JACK__"
   fi
 
index 8fc6384f3e2168b1ab29192433c5759462eaf053..b71225495067b6e1907413bcb2e9ad9e9232bf5f 100644 (file)
@@ -3,8 +3,13 @@ RtAudio - a set of C++ classes that provide a common API for realtime audio inpu
 By Gary P. Scavone, 2001-2008.
 
 v4.0.4: ()
+- added functionality to allow getDeviceInfo() to work in ALSA on an open device (like ASIO)
+- fixes in configure script
 - fixed clearing of error message stream in error()
 - fixed RtAudio::DeviceInfo description in "probing" documentation
+- memory leak fixes in ALSA and OSS
+- Jack in/out port flag fix
+- Windows changes for thread priority and GLOBALFOCUS
 
 v4.0.3: (7 December 2007)
 - added support for MinGW compiler to configure script
index f950f4ef64e980a694873e8387effe196d2dbb51..c689a989e615ecc97ded0df5ea32abd15aab0acf 100644 (file)
@@ -9,7 +9,7 @@ CFLAGS="@audio_apis@"
 
 if (test "x$1" == "x--libs") ; then
   echo "$LIBRARY"
-elif (test "x$1" == "x--cflags") ; then
+elif (test "x$1" == "x--CFLAGS") ; then
   echo "$CFLAGS"
 else
   echo "Unknown option: $1"
index ec4144791a9203dc2d7398e5fb291d5f82b726fa..059b5ce9239ecb8684c53afb8f947ec56831c890 100644 (file)
@@ -13,7 +13,7 @@ OBJECTS       =       RtAudio.o @objects@
 CC       = @CXX@
 DEFS     = @debug@
 DEFS    += @audio_apis@
-CFLAGS   = @cflags@
+CFLAGS   = @CFLAGS@
 CFLAGS  += @warn@ -I$(INCLUDE) -I../include
 LIBRARY  = @LIBS@
 LIBRARY += @frameworks@