Changeset 388 for python/vendor/current/PC/winsound.c
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/PC/winsound.c
r2 r388 79 79 80 80 if(!PyArg_ParseTuple(args,"z#i:PlaySound",&sound,&length,&flags)) { 81 81 return NULL; 82 82 } 83 83 84 84 if(flags&SND_ASYNC && flags &SND_MEMORY) { 85 86 87 88 85 /* Sidestep reference counting headache; unfortunately this also 86 prevent SND_LOOP from memory. */ 87 PyErr_SetString(PyExc_RuntimeError,"Cannot play asynchronously from memory"); 88 return NULL; 89 89 } 90 90 … … 94 94 if(!ok) 95 95 { 96 97 96 PyErr_SetString(PyExc_RuntimeError,"Failed to play sound"); 97 return NULL; 98 98 } 99 99 … … 105 105 sound_beep(PyObject *self, PyObject *args) 106 106 { 107 108 109 107 int freq; 108 int dur; 109 BOOL ok; 110 110 111 112 111 if (!PyArg_ParseTuple(args, "ii:Beep", &freq, &dur)) 112 return NULL; 113 113 114 115 116 117 118 114 if (freq < 37 || freq > 32767) { 115 PyErr_SetString(PyExc_ValueError, 116 "frequency must be in 37 thru 32767"); 117 return NULL; 118 } 119 119 120 121 122 123 124 125 126 120 Py_BEGIN_ALLOW_THREADS 121 ok = Beep(freq, dur); 122 Py_END_ALLOW_THREADS 123 if (!ok) { 124 PyErr_SetString(PyExc_RuntimeError,"Failed to beep"); 125 return NULL; 126 } 127 127 128 129 128 Py_INCREF(Py_None); 129 return Py_None; 130 130 } 131 131 … … 133 133 sound_msgbeep(PyObject *self, PyObject *args) 134 134 { 135 136 137 138 139 140 135 int x = MB_OK; 136 if (!PyArg_ParseTuple(args, "|i:MessageBeep", &x)) 137 return NULL; 138 MessageBeep(x); 139 Py_INCREF(Py_None); 140 return Py_None; 141 141 } 142 142 … … 156 156 if(v&&k) 157 157 { 158 158 PyDict_SetItem(dict,k,v); 159 159 } 160 160 Py_XDECREF(k); … … 167 167 initwinsound(void) 168 168 { 169 170 171 172 173 174 175 169 PyObject *dict; 170 PyObject *module = Py_InitModule3("winsound", 171 sound_methods, 172 sound_module_doc); 173 if (module == NULL) 174 return; 175 dict = PyModule_GetDict(module); 176 176 177 178 179 180 181 182 183 184 185 186 177 ADD_DEFINE(SND_ASYNC); 178 ADD_DEFINE(SND_NODEFAULT); 179 ADD_DEFINE(SND_NOSTOP); 180 ADD_DEFINE(SND_NOWAIT); 181 ADD_DEFINE(SND_ALIAS); 182 ADD_DEFINE(SND_FILENAME); 183 ADD_DEFINE(SND_MEMORY); 184 ADD_DEFINE(SND_PURGE); 185 ADD_DEFINE(SND_LOOP); 186 ADD_DEFINE(SND_APPLICATION); 187 187 188 189 190 191 192 188 ADD_DEFINE(MB_OK); 189 ADD_DEFINE(MB_ICONASTERISK); 190 ADD_DEFINE(MB_ICONEXCLAMATION); 191 ADD_DEFINE(MB_ICONHAND); 192 ADD_DEFINE(MB_ICONQUESTION); 193 193 }
Note:
See TracChangeset
for help on using the changeset viewer.