mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2025-07-18 08:17:29 +00:00
Merge pull request #152 from ul/master
fix microphone example fill with zeros case
This commit is contained in:
commit
85103e43e4
|
@ -113,6 +113,7 @@ static void read_callback(struct SoundIoInStream *instream, int frame_count_min,
|
||||||
|
|
||||||
static void write_callback(struct SoundIoOutStream *outstream, int frame_count_min, int frame_count_max) {
|
static void write_callback(struct SoundIoOutStream *outstream, int frame_count_min, int frame_count_max) {
|
||||||
struct SoundIoChannelArea *areas;
|
struct SoundIoChannelArea *areas;
|
||||||
|
int frames_left;
|
||||||
int frame_count;
|
int frame_count;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -122,7 +123,11 @@ static void write_callback(struct SoundIoOutStream *outstream, int frame_count_m
|
||||||
|
|
||||||
if (frame_count_min > fill_count) {
|
if (frame_count_min > fill_count) {
|
||||||
// Ring buffer does not have enough data, fill with zeroes.
|
// Ring buffer does not have enough data, fill with zeroes.
|
||||||
|
frames_left = frame_count_min;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
frame_count = frames_left;
|
||||||
|
if (frame_count <= 0)
|
||||||
|
return;
|
||||||
if ((err = soundio_outstream_begin_write(outstream, &areas, &frame_count)))
|
if ((err = soundio_outstream_begin_write(outstream, &areas, &frame_count)))
|
||||||
panic("begin write error: %s", soundio_strerror(err));
|
panic("begin write error: %s", soundio_strerror(err));
|
||||||
if (frame_count <= 0)
|
if (frame_count <= 0)
|
||||||
|
@ -135,11 +140,12 @@ static void write_callback(struct SoundIoOutStream *outstream, int frame_count_m
|
||||||
}
|
}
|
||||||
if ((err = soundio_outstream_end_write(outstream)))
|
if ((err = soundio_outstream_end_write(outstream)))
|
||||||
panic("end write error: %s", soundio_strerror(err));
|
panic("end write error: %s", soundio_strerror(err));
|
||||||
|
frames_left -= frame_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_count = min_int(frame_count_max, fill_count);
|
int read_count = min_int(frame_count_max, fill_count);
|
||||||
int frames_left = read_count;
|
frames_left = read_count;
|
||||||
|
|
||||||
while (frames_left > 0) {
|
while (frames_left > 0) {
|
||||||
int frame_count = frames_left;
|
int frame_count = frames_left;
|
||||||
|
|
Loading…
Reference in a new issue