mal_uint8dsound[16];// DirectSound uses a GUID for identification.
mal_uint8dsound[16];// DirectSound uses a GUID for identification.
#endif
#endif
#ifdef MAL_SUPPORT_WINMM
#ifdef MAL_SUPPORT_WINMM
/*UINT_PTR*/ mal_uint32 winmm; // When creating a device, WinMM expects a Win32 UINT_PTR for device identification. In practice it's actually just a UINT.
/*UINT_PTR*/mal_uint32winmm;// When creating a device, WinMM expects a Win32 UINT_PTR for device identification. In practice it's actually just a UINT.
#endif
#endif
#ifdef MAL_SUPPORT_ALSA
#ifdef MAL_SUPPORT_ALSA
charalsa[256];// ALSA uses a name string for identification.
charalsa[256];// ALSA uses a name string for identification.
#endif
#endif
#ifdef MAL_SUPPORT_COREAUDIO
#ifdef MAL_SUPPORT_COREAUDIO
// TODO: Implement me.
// TODO: Implement me.
#endif
#endif
#ifdef MAL_SUPPORT_OSS
#ifdef MAL_SUPPORT_OSS
char oss[64]; // "dev/dsp0", etc. "dev/dsp" for the default device.
chaross[64];// "dev/dsp0", etc. "dev/dsp" for the default device.
#endif
#endif
#ifdef MAL_SUPPORT_OPENSL
#ifdef MAL_SUPPORT_OPENSL
mal_uint32opensl;// OpenSL|ES uses a 32-bit unsigned integer for identification.
mal_uint32opensl;// OpenSL|ES uses a 32-bit unsigned integer for identification.
...
@@ -546,7 +546,7 @@ typedef union
...
@@ -546,7 +546,7 @@ typedef union
intsdl;// SDL devices are identified with an index.
intsdl;// SDL devices are identified with an index.
#endif
#endif
#ifdef MAL_SUPPORT_NULL
#ifdef MAL_SUPPORT_NULL
int nullbackend; // Always 0.
intnullbackend;// Always 0.
#endif
#endif
}mal_device_id;
}mal_device_id;
...
@@ -690,8 +690,8 @@ struct mal_context
...
@@ -690,8 +690,8 @@ struct mal_context
}dsound;
}dsound;
#endif
#endif
#ifdef MAL_SUPPORT_WINMM
#ifdef MAL_SUPPORT_WINMM
struct
struct
{
{
/*HMODULE*/mal_handlehWinMM;
/*HMODULE*/mal_handlehWinMM;
mal_procwaveOutGetNumDevs;
mal_procwaveOutGetNumDevs;
mal_procwaveOutGetDevCapsA;
mal_procwaveOutGetDevCapsA;
...
@@ -710,7 +710,7 @@ struct mal_context
...
@@ -710,7 +710,7 @@ struct mal_context
mal_procwaveInAddBuffer;
mal_procwaveInAddBuffer;
mal_procwaveInStart;
mal_procwaveInStart;
mal_procwaveInReset;
mal_procwaveInReset;
} winmm;
}winmm;
#endif
#endif
#ifdef MAL_SUPPORT_ALSA
#ifdef MAL_SUPPORT_ALSA
struct
struct
...
@@ -765,17 +765,17 @@ struct mal_context
...
@@ -765,17 +765,17 @@ struct mal_context
}alsa;
}alsa;
#endif
#endif
#ifdef MAL_SUPPORT_COREAUDIO
#ifdef MAL_SUPPORT_COREAUDIO
struct
struct
{
{
int _unused;
int_unused;
} coreaudio;
}coreaudio;
#endif
#endif
#ifdef MAL_SUPPORT_OSS
#ifdef MAL_SUPPORT_OSS
struct
struct
{
{
int versionMajor;
intversionMajor;
int versionMinor;
intversionMinor;
} oss;
}oss;
#endif
#endif
#ifdef MAL_SUPPORT_OPENSL
#ifdef MAL_SUPPORT_OPENSL
struct
struct
...
@@ -997,8 +997,8 @@ struct mal_device
...
@@ -997,8 +997,8 @@ struct mal_device
}dsound;
}dsound;
#endif
#endif
#ifdef MAL_SUPPORT_WINMM
#ifdef MAL_SUPPORT_WINMM
struct
struct
{
{
/*HWAVEOUT, HWAVEIN*/mal_handlehDevice;
/*HWAVEOUT, HWAVEIN*/mal_handlehDevice;
/*HANDLE*/mal_handlehEvent;
/*HANDLE*/mal_handlehEvent;
mal_uint32fragmentSizeInFrames;
mal_uint32fragmentSizeInFrames;
...
@@ -1008,7 +1008,7 @@ struct mal_device
...
@@ -1008,7 +1008,7 @@ struct mal_device
mal_uint8*pIntermediaryBuffer;
mal_uint8*pIntermediaryBuffer;
mal_uint8*_pHeapData;// Used internally and is used for the heap allocated data for the intermediary buffer and the WAVEHDR structures.
mal_uint8*_pHeapData;// Used internally and is used for the heap allocated data for the intermediary buffer and the WAVEHDR structures.
mal_post_error(pDevice,"[WinMM] Failed to unprepare header for playback device in preparation for sending a new block of data to the device for playback.",mal_result_from_MMRESULT(resultMM));
mal_post_error(pDevice,"[WinMM] Failed to unprepare header for playback device in preparation for sending a new block of data to the device for playback.",mal_result_from_MMRESULT(resultMM));
mal_post_error(pDevice,"[WinMM] Failed to prepare header for playback device in preparation for sending a new block of data to the device for playback.",mal_result_from_MMRESULT(resultMM));
mal_post_error(pDevice,"[WinMM] Failed to prepare header for playback device in preparation for sending a new block of data to the device for playback.",mal_result_from_MMRESULT(resultMM));
mal_post_error(pDevice,"[WinMM] Failed to prepare header for capture device in preparation for adding a new capture buffer for the device.",mal_result_from_MMRESULT(resultMM));
mal_post_error(pDevice,"[WinMM] Failed to prepare header for capture device in preparation for adding a new capture buffer for the device.",mal_result_from_MMRESULT(resultMM));
// Try opening a temporary device first so we can get version information. This is closed at the end.
// Try opening a temporary device first so we can get version information. This is closed at the end.
int fd = mal_open_temp_device__oss();
intfd=mal_open_temp_device__oss();
if (fd == -1) {
if(fd==-1){
returnmal_context_post_error(pContext,NULL,"[OSS] Failed to open temporary device for retrieving system properties.",MAL_NO_BACKEND);// Looks liks OSS isn't installed, or there are no available devices.
returnmal_context_post_error(pContext,NULL,"[OSS] Failed to open temporary device for retrieving system properties.",MAL_NO_BACKEND);// Looks liks OSS isn't installed, or there are no available devices.
}
}
// Grab the OSS version.
// Grab the OSS version.
int ossVersion = 0;
intossVersion=0;
int result = ioctl(fd, OSS_GETVERSION, &ossVersion);
intresult=ioctl(fd,OSS_GETVERSION,&ossVersion);
if (result == -1) {
if(result==-1){
close(fd);
close(fd);
returnmal_context_post_error(pContext,NULL,"[OSS] Failed to retrieve OSS version.",MAL_NO_BACKEND);
returnmal_context_post_error(pContext,NULL,"[OSS] Failed to retrieve OSS version.",MAL_NO_BACKEND);
// The object returned by SNDCTL_SYSINFO will have the information we're after.
// The object returned by SNDCTL_SYSINFO will have the information we're after.
int fd = mal_open_temp_device__oss();
intfd=mal_open_temp_device__oss();
if (fd == -1) {
if(fd==-1){
returnmal_context_post_error(pContext,NULL,"[OSS] Failed to open a temporary device for retrieving system information used for device enumeration.",MAL_NO_BACKEND);
returnmal_context_post_error(pContext,NULL,"[OSS] Failed to open a temporary device for retrieving system information used for device enumeration.",MAL_NO_BACKEND);
}
}
oss_sysinfo si;
oss_sysinfosi;
int result = ioctl(fd, SNDCTL_SYSINFO, &si);
intresult=ioctl(fd,SNDCTL_SYSINFO,&si);
if (result != -1) {
if(result!=-1){
for (int iAudioDevice = 0; iAudioDevice < si.numaudios; ++iAudioDevice) {
if(pDevice==NULL)returnmal_post_error(pDevice,"mal_device_start() called with invalid arguments (pDevice == NULL).",MAL_INVALID_ARGS);
if(pDevice==NULL)returnmal_post_error(pDevice,"mal_device_start() called with invalid arguments (pDevice == NULL).",MAL_INVALID_ARGS);
if(mal_device__get_state(pDevice)==MAL_STATE_UNINITIALIZED)returnmal_post_error(pDevice,"mal_device_start() called for an uninitialized device.",MAL_DEVICE_NOT_INITIALIZED);
if(mal_device__get_state(pDevice)==MAL_STATE_UNINITIALIZED)returnmal_post_error(pDevice,"mal_device_start() called for an uninitialized device.",MAL_DEVICE_NOT_INITIALIZED);