libdragon
Loading...
Searching...
No Matches
audio.h
Go to the documentation of this file.
1
6#ifndef __LIBDRAGON_AUDIO_H
7#define __LIBDRAGON_AUDIO_H
8
9#include <stdbool.h>
10#include <stddef.h>
11
48#ifdef __cplusplus
49extern "C" {
50#endif
51
61typedef void(*audio_fill_buffer_callback)(short *buffer, size_t numsamples);
62
77void audio_init(const int frequency, int numbuffers);
78
90
98void audio_pause(bool pause);
99
107volatile int audio_can_write();
108
120
127void audio_close();
128
135
145
146
167short* audio_write_begin(void);
168
177void audio_write_end(void);
178
205int audio_push(const short *buffer, int nsamples, bool blocking);
206
207__attribute__((deprecated("use audio_write_begin or audio_push instead")))
208void audio_write(const short * const buffer);
209
210#ifdef __cplusplus
211}
212#endif
213
/* audio */
215
216#endif
int audio_get_buffer_length()
Get the number of stereo samples that fit into an allocated buffer.
Definition audio.c:480
void audio_set_buffer_callback(audio_fill_buffer_callback fill_buffer_callback)
Install a audio callback to fill the audio buffer when required.
Definition audio.c:263
int audio_get_frequency()
Return actual frequency of audio playback.
Definition audio.c:475
volatile int audio_can_write()
Return whether there is an empty buffer to write to.
Definition audio.c:433
short * audio_write_begin(void)
Start writing to the first free internal buffer.
Definition audio.c:372
void audio_init(const int frequency, int numbuffers)
Initialize the audio subsystem.
Definition audio.c:175
void audio_pause(bool pause)
Pause or resume audio playback.
Definition audio.c:311
void audio_write(const short *const buffer)
Write a chunk of audio data.
Definition audio.c:345
int audio_push(const short *buffer, int nsamples, bool blocking)
Push a chunk of audio data (high-level function)
Definition audio.c:445
void audio_write_end(void)
Complete writing to an internal buffer.
Definition audio.c:398
void audio_write_silence()
Write a chunk of silence.
Definition audio.c:406
void audio_close()
Close the audio subsystem.
Definition audio.c:273
void(* audio_fill_buffer_callback)(short *buffer, size_t numsamples)
Will be called periodically when more sample data is needed.
Definition audio.h:61