Mercurial > sdl-ios-xcode
comparison src/audio/dart/SDL_dart.c @ 1999:dd4b184b3050
Let OS/2 DART backend use SDL converters at a higher level (would fail if
DART didn't directly support AudioSpec before).
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 31 Aug 2006 22:40:53 +0000 |
parents | c121d94672cb |
children | 02108bfd6550 |
comparison
equal
deleted
inserted
replaced
1998:cbac0f77a799 | 1999:dd4b184b3050 |
---|---|
72 | 72 |
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 MCI_AMP_OPEN_PARMS AmpOpenParms; | 78 MCI_AMP_OPEN_PARMS AmpOpenParms; |
78 MCI_GENERIC_PARMS GenericParms; | 79 MCI_GENERIC_PARMS GenericParms; |
79 int iDeviceOrd = 0; // Default device to be used | 80 int iDeviceOrd = 0; // Default device to be used |
80 int bOpenShared = 1; // Try opening it shared | 81 int bOpenShared = 1; // Try opening it shared |
81 int iBits = 16; // Default is 16 bits signed | 82 int iBits = 16; // Default is 16 bits signed |
103 // Save the device ID we got from DART! | 104 // Save the device ID we got from DART! |
104 // We will use this in the next calls! | 105 // We will use this in the next calls! |
105 iDeviceOrd = AmpOpenParms.usDeviceID; | 106 iDeviceOrd = AmpOpenParms.usDeviceID; |
106 | 107 |
107 // Determine the audio parameters from the AudioSpec | 108 // Determine the audio parameters from the AudioSpec |
108 switch (spec->format & 0xFF) { | 109 if (spec->channels > 2) |
109 case 8: | 110 spec->channels = 2; // !!! FIXME: more than stereo support in OS/2? |
110 /* Unsigned 8 bit audio data */ | 111 |
111 spec->format = AUDIO_U8; | 112 while (test_format) { |
112 iSilence = 0x80; | 113 spec->format = test_format; |
113 iBits = 8; | 114 switch (test_format) { |
114 break; | 115 case AUDIO_U8: |
115 case 16: | 116 // Unsigned 8 bit audio data |
116 /* Signed 16 bit audio data */ | 117 iSilence = 0x80; |
117 spec->format = AUDIO_S16; | 118 iBits = 8; |
118 iSilence = 0x00; | 119 break; |
119 iBits = 16; | 120 |
120 break; | 121 case AUDIO_S16LSB: |
121 default: | 122 // Signed 16 bit audio data |
123 iSilence = 0x00; | |
124 iBits = 16; | |
125 break; | |
126 | |
127 // !!! FIXME: int32? | |
128 | |
129 default: | |
130 test_format = SDL_NextAudioFormat(); | |
131 break; | |
132 } | |
133 } | |
134 | |
135 if (!test_format) { // shouldn't happen, but just in case... | |
122 // Close DART, and exit with error code! | 136 // Close DART, and exit with error code! |
123 mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); | 137 mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0); |
124 SDL_SetError("Unsupported audio format"); | 138 SDL_SetError("Unsupported audio format"); |
125 return (-1); | 139 return (-1); |
126 } | 140 } |
141 | |
127 iFreq = spec->freq; | 142 iFreq = spec->freq; |
128 iChannels = spec->channels; | 143 iChannels = spec->channels; |
129 /* Update the fragment size as size in bytes */ | 144 /* Update the fragment size as size in bytes */ |
130 SDL_CalculateAudioSpec(spec); | 145 SDL_CalculateAudioSpec(spec); |
131 iBufSize = spec->size; | 146 iBufSize = spec->size; |