src/audio/SDL_audio.c
changeset 1982 3b4ce57c6215
parent 1978 542c78b6fb12
child 1993 7a3889fc9e5d
equal deleted inserted replaced
1981:3f21778e7433 1982:3b4ce57c6215
   284         return;
   284         return;
   285     }
   285     }
   286     SDL_mutexV(audio->mixer_lock);
   286     SDL_mutexV(audio->mixer_lock);
   287 }
   287 }
   288 
   288 
   289 static Uint16
   289 static SDL_AudioFormat
   290 SDL_ParseAudioFormat(const char *string)
   290 SDL_ParseAudioFormat(const char *string)
   291 {
   291 {
   292     Uint16 format = 0;
   292     SDL_AudioFormat format = 0;
   293 
   293 
   294     switch (*string) {
   294     switch (*string) {
   295     case 'U':
   295     case 'U':
   296         ++string;
   296         ++string;
   297         format |= 0x0000;
   297         format |= 0x0000;
   738         audio->free(audio);
   738         audio->free(audio);
   739         current_audio = NULL;
   739         current_audio = NULL;
   740     }
   740     }
   741 }
   741 }
   742 
   742 
   743 #define NUM_FORMATS	6
   743 #define NUM_FORMATS 10
   744 static int format_idx;
   744 static int format_idx;
   745 static int format_idx_sub;
   745 static int format_idx_sub;
   746 static Uint16 format_list[NUM_FORMATS][NUM_FORMATS] = {
   746 static SDL_AudioFormat format_list[NUM_FORMATS][NUM_FORMATS] = {
   747     {AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB,
   747     {AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB,
   748      AUDIO_U16MSB},
   748      AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB},
   749     {AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB,
   749     {AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB,
   750      AUDIO_U16MSB},
   750      AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB},
   751     {AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8,
   751     {AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S32LSB,
   752      AUDIO_S8},
   752      AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8},
   753     {AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8,
   753     {AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S32MSB,
   754      AUDIO_S8},
   754      AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8},
   755     {AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U8,
   755     {AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S32LSB,
   756      AUDIO_S8},
   756      AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8},
   757     {AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U8,
   757     {AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_S32MSB,
   758      AUDIO_S8},
   758      AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8},
       
   759     {AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB,
       
   760      AUDIO_S16MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8},
       
   761     {AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB,
       
   762      AUDIO_S16LSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8},
       
   763     {AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_U16LSB,
       
   764      AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U8, AUDIO_S8},
       
   765     {AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_U16MSB,
       
   766      AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U8, AUDIO_S8},
   759 };
   767 };
   760 
   768 
   761 Uint16
   769 SDL_AudioFormat
   762 SDL_FirstAudioFormat(Uint16 format)
   770 SDL_FirstAudioFormat(SDL_AudioFormat format)
   763 {
   771 {
   764     for (format_idx = 0; format_idx < NUM_FORMATS; ++format_idx) {
   772     for (format_idx = 0; format_idx < NUM_FORMATS; ++format_idx) {
   765         if (format_list[format_idx][0] == format) {
   773         if (format_list[format_idx][0] == format) {
   766             break;
   774             break;
   767         }
   775         }
   768     }
   776     }
   769     format_idx_sub = 0;
   777     format_idx_sub = 0;
   770     return (SDL_NextAudioFormat());
   778     return (SDL_NextAudioFormat());
   771 }
   779 }
   772 
   780 
   773 Uint16
   781 SDL_AudioFormat
   774 SDL_NextAudioFormat(void)
   782 SDL_NextAudioFormat(void)
   775 {
   783 {
   776     if ((format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS)) {
   784     if ((format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS)) {
   777         return (0);
   785         return (0);
   778     }
   786     }