diff options
| author | Juanma Barranquero | 2002-11-19 13:05:28 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2002-11-19 13:05:28 +0000 |
| commit | 06c3eeed12388e8e1e64f355e2629f43d3eaef3a (patch) | |
| tree | e79d3396be7a6cf418b72e6c7a83cb86d21b3f69 /src | |
| parent | 7be215b4a40c2f6748ec85b12b9b9febc5927565 (diff) | |
| download | emacs-06c3eeed12388e8e1e64f355e2629f43d3eaef3a.tar.gz emacs-06c3eeed12388e8e1e64f355e2629f43d3eaef3a.zip | |
Fix spacing and adapt to GNU coding conventions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/sound.c | 114 |
1 files changed, 56 insertions, 58 deletions
diff --git a/src/sound.c b/src/sound.c index 185ba864be7..c43cb49d3c4 100644 --- a/src/sound.c +++ b/src/sound.c | |||
| @@ -33,7 +33,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 33 | 33 | ||
| 34 | The Windows implementation of play-sound is implemented via the | 34 | The Windows implementation of play-sound is implemented via the |
| 35 | Win32 API functions mciSendString, waveOutGetVolume, and | 35 | Win32 API functions mciSendString, waveOutGetVolume, and |
| 36 | waveOutGetVolume which are exported by Winmm.dll. | 36 | waveOutSetVolume which are exported by Winmm.dll. |
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| 39 | #include <config.h> | 39 | #include <config.h> |
| @@ -900,79 +900,74 @@ vox_write (sd, buffer, nbytes) | |||
| 900 | 900 | ||
| 901 | static int | 901 | static int |
| 902 | do_play_sound (psz_file, ui_volume) | 902 | do_play_sound (psz_file, ui_volume) |
| 903 | const char * psz_file; | 903 | const char *psz_file; |
| 904 | unsigned long ui_volume; | 904 | unsigned long ui_volume; |
| 905 | { | 905 | { |
| 906 | int i_result=0; | 906 | int i_result = 0; |
| 907 | MCIERROR mci_error=0; | 907 | MCIERROR mci_error = 0; |
| 908 | char sz_cmd_buf[520]={0}; | 908 | char sz_cmd_buf[520] = {0}; |
| 909 | char sz_ret_buf[520]={0}; | 909 | char sz_ret_buf[520] = {0}; |
| 910 | MMRESULT mm_result=MMSYSERR_NOERROR; | 910 | MMRESULT mm_result = MMSYSERR_NOERROR; |
| 911 | unsigned long ui_volume_org=0; | 911 | unsigned long ui_volume_org = 0; |
| 912 | BOOL b_reset_volume=FALSE; | 912 | BOOL b_reset_volume = FALSE; |
| 913 | |||
| 913 | memset (sz_cmd_buf, 0, sizeof(sz_cmd_buf)); | 914 | memset (sz_cmd_buf, 0, sizeof(sz_cmd_buf)); |
| 914 | memset (sz_ret_buf, 0, sizeof(sz_ret_buf)); | 915 | memset (sz_ret_buf, 0, sizeof(sz_ret_buf)); |
| 915 | sprintf ( | 916 | sprintf (sz_cmd_buf, |
| 916 | sz_cmd_buf, | 917 | "open \"%s\" alias GNUEmacs_PlaySound_Device wait", |
| 917 | "open \"%s\" alias GNUEmacs_PlaySound_Device wait", | 918 | psz_file); |
| 918 | psz_file); | 919 | mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, 520, NULL); |
| 919 | mci_error=mciSendString (sz_cmd_buf, sz_ret_buf, 520, NULL); | ||
| 920 | if (mci_error != 0) | 920 | if (mci_error != 0) |
| 921 | { | 921 | { |
| 922 | sound_warning ( | 922 | sound_warning ("The open mciSendString command failed to open\n" |
| 923 | "The open mciSendString command failed to open\n" | 923 | "the specified sound file"); |
| 924 | "the specified sound file"); | 924 | i_result = (int) mci_error; |
| 925 | i_result=(int)mci_error; | ||
| 926 | return i_result; | 925 | return i_result; |
| 927 | } | 926 | } |
| 928 | if ((ui_volume > 0) && (ui_volume != UINT_MAX)) | 927 | if ((ui_volume > 0) && (ui_volume != UINT_MAX)) |
| 929 | { | 928 | { |
| 930 | mm_result=waveOutGetVolume ((HWAVEOUT)WAVE_MAPPER, &ui_volume_org); | 929 | mm_result = waveOutGetVolume ((HWAVEOUT) WAVE_MAPPER, &ui_volume_org); |
| 931 | if (mm_result == MMSYSERR_NOERROR) | 930 | if (mm_result == MMSYSERR_NOERROR) |
| 932 | { | 931 | { |
| 933 | b_reset_volume=TRUE; | 932 | b_reset_volume = TRUE; |
| 934 | mm_result=waveOutSetVolume ((HWAVEOUT)WAVE_MAPPER, ui_volume); | 933 | mm_result = waveOutSetVolume ((HWAVEOUT) WAVE_MAPPER, ui_volume); |
| 935 | if ( mm_result != MMSYSERR_NOERROR) | 934 | if ( mm_result != MMSYSERR_NOERROR) |
| 936 | { | 935 | { |
| 937 | sound_warning ( | 936 | sound_warning ("waveOutSetVolume failed to set the volume level\n" |
| 938 | "waveOutSetVolume failed to set the volume level\n" | 937 | "of the WAVE_MAPPER device.\n" |
| 939 | "of the WAVE_MAPPER device.\n" | 938 | "As a result, the user selected volume level will\n" |
| 940 | "As a result, the user selected volume level will\n" | 939 | "not be used."); |
| 941 | "not be used."); | ||
| 942 | } | 940 | } |
| 943 | } | 941 | } |
| 944 | else | 942 | else |
| 945 | { | 943 | { |
| 946 | sound_warning ( | 944 | sound_warning ("waveOutGetVolume failed to obtain the original\n" |
| 947 | "waveOutGetVolume failed to obtain the original\n" | 945 | "volume level of the WAVE_MAPPER device.\n" |
| 948 | "volume level of the WAVE_MAPPER device.\n" | 946 | "As a result, the user selected volume level will\n" |
| 949 | "As a result, the user selected volume level will\n" | 947 | "not be used."); |
| 950 | "not be used."); | ||
| 951 | } | 948 | } |
| 952 | } | 949 | } |
| 953 | memset (sz_cmd_buf, 0, sizeof(sz_cmd_buf)); | 950 | memset (sz_cmd_buf, 0, sizeof(sz_cmd_buf)); |
| 954 | memset (sz_ret_buf, 0, sizeof(sz_ret_buf)); | 951 | memset (sz_ret_buf, 0, sizeof(sz_ret_buf)); |
| 955 | strcpy (sz_cmd_buf, "play GNUEmacs_PlaySound_Device wait"); | 952 | strcpy (sz_cmd_buf, "play GNUEmacs_PlaySound_Device wait"); |
| 956 | mci_error=mciSendString (sz_cmd_buf, sz_ret_buf, 520, NULL); | 953 | mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, 520, NULL); |
| 957 | if (mci_error != 0) | 954 | if (mci_error != 0) |
| 958 | { | 955 | { |
| 959 | sound_warning ( | 956 | sound_warning ("The play mciSendString command failed to play the\n" |
| 960 | "The play mciSendString command failed to play the\n" | 957 | "opened sound file."); |
| 961 | "opened sound file."); | 958 | i_result = (int) mci_error; |
| 962 | i_result=(int)mci_error; | ||
| 963 | } | 959 | } |
| 964 | memset (sz_cmd_buf, 0, sizeof(sz_cmd_buf)); | 960 | memset (sz_cmd_buf, 0, sizeof(sz_cmd_buf)); |
| 965 | memset (sz_ret_buf, 0, sizeof(sz_ret_buf)); | 961 | memset (sz_ret_buf, 0, sizeof(sz_ret_buf)); |
| 966 | strcpy (sz_cmd_buf, "close GNUEmacs_PlaySound_Device wait"); | 962 | strcpy (sz_cmd_buf, "close GNUEmacs_PlaySound_Device wait"); |
| 967 | mci_error=mciSendString ( sz_cmd_buf, sz_ret_buf, 520, NULL); | 963 | mci_error = mciSendString (sz_cmd_buf, sz_ret_buf, 520, NULL); |
| 968 | if (b_reset_volume == TRUE) | 964 | if (b_reset_volume == TRUE) |
| 969 | { | 965 | { |
| 970 | mm_result=waveOutSetVolume ((HWAVEOUT)WAVE_MAPPER, ui_volume_org); | 966 | mm_result=waveOutSetVolume ((HWAVEOUT) WAVE_MAPPER, ui_volume_org); |
| 971 | if (mm_result != MMSYSERR_NOERROR) | 967 | if (mm_result != MMSYSERR_NOERROR) |
| 972 | { | 968 | { |
| 973 | sound_warning ( | 969 | sound_warning ("waveOutSetVolume failed to reset the original volume\n" |
| 974 | "waveOutSetVolume failed to reset the original volume\n" | 970 | "level of the WAVE_MAPPER device."); |
| 975 | "level of the WAVE_MAPPER device."); | ||
| 976 | } | 971 | } |
| 977 | } | 972 | } |
| 978 | return i_result; | 973 | return i_result; |
| @@ -982,7 +977,6 @@ do_play_sound (psz_file, ui_volume) | |||
| 982 | 977 | ||
| 983 | #endif /* WINDOWSNT */ | 978 | #endif /* WINDOWSNT */ |
| 984 | 979 | ||
| 985 | |||
| 986 | DEFUN ("play-sound-internal", Fplay_sound_internal, Splay_sound_internal, 1, 1, 0, | 980 | DEFUN ("play-sound-internal", Fplay_sound_internal, Splay_sound_internal, 1, 1, 0, |
| 987 | doc: /* Play sound SOUND. | 981 | doc: /* Play sound SOUND. |
| 988 | 982 | ||
| @@ -1000,12 +994,12 @@ Internal use only, use `play-sound' instead.\n */) | |||
| 1000 | struct sound s; | 994 | struct sound s; |
| 1001 | Lisp_Object args[2]; | 995 | Lisp_Object args[2]; |
| 1002 | #else /* WINDOWSNT */ | 996 | #else /* WINDOWSNT */ |
| 1003 | int len=0; | 997 | int len = 0; |
| 1004 | Lisp_Object lo_file={0}; | 998 | Lisp_Object lo_file = {0}; |
| 1005 | char * psz_file=NULL; | 999 | char * psz_file = NULL; |
| 1006 | unsigned long ui_volume_tmp=UINT_MAX; | 1000 | unsigned long ui_volume_tmp = UINT_MAX; |
| 1007 | unsigned long ui_volume=UINT_MAX; | 1001 | unsigned long ui_volume = UINT_MAX; |
| 1008 | int i_result=0; | 1002 | int i_result = 0; |
| 1009 | #endif /* WINDOWSNT */ | 1003 | #endif /* WINDOWSNT */ |
| 1010 | 1004 | ||
| 1011 | /* Parse the sound specification. Give up if it is invalid. */ | 1005 | /* Parse the sound specification. Give up if it is invalid. */ |
| @@ -1087,18 +1081,20 @@ Internal use only, use `play-sound' instead.\n */) | |||
| 1087 | current_sound_device = NULL; | 1081 | current_sound_device = NULL; |
| 1088 | current_sound = NULL; | 1082 | current_sound = NULL; |
| 1089 | UNGCPRO; | 1083 | UNGCPRO; |
| 1084 | |||
| 1090 | #else /* WINDOWSNT */ | 1085 | #else /* WINDOWSNT */ |
| 1091 | lo_file=Fexpand_file_name (attrs[SOUND_FILE], Qnil); | 1086 | |
| 1092 | len=XSTRING (lo_file)->size; | 1087 | lo_file = Fexpand_file_name (attrs[SOUND_FILE], Qnil); |
| 1093 | psz_file=(char *)alloca (len+1); | 1088 | len = XSTRING (lo_file)->size; |
| 1089 | psz_file = (char *) alloca (len + 1); | ||
| 1094 | strcpy (psz_file, XSTRING (lo_file)->data); | 1090 | strcpy (psz_file, XSTRING (lo_file)->data); |
| 1095 | if (INTEGERP (attrs[SOUND_VOLUME])) | 1091 | if (INTEGERP (attrs[SOUND_VOLUME])) |
| 1096 | { | 1092 | { |
| 1097 | ui_volume_tmp=XFASTINT (attrs[SOUND_VOLUME]); | 1093 | ui_volume_tmp = XFASTINT (attrs[SOUND_VOLUME]); |
| 1098 | } | 1094 | } |
| 1099 | else if (FLOATP (attrs[SOUND_VOLUME])) | 1095 | else if (FLOATP (attrs[SOUND_VOLUME])) |
| 1100 | { | 1096 | { |
| 1101 | ui_volume_tmp=(unsigned long)XFLOAT_DATA (attrs[SOUND_VOLUME])*100; | 1097 | ui_volume_tmp = (unsigned long) XFLOAT_DATA (attrs[SOUND_VOLUME]) * 100; |
| 1102 | } | 1098 | } |
| 1103 | /* | 1099 | /* |
| 1104 | Based on some experiments I have conducted, a value of 100 or less | 1100 | Based on some experiments I have conducted, a value of 100 or less |
| @@ -1106,15 +1102,17 @@ Internal use only, use `play-sound' instead.\n */) | |||
| 1106 | A value of UINT_MAX indicates that you wish for the sound to played | 1102 | A value of UINT_MAX indicates that you wish for the sound to played |
| 1107 | at the maximum possible volume. A value of UINT_MAX/2 plays the | 1103 | at the maximum possible volume. A value of UINT_MAX/2 plays the |
| 1108 | sound at 50% maximum volume. Therefore the value passed to do_play_sound | 1104 | sound at 50% maximum volume. Therefore the value passed to do_play_sound |
| 1109 | (and thus to waveOutSetVolume must be some fraction of UINT_MAX. | 1105 | (and thus to waveOutSetVolume) must be some fraction of UINT_MAX. |
| 1110 | The following code adjusts the user specified volume level appropriately. | 1106 | The following code adjusts the user specified volume level appropriately. |
| 1111 | */ | 1107 | */ |
| 1112 | if ((ui_volume_tmp > 0) && (ui_volume_tmp <= 100)) | 1108 | if ((ui_volume_tmp > 0) && (ui_volume_tmp <= 100)) |
| 1113 | { | 1109 | { |
| 1114 | ui_volume=ui_volume_tmp * (UINT_MAX / 100); | 1110 | ui_volume = ui_volume_tmp * (UINT_MAX / 100); |
| 1115 | } | 1111 | } |
| 1116 | i_result=do_play_sound (psz_file, ui_volume); | 1112 | i_result = do_play_sound (psz_file, ui_volume); |
| 1113 | |||
| 1117 | #endif /* WINDOWSNT */ | 1114 | #endif /* WINDOWSNT */ |
| 1115 | |||
| 1118 | unbind_to (count, Qnil); | 1116 | unbind_to (count, Qnil); |
| 1119 | return Qnil; | 1117 | return Qnil; |
| 1120 | } | 1118 | } |