Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential fix for White Screen with RtAudio enabled #179

Open
ekirts-h opened this issue Oct 27, 2024 · 1 comment
Open

Potential fix for White Screen with RtAudio enabled #179

ekirts-h opened this issue Oct 27, 2024 · 1 comment

Comments

@ekirts-h
Copy link

ekirts-h commented Oct 27, 2024

Issue

Make sure you are running the latest version before reporting an issue.

Hardware

Device Connection Method Screen Mobile Device Android Auto Version
Raspberry Pi 4 2GB USB Cable/wireless 7" Screen pixel 7 v.1.EXAMPLE
Raspberry Pi 3 1GB USB Cable 7" Screen pixel 7 / redmi 9t v.1.EXAMPLE
x86 laptop USB Cable - pixel 7 / redmi 9t v.1.EXAMPLE

Installation Method: Install.sh

Description of problem:

White screen is displayed in place of AA when RtAudio is enabled

Expected Result:

AA is displayed

Problem-relevant steps to reproduce:

enable RtAudio in AA page settings

Additional info:

This fix seems to be working consistently for me testing on ubuntu x86 for debugging, pi4 2gb in use as dash and on a spare rpi3 with fresh raspberry pi os installation.
Only pi4 was tested with wireless connection.

Changing this line in openauto/openauto/Projection/RtAudioOutput.cpp (line 36) from LINUX_PULSE to LINUX_ALSA has fixed the white screen problem for me and is working consistently.

    dac_ = std::find(apis.begin(), apis.end(), RtAudio::LINUX_PULSE) == apis.end() ? std::make_unique<RtAudio>() : std::make_unique<RtAudio>(RtAudio::LINUX_PULSE);

to

    dac_ = std::find(apis.begin(), apis.end(), RtAudio::LINUX_ALSA) == apis.end() ? std::make_unique<RtAudio>() : std::make_unique<RtAudio>(RtAudio::LINUX_ALSA);

With pulse when open() is called it seems to fail at if(dac_->getDeviceCount() > 0) for the first two calls completely skipping them then proceeds with third call with devicecount = 1 for samplerate = 16k.
I also tested calling it before the if satetement and placing the value into a int variable with try catch but same thing happens.
When this happens and the video output section is called it seems nothing is processed (no video stream opened) so a white screen is displayed instead, noticed this when with QTAudio is enabled h264 header replacement code is called but not with RtAudio.

bool RtAudioOutput::open()
{
    std::lock_guard<decltype(mutex_)> lock(mutex_);

    if(dac_->getDeviceCount() > 0)
    {
        RtAudio::StreamParameters parameters;
        parameters.deviceId = dac_->getDefaultOutputDevice();
        parameters.nChannels = channelCount_;
        parameters.firstChannel = 0;

        try
        {
            RtAudio::StreamOptions streamOptions;
            streamOptions.flags = RTAUDIO_MINIMIZE_LATENCY | RTAUDIO_SCHEDULE_REALTIME;
            uint32_t bufferFrames = sampleRate_ == 16000 ? 1024 : 2048; //according to the observation of audio packets
            dac_->openStream(&parameters, nullptr, RTAUDIO_SINT16, sampleRate_, &bufferFrames, &RtAudioOutput::audioBufferReadHandler, static_cast<void*>(this), &streamOptions);
            return audioBuffer_.open(QIODevice::ReadWrite);
        }
        catch(const RtAudioError& e)
        {
            OPENAUTO_LOG(error) << "[RtAudioOutput] Failed to open audio output, what: " << e.what();
        }
    }
    else
    {
        OPENAUTO_LOG(error) << "[RtAudioOutput] No output devices found.";
    }

    return false;
}
@memtech3
Copy link
Contributor

related to #171

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants