OSDN Git Service

2006-12-26 Keishi Suenaga <skeishi@yahoo.co.jp>
authorKeishi Suenaga <s_keishi@mutt.freemail.ne.jp>
Tue, 26 Dec 2006 08:03:53 +0000 (08:03 +0000)
committerKeishi Suenaga <s_keishi@mutt.freemail.ne.jp>
Tue, 26 Dec 2006 08:03:53 +0000 (08:03 +0000)
* timidity/portaudio_a.c
  timidity/w32_portaudio_dll.c: fix portaudio v19 support
  now use only one dll named portaudio.dll.

ChangeLog
timidity/portaudio_a.c
timidity/w32_portaudio_dll.c

index 498489d..b8c85ac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-26  Keishi Suenaga <skeishi@yahoo.co.jp>
+       * timidity/portaudio_a.c
+         timidity/w32_portaudio_dll.c: fix portaudio v19 support
+         now use only one dll named portaudio.dll.
+
 2006-12-23  Keishi Suenaga <skeishi@yahoo.co.jp>
 
        * windrv/Makefile.am
index 3dfe33b..b6d1a14 100644 (file)
@@ -80,6 +80,8 @@ static int pa_active=0;
 static int first=1;
 
 #if PORTAUDIO_V19
+PaHostApiTypeId HostApiTypeId;
+const PaHostApiInfo  *HostApiInfo;
 PaDeviceIndex DeviceIndex;
 const PaDeviceInfo *DeviceInfo;
 PaStreamParameters StreamParameters;
@@ -281,6 +283,21 @@ static int open_output(void)
        PaSampleFormat SampleFormat, nativeSampleFormats;
 
 #ifdef AU_PORTAUDIO_DLL
+#if PORTAUDIO_V19
+  {
+               if(&dpm == &portaudio_asio_play_mode){
+                       HostApiTypeId = paASIO;
+               } else if(&dpm == &portaudio_win_ds_play_mode){
+                       HostApiTypeId = paDirectSound;
+               } else if(&dpm == &portaudio_win_wmme_play_mode){
+                       HostApiTypeId = paMME;
+               } else {
+                       return -1;
+               }
+               if(load_portaudio_dll(0))
+                               return -1;
+  }
+#else
   {
                if(&dpm == &portaudio_asio_play_mode){
                        if(load_portaudio_dll(PA_DLL_ASIO))
@@ -296,6 +313,7 @@ static int open_output(void)
                }
   }
 #endif
+#endif
        /* if call twice Pa_OpenStream causes paDeviceUnavailable error  */
        if(pa_active == 1) return 0; 
        if(pa_active == 0){
@@ -305,7 +323,18 @@ static int open_output(void)
        }
 
 #ifdef PORTAUDIO_V19
-       DeviceIndex = Pa_GetDefaultOutputDevice();
+       {
+               PaHostApiIndex i, ApiCount;
+               i = 0;
+               ApiCount = Pa_GetHostApiCount();
+               do{
+                       HostApiInfo=Pa_GetHostApiInfo(i);
+                       if( HostApiInfo->type == HostApiTypeId ) break;
+               i++;
+               }while ( i < ApiCount );
+               if ( i == ApiCount ) goto error;
+    }
+       DeviceIndex = HostApiInfo->defaultOutputDevice;
        if(DeviceIndex==paNoDevice) goto error;
        DeviceInfo = Pa_GetDeviceInfo( DeviceIndex);
        if(DeviceInfo==NULL) goto error;
index e9f1e03..551dae2 100644 (file)
 
 #include "w32_portaudio.h"
 
-extern int load_portaudio_dll(int type);
-extern void free_portaudio_dll(void);
 
 #ifdef PORTAUDIO_V19
+
+extern int load_portaudio_dll(int);
+extern void free_portaudio_dll(void);
+
 /***************************************************************
  name: portaudio_dll  dll: portaudio.dll 
 ***************************************************************/
 
-// (PaError)0 -> paDeviceUnavailable
-// (PaDeviceID)0 -> paNoDevice
-
-// #define PA_DLL_ASIO     1
-// #define PA_DLL_WIN_DS   2
-// #define PA_DLL_WIN_WMME 3
-#define PA_DLL_ASIO_FILE     "pa_asio.dll"
-#define PA_DLL_WIN_DS_FILE   "pa_win_ds.dll"
-#define PA_DLL_WIN_WMME_FILE "pa_win_wmme.dll"
-
-
 typedef int(*type_Pa_GetVersion)( void );
 typedef const char*(*type_Pa_GetVersionText)( void );
 typedef const char*(*type_Pa_GetErrorText)( PaError errorCode );
@@ -128,24 +119,10 @@ void free_portaudio_dll(void)
        }
 }
 
-int load_portaudio_dll(int type)
+int load_portaudio_dll(int a)
 {
-       char* dll_file = NULL;
-       switch(type){
-       case PA_DLL_ASIO:
-               dll_file = PA_DLL_ASIO_FILE;
-               break;
-       case PA_DLL_WIN_DS:
-               dll_file = PA_DLL_WIN_DS_FILE;
-               break;
-       case PA_DLL_WIN_WMME:
-               dll_file = PA_DLL_WIN_WMME_FILE;
-               break;
-       default:
-               return -1;
-       }
        if(!h_portaudio_dll){
-               h_portaudio_dll = LoadLibrary(dll_file);
+               h_portaudio_dll = LoadLibrary("portaudio.dll");
                if(!h_portaudio_dll) return -1;
        }
        portaudio_dll.Pa_GetVersion = (type_Pa_GetVersion)GetProcAddress(h_portaudio_dll,"Pa_GetVersion");
@@ -470,7 +447,16 @@ void Pa_Sleep( long msec )
 }
 
 /***************************************************************/
+
+
+
 #else
+
+
+
+extern int load_portaudio_dll(int type);
+extern void free_portaudio_dll(void);
+
 /***************************************************************
  name: portaudio_dll  dll: portaudio.dll 
 ***************************************************************/