Mercurial > sdl-ios-xcode
comparison src/audio/mint/SDL_mintaudio.c @ 961:185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
From: Patrice Mandin
Subject: Reworked audio drivers for Atari platform
These are reworked audio drivers for the Atari platform.
Previous drivers were missing some features:
- Test external clock plugged to DSP port on Atari Falcon 030.
- Ability to select internal or external clock.
So now, I generate a list of frequencies available, with the master clock
and predivisor to use. One big caveat to this: I do not have an external
clock, so I hope it works.
author | Patrice Mandin <patmandin@gmail.com> |
---|---|
date | Fri, 29 Oct 2004 09:56:53 +0000 |
parents | b8d311d90021 |
children | 2eca15c3f609 |
comparison
equal
deleted
inserted
replaced
960:eec28a5278be | 961:185acc07127a |
---|---|
39 SDL_AudioDevice *SDL_MintAudio_device; | 39 SDL_AudioDevice *SDL_MintAudio_device; |
40 Uint8 *SDL_MintAudio_audiobuf[2]; /* Pointers to buffers */ | 40 Uint8 *SDL_MintAudio_audiobuf[2]; /* Pointers to buffers */ |
41 unsigned long SDL_MintAudio_audiosize; /* Length of audio buffer=spec->size */ | 41 unsigned long SDL_MintAudio_audiosize; /* Length of audio buffer=spec->size */ |
42 unsigned short SDL_MintAudio_numbuf; /* Buffer to play */ | 42 unsigned short SDL_MintAudio_numbuf; /* Buffer to play */ |
43 unsigned short SDL_MintAudio_mutex; | 43 unsigned short SDL_MintAudio_mutex; |
44 unsigned long SDL_MintAudio_clocktics; | |
44 cookie_stfa_t *SDL_MintAudio_stfa; | 45 cookie_stfa_t *SDL_MintAudio_stfa; |
45 | 46 |
46 /* The callback function, called by each driver whenever needed */ | 47 /* The callback function, called by each driver whenever needed */ |
47 | 48 |
48 void SDL_MintAudio_Callback(void) | 49 void SDL_MintAudio_Callback(void) |
62 SDL_MintAudio_device->spec.callback(SDL_MintAudio_device->spec.userdata, buffer, SDL_MintAudio_device->spec.size); | 63 SDL_MintAudio_device->spec.callback(SDL_MintAudio_device->spec.userdata, buffer, SDL_MintAudio_device->spec.size); |
63 } | 64 } |
64 } | 65 } |
65 } | 66 } |
66 | 67 |
67 /* Simple function to search for the nearest frequency */ | 68 /* Add a new frequency/clock/predivisor to the current list */ |
68 int SDL_MintAudio_SearchFrequency(_THIS, int falcon_codec, int desired_freq) | 69 void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock, Uint32 prediv) |
70 { | |
71 int i, p; | |
72 | |
73 if (MINTAUDIO_freqcount==MINTAUDIO_maxfreqs) { | |
74 return; | |
75 } | |
76 | |
77 /* Search where to insert the frequency (highest first) */ | |
78 for (p=0; p<MINTAUDIO_freqcount; p++) { | |
79 if (frequency > MINTAUDIO_frequencies[p].frequency) { | |
80 break; | |
81 } | |
82 } | |
83 | |
84 /* Put all following ones farer */ | |
85 if (MINTAUDIO_freqcount>0) { | |
86 for (i=MINTAUDIO_freqcount; i>p; i--) { | |
87 MINTAUDIO_frequencies[i].frequency = MINTAUDIO_frequencies[i-1].frequency; | |
88 MINTAUDIO_frequencies[i].masterclock = MINTAUDIO_frequencies[i-1].masterclock; | |
89 MINTAUDIO_frequencies[i].predivisor = MINTAUDIO_frequencies[i-1].predivisor; | |
90 } | |
91 } | |
92 | |
93 /* And insert new one */ | |
94 MINTAUDIO_frequencies[p].frequency = frequency; | |
95 MINTAUDIO_frequencies[p].masterclock = clock; | |
96 MINTAUDIO_frequencies[p].predivisor = prediv; | |
97 | |
98 MINTAUDIO_freqcount++; | |
99 } | |
100 | |
101 /* Search for the nearest frequency */ | |
102 int SDL_MintAudio_SearchFrequency(_THIS, int desired_freq) | |
69 { | 103 { |
70 int i; | 104 int i; |
71 | 105 |
72 /* Only 1 freq ? */ | 106 /* Only 1 freq ? */ |
73 if (MINTAUDIO_nfreq==1) { | 107 if (MINTAUDIO_freqcount==1) { |
74 return(MINTAUDIO_sfreq); | 108 return 0; |
75 } | 109 } |
76 | 110 |
77 /* Check the array */ | 111 /* Check the array */ |
78 for (i=MINTAUDIO_sfreq; i<MINTAUDIO_nfreq-1; i++) { | 112 for (i=0; i<MINTAUDIO_freqcount; i++) { |
79 /* Remove unusable falcon codec frequencies */ | 113 if (desired_freq >= ((MINTAUDIO_frequencies[i].frequency+ |
80 if (falcon_codec) { | 114 MINTAUDIO_frequencies[i+1].frequency)>>1)) { |
81 if ((i==6) || (i==8) || (i==10)) { | |
82 continue; | |
83 } | |
84 } | |
85 | |
86 if (desired_freq >= ((MINTAUDIO_hardfreq[i]+MINTAUDIO_hardfreq[i+1])>>1)) { | |
87 return i; | 115 return i; |
88 } | 116 } |
89 } | 117 } |
90 | 118 |
91 /* Not in the array, give the latest */ | 119 /* Not in the array, give the latest */ |
92 return MINTAUDIO_nfreq-1; | 120 return MINTAUDIO_freqcount-1; |
93 } | 121 } |