63 check(AAudioStream_close(
stream),
"Error when closing stream");
68 AAudioStreamBuilder *builder;
69 check(AAudio_createStreamBuilder(&builder),
70 "Error when creating stream builder.");
73 AAudioStreamBuilder_setSampleRate(builder,
mode.sampleRate);
74 AAudioStreamBuilder_setChannelCount(builder,
mode.numChannels);
75 switch (
mode.sampleFormat) {
77 AAudioStreamBuilder_setFormat(builder, AAUDIO_FORMAT_PCM_I16);
80 AAudioStreamBuilder_setFormat(builder, AAUDIO_FORMAT_PCM_FLOAT);
86 AAudioStreamBuilder_setBufferCapacityInFrames(builder,
mode.bufferLength);
89 AAudioStreamBuilder_setSharingMode(builder, AAUDIO_SHARING_MODE_EXCLUSIVE);
91 AAudioStreamBuilder_setPerformanceMode(builder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
94 check(AAudioStreamBuilder_openStream(builder, &
stream),
95 "Error when opening stream");
100 " sharing mode: %d\n"
101 " performance mode: %d\n",
102 (
int)
mode.numChannels, (
int)
mode.sampleRate, (
int)
mode.bufferLength,
103 (
int)AAudioStream_getDeviceId(
stream),
104 (
int)AAudioStream_getSharingMode(
stream),
105 (
int)AAudioStream_getPerformanceMode(
stream));
109 AAudioStreamBuilder_delete(builder);
aaudio_data_callback_result_t aaudioDataCallback(AAudioStream *stream, void *userData, void *audioData, int32_t numFrames)
void check(aaudio_result_t code, const char *message)
#define BEATMUP_DEBUG_I(...)
@ Float32
floating point, 32 bit per sample
@ Int16
signed integer, 16 bit per sample