Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
5619fd0b
Commit
5619fd0b
authored
Mar 23, 2020
by
Thomas Guillem
Committed by
Max Kellermann
Mar 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
android: Context: add GetAudioManager
parent
200258c7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
Context.cxx
src/android/Context.cxx
+21
-0
Context.hxx
src/android/Context.hxx
+4
-0
No files found.
src/android/Context.cxx
View file @
5619fd0b
...
...
@@ -20,8 +20,11 @@
#include "Context.hxx"
#include "java/Class.hxx"
#include "java/File.hxx"
#include "java/String.hxx"
#include "fs/AllocatedPath.hxx"
#include "AudioManager.hxx"
AllocatedPath
Context
::
GetCacheDir
(
JNIEnv
*
env
)
const
noexcept
{
...
...
@@ -40,3 +43,21 @@ Context::GetCacheDir(JNIEnv *env) const noexcept
return
Java
::
File
::
ToAbsolutePath
(
env
,
file
);
}
AudioManager
*
Context
::
GetAudioManager
(
JNIEnv
*
env
)
noexcept
{
assert
(
env
!=
nullptr
);
Java
::
Class
cls
(
env
,
env
->
GetObjectClass
(
Get
()));
jmethodID
method
=
env
->
GetMethodID
(
cls
,
"getSystemService"
,
"(Ljava/lang/String;)Ljava/lang/Object;"
);
assert
(
method
);
Java
::
String
name
(
env
,
"audio"
);
jobject
am
=
env
->
CallObjectMethod
(
Get
(),
method
,
name
.
Get
());
if
(
Java
::
DiscardException
(
env
)
||
am
==
nullptr
)
return
nullptr
;
return
new
AudioManager
(
env
,
am
);
}
src/android/Context.hxx
View file @
5619fd0b
...
...
@@ -23,6 +23,7 @@
#include "java/Object.hxx"
class
AllocatedPath
;
class
AudioManager
;
class
Context
:
public
Java
::
GlobalObject
{
public
:
...
...
@@ -31,6 +32,9 @@ public:
gcc_pure
AllocatedPath
GetCacheDir
(
JNIEnv
*
env
)
const
noexcept
;
gcc_pure
AudioManager
*
GetAudioManager
(
JNIEnv
*
env
)
noexcept
;
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment