mirror of
https://github.com/zserge/fenster.git
synced 2025-07-18 17:56:11 +03:00
formatting
This commit is contained in:
@ -33,12 +33,13 @@ static int run() {
|
||||
for (int i = 0; i < n; i++) {
|
||||
u++;
|
||||
/*audio[i] = (rand() & 0xff)/256.f;*/
|
||||
int x = u * 80/441;
|
||||
audio[i] = ((((x >> 10) & 42) * x)&0xff)/256.f;
|
||||
int x = u * 80 / 441;
|
||||
audio[i] = ((((x >> 10) & 42) * x) & 0xff) / 256.f;
|
||||
}
|
||||
fenster_audio_write(&fa, audio, n);
|
||||
}
|
||||
if (f.keys[27]) break;
|
||||
if (f.keys[27])
|
||||
break;
|
||||
|
||||
for (int i = 0; i < 320; i++) {
|
||||
for (int j = 0; j < 240; j++) {
|
||||
|
@ -100,21 +100,26 @@ int snd_pcm_writei(void *, const void *, unsigned long);
|
||||
int snd_pcm_recover(void *, int, int);
|
||||
int snd_pcm_close(void *);
|
||||
FENSTER_API int fenster_audio_open(struct fenster_audio *fa) {
|
||||
if (snd_pcm_open(&fa->pcm, "default", 0, 0)) return -1;
|
||||
int fmt = (*(unsigned char *)(&(uint16_t){1}))?14:15;
|
||||
if (snd_pcm_open(&fa->pcm, "default", 0, 0))
|
||||
return -1;
|
||||
int fmt = (*(unsigned char *)(&(uint16_t){1})) ? 14 : 15;
|
||||
return snd_pcm_set_params(fa->pcm, fmt, 3, 1, FENSTER_SAMPLE_RATE, 1, 100000);
|
||||
}
|
||||
FENSTER_API int fenster_audio_available(struct fenster_audio *fa) {
|
||||
int n = snd_pcm_avail(fa->pcm);
|
||||
if (n < 0) snd_pcm_recover(fa->pcm, n, 0);
|
||||
if (n < 0)
|
||||
snd_pcm_recover(fa->pcm, n, 0);
|
||||
return n;
|
||||
}
|
||||
FENSTER_API void fenster_audio_write(struct fenster_audio *fa, float *buf,
|
||||
size_t n) {
|
||||
int r = snd_pcm_writei(fa->pcm, buf, n);
|
||||
if (r < 0) snd_pcm_recover(fa->pcm, r, 0);
|
||||
if (r < 0)
|
||||
snd_pcm_recover(fa->pcm, r, 0);
|
||||
}
|
||||
FENSTER_API void fenster_audio_close(struct fenster_audio *fa) {
|
||||
snd_pcm_close(fa->pcm);
|
||||
}
|
||||
FENSTER_API void fenster_audio_close(struct fenster_audio *fa) { snd_pcm_close(fa->pcm); }
|
||||
#endif
|
||||
|
||||
#endif /* FENSTER_HEADER */
|
||||
|
Reference in New Issue
Block a user