mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-15 14:10:11 +00:00
remove exception handling form MidiTest/rtMidi
add Mac OSX defines/linking frameworks for rtMidi
This commit is contained in:
parent
cee546b51e
commit
e0254539a6
@ -45,7 +45,7 @@
|
||||
// RtMidi Definitions
|
||||
//*********************************************************************//
|
||||
|
||||
void RtMidi :: getCompiledApi( std::vector<RtMidi::Api> &apis ) throw()
|
||||
void RtMidi :: getCompiledApi( std::vector<RtMidi::Api> &apis )
|
||||
{
|
||||
apis.clear();
|
||||
|
||||
@ -69,6 +69,7 @@ void RtMidi :: getCompiledApi( std::vector<RtMidi::Api> &apis ) throw()
|
||||
#if defined(__RTMIDI_DUMMY__)
|
||||
apis.push_back( RTMIDI_DUMMY );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void RtMidi :: error( RtError::Type type, std::string errorString )
|
||||
@ -155,7 +156,7 @@ RtMidiIn :: RtMidiIn( RtMidi::Api api, const std::string clientName, unsigned in
|
||||
RtMidi::error( RtError::WARNING, "RtMidiIn: no compiled API support found ... critical error!!" );
|
||||
}
|
||||
|
||||
RtMidiIn :: ~RtMidiIn() throw()
|
||||
RtMidiIn :: ~RtMidiIn()
|
||||
{
|
||||
delete rtapi_;
|
||||
}
|
||||
@ -229,7 +230,7 @@ RtMidiOut :: RtMidiOut( RtMidi::Api api, const std::string clientName )
|
||||
RtMidi::error( RtError::WARNING, "RtMidiOut: no compiled API support found ... critical error!!" );
|
||||
}
|
||||
|
||||
RtMidiOut :: ~RtMidiOut() throw()
|
||||
RtMidiOut :: ~RtMidiOut()
|
||||
{
|
||||
delete rtapi_;
|
||||
}
|
||||
@ -2421,16 +2422,21 @@ public:
|
||||
DestroyLists();
|
||||
|
||||
if (categories == 0)
|
||||
throw std::runtime_error("CKsEnumFilters: invalid argument");
|
||||
|
||||
{
|
||||
printf ("Error: CKsEnumFilters: invalid argument\n");
|
||||
assert(0);
|
||||
}
|
||||
// Get a handle to the device set specified by the guid
|
||||
HDEVINFO hDevInfo = ::SetupDiGetClassDevs(&categories[0], NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
|
||||
if (!IsValid(hDevInfo))
|
||||
throw std::runtime_error("CKsEnumFilters: no devices found");
|
||||
{
|
||||
printf ("Error: CKsEnumFilters: no devices found");
|
||||
assert (0);
|
||||
}
|
||||
|
||||
// Loop through members of the set and get details for each
|
||||
for (int iClassMember=0;;iClassMember++) {
|
||||
try {
|
||||
{
|
||||
SP_DEVICE_INTERFACE_DATA DID;
|
||||
DID.cbSize = sizeof(DID);
|
||||
DID.Reserved = 0;
|
||||
@ -2442,15 +2448,19 @@ public:
|
||||
// Get filter friendly name
|
||||
HKEY hRegKey = ::SetupDiOpenDeviceInterfaceRegKey(hDevInfo, &DID, 0, KEY_READ);
|
||||
if (hRegKey == INVALID_HANDLE_VALUE)
|
||||
throw std::runtime_error("CKsEnumFilters: interface has no registry");
|
||||
|
||||
{
|
||||
assert(0);
|
||||
printf "CKsEnumFilters: interface has no registry\n");
|
||||
}
|
||||
char friendlyName[256];
|
||||
DWORD dwSize = sizeof friendlyName;
|
||||
LONG lval = ::RegQueryValueEx(hRegKey, TEXT("FriendlyName"), NULL, NULL, (LPBYTE)friendlyName, &dwSize);
|
||||
::RegCloseKey(hRegKey);
|
||||
if (lval != ERROR_SUCCESS)
|
||||
throw std::runtime_error("CKsEnumFilters: interface has no friendly name");
|
||||
|
||||
{
|
||||
assert(0);
|
||||
printf ("CKsEnumFilters: interface has no friendly name");
|
||||
}
|
||||
// Get details for the device registered in this class
|
||||
DWORD const cbItfDetails = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA) + MAX_PATH * sizeof(WCHAR);
|
||||
std::vector<BYTE> buffer(cbItfDetails);
|
||||
@ -2464,8 +2474,10 @@ public:
|
||||
|
||||
fRes = ::SetupDiGetDeviceInterfaceDetail(hDevInfo, &DID, pDevInterfaceDetails, cbItfDetails, NULL, &DevInfoData);
|
||||
if (!fRes)
|
||||
throw std::runtime_error("CKsEnumFilters: could not get interface details");
|
||||
|
||||
{
|
||||
printf("CKsEnumFilters: could not get interface details");
|
||||
assert(0);
|
||||
}
|
||||
// check additional category guids which may (or may not) have been supplied
|
||||
for (size_t i=1; i < numCategories; ++i) {
|
||||
SP_DEVICE_INTERFACE_DATA DIDAlias;
|
||||
@ -2474,11 +2486,16 @@ public:
|
||||
|
||||
fRes = ::SetupDiGetDeviceInterfaceAlias(hDevInfo, &DID, &categories[i], &DIDAlias);
|
||||
if (!fRes)
|
||||
throw std::runtime_error("CKsEnumFilters: could not get interface alias");
|
||||
|
||||
{
|
||||
printf("CKsEnumFilters: could not get interface alias");
|
||||
assert(0);
|
||||
}
|
||||
// Check if the this interface alias is enabled.
|
||||
if (!DIDAlias.Flags || (DIDAlias.Flags & SPINT_REMOVED))
|
||||
throw std::runtime_error("CKsEnumFilters: interface alias is not enabled");
|
||||
{
|
||||
printf("CKsEnumFilters: interface alias is not enabled");
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
std::auto_ptr<TFilterType> pFilter(new TFilterType(pDevInterfaceDetails->DevicePath, friendlyName));
|
||||
@ -2489,8 +2506,6 @@ public:
|
||||
|
||||
m_Filters.push_back(pFilter.release());
|
||||
}
|
||||
catch (std::runtime_error const& e) {
|
||||
}
|
||||
}
|
||||
|
||||
::SetupDiDestroyDeviceInfoList(hDevInfo);
|
||||
@ -2698,7 +2713,10 @@ CKsFilter::CKsFilter(tstring const& sName, std::string const& sFriendlyName) :
|
||||
m_sName(sName)
|
||||
{
|
||||
if (sName.empty())
|
||||
throw std::runtime_error("CKsFilter::CKsFilter: name can't be empty");
|
||||
{
|
||||
printf("CKsFilter::CKsFilter: name can't be empty");
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
CKsFilter::~CKsFilter()
|
||||
@ -2794,8 +2812,10 @@ void CKsPin::SetState(KSSTATE ksState)
|
||||
void CKsPin::Instantiate()
|
||||
{
|
||||
if (!m_pKsPinConnect)
|
||||
throw std::runtime_error("CKsPin::Instanciate: abstract pin");
|
||||
|
||||
{
|
||||
printf("CKsPin::Instanciate: abstract pin");
|
||||
assert(0);
|
||||
}
|
||||
DWORD const dwResult = KsCreatePin(m_pFilter->m_handle, m_pKsPinConnect, GENERIC_WRITE | GENERIC_READ, &m_handle);
|
||||
if (dwResult != ERROR_SUCCESS)
|
||||
throw ComException("CKsMidiCapFilter::CreateRenderPin: Pin instanciation failed", HRESULT_FROM_WIN32(dwResult));
|
||||
@ -2863,7 +2883,10 @@ public:
|
||||
void Validate()
|
||||
{
|
||||
if (m_RenderPins.empty())
|
||||
throw std::runtime_error("Could not find a MIDI render pin");
|
||||
{
|
||||
printf("Could not find a MIDI render pin");
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -2876,7 +2899,10 @@ public:
|
||||
void Validate()
|
||||
{
|
||||
if (m_CapturePins.empty())
|
||||
throw std::runtime_error("Could not find a MIDI capture pin");
|
||||
{
|
||||
assert(0);
|
||||
printf("Could not find a MIDI capture pin");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -2890,16 +2916,17 @@ void CKsMidiFilter::FindMidiPins()
|
||||
ULONG numPins = GetPinProperty<ULONG>(0, KSPROPERTY_PIN_CTYPES);
|
||||
|
||||
for (ULONG iPin = 0; iPin < numPins; ++iPin) {
|
||||
try {
|
||||
{
|
||||
KSPIN_COMMUNICATION com = GetPinProperty<KSPIN_COMMUNICATION>(iPin, KSPROPERTY_PIN_COMMUNICATION);
|
||||
if (com != KSPIN_COMMUNICATION_SINK && com != KSPIN_COMMUNICATION_BOTH)
|
||||
throw std::runtime_error("Unknown pin communication value");
|
||||
{
|
||||
printf("Unknown pin communication value");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
m_Pins.push_back(new CKsMidiPin(this, iPin));
|
||||
}
|
||||
catch (std::runtime_error const&) {
|
||||
// pin instanciation has failed, continue to the next pin.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
m_RenderPins.clear();
|
||||
@ -2917,7 +2944,11 @@ void CKsMidiFilter::FindMidiPins()
|
||||
}
|
||||
|
||||
if (m_RenderPins.empty() && m_CapturePins.empty())
|
||||
throw std::runtime_error("No valid pins found on the filter.");
|
||||
{
|
||||
printf("No valid pins found on the filter.");
|
||||
assert(0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
CKsMidiRenFilter::CKsMidiRenFilter(tstring const& sPath, std::string const& sFriendlyName) :
|
||||
@ -2928,7 +2959,10 @@ CKsMidiRenFilter::CKsMidiRenFilter(tstring const& sPath, std::string const& sFri
|
||||
CKsMidiPin* CKsMidiRenFilter::CreateRenderPin()
|
||||
{
|
||||
if (m_RenderPins.empty())
|
||||
throw std::runtime_error("Could not find a MIDI render pin");
|
||||
{
|
||||
printf("Could not find a MIDI render pin");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
CKsMidiPin* pPin = (CKsMidiPin*)m_RenderPins[0];
|
||||
pPin->Instantiate();
|
||||
@ -2943,8 +2977,10 @@ CKsMidiCapFilter::CKsMidiCapFilter(tstring const& sPath, std::string const& sFri
|
||||
CKsMidiPin* CKsMidiCapFilter::CreateCapturePin()
|
||||
{
|
||||
if (m_CapturePins.empty())
|
||||
throw std::runtime_error("Could not find a MIDI capture pin");
|
||||
|
||||
{
|
||||
printf("Could not find a MIDI capture pin");
|
||||
assert(0);
|
||||
}
|
||||
CKsMidiPin* pPin = (CKsMidiPin*)m_CapturePins[0];
|
||||
pPin->Instantiate();
|
||||
return pPin;
|
||||
@ -2993,10 +3029,16 @@ CKsMidiPin::CKsMidiPin(CKsFilter* pFilter, ULONG nId) :
|
||||
}
|
||||
|
||||
if (!hasStdStreamingInterface) // No standard streaming interfaces on the pin
|
||||
throw std::runtime_error("CKsMidiPin::CKsMidiPin: no standard streaming interface");
|
||||
{
|
||||
printf("CKsMidiPin::CKsMidiPin: no standard streaming interface");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (!hasStdStreamingMedium) // No standard streaming mediums on the pin
|
||||
throw std::runtime_error("CKsMidiPin::CKsMidiPin: no standard streaming medium");
|
||||
{
|
||||
printf("CKsMidiPin::CKsMidiPin: no standard streaming medium")
|
||||
assert(0);
|
||||
};
|
||||
|
||||
bool hasMidiDataRange = false;
|
||||
|
||||
@ -3014,7 +3056,10 @@ CKsMidiPin::CKsMidiPin(CKsFilter* pFilter, ULONG nId) :
|
||||
}
|
||||
|
||||
if (!hasMidiDataRange) // No MIDI dataranges on the pin
|
||||
throw std::runtime_error("CKsMidiPin::CKsMidiPin: no MIDI datarange");
|
||||
{
|
||||
printf("CKsMidiPin::CKsMidiPin: no MIDI datarange");
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3134,12 +3179,10 @@ void MidiInWinKS :: initialize( const std::string& clientName )
|
||||
MidiInWinKS :: ~MidiInWinKS()
|
||||
{
|
||||
WindowsKsData* data = static_cast<WindowsKsData*>(apiData_);
|
||||
try {
|
||||
{
|
||||
if ( data->m_pPin )
|
||||
closePort();
|
||||
}
|
||||
catch(...) {
|
||||
}
|
||||
|
||||
delete data;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class RtMidi
|
||||
the enumerated list values. Note that there can be more than one
|
||||
API compiled for certain operating systems.
|
||||
*/
|
||||
static void getCompiledApi( std::vector<RtMidi::Api> &apis ) throw();
|
||||
static void getCompiledApi( std::vector<RtMidi::Api> &apis );
|
||||
|
||||
//! Pure virtual openPort() function.
|
||||
virtual void openPort( unsigned int portNumber = 0, const std::string portName = std::string( "RtMidi" ) ) = 0;
|
||||
@ -140,7 +140,7 @@ class RtMidiIn : public RtMidi
|
||||
|
||||
//! Default constructor that allows an optional api, client name and queue size.
|
||||
/*!
|
||||
An exception will be thrown if a MIDI system initialization
|
||||
An assert will be fired if a MIDI system initialization
|
||||
error occurs. The queue size defines the maximum number of
|
||||
messages that can be held in the MIDI queue (when not using a
|
||||
callback function). If the queue size limit is reached,
|
||||
@ -155,10 +155,10 @@ class RtMidiIn : public RtMidi
|
||||
unsigned int queueSizeLimit = 100 );
|
||||
|
||||
//! If a MIDI connection is still open, it will be closed by the destructor.
|
||||
~RtMidiIn ( void ) throw();
|
||||
~RtMidiIn ( void );
|
||||
|
||||
//! Returns the MIDI API specifier for the current instance of RtMidiIn.
|
||||
RtMidi::Api getCurrentApi( void ) throw();
|
||||
RtMidi::Api getCurrentApi( void );
|
||||
|
||||
//! Open a MIDI input connection.
|
||||
/*!
|
||||
@ -218,7 +218,7 @@ class RtMidiIn : public RtMidi
|
||||
/*!
|
||||
This function returns immediately whether a new message is
|
||||
available or not. A valid message is indicated by a non-zero
|
||||
vector size. An exception is thrown if an error occurs during
|
||||
vector size. An assert is fired if an error occurs during
|
||||
message retrieval or an input connection was not previously
|
||||
established.
|
||||
*/
|
||||
@ -262,10 +262,10 @@ class RtMidiOut : public RtMidi
|
||||
const std::string clientName = std::string( "RtMidi Output Client") );
|
||||
|
||||
//! The destructor closes any open MIDI connections.
|
||||
~RtMidiOut( void ) throw();
|
||||
~RtMidiOut( void );
|
||||
|
||||
//! Returns the MIDI API specifier for the current instance of RtMidiOut.
|
||||
RtMidi::Api getCurrentApi( void ) throw();
|
||||
RtMidi::Api getCurrentApi( void );
|
||||
|
||||
//! Open a MIDI output connection.
|
||||
/*!
|
||||
@ -423,7 +423,7 @@ class MidiOutApi
|
||||
//
|
||||
// **************************************************************** //
|
||||
|
||||
inline RtMidi::Api RtMidiIn :: getCurrentApi( void ) throw() { return rtapi_->getCurrentApi(); }
|
||||
inline RtMidi::Api RtMidiIn :: getCurrentApi( void ) { return rtapi_->getCurrentApi(); }
|
||||
inline void RtMidiIn :: openPort( unsigned int portNumber, const std::string portName ) { return rtapi_->openPort( portNumber, portName ); }
|
||||
inline void RtMidiIn :: openVirtualPort( const std::string portName ) { return rtapi_->openVirtualPort( portName ); }
|
||||
inline void RtMidiIn :: closePort( void ) { return rtapi_->closePort(); }
|
||||
@ -434,7 +434,7 @@ inline std::string RtMidiIn :: getPortName( unsigned int portNumber ) { return r
|
||||
inline void RtMidiIn :: ignoreTypes( bool midiSysex, bool midiTime, bool midiSense ) { return rtapi_->ignoreTypes( midiSysex, midiTime, midiSense ); }
|
||||
inline double RtMidiIn :: getMessage( std::vector<unsigned char> *message ) { return rtapi_->getMessage( message ); }
|
||||
|
||||
inline RtMidi::Api RtMidiOut :: getCurrentApi( void ) throw() { return rtapi_->getCurrentApi(); }
|
||||
inline RtMidi::Api RtMidiOut :: getCurrentApi( void ) { return rtapi_->getCurrentApi(); }
|
||||
inline void RtMidiOut :: openPort( unsigned int portNumber, const std::string portName ) { return rtapi_->openPort( portNumber, portName ); }
|
||||
inline void RtMidiOut :: openVirtualPort( const std::string portName ) { return rtapi_->openVirtualPort( portName ); }
|
||||
inline void RtMidiOut :: closePort( void ) { return rtapi_->closePort(); }
|
||||
@ -638,7 +638,7 @@ class MidiOutWinKS: public MidiOutApi
|
||||
#endif
|
||||
|
||||
#if defined(__RTMIDI_DUMMY__)
|
||||
|
||||
aa
|
||||
class MidiInDummy: public MidiInApi
|
||||
{
|
||||
public:
|
||||
|
@ -40,7 +40,6 @@ int main( int argc, char *argv[] )
|
||||
// Minimal command-line check.
|
||||
if ( argc > 2 ) usage();
|
||||
|
||||
try {
|
||||
|
||||
// RtMidiIn constructor
|
||||
midiin = new RtMidiIn();
|
||||
@ -59,10 +58,8 @@ int main( int argc, char *argv[] )
|
||||
std::cout << "\nReading MIDI input ... press <enter> to quit.\n";
|
||||
char input;
|
||||
std::cin.get(input);
|
||||
getchar();
|
||||
|
||||
} catch ( RtError &error ) {
|
||||
error.printMessage();
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
||||
|
@ -29,5 +29,7 @@
|
||||
end
|
||||
|
||||
if os.is("MacOSX") then
|
||||
links{"Cocoa.framework"}
|
||||
links{"CoreAudio.framework", "coreMIDI.framework", "Cocoa.framework"}
|
||||
defines {"__MACOSX_CORE__"}
|
||||
print ("hi!")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user