diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-05-16 02:54:33 (GMT) |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-05-16 02:54:33 (GMT) |
commit | eca20b611433fac88057da092efc0b6d6d2a7fb3 (patch) | |
tree | b7c6ce421f22a464f28152ea7620e09cde051f1f /PC | |
parent | 18bf893935343a918f9d00b3b934d858607bdc40 (diff) | |
download | cpython-eca20b611433fac88057da092efc0b6d6d2a7fb3.zip cpython-eca20b611433fac88057da092efc0b6d6d2a7fb3.tar.gz cpython-eca20b611433fac88057da092efc0b6d6d2a7fb3.tar.bz2 |
Merged revisions 63119-63128,63130-63131,63133,63135-63144,63146-63148,63151-63152,63155-63165,63167-63176,63181-63186,63188-63189 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r63119 | benjamin.peterson | 2008-05-11 20:41:23 -0400 (Sun, 11 May 2008) | 2 lines
#2196 hasattr now allows SystemExit and KeyboardInterrupt to propagate
........
r63122 | benjamin.peterson | 2008-05-11 20:46:49 -0400 (Sun, 11 May 2008) | 2 lines
make message slightly more informative, so there's no chance of misunderstanding it
........
r63158 | ronald.oussoren | 2008-05-12 07:24:33 -0400 (Mon, 12 May 2008) | 5 lines
Remove references to platform 'mac'
The 'mac' platform (that is, os.name == 'mac') was used for the MacOS 9 port,
which is no longer supported (as of Python 2.4 IIRC).
........
r63159 | ronald.oussoren | 2008-05-12 07:31:05 -0400 (Mon, 12 May 2008) | 8 lines
MacOSX: remove dependency on Carbon package for urllib
This patch removes the dependency on the Carbon package from urllib.
The mac-specific code for getting proxy configuration is now writting in
Python using ctypes and uses the SystemConfiguration framework instead of
InternetConfig. Also provides a mac-specific implementation of proxy_bypass.
........
r63162 | eric.smith | 2008-05-12 10:00:01 -0400 (Mon, 12 May 2008) | 1 line
Added 'n' presentation type for integers.
........
r63164 | georg.brandl | 2008-05-12 12:26:52 -0400 (Mon, 12 May 2008) | 2 lines
#1713041: fix pprint's handling of maximum depth.
........
r63170 | georg.brandl | 2008-05-12 12:53:42 -0400 (Mon, 12 May 2008) | 2 lines
Fix parameter name for enumerate().
........
r63173 | georg.brandl | 2008-05-12 13:01:58 -0400 (Mon, 12 May 2008) | 2 lines
#2766: remove code without effect.
........
r63174 | georg.brandl | 2008-05-12 13:04:10 -0400 (Mon, 12 May 2008) | 3 lines
#2767: don't clear globs in run() call, since they could be needed in tearDown,
which clears them at the end.
........
r63175 | georg.brandl | 2008-05-12 13:14:51 -0400 (Mon, 12 May 2008) | 2 lines
#1760: try-except-finally is one statement since PEP 341.
........
r63186 | amaury.forgeotdarc | 2008-05-12 17:30:24 -0400 (Mon, 12 May 2008) | 2 lines
Sync code with documentation, and remove Win95 support in winsound module.
........
r63189 | amaury.forgeotdarc | 2008-05-12 18:21:39 -0400 (Mon, 12 May 2008) | 3 lines
Adapt test_pyclbr to the new version of urllib.py:
The new mac-specific functions must be ignored.
........
Diffstat (limited to 'PC')
-rw-r--r-- | PC/winsound.c | 78 |
1 files changed, 9 insertions, 69 deletions
diff --git a/PC/winsound.c b/PC/winsound.c index 9fc7f6f..62e87ae 100644 --- a/PC/winsound.c +++ b/PC/winsound.c @@ -38,9 +38,6 @@ #include <Python.h> #include <windows.h> #include <mmsystem.h> -#ifdef HAVE_CONIO_H -#include <conio.h> /* port functions on Win9x */ -#endif PyDoc_STRVAR(sound_playsound_doc, "PlaySound(sound, flags) - a wrapper around the Windows PlaySound API\n" @@ -53,10 +50,7 @@ PyDoc_STRVAR(sound_beep_doc, "\n" "The frequency argument specifies frequency, in hertz, of the sound.\n" "This parameter must be in the range 37 through 32,767.\n" -"The duration argument specifies the number of milliseconds.\n" -"On WinNT and 2000, the platform Beep API is used directly. Else funky\n" -"code doing direct port manipulation is used; it's unknown whether that\n" -"will work on all systems."); +"The duration argument specifies the number of milliseconds.\n"); PyDoc_STRVAR(sound_msgbeep_doc, "MessageBeep(x) - call Windows MessageBeep(x). x defaults to MB_OK."); @@ -107,14 +101,12 @@ sound_playsound(PyObject *s, PyObject *args) return Py_None; } -enum OSType {Win9X, WinNT2000}; -static enum OSType whichOS; /* set by module init */ - static PyObject * sound_beep(PyObject *self, PyObject *args) { int freq; int dur; + BOOL ok; if (!PyArg_ParseTuple(args, "ii:Beep", &freq, &dur)) return NULL; @@ -125,57 +117,14 @@ sound_beep(PyObject *self, PyObject *args) return NULL; } - /* On NT and 2000, the SDK Beep() function does the whole job. - * But while Beep() exists before NT, it ignores its arguments and - * plays the system default sound. Sheesh ... - * The Win9X code is mondo bizarre. I (Tim) pieced it together from - * crap all over the web. The original IBM PC used some particular - * pieces of hardware (Intel 8255 and 8254 chips) hardwired to - * particular port addresses and running at particular clock speeds, - * and the poor sound card folks have been forced to emulate that in - * all particulars ever since. But NT and 2000 don't support port - * manipulation. Don't know about WinME; guessing it's like 98. - */ - - if (whichOS == WinNT2000) { - BOOL ok; - Py_BEGIN_ALLOW_THREADS - ok = Beep(freq, dur); - Py_END_ALLOW_THREADS - if (!ok) { - PyErr_SetString(PyExc_RuntimeError,"Failed to beep"); - return NULL; - } - } -#if defined(_M_IX86) && defined(HAVE_CONIO_H) - else if (whichOS == Win9X) { - int speaker_state; - /* Force timer into oscillator mode via timer control port. */ - _outp(0x43, 0xb6); - /* Compute ratio of ancient hardcoded timer frequency to - * frequency we want. Then feed that ratio (lowest byte - * first) into timer data port. - */ - freq = 1193180 / freq; - _outp(0x42, freq & 0xff); - _outp(0x42, (freq >> 8) & 0xff); - /* Get speaker control state. */ - speaker_state = _inp(0x61); - /* Turn the speaker on (bit 1) - * and drive speaker from timer (bit 0). - */ - _outp(0x61, speaker_state | 0x3); - /* Let it blast in peace for the duration. */ - Py_BEGIN_ALLOW_THREADS - Sleep(dur); - Py_END_ALLOW_THREADS - /* Restore speaker control to original state. */ - _outp(0x61, speaker_state); - } -#endif /* _M_IX86 && HAVE_CONIO_H */ - else { - assert(!"winsound's whichOS has insane value"); + Py_BEGIN_ALLOW_THREADS + ok = Beep(freq, dur); + Py_END_ALLOW_THREADS + if (!ok) { + PyErr_SetString(PyExc_RuntimeError,"Failed to beep"); + return NULL; } + Py_INCREF(Py_None); return Py_None; } @@ -217,8 +166,6 @@ add_define(PyObject *dict, const char *key, long value) PyMODINIT_FUNC initwinsound(void) { - OSVERSIONINFO version; - PyObject *dict; PyObject *module = Py_InitModule3("winsound", sound_methods, @@ -243,11 +190,4 @@ initwinsound(void) ADD_DEFINE(MB_ICONEXCLAMATION); ADD_DEFINE(MB_ICONHAND); ADD_DEFINE(MB_ICONQUESTION); - - version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&version); - whichOS = Win9X; - if (version.dwPlatformId != VER_PLATFORM_WIN32s && - version.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) - whichOS = WinNT2000; } |