Hello Sirs,
We’re developing an application using C++ for backend and QML for frontend.
In this application we’ll play some audios which format is WAV and length from
1 to 5 secs.
The problem is that when an audio will be played after no audio was played
before under ~6 seconds, it is delayed about ~2 seconds before starting
playing. So If the audio is played constantly, it has no delay.
Follows below two C++ functions, the first one (loadSystemSounds) is executed
in constructor’s class, the second function is a SLOT that’s called from QML
when a button is clicked.
As you can see, I’m debbuging the sound status before calling the play
function, and it’s always loaded and ready to play (status = 2 =
QSoundEffect::Ready).
private:
void TerminalManager::loadSystemSounds()
{
clickSoundUrl.setUrl("qrc:/sounds/SOUND_CLICK_2.wav");
clickSound.setSource(clickSoundUrl);
}
public slots:
void TerminalManager::playClickSound()
{
if(clickSound.isPlaying()){
clickSound.stop();
clickSound.play();
}else {
clickSound.play();
}
}
private:
void TerminalManager::loadSystemSounds()
{
qDebug() << clickSound.status();
clickSoundUrl.setUrl("qrc:/sounds/SOUND_CLICK_2.wav");
clickSound.setSource(clickSoundUrl);
}
void TerminalManager::loadSystemSounds()
{
clickSoundUrl.setUrl("qrc:/sounds/SOUND_CLICK_2.wav");
clickSound.setSource(clickSoundUrl);
}
void TerminalManager::playClickSound()
{
qDebug() << clickSound.status();
if(clickSound.isPlaying()){
clickSound.stop();
clickSound.play();
}else {
clickSound.play();
}
}
We’re using pulseaudio, there’s any configuration to be set on
pulseaudio to work properly with Qt?
One important detail that we’ve tested.
We put the oscilloscope on the pin module - pin15 - output for headphone left.
This pin Toradex recommend to use for audio system.
At stand-by mode, this pin have the level 0 (0V). When I play one sound, this
pin goes to level 1 (3.3V). After 5 seconds, this pin return to 0V.
If you play a sound before this 5 seconds, the module maintain this pin in
3.3V - and the delay doesn’t occur.
But, the delay every occurs when this pin is 0V.
So, I think maybe have one configuration about this (delay time to pin go to
0)
Are there any important configuration for this .. or for SGTL500??
In terms of audio, we enabled alsa and pulseaudio using:
IMAGE_INSTALL_append = "
pulseaudio pulseaudio-server pulseaudio-misc pulseaudio-module-dbus-protocol
alsa-tools alsa-utils \ "
Regards,
