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

Android: fix audio metatable being covered #698

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

clang-clang-clang
Copy link
Contributor

@clang-clang-clang clang-clang-clang commented Apr 26, 2024

The metatable for Android audio2 overwrites the metatable for audio, causing the following properties (obtained by __index) to get incorrectly:

audio.freeChannels
audio.unreservedFreeChannels
audio.usedChannels
audio.unreservedUsedChannels
audio.totalChannels
audio.reservedChannels
audio.supportsSessionProperty

And an error prints:

Unsupported key: supportsSessionProperty in audio library

when obtaining the supportsSessionProperty instead of return false:

if supportsSessionProperty == true then
	audio.setSessionProperty(audio.MixMode, audio.AmbientMixMode)
end

AFAIK, there should be no side effects other than affecting the acquisition of the above properties.
However, it is still necessary to be cautious about merging, because it is possible to break previous usage, although the previous value is always wrong.


Tested with Media/AudioPlayer and the following new lines:

timer.performWithDelay( 1000, function()
    print( "---------------------------------------------------------------------------------------" )
    print( "freeChannels:", audio.freeChannels, audio2.freeChannels )
    print( "totalChannels:", audio.totalChannels, audio2.totalChannels )
    print( "unreservedFreeChannels:", audio.unreservedFreeChannels, audio2.unreservedFreeChannels )
    print( "unreservedUsedChannels:", audio.unreservedUsedChannels, audio2.unreservedUsedChannels )
    print( "usedChannels:", audio.usedChannels, audio2.usedChannels )
    print( "reservedChannels:", audio.reservedChannels, audio2.reservedChannels )
end, 0)

Related to:

  1. audio.reserveChannels and audio.reservedChannels don't agree

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

Successfully merging this pull request may close these issues.

None yet

1 participant