mirror of
https://github.com/TomHarte/CLK.git
synced 2024-10-19 14:25:35 +00:00
Corrects missing audio, at the cost of frame rate.
I'm now spinning on the ability of QAudioOutput to accept additional data.
This commit is contained in:
parent
68b165e244
commit
7c7cb61d2f
@ -180,7 +180,7 @@ void MainWindow::launchMachine() {
|
|||||||
// are available, and — at least for now — assume 512 samples/buffer is a good size.
|
// are available, and — at least for now — assume 512 samples/buffer is a good size.
|
||||||
audioIsStereo = (idealFormat.channelCount() > 1) && speaker->get_is_stereo();
|
audioIsStereo = (idealFormat.channelCount() > 1) && speaker->get_is_stereo();
|
||||||
audioIs8bit = idealFormat.sampleSize() < 16;
|
audioIs8bit = idealFormat.sampleSize() < 16;
|
||||||
const int samplesPerBuffer = 65536;
|
const int samplesPerBuffer = 512;
|
||||||
speaker->set_output_rate(idealFormat.sampleRate(), samplesPerBuffer, audioIsStereo);
|
speaker->set_output_rate(idealFormat.sampleRate(), samplesPerBuffer, audioIsStereo);
|
||||||
|
|
||||||
// Adjust format appropriately, and create an audio output.
|
// Adjust format appropriately, and create an audio output.
|
||||||
@ -322,7 +322,13 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
|
|||||||
case QEvent::User: {
|
case QEvent::User: {
|
||||||
const auto audioEvent = dynamic_cast<AudioEvent *>(event);
|
const auto audioEvent = dynamic_cast<AudioEvent *>(event);
|
||||||
if(audioEvent) {
|
if(audioEvent) {
|
||||||
audioIODevice->write(reinterpret_cast<const char *>(audioEvent->audio.data()), qint64(audioEvent->audio.size()));
|
const char *buffer = reinterpret_cast<const char *>(audioEvent->audio.data());
|
||||||
|
size_t sizeLeft = audioEvent->audio.size() * sizeof(int16_t);
|
||||||
|
while(sizeLeft) {
|
||||||
|
const auto bytesWritten = audioIODevice->write(buffer, qint64(sizeLeft));
|
||||||
|
sizeLeft -= bytesWritten;
|
||||||
|
buffer += bytesWritten;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user