mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 17:58:43 -05:00
DATV demod: use just ffmpeg buffer for audio
This commit is contained in:
parent
a04605f6ca
commit
debc5c74f1
@ -651,45 +651,44 @@ bool DATVideoRender::RenderStream()
|
|||||||
|
|
||||||
if (gotFrame)
|
if (gotFrame)
|
||||||
{
|
{
|
||||||
int16_t *audioBuffer;
|
int16_t *audioBuffer = nullptr;
|
||||||
av_samples_alloc((uint8_t**) &audioBuffer, nullptr, 2, m_frame->nb_samples, AV_SAMPLE_FMT_S16, 0);
|
av_samples_alloc((uint8_t**) &audioBuffer, nullptr, 2, m_frame->nb_samples, AV_SAMPLE_FMT_S16, 0);
|
||||||
int frame_count = swr_convert(m_audioSWR, (uint8_t**) &audioBuffer, m_frame->nb_samples, (const uint8_t**) m_frame->data, m_frame->nb_samples);
|
int samples_per_channel = swr_convert(m_audioSWR, (uint8_t**) &audioBuffer, m_frame->nb_samples, (const uint8_t**) m_frame->data, m_frame->nb_samples);
|
||||||
|
if (samples_per_channel < m_frame->nb_samples) {
|
||||||
|
qDebug("DATVideoRender::RenderStream: converted samples missing %d/%d returned", samples_per_channel, m_frame->nb_samples);
|
||||||
|
}
|
||||||
|
|
||||||
// direct writing:
|
// direct writing:
|
||||||
// int ret = m_audioFifo->write((const quint8*) &audioBuffer[0], frame_count);
|
std::for_each(audioBuffer, audioBuffer + 2*samples_per_channel, [this](int16_t &x) {
|
||||||
|
x *= m_audioVolume;
|
||||||
// if (ret < frame_count) {
|
});
|
||||||
// qDebug("DATVideoRender::RenderStream: audio frames missing %d vs %d", ret, frame_count);
|
int ret = m_audioFifo->write((const quint8*) &audioBuffer[0], samples_per_channel);
|
||||||
// }
|
if (ret < samples_per_channel) {
|
||||||
|
qDebug("DATVideoRender::RenderStream: audio samples missing %d/%d written", ret, samples_per_channel);
|
||||||
|
}
|
||||||
|
|
||||||
// buffered writing:
|
// buffered writing:
|
||||||
// if (m_audioFifoBufferIndex + frame_count < m_audioFifoBufferSize)
|
// if (m_audioFifoBufferIndex + samples_per_channel < m_audioFifoBufferSize)
|
||||||
// {
|
// {
|
||||||
// std::copy(&audioBuffer[0], &audioBuffer[2*frame_count], &m_audioFifoBuffer[2*m_audioFifoBufferIndex]);
|
// std::copy(&audioBuffer[0], &audioBuffer[2*samples_per_channel], &m_audioFifoBuffer[2*m_audioFifoBufferIndex]);
|
||||||
// m_audioFifoBufferIndex += frame_count;
|
// m_audioFifoBufferIndex += samples_per_channel;
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// int remainder = m_audioFifoBufferSize - m_audioFifoBufferIndex;
|
// int remainder = m_audioFifoBufferSize - m_audioFifoBufferIndex;
|
||||||
// std::copy(&audioBuffer[0], &audioBuffer[2*remainder], &m_audioFifoBuffer[2*m_audioFifoBufferIndex]);
|
// std::copy(&audioBuffer[0], &audioBuffer[2*remainder], &m_audioFifoBuffer[2*m_audioFifoBufferIndex]);
|
||||||
// m_audioFifo->write((const quint8*) &m_audioFifoBuffer[0], m_audioFifoBufferSize);
|
// std::for_each(m_audioFifoBuffer, m_audioFifoBuffer+2*m_audioFifoBufferSize, [this](int16_t &x) {
|
||||||
// std::copy(&audioBuffer[2*remainder], &audioBuffer[2*frame_count], &m_audioFifoBuffer[0]);
|
// x *= m_audioVolume;
|
||||||
// m_audioFifoBufferIndex = frame_count - remainder;
|
// });
|
||||||
|
// int ret = m_audioFifo->write((const quint8*) &m_audioFifoBuffer[0], m_audioFifoBufferSize);
|
||||||
|
// if (ret < m_audioFifoBufferSize) {
|
||||||
|
// qDebug("DATVideoRender::RenderStream: audio samples missing %d/%d written", ret, m_audioFifoBufferSize);
|
||||||
|
// }
|
||||||
|
// std::copy(&audioBuffer[2*remainder], &audioBuffer[2*samples_per_channel], &m_audioFifoBuffer[0]);
|
||||||
|
// m_audioFifoBufferIndex = samples_per_channel - remainder;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Apply volume:
|
av_freep(&audioBuffer);
|
||||||
for (int i = 0; i < frame_count; i++)
|
|
||||||
{
|
|
||||||
m_audioFifoBuffer[2*m_audioFifoBufferIndex] = m_audioVolume * audioBuffer[2*i];
|
|
||||||
m_audioFifoBuffer[2*m_audioFifoBufferIndex+1] = m_audioVolume * audioBuffer[2*i+1];
|
|
||||||
m_audioFifoBufferIndex++;
|
|
||||||
|
|
||||||
if (m_audioFifoBufferIndex >= m_audioFifoBufferSize)
|
|
||||||
{
|
|
||||||
m_audioFifo->write((const quint8*) &m_audioFifoBuffer[0], m_audioFifoBufferSize);
|
|
||||||
m_audioFifoBufferIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user