Index: include/portaudio.h
===================================================================
--- include/portaudio.h	(revision 43419)
+++ include/portaudio.h	(revision 43420)
@@ -143,6 +143,11 @@
 PaError Pa_Terminate( void );
 
 
+//ADDED BY HW
+/** Rescan devices in order to detect while launched new devices
+*/
+PaError Pa_RescanDevice(void);
+//END OF MODIFICATION BY HW
 
 /** The type used to refer to audio devices. Values of this type usually
  range from 0 to (Pa_DeviceCount-1), and may also take on the PaNoDevice
Index: src/hostapi/alsa/pa_linux_alsa.c
===================================================================
--- src/hostapi/alsa/pa_linux_alsa.c	(revision 43419)
+++ src/hostapi/alsa/pa_linux_alsa.c	(revision 43420)
@@ -171,6 +171,9 @@
 /* prototypes for functions declared in this file */
 
 static void Terminate( struct PaUtilHostApiRepresentation *hostApi );
+//ADDED BY HW
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi );
+//END OF MODIFICATION BY HW
 static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
                                   const PaStreamParameters *inputParameters,
                                   const PaStreamParameters *outputParameters,
@@ -231,6 +234,9 @@
     (*hostApi)->info.name = "ALSA";
 
     (*hostApi)->Terminate = Terminate;
+    //ADDED BY HW
+    (*hostApi)->RescanDevice = RescanDevice;
+    //END OF MODIFICATION BY HW
     (*hostApi)->OpenStream = OpenStream;
     (*hostApi)->IsFormatSupported = IsFormatSupported;
 
@@ -291,6 +297,14 @@
     snd_config_update_free_global();
 }
 
+//ADDED BY HW
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi )
+{
+	//TODO
+    return paNoError;
+}
+//END OF MODIFICATION BY HW
+
 /** Determine max channels and default latencies.
  *
  * This function provides functionality to grope an opened (might be opened for capture or playback) pcm device for 
Index: src/hostapi/oss/pa_unix_oss.c
===================================================================
--- src/hostapi/oss/pa_unix_oss.c	(revision 43419)
+++ src/hostapi/oss/pa_unix_oss.c	(revision 43420)
@@ -184,6 +184,9 @@
 /* prototypes for functions declared in this file */
 
 static void Terminate( struct PaUtilHostApiRepresentation *hostApi );
+//ADDED BY HW
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi );
+//END OF MODIFICATION BY HW
 static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
                                   const PaStreamParameters *inputParameters,
                                   const PaStreamParameters *outputParameters,
@@ -237,6 +240,9 @@
     (*hostApi)->info.type = paOSS;
     (*hostApi)->info.name = "OSS";
     (*hostApi)->Terminate = Terminate;
+    //ADDED BY HW
+    (*hostApi)->RescanDevice = RescanDevice;
+    //END OF MODIFICATION BY HW
     (*hostApi)->OpenStream = OpenStream;
     (*hostApi)->IsFormatSupported = IsFormatSupported;
 
@@ -571,6 +577,14 @@
     PaUtil_FreeMemory( ossHostApi );
 }
 
+//ADDED BY HW
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi )
+{
+	//TODO
+    return paNoError;
+}
+//END OF MODIFICATION BY HW
+
 static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
                                   const PaStreamParameters *inputParameters,
                                   const PaStreamParameters *outputParameters,
Index: src/hostapi/wasapi/pa_win_wasapi.cpp
===================================================================
--- src/hostapi/wasapi/pa_win_wasapi.cpp	(revision 43419)
+++ src/hostapi/wasapi/pa_win_wasapi.cpp	(revision 43420)
@@ -78,7 +78,10 @@
 
 
 
-static void Terminate( struct PaUtilHostApiRepresentation *hostApi );
+static void Terminate( struct PaUtilHostApiRepresentation *hostApi );
+//ADDED BY HW
+static void RescanDevice( struct PaUtilHostApiRepresentation *hostApi );
+//END OF MODIFICATION BY HW
 static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
                                   const PaStreamParameters *inputParameters,
                                   const PaStreamParameters *outputParameters,
@@ -601,7 +604,10 @@
 
     spEndpoints->Release();
 
-    (*hostApi)->Terminate = Terminate;
+    (*hostApi)->Terminate = Terminate;
+    //ADDED BY HW
+    (*hostApi)->RescanDevice = RescanDevice;
+    //END OF MODIFICATION BY HW
     (*hostApi)->OpenStream = OpenStream;
     (*hostApi)->IsFormatSupported = IsFormatSupported;
 
