Mercurial > sdl-ios-xcode
comparison src/audio/dart/SDL_dart.c @ 2001:02108bfd6550
Actually, my silly logic bug was actually correct. :/
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 31 Aug 2006 23:16:48 +0000 |
parents | dd4b184b3050 |
children | adf732f1f016 |
comparison
equal
deleted
inserted
replaced
2000:8c05b048c32c | 2001:02108bfd6550 |
---|---|
73 | 73 |
74 int | 74 int |
75 DART_OpenAudio(_THIS, SDL_AudioSpec * spec) | 75 DART_OpenAudio(_THIS, SDL_AudioSpec * spec) |
76 { | 76 { |
77 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format); | 77 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format); |
78 int valid_datatype = 0; | |
78 MCI_AMP_OPEN_PARMS AmpOpenParms; | 79 MCI_AMP_OPEN_PARMS AmpOpenParms; |
79 MCI_GENERIC_PARMS GenericParms; | 80 MCI_GENERIC_PARMS GenericParms; |
80 int iDeviceOrd = 0; // Default device to be used | 81 int iDeviceOrd = 0; // Default device to be used |
81 int bOpenShared = 1; // Try opening it shared | 82 int bOpenShared = 1; // Try opening it shared |
82 int iBits = 16; // Default is 16 bits signed | 83 int iBits = 16; // Default is 16 bits signed |
107 | 108 |
108 // Determine the audio parameters from the AudioSpec | 109 // Determine the audio parameters from the AudioSpec |
109 if (spec->channels > 2) | 110 if (spec->channels > 2) |
110 spec->channels = 2; // !!! FIXME: more than stereo support in OS/2? | 111 spec->channels = 2; // !!! FIXME: more than stereo support in OS/2? |
111 | 112 |
112 while (test_format) { | 113 while ((!valid_datatype) && (test_format)) { |
113 spec->format = test_format; | 114 spec->format = test_format; |
115 valid_datatype = 1; | |
114 switch (test_format) { | 116 switch (test_format) { |
115 case AUDIO_U8: | 117 case AUDIO_U8: |
116 // Unsigned 8 bit audio data | 118 // Unsigned 8 bit audio data |
117 iSilence = 0x80; | 119 iSilence = 0x80; |
118 iBits = 8; | 120 iBits = 8; |
125 break; | 127 break; |
126 | 128 |
127 // !!! FIXME: int32? | 129 // !!! FIXME: int32? |
128 | 130 |
129 default: | 131 default: |
132 valid_datatype = 0; | |
130 test_format = SDL_NextAudioFormat(); | 133 test_format = SDL_NextAudioFormat(); |
131 break; | 134 break; |
132 } | 135 } |
133 } | 136 } |
134 | 137 |
135 if (!test_format) { // shouldn't happen, but just in case... | 138 if (!valid_datatype) { // shouldn't happen, but just in case... |
136 // Close DART, and exit with error code! | 139 // Close DART, and exit with error code! |
137 mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); | 140 mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); |
138 SDL_SetError("Unsupported audio format"); | 141 SDL_SetError("Unsupported audio format"); |
139 return (-1); | 142 return (-1); |
140 } | 143 } |