libdragon
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
62typedef void(*audio_fill_buffer_callback)(short *buffer, size_t numsamples);
63
78void audio_init(const int frequency, int numbuffers);
79
91
99void audio_pause(bool pause);
100
108volatile int audio_can_write();
109
121
128void audio_close();
129
136
146
147
168short* audio_write_begin(void);
169
178void audio_write_end(void);
179
206int audio_push(const short *buffer, int nsamples, bool blocking);
207
208__attribute__((deprecated("use audio_write_begin or audio_push instead")))
209void audio_write(const short * const buffer);
210
211#ifdef __cplusplus
212}
213#endif
214 /* audio */
216
217#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:62