Skip to content

Commit

Permalink
ensure MediaInstance is audio before using it
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattkc committed Dec 12, 2024
1 parent 41c9e54 commit e09b50e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions app/viewer/mediapanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,16 +812,18 @@ qint64 MediaAudioMixer::readData(char *data, qint64 maxSize)
for (auto it = m_mediaInstances->cbegin(); it != m_mediaInstances->cend(); it++) {
auto m = *it;

qint64 thisRead = m->ReadAudio(reinterpret_cast<char *>(tmp), maxSize);
if (thisRead > touchedBytes) {
memset(data + touchedBytes, 0, thisRead - touchedBytes);
touchedBytes = thisRead;
}

// TODO: Optimize with SSE and NEON
qint64 thisSamples = thisRead / m_audioFormat.bytesPerSample();
for (qint64 j = 0; j < thisSamples; j++) {
output[j] += tmp[j] * m->GetVolume();
if (m->codec_type() == AVMEDIA_TYPE_AUDIO) {
qint64 thisRead = m->ReadAudio(reinterpret_cast<char *>(tmp), maxSize);
if (thisRead > touchedBytes) {
memset(data + touchedBytes, 0, thisRead - touchedBytes);
touchedBytes = thisRead;
}

// TODO: Optimize with SSE and NEON
qint64 thisSamples = thisRead / m_audioFormat.bytesPerSample();
for (qint64 j = 0; j < thisSamples; j++) {
output[j] += tmp[j] * m->GetVolume();
}
}
}

Expand Down

0 comments on commit e09b50e

Please sign in to comment.