@@ -666,6 +672,14 @@
 
     PaUtil_FreeMemory( paWasapi );
 }
+
+//ADDED BY HW
+static void RescanDevice( struct PaUtilHostApiRepresentation *hostApi )
+{
+	//TODO
+    return paNoError;
+}
+//END OF MODIFICATION BY HW
 
 static void
 LogWAVEFORMATEXTENSIBLE(const WAVEFORMATEXTENSIBLE &in){
Index: src/hostapi/wdmks/pa_win_wdmks.c
===================================================================
--- src/hostapi/wdmks/pa_win_wdmks.c	(revision 43419)
+++ src/hostapi/wdmks/pa_win_wdmks.c	(revision 43420)
@@ -326,6 +326,9 @@
 
 /* Interface functions */
 static void Terminate( struct PaUtilHostApiRepresentation *hostApi );
+//ADDED BY HW
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi );
+//END OF MODIFICATION BY HW
 static PaError IsFormatSupported(
     struct PaUtilHostApiRepresentation *hostApi,
     const PaStreamParameters *inputParameters,
@@ -1862,6 +1865,9 @@
     (*hostApi)->info.deviceCount = deviceCount;
 
     (*hostApi)->Terminate = Terminate;
+    //ADDED BY HW
+    (*hostApi)->RescanDevice = RescanDevice;
+    //END OF MODIFICATION BY HW
     (*hostApi)->OpenStream = OpenStream;
     (*hostApi)->IsFormatSupported = IsFormatSupported;
 
@@ -1928,6 +1934,14 @@
     PA_LOGL_;
 }
 
+//ADDED BY HW
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi )
+{
+	//TODO
+    return paNoError;
+}
+//END OF MODIFICATION BY HW
+
 static void FillWFEXT( WAVEFORMATEXTENSIBLE* pwfext, PaSampleFormat sampleFormat, double sampleRate, int channelCount)
 {
     PA_LOGE_;
Index: src/hostapi/wmme/pa_win_wmme.c
===================================================================
--- src/hostapi/wmme/pa_win_wmme.c	(revision 43419)
+++ src/hostapi/wmme/pa_win_wmme.c	(revision 43420)
@@ -187,6 +187,9 @@
 #endif /* __cplusplus */
 
 static void Terminate( struct PaUtilHostApiRepresentation *hostApi );
+/* ADDED BY HW */
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi );
+/* END OF MODIFICATION BY HW */
 static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
                            PaStream** stream,
                            const PaStreamParameters *inputParameters,
@@ -883,6 +886,9 @@
     InitializeDefaultDeviceIdsFromEnv( winMmeHostApi );
 
     (*hostApi)->Terminate = Terminate;
+    /* ADDED BY HW */
+    (*hostApi)->RescanDevice = RescanDevice;
+    /* END OF MODIFICATION BY HW */
     (*hostApi)->OpenStream = OpenStream;
     (*hostApi)->IsFormatSupported = IsFormatSupported;
 
@@ -928,7 +934,150 @@
     PaUtil_FreeMemory( winMmeHostApi );
 }
 
+/* ADDED BY HW */
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi )
+{ 
+    PaError result = paNoError;
+    int i;
+    PaWinMmeHostApiRepresentation *winMmeHostApi = (PaWinMmeHostApiRepresentation*)hostApi;
+    int inputDeviceCount, outputDeviceCount, maximumPossibleDeviceCount;
+    PaWinMmeDeviceInfo *deviceInfoArray;
+    int deviceInfoInitializationSucceeded;
+    PaTime defaultLowLatency, defaultHighLatency;
+    PaHostApiIndex hostApiIndex = Pa_HostApiTypeIdToHostApiIndex(hostApi->info.type);
 
+    maximumPossibleDeviceCount = 0;
+
+    inputDeviceCount = waveInGetNumDevs();
+    if( inputDeviceCount > 0 )
+    	maximumPossibleDeviceCount += inputDeviceCount + 1;
+
+    outputDeviceCount = waveOutGetNumDevs();
+    if( outputDeviceCount > 0 )
+	    maximumPossibleDeviceCount += outputDeviceCount + 1;
+
+    if( inputDeviceCount + 1 == winMmeHostApi->inputDeviceCount 
+      && outputDeviceCount + 1 == winMmeHostApi->outputDeviceCount)
+  {
+      //nothing new return
+      return paNoError;
+  }
+    hostApi->info.deviceCount = 0;
+    hostApi->info.defaultInputDevice = paNoDevice;
+    hostApi->info.defaultOutputDevice = paNoDevice;
+    winMmeHostApi->inputDeviceCount = 0;
+    winMmeHostApi->outputDeviceCount = 0;
+
+    //WARM doc says this operation is time consuming
+    PaUtil_GroupFreeMemory( winMmeHostApi->allocations, hostApi->deviceInfos );
+    if( maximumPossibleDeviceCount > 0 ){
+        hostApi->deviceInfos = (PaDeviceInfo**)PaUtil_GroupAllocateMemory(
+                winMmeHostApi->allocations, sizeof(PaDeviceInfo*) * maximumPossibleDeviceCount );
+        if( !hostApi->deviceInfos )
+        {
+          return paInsufficientMemory;
+            /*result = paInsufficientMemory;
+            goto error;*/
+        }
+
+        /* allocate all device info structs in a contiguous block */
+        deviceInfoArray = (PaWinMmeDeviceInfo*)PaUtil_GroupAllocateMemory(
+                winMmeHostApi->allocations, sizeof(PaWinMmeDeviceInfo) * maximumPossibleDeviceCount );
+        if( !deviceInfoArray )
+        {
+          return paInsufficientMemory;
+            /*result = paInsufficientMemory;
+            goto error;*/
+        }
+
+        
+        winMmeHostApi->winMmeDeviceIds = (UINT*)PaUtil_GroupAllocateMemory(
+                winMmeHostApi->allocations, sizeof(int) * maximumPossibleDeviceCount );
+        if( !winMmeHostApi->winMmeDeviceIds )
+        {
+          return paInsufficientMemory;
+            /*result = paInsufficientMemory;
+            goto error;*/
+        }
+
+        GetDefaultLatencies( &defaultLowLatency, &defaultHighLatency );
+
+        if( inputDeviceCount > 0 ){
+            /* -1 is the WAVE_MAPPER */ 
+            for( i = -1; i < inputDeviceCount; ++i ){
+                UINT winMmeDeviceId = (UINT)((i==-1) ? WAVE_MAPPER : i);
+                PaWinMmeDeviceInfo *wmmeDeviceInfo = &deviceInfoArray[ hostApi->info.deviceCount ];
+                PaDeviceInfo *deviceInfo = &wmmeDeviceInfo->inheritedDeviceInfo;
+                deviceInfo->structVersion = 2;
+                deviceInfo->hostApi = hostApiIndex;
+
+                deviceInfo->maxInputChannels = 0;
+                deviceInfo->maxOutputChannels = 0;
+
+                deviceInfo->defaultLowInputLatency = defaultLowLatency;
+                deviceInfo->defaultLowOutputLatency = defaultLowLatency;
+                deviceInfo->defaultHighInputLatency = defaultHighLatency;
+                deviceInfo->defaultHighOutputLatency = defaultHighLatency;
+
+                result = InitializeInputDeviceInfo( winMmeHostApi, wmmeDeviceInfo,
+                        winMmeDeviceId, &deviceInfoInitializationSucceeded );
+                if( result != paNoError )
+                    return result;
+                  /*  goto error; */
+
+                if( deviceInfoInitializationSucceeded ){
+                    if( hostApi->info.defaultInputDevice == paNoDevice )
+                        hostApi->info.defaultInputDevice = hostApi->info.deviceCount;
+
+                    winMmeHostApi->winMmeDeviceIds[ hostApi->info.deviceCount ] = winMmeDeviceId;
+                    hostApi->deviceInfos[ hostApi->info.deviceCount ] = deviceInfo;
+
+                    winMmeHostApi->inputDeviceCount++;
+                    hostApi->info.deviceCount++;
+                }
+            }
+        }
+
+        if( outputDeviceCount > 0 ){
+            /* -1 is the WAVE_MAPPER */
+            for( i = -1; i < outputDeviceCount; ++i ){
+                UINT winMmeDeviceId = (UINT)((i==-1) ? WAVE_MAPPER : i);
+                PaWinMmeDeviceInfo *wmmeDeviceInfo = &deviceInfoArray[ hostApi->info.deviceCount ];
+                PaDeviceInfo *deviceInfo = &wmmeDeviceInfo->inheritedDeviceInfo;
+                deviceInfo->structVersion = 2;
+                deviceInfo->hostApi = hostApiIndex;
+
+                deviceInfo->maxInputChannels = 0;
+                deviceInfo->maxOutputChannels = 0;
+
+                deviceInfo->defaultLowInputLatency = defaultLowLatency;
+                deviceInfo->defaultLowOutputLatency = defaultLowLatency;
+                deviceInfo->defaultHighInputLatency = defaultHighLatency;
+                deviceInfo->defaultHighOutputLatency = defaultHighLatency; 
+
+                result = InitializeOutputDeviceInfo( winMmeHostApi, wmmeDeviceInfo,
+                        winMmeDeviceId, &deviceInfoInitializationSucceeded );
+                if( result != paNoError )
+                  return result;
+                   // goto error;
+
+                if( deviceInfoInitializationSucceeded ){
+                    if( hostApi->info.defaultOutputDevice == paNoDevice )
+                        hostApi->info.defaultOutputDevice = hostApi->info.deviceCount;
+
+                    winMmeHostApi->winMmeDeviceIds[ hostApi->info.deviceCount ] = winMmeDeviceId;
+                    hostApi->deviceInfos[ hostApi->info.deviceCount ] = deviceInfo;
+
+                    winMmeHostApi->outputDeviceCount++;
+                    hostApi->info.deviceCount++;
+                }
+            }
+        }
+    }    
+  return paNoError;
+}
+/* END OF MODIFICATION BY HW */
+
 static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
                                   const PaStreamParameters *inputParameters,
                                   const PaStreamParameters *outputParameters,
Index: src/hostapi/jack/pa_jack.c
===================================================================
--- src/hostapi/jack/pa_jack.c	(revision 43419)
+++ src/hostapi/jack/pa_jack.c	(revision 43420)
@@ -106,6 +106,9 @@
  */
 
 static void Terminate( struct PaUtilHostApiRepresentation *hostApi );
+//ADDED BY HW
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi );
+//END OF MODIFICATION BY HW
 static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
                                   const PaStreamParameters *inputParameters,
                                   const PaStreamParameters *outputParameters,
@@ -734,6 +737,9 @@
     /* Register functions */
 
     (*hostApi)->Terminate = Terminate;
+    //ADDED BY HW
+    (*hostApi)->RescanDevice = RescanDevice;
+    //END OF MODIFICATION BY HW
     (*hostApi)->OpenStream = OpenStream;
     (*hostApi)->IsFormatSupported = IsFormatSupported;
 
@@ -814,6 +820,14 @@
     free( jackErr_ );
 }
 
+//ADDED BY HW
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi )
+{
+	//TODO
+    return paNoError;
+}
+//END OF MODIFICATION BY HW
+
 static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
                                   const PaStreamParameters *inputParameters,
                                   const PaStreamParameters *outputParameters,
Index: src/hostapi/coreaudio/pa_mac_core.c
===================================================================
--- src/hostapi/coreaudio/pa_mac_core.c	(revision 43419)
+++ src/hostapi/coreaudio/pa_mac_core.c	(revision 43420)
@@ -79,6 +79,9 @@
 #define RING_BUFFER_ADVANCE_DENOMINATOR (4)
 
 static void Terminate( struct PaUtilHostApiRepresentation *hostApi );
+//ADDED BY HW
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi );
+//END OF MODIFICATION BY HW
 static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
                                   const PaStreamParameters *inputParameters,
                                   const PaStreamParameters *outputParameters,
@@ -423,6 +426,9 @@
     }
 
     (*hostApi)->Terminate = Terminate;
+    //ADDED BY HW
+    (*hostApi)->RescanDevice = RescanDevice;
+    //END OF MODIFICATION BY HW
     (*hostApi)->OpenStream = OpenStream;
     (*hostApi)->IsFormatSupported = IsFormatSupported;
 
@@ -483,6 +489,77 @@
 }
 
 
+//ADDED BY HW
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi )
+{
+	PaError result = paNoError;
+    PaMacAUHAL *auhalHostApi = (PaMacAUHAL*)hostApi;
+    int devCount = auhalHostApi->devCount;
+    PaDeviceInfo *deviceInfoArray;
+    int i;
+    PaHostApiIndex hostApiIndex = Pa_HostApiTypeIdToHostApiIndex(hostApi->info.type);
+    
+    gatherDeviceInfo(auhalHostApi);
+    if( devCount == auhalHostApi->devCount )
+    {
+    	//No devices has been added return
+    	return result;	
+    }
+    //WARM doc SAYS IT IS TIME CONSUMING
+    PaUtil_GroupFreeMemory( auhalHostApi->allocations, hostApi->deviceInfos );
+
+
+    hostApi->info.deviceCount = 0;
+    
+    if( auhalHostApi->devCount > 0 )
+    {
+        hostApi->deviceInfos = (PaDeviceInfo**)PaUtil_GroupAllocateMemory(
+                auhalHostApi->allocations, sizeof(PaDeviceInfo*) * auhalHostApi->devCount);
+        if( !hostApi->deviceInfos )
+        {
+            return paInsufficientMemory;
+            //goto error;
+            
+        }
+
+        /* allocate all device info structs in a contiguous block */
+        deviceInfoArray = (PaDeviceInfo*)PaUtil_GroupAllocateMemory(
+                auhalHostApi->allocations, sizeof(PaDeviceInfo) * auhalHostApi->devCount );
+        if( !deviceInfoArray )
+        {
+            return paInsufficientMemory;
+        }
+
+        for( i=0; i < auhalHostApi->devCount; ++i )
+        {
+            int err;
+            err = InitializeDeviceInfo( auhalHostApi, &deviceInfoArray[i],
+                                      auhalHostApi->devIds[i],
+                                      hostApiIndex );
+            if (err == paNoError)
+            { /* copy some info and set the defaults */
+                hostApi->deviceInfos[hostApi->info.deviceCount] = &deviceInfoArray[i];
+                if (auhalHostApi->devIds[i] == auhalHostApi->defaultIn)
+                    hostApi->info.defaultInputDevice = hostApi->info.deviceCount;
+                if (auhalHostApi->devIds[i] == auhalHostApi->defaultOut)
+                    hostApi->info.defaultOutputDevice = hostApi->info.deviceCount;
+                hostApi->info.deviceCount++;
+            }
+            else
+            { /* there was an error. we need to shift the devices down, so we ignore this one */
+                int j;
+                auhalHostApi->devCount--;
+                for( j=i; j<auhalHostApi->devCount; ++j )
+                   auhalHostApi->devIds[j] = auhalHostApi->devIds[j+1];
+                i--;
+            }
+        }
+    }    
+    
+    return result;
+}
+//END OF MODIFICATION BY HW
+
 static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
                                   const PaStreamParameters *inputParameters,
                                   const PaStreamParameters *outputParameters,
Index: src/hostapi/asio/pa_asio.cpp
===================================================================
--- src/hostapi/asio/pa_asio.cpp	(revision 43419)
+++ src/hostapi/asio/pa_asio.cpp	(revision 43420)
@@ -172,6 +172,9 @@
 
 extern "C" PaError PaAsio_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex hostApiIndex );
 static void Terminate( struct PaUtilHostApiRepresentation *hostApi );
+//ADDED BY HW
+static void RescanDevice( struct PaUtilHostApiRepresentation *hostApi );
+//END OF MODIFICATION BY HW
 static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
                            PaStream** s,
                            const PaStreamParameters *inputParameters,
@@ -1257,6 +1260,9 @@
 
 
     (*hostApi)->Terminate = Terminate;
+    //ADDED BY HW
+    (*hostApi)->RescanDevice = RescanDevice;
+    //END OF MODIFICATION BY HW
     (*hostApi)->OpenStream = OpenStream;
     (*hostApi)->IsFormatSupported = IsFormatSupported;
 
@@ -1306,7 +1312,15 @@
     PaUtil_FreeMemory( asioHostApi );
 }
 
+//ADDED BY HW
+static void RescanDevice( struct PaUtilHostApiRepresentation *hostApi )
+{
+	//TODO
+    return paNoError;
+}
+//END OF MODIFICATION BY HW
 
+
 static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
                                   const PaStreamParameters *inputParameters,
                                   const PaStreamParameters *outputParameters,
Index: src/hostapi/dsound/pa_win_ds.c
===================================================================
--- src/hostapi/dsound/pa_win_ds.c	(revision 43419)
+++ src/hostapi/dsound/pa_win_ds.c	(revision 43420)
@@ -116,6 +116,9 @@
 #endif /* __cplusplus */
 
 static void Terminate( struct PaUtilHostApiRepresentation *hostApi );
+//ADDED BY HW
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi );
+//END OF MODIFICATION BY HW
 static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
                            PaStream** s,
                            const PaStreamParameters *inputParameters,
@@ -896,6 +899,9 @@
 
     
     (*hostApi)->Terminate = Terminate;
+    //ADDED BY HW
+    (*hostApi)->RescanDevice = RescanDevice;
+    //END OF MODIFICATION BY HW
     (*hostApi)->OpenStream = OpenStream;
     (*hostApi)->IsFormatSupported = IsFormatSupported;
 
@@ -954,6 +960,13 @@
     CoUninitialize();
 }
 
+//ADDED BY HW
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi )
+{
+	//TODO
+    return paNoError;
+}
+//END OF MODIFICATION BY HW
 
 /* Set minimal latency based on whether NT or Win95.
  * NT has higher latency.
Index: src/common/pa_skeleton.c
===================================================================
--- src/common/pa_skeleton.c	(revision 43419)
+++ src/common/pa_skeleton.c	(revision 43420)
@@ -65,6 +65,15 @@
 
 
 static void Terminate( struct PaUtilHostApiRepresentation *hostApi );
+//ADDED BY HW
+/**
+    (*RescanDevice)() is guaranteed to be called with a valid <hostApi>
+    parameter, which was previously returned from the same implementation's
+    initializer.
+*/    
+static  PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi);
+//END OF MODIFICATION BY HW
+
 static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
                                   const PaStreamParameters *inputParameters,
                                   const PaStreamParameters *outputParameters,
@@ -196,6 +205,9 @@
     }
 
     (*hostApi)->Terminate = Terminate;
+    //ADDED BY HW
+    (*hostApi)->RescanDevice = RescanDevice;
+    //END OF MODIFICATION BY HW
     (*hostApi)->OpenStream = OpenStream;
     (*hostApi)->IsFormatSupported = IsFormatSupported;
 
@@ -245,6 +257,13 @@
     PaUtil_FreeMemory( skeletonHostApi );
 }
 
+//ADDED BY HW
+static PaError RescanDevice( struct PaUtilHostApiRepresentation *hostApi )
+{
+	//Do nothing
+    return;
+}
+//END OF MODIFICATION BY HW
 
 static PaError IsFormatSupported( struct PaUtilHostApiRepresentation *hostApi,
                                   const PaStreamParameters *inputParameters,
Index: src/common/pa_front.c
===================================================================
--- src/common/pa_front.c	(revision 43419)
+++ src/common/pa_front.c	(revision 43420)
@@ -431,7 +431,43 @@
     return result;
 }
 
+// ADDED BY HW
+PaError Pa_RescanDevice( void )
+{
+	int baseDeviceIndex = 0;
+    int i=0;
 
+    if( !PA_IS_INITIALISED_ )
+        return -1;
+
+    while( i < hostApisCount_ )
+    {
+    	//Remove old devices
+    	deviceCount_ -= hostApis_[i]->info.deviceCount;
+    	
+        hostApis_[i]->RescanDevice( hostApis_[i] );
+
+        PaUtilHostApiRepresentation* hostApi = hostApis_[i];
+        assert( hostApi->info.defaultInputDevice < hostApi->info.deviceCount );
+        assert( hostApi->info.defaultOutputDevice < hostApi->info.deviceCount );
+
+        hostApis_[i]->privatePaFrontInfo.baseDeviceIndex = baseDeviceIndex;
+        
+        if( hostApis_[i]->info.defaultInputDevice != paNoDevice )
+            hostApis_[i]->info.defaultInputDevice += baseDeviceIndex;
+
+        if( hostApis_[i]->info.defaultOutputDevice != paNoDevice )
+            hostApis_[i]->info.defaultOutputDevice += baseDeviceIndex;
+
+        baseDeviceIndex += hostApis_[i]->info.deviceCount;
+        deviceCount_ += hostApis_[i]->info.deviceCount;
+        ++i;
+    }
+
+    return paNoError;
+}
+//END OF MODIFICATION BY HW
+
 const PaHostErrorInfo* Pa_GetLastHostErrorInfo( void )
 {
     return &lastHostErrorInfo_;
Index: src/common/pa_hostapi.h
===================================================================
--- src/common/pa_hostapi.h	(revision 43419)
+++ src/common/pa_hostapi.h	(revision 43420)
@@ -99,7 +99,16 @@
     */
     void (*Terminate)( struct PaUtilHostApiRepresentation *hostApi );
 
+	//ADDED BY HW
     /**
+        (*RescanDevice)() is guaranteed to be called with a valid <hostApi>
+        parameter, which was previously returned from the same implementation's
+        initializer.
+    */    
+    PaError (*RescanDevice)( struct PaUtilHostApiRepresentation *hostApi);
+    //END OF MODIFICATION BY HW
+
+    /**
         The inputParameters and outputParameters pointers should not be saved
         as they will not remain valid after OpenStream is called.
 
