mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2025-01-03 15:25:42 +00:00
update tests to catch pausing during write_callback
This commit is contained in:
parent
c09a64c64f
commit
a37b8cf847
|
@ -259,6 +259,7 @@ For each backend, do the following:
|
|||
- Use 'p' to test pausing, 'u' to test unpausing, 'q' to test cleanup.
|
||||
- 'c' for clear buffer. Clear buffer should not pause the stream and it
|
||||
should also not cause an underflow.
|
||||
- Use 'P' to test pausing from the callback, and then 'u' to unpause.
|
||||
0. Run `./underflow` and read the testing instructions that it prints.
|
||||
0. Run `./sio_microphone` and ensure that it is both recording and playing
|
||||
back correctly. If possible use the `--in-device` and `--out-device`
|
||||
|
|
|
@ -53,6 +53,7 @@ static void write_sample_float64ne(char *ptr, double sample) {
|
|||
static void (*write_sample)(char *ptr, double sample);
|
||||
static const double PI = 3.14159265358979323846264338328;
|
||||
static double seconds_offset = 0.0;
|
||||
static volatile bool want_pause = false;
|
||||
static void write_callback(struct SoundIoOutStream *outstream, int frame_count_min, int frame_count_max) {
|
||||
double float_sample_rate = outstream->sample_rate;
|
||||
double seconds_per_frame = 1.0 / float_sample_rate;
|
||||
|
@ -95,6 +96,8 @@ static void write_callback(struct SoundIoOutStream *outstream, int frame_count_m
|
|||
if (frames_left <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
soundio_outstream_pause(outstream, want_pause);
|
||||
}
|
||||
|
||||
static void underflow_callback(struct SoundIoOutStream *outstream) {
|
||||
|
@ -200,6 +203,7 @@ int main(int argc, char **argv) {
|
|||
fprintf(stderr,
|
||||
"'p\\n' - pause\n"
|
||||
"'u\\n' - unpause\n"
|
||||
"'P\\n' - pause from within callback\n"
|
||||
"'c\\n' - clear buffer\n"
|
||||
"'q\\n' - quit\n");
|
||||
|
||||
|
@ -252,7 +256,10 @@ int main(int argc, char **argv) {
|
|||
if (c == 'p') {
|
||||
fprintf(stderr, "pausing result: %s\n",
|
||||
soundio_strerror(soundio_outstream_pause(outstream, true)));
|
||||
} else if (c == 'P') {
|
||||
want_pause = true;
|
||||
} else if (c == 'u') {
|
||||
want_pause = false;
|
||||
fprintf(stderr, "unpausing result: %s\n",
|
||||
soundio_strerror(soundio_outstream_pause(outstream, false)));
|
||||
} else if (c == 'c') {
|
||||
|
|
Loading…
Reference in a new issue