OSDN Git Service

2006-12-27 Keishi Suenaga <skeishi@yahoo.co.jp>
authorKeishi Suenaga <s_keishi@mutt.freemail.ne.jp>
Wed, 27 Dec 2006 11:35:38 +0000 (11:35 +0000)
committerKeishi Suenaga <s_keishi@mutt.freemail.ne.jp>
Wed, 27 Dec 2006 11:35:38 +0000 (11:35 +0000)
* timidity/portaudio_a.c:  bug fix
* interface/w32g_pref.c, interface/w32g_pref.h,
  w32_portaudio_dll.c: asio dialog in win GUI.

ChangeLog
interface/w32g_pref.c
interface/w32g_pref.h
timidity/portaudio_a.c
timidity/w32_portaudio_dll.c

index b8c85ac..39bb713 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,11 @@
+2006-12-27  Keishi Suenaga <skeishi@yahoo.co.jp>
+
+       * timidity/portaudio_a.c:  bug fix
+       * interface/w32g_pref.c, interface/w32g_pref.h,
+         w32_portaudio_dll.c: asio dialog in win GUI.
+         
 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.
index 1d2ed2e..a141bb1 100644 (file)
@@ -1507,6 +1507,11 @@ PrefTiMidity3DialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
                                        gogoConfigDialog();
                                }
 #endif
+#ifdef AU_PORTAUDIO_DLL
+                               if(st_temp->opt_playmode[0]=='o'){
+                                       asioConfigDialog();
+                               }
+#endif
                        }
                        break;
                case IDC_COMBO_OUTPUT_MODE:
@@ -3551,3 +3556,72 @@ int vorbis_ConfigDialogInfoLoadINI(void)
 }
 
 #endif // AU_VORBIS
+
+
+#ifdef AU_PORTAUDIO_DLL
+///////////////////////////////////////////////////////////////////////
+//
+// asioConfigDialog
+//
+///////////////////////////////////////////////////////////////////////
+#include <portaudio.h>
+#include <pa_asio.h>
+#include "w32_portaudio.h"
+
+
+int asioConfigDialog(void)
+{
+       extern HWND hMainWnd;
+
+       PaHostApiTypeId HostApiTypeId;
+       const PaHostApiInfo  *HostApiInfo;
+       PaDeviceIndex DeviceIndex;
+       PaError err;
+       HWND hWnd;
+       int buffered_data;
+
+       PaHostApiIndex i, ApiCount;
+       
+       
+       if(load_portaudio_dll(0))
+               return -1;
+       
+       play_mode->acntl(PM_REQ_GETFILLED, &buffered_data);
+       if (buffered_data != 0) return -1;
+       
+       play_mode->close_output();
+       err = Pa_Initialize();
+       if( err != paNoError ) goto error1;
+
+
+       HostApiTypeId = paASIO;
+       i = 0;
+       hWnd = hPrefWnd;
+       ApiCount = Pa_GetHostApiCount();
+       do{
+               HostApiInfo=Pa_GetHostApiInfo(i);
+               if( HostApiInfo->type == HostApiTypeId ) break;
+           i++;
+       }while ( i < ApiCount );
+       if ( i == ApiCount ) goto error2;
+    DeviceIndex = HostApiInfo->defaultOutputDevice;
+       if(DeviceIndex==paNoDevice) goto error2;
+
+       if (HostApiTypeId ==  paASIO){
+       err = PaAsio_ShowControlPanel( DeviceIndex, (void*) hWnd);
+               if( err != paNoError ) goto error1;
+       }
+       Pa_Terminate();
+       play_mode->open_output();
+//     free_portaudio_dll();
+       return 0;
+       
+error1:
+//     free_portaudio_dll();
+       MessageBox(NULL, Pa_GetErrorText( err ), "Port Audio (asio) error", IDOK);
+error2:
+       Pa_Terminate();
+       return -1;
+}
+
+#endif //AU_PORTAUDIO_DLL
index 6493a86..1103562 100644 (file)
@@ -95,5 +95,10 @@ extern int vorbisConfigDialog(void);
 
 #endif // AU_VORBIS
 
+#ifdef AU_PORTAUDIO_DLL
+
+extern int asioConfigDialog(void);
+
+#endif //AU_PORTAUDIO_DLL
 
 #endif /* __W32G2_PREF_H__ */
index b6d1a14..d17516c 100644 (file)
     portaudio_a.c by skeishi <s_keishi@mutt.freemail.ne.jp>
     based on esd_a.c
 
-    Functions to play sound through EsounD
+    Functions to play sound through Portaudio
 */
 #define PORTAUDIO_V19 1
 
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif /* HAVE_CONFIG_H */
 #include <strings.h>
 #endif
 
-//#include <windows.h>
+#if defined(PORTAUDIO_V19) && defined(__W32__)
+#include <windows.h>
+#endif
 #include <portaudio.h>
+#if defined(PORTAUDIO_V19) && defined(__W32__)
+#include <pa_asio.h>
+#endif
 
 #ifdef AU_PORTAUDIO_DLL
 #include "w32_portaudio.h"
@@ -323,6 +327,7 @@ static int open_output(void)
        }
 
 #ifdef PORTAUDIO_V19
+#ifdef AU_PORTAUDIO_DLL
        {
                PaHostApiIndex i, ApiCount;
                i = 0;
@@ -339,6 +344,13 @@ static int open_output(void)
        DeviceInfo = Pa_GetDeviceInfo( DeviceIndex);
        if(DeviceInfo==NULL) goto error;
 
+#else
+       DeviceIndex = Pa_GetDefaultOutputDevice();
+       if(DeviceIndex==paNoDevice) goto error;
+       DeviceInfo = Pa_GetDeviceInfo( DeviceIndex);
+       if(DeviceInfo==NULL) goto error;
+#endif
+       
        if (dpm.encoding & PE_24BIT) {
                SampleFormat = paInt24;
        }else if (dpm.encoding & PE_16BIT) {
@@ -403,9 +415,9 @@ static int open_output(void)
        
 #else
        DeviceID = Pa_GetDefaultOutputDeviceID();
-       if(DeviceID==paNoDevice) goto error;
+       if(DeviceID==paNoDevice) goto error2;
        DeviceInfo = Pa_GetDeviceInfo( DeviceID);       
-       if(DeviceInfo==NULL) goto error;
+       if(DeviceInfo==NULL) goto error2;
        nativeSampleFormats = DeviceInfo->nativeSampleFormats;
 
        exclude_enc = PE_ULAW | PE_ALAW | PE_BYTESWAP;
@@ -469,11 +481,15 @@ static int open_output(void)
 #endif
 
 error:
+       ctl->cmsg(  CMSG_ERROR, VERB_NORMAL, "PortAudio error: %s\n", Pa_GetErrorText( err ) );
+error2:
        Pa_Terminate(); pa_active = 0;
 #ifdef AU_PORTAUDIO_DLL
+#ifndef PORTAUDIO_V19
   free_portaudio_dll();
 #endif
-       ctl->cmsg(  CMSG_ERROR, VERB_NORMAL, "PortAudio error: %s\n", Pa_GetErrorText( err ) );
+#endif
+
        return -1;
 }
 static int output_data(char *buf, int32 nbytes)
@@ -530,7 +546,7 @@ error:
 static void close_output(void)
 {      
        if( pa_active==0) return;
-#if PORTAUDIO_V19
+#ifdef PORTAUDIO_V19
        if(Pa_IsStreamActive(stream)){
 #else
        if(Pa_StreamActive(stream)){
@@ -545,16 +561,20 @@ static void close_output(void)
        pa_active=0;
 
 #ifdef AU_PORTAUDIO_DLL
+#ifndef PORTAUDIO_V19
   free_portaudio_dll();
 #endif
+#endif
 
        return;
 
 error:
        Pa_Terminate(); pa_active=0;
 #ifdef AU_PORTAUDIO_DLL
+#ifndef PORTAUDIO_V19
   free_portaudio_dll();
 #endif
+#endif
        ctl->cmsg(  CMSG_ERROR, VERB_NORMAL, "PortAudio error: %s\n", Pa_GetErrorText( err ) );
        return;
 }
index 551dae2..464b9ad 100644 (file)
 
 #ifdef AU_PORTAUDIO_DLL
 
+#ifdef __W32__
 #include <windows.h>
+#endif
 #include <portaudio.h>
 
+
 #include "w32_portaudio.h"
 
 
 #ifdef PORTAUDIO_V19
 
+#include <pa_asio.h>
+
 extern int load_portaudio_dll(int);
 extern void free_portaudio_dll(void);
 
@@ -73,6 +78,7 @@ typedef signed long(*type_Pa_GetStreamReadAvailable)( PaStream* stream );
 typedef signed long(*type_Pa_GetStreamWriteAvailable)( PaStream* stream );
 typedef PaError(*type_Pa_GetSampleSize)( PaSampleFormat format );
 typedef void(*type_Pa_Sleep)( long msec );
+typedef PaError(*type_PaAsio_ShowControlPanel)( PaDeviceIndex device, void* systemSpecific );
 
 static struct portaudio_dll_ {
         type_Pa_GetVersion Pa_GetVersion;
@@ -107,6 +113,7 @@ static struct portaudio_dll_ {
         type_Pa_GetStreamWriteAvailable Pa_GetStreamWriteAvailable;
         type_Pa_GetSampleSize Pa_GetSampleSize;
         type_Pa_Sleep Pa_Sleep;
+        type_PaAsio_ShowControlPanel PaAsio_ShowControlPanel;
 } portaudio_dll;
 
 static volatile HANDLE h_portaudio_dll = NULL;
@@ -189,6 +196,8 @@ int load_portaudio_dll(int a)
        if(!portaudio_dll.Pa_GetSampleSize){ free_portaudio_dll(); return -1; }
        portaudio_dll.Pa_Sleep = (type_Pa_Sleep)GetProcAddress(h_portaudio_dll,"Pa_Sleep");
        if(!portaudio_dll.Pa_Sleep){ free_portaudio_dll(); return -1; }
+       portaudio_dll.PaAsio_ShowControlPanel = (type_PaAsio_ShowControlPanel)GetProcAddress(h_portaudio_dll,"PaAsio_ShowControlPanel");
+       if(!portaudio_dll.PaAsio_ShowControlPanel){ free_portaudio_dll(); return -1; }
        return 0;
 }
 
@@ -445,6 +454,13 @@ void Pa_Sleep( long msec )
                portaudio_dll.Pa_Sleep(msec);
        }
 }
+PaError PaAsio_ShowControlPanel( PaDeviceIndex device, void* systemSpecific )
+{
+       if(h_portaudio_dll){
+               return portaudio_dll.PaAsio_ShowControlPanel(device,systemSpecific);
+       }
+       return (PaError)0;
+}
 
 /***************************************************************/