+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.
gogoConfigDialog();
}
#endif
+#ifdef AU_PORTAUDIO_DLL
+ if(st_temp->opt_playmode[0]=='o'){
+ asioConfigDialog();
+ }
+#endif
}
break;
case IDC_COMBO_OUTPUT_MODE:
}
#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
#endif // AU_VORBIS
+#ifdef AU_PORTAUDIO_DLL
+
+extern int asioConfigDialog(void);
+
+#endif //AU_PORTAUDIO_DLL
#endif /* __W32G2_PREF_H__ */
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"
}
#ifdef PORTAUDIO_V19
+#ifdef AU_PORTAUDIO_DLL
{
PaHostApiIndex i, ApiCount;
i = 0;
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) {
#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;
#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)
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)){
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;
}
#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);
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;
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;
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;
}
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;
+}
/***************************************************************/