Changeset 657
- Timestamp:
- 04/07/13 20:15:59 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/StreamVision/AudioDevicemodule.c
r654 r657 1 1 #include "Python.h" 2 2 #include <AudioToolbox/AudioServices.h> 3 4 #define FourCC2Str(code) (char[5]){(code >> 24) & 0xFF, (code >> 16) & 0xFF, (code >> 8) & 0xFF, code & 0xFF, 0} 5 6 static PyObject * 7 OSError_from_HALError(const char *failed_operation, OSStatus err) { 8 // these error codes are actually mnemonic, so display them 9 return PyErr_Format(PyExc_OSError, 10 "%s failed (%ld - %s)", 11 failed_operation, (long)err, FourCC2Str(err)); 12 } 3 13 4 14 static PyObject * … … 17 27 &size, &deviceID); 18 28 if (err != noErr) 19 return PyErr_Format(PyExc_OSError, 20 "AudioHardwareServiceGetPropertyData failed (%ld)", 21 (long)err); 29 return OSError_from_HALError("AudioHardwareServiceGetPropertyData", err); 22 30 23 31 if (deviceID == kAudioDeviceUnknown) … … 29 37 &propertyAddress, 0, NULL, 30 38 &size, &transportType); 39 if (err == kAudioHardwareBadObjectError) 40 Py_RETURN_NONE; 31 41 if (err != noErr) 32 return PyErr_Format(PyExc_OSError, 33 "AudioObjectGetPropertyData failed (%ld)", 34 (long)err); 42 return OSError_from_HALError("AudioObjectGetPropertyData", err); 35 43 36 44 if (transportType == kAudioDeviceTransportTypeAirPlay) 37 45 Py_RETURN_TRUE; 38 46 else 39 47 Py_RETURN_FALSE; 40 48 } 41 49 … … 78 86 NULL); 79 87 if (err != noErr) 80 return PyErr_Format(PyExc_OSError, 81 "AudioObjectAddPropertyListener failed (%ld)", 82 (long)err); 88 return OSError_from_HALError("AudioObjectAddPropertyListener", err); 83 89 } else { 84 90 Py_DECREF(default_output_device_changed_callback);
Note:
See TracChangeset
for help on using the changeset viewer.