Rakashazi / emu-ex-plus-alpha

Multi-platform computer & game console emulation system including supporting code (EmuFramework) and core engine (Imagine)
GNU General Public License v3.0
600 stars 145 forks source link

build all emu no sound? #178

Closed ghost closed 3 years ago

ghost commented 3 years ago

why? build with ubuntu 20.04.1 android studio is latest. phone system is lineageos 17.1 latest. not change emu source code.

emu run well, but only no sound out. graphics and controls is okay.

ghost commented 3 years ago

i build many more then i found problem is: Add AAudio API support for Android 8.0+ devices this commit make sound not output with android 10.

ghost commented 3 years ago

okay~~ i delete two fuction from imagine/src/audio/AndroidAudioManager.cc

if(Base::androidSDK() >= 26) { desc.reserve(2); desc.emplace_back("AAudio", Api::AAUDIO); }

and

if(Base::androidSDK() >= 26) { if(api == Api::OPENSL_ES) return Api::OPENSL_ES; // OpenSL ES was explicitly requested return Api::AAUDIO; }

then build from latest source, that work fine. so i think that is aaudio's bug.

Rakashazi commented 3 years ago

Hi, can you compile it with AAudio again and send a logcat from when AAudioOutputStream::open() is called? This happens right after you load a game and emulation starts.

ghost commented 3 years ago

okay~ but where find logcat? sorry,I am not very good at compiling and using ubuntu... change source and make log output? or...?

Rakashazi commented 3 years ago

First make sure you install a debug build, not release, which is indicated by the "D" at the end of the version number on the main menu. Then with the device connected and USB debugging enabled, run adb logcat

In case you're unable to do that, create an empty file or directory called imagine_enable_log_file in the root of internal storage. This causes the app to log everything to a file imagine_log.txt instead.

ghost commented 3 years ago

fine. build system with VirtualBox 6.1.14. Ubuntu 20.04.1 and update all patch. android studio version is 4.0.1. install default package,and ndk 21.3 phone system is lineage os 17.1 with arm64 devices. install gapps. emu source is "Additional renderer texture updates and misc tweaks"this version. not change any emu source. all compilations completed normally without errors.

i use imagine_enable_log_file to make log, and not change any emu setting, only load game. some rom download from edgeemu.net, neo rom download from winkawaks.org.

gba.emu: game is Pokemon - Emerald Version (USA, Europe).gba. enter new game screen. log file: https://github.com/DogUoUo/temptest/blob/master/GBA_imagine_log.txt

md.emu: game is Sonic The Hedgehog (USA, Europe).md. enter game act.1 and play sonic kill by monster. log file: https://github.com/DogUoUo/temptest/blob/master/MD_imagine_log.txt

neo.emu: game is kof97. only select bios is unibios 3.3, and enter game fight, maybe play 20 sec. log file: https://github.com/DogUoUo/temptest/blob/master/NEO_imagine_log.txt

nes.emu: game is Super Mario Bros. (World).nes. play finish the world 1-1. log file: https://github.com/DogUoUo/temptest/blob/master/NES_imagine_log.txt

every log file is only for that .emu, when i change emu, and delete old log file, then emu make new file. hm......still no sound out. other .emu had same bug, but i only build this fours.

there is that four emu apk file: https://github.com/DogUoUo/temptest unpack need winrar 5.91, maybe you need this?

I think these should be detailed enough to help you find bugs…… ^-^

Rakashazi commented 3 years ago

Thanks for the logs. I don't see any AAudio errors so it's strange there's no sound output. Let's try disabling exclusive mode in case the there's some kind of driver issue related to that. Find AAudioOutputStream::openStream in aaudio.cc and comment out this section:

if(lowLatencyMode)
{
    AAudioStreamBuilder_setPerformanceMode(builder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
    AAudioStreamBuilder_setSharingMode(builder, AAUDIO_SHARING_MODE_EXCLUSIVE);
}

Then recompile and check if there's any sound.

ghost commented 3 years ago

hm…… okay,i install build apk to another device. that device is android 6.0 official original system, and that sound work fine.

so~ i remember i delete my phone some system apk, i don't know that problem is this? but another emu apk's like ps emu, wii emu, nds emu……all work fine…and normal game work fine too.

now…maybe I should refresh the phone system again, without deleting any system programs, and test again? or the problem is incompatibility with the source code of lineageos?

I will test the exclusive mode later, thank you for your help, I like your emulator series very much, i play many more classic games so happy~~

by the way, sorry for my so bad english……

Rakashazi commented 3 years ago

No problem, you'll need to test another app that uses the AAudio API to make sure it's working properly. Since it was only added in API level 26 I don't think any other games or emulators use it yet. I've linked a compiled APK of the AAudio sample app from the Android high performance audio repo. Please try it out and check if you hear a sine wave when touching the screen.

https://drive.google.com/file/d/1fQUB3R0ZDF1PssvwZ3B3P2uzVXHlJ7gu/view

ghost commented 3 years ago

no, my phone can't hear sample app any sound. i choose different playback device and buffer size.

but anothe phone, it's huawei p30, system is android 10.0, this can hear sound. i think bug maybe 100% is lineageos's bug, i'm late some day must reflash my phone to test aaudio......

by the way, when select playback device to telephony, that show latency is 16001254985(37~46).(random)ms, this is so long~~

Rakashazi commented 3 years ago

It's probably a bug with LineageOS but let me know if it gets fixed in a future version. For now, I've added an option to change the audio driver between OpenSL ES and AAudio to work around the issue.