Commit 2afb25b2316215a66cf266f58b979bd0ce84e04a
Note code taken from alsa-lib
cel committed on 10/27/2016, 12:22:47 AMParent: 181a071b13ee98141c4e505a58d5eb0c43b71236
Files changed
foostudio.c | changed |
foostudio.c | ||
---|---|---|
@@ -39,9 +39,10 @@ | ||
39 | 39 … | } |
40 | 40 … | return err; |
41 | 41 … | } |
42 | 42 … | |
43 | -static void generate(struct ccdl *ccdl, | |
43 … | +/* generate(): adapted from generate_sine() from alsa-lib/test/pcm.c */ | |
44 … | +static void generate(struct tune *tune, | |
44 | 45 … | const snd_pcm_channel_area_t *areas, |
45 | 46 … | snd_pcm_uframes_t offset, |
46 | 47 … | int count, double *_phase) |
47 | 48 … | { |
@@ -69,10 +70,8 @@ | ||
69 | 70 … | steps[chn] = areas[chn].step / 8; |
70 | 71 … | samples[chn] += offset * steps[chn]; |
71 | 72 … | } |
72 | 73 … | |
73 | - struct tune *tune = ccdl_get(ccdl); | |
74 | - | |
75 | 74 … | /* fill the channel areas */ |
76 | 75 … | while (count-- > 0) { |
77 | 76 … | union { |
78 | 77 … | float f; |
@@ -154,8 +153,9 @@ | ||
154 | 153 … | snd_pcm_sframes_t avail, commitres; |
155 | 154 … | snd_pcm_state_t state; |
156 | 155 … | int first = 1; |
157 | 156 … | |
157 … | + /* main loop: adapted from direct_loop() from alsa-lib/test/pcm.c */ | |
158 | 158 … | while (1) { |
159 | 159 … | state = snd_pcm_state(pcm_out); |
160 | 160 … | if (state == SND_PCM_STATE_XRUN) { |
161 | 161 … | err = xrun_recovery(pcm_out, -EPIPE); |
@@ -211,10 +211,10 @@ | ||
211 | 211 … | exit(EXIT_FAILURE); |
212 | 212 … | } |
213 | 213 … | first = 1; |
214 | 214 … | } |
215 | - generate(&ccdl, my_areas, offset, frames, &phase); | |
216 | - // generate_sine(my_areas, offset, frames, &phase); | |
215 … | + struct tune *tune = ccdl_get(&ccdl); | |
216 … | + generate(tune, my_areas, offset, frames, &phase); | |
217 | 217 … | commitres = snd_pcm_mmap_commit(pcm_out, offset, frames); |
218 | 218 … | if (commitres < 0 || (snd_pcm_uframes_t)commitres != frames) { |
219 | 219 … | if ((err = xrun_recovery(pcm_out, commitres >= 0 ? -EPIPE : commitres)) < 0) { |
220 | 220 … | printf("MMAP commit error: %s\n", snd_strerror(err)); |
Built with git-ssb-web