• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "chre_api/chre/audio.h"
18 
19 #include "chre/core/event_loop_manager.h"
20 #include "chre/util/macros.h"
21 
22 #ifdef CHRE_AUDIO_SUPPORT_ENABLED
23 #include "chre/platform/platform_audio.h"
24 #endif  // CHRE_AUDIO_SUPPORT_ENABLED
25 
26 using chre::EventLoopManager;
27 using chre::EventLoopManagerSingleton;
28 using chre::Nanoapp;
29 
chreAudioGetSource(uint32_t handle,struct chreAudioSource * audioSource)30 DLL_EXPORT bool chreAudioGetSource(uint32_t handle,
31                                    struct chreAudioSource *audioSource) {
32 #ifdef CHRE_AUDIO_SUPPORT_ENABLED
33   bool success = false;
34   if (audioSource != nullptr) {
35     success = EventLoopManagerSingleton::get()
36                   ->getAudioRequestManager()
37                   .getAudioSource(handle, audioSource);
38   }
39 
40   return success;
41 #else
42   return false;
43 #endif  // CHRE_AUDIO_SUPPORT_ENABLED
44 }
45 
chreAudioConfigureSource(uint32_t handle,bool enable,uint64_t bufferDuration,uint64_t deliveryInterval)46 DLL_EXPORT bool chreAudioConfigureSource(uint32_t handle, bool enable,
47                                          uint64_t bufferDuration,
48                                          uint64_t deliveryInterval) {
49 #ifdef CHRE_AUDIO_SUPPORT_ENABLED
50   Nanoapp *nanoapp = EventLoopManager::validateChreApiCall(__func__);
51   return EventLoopManagerSingleton::get()
52       ->getAudioRequestManager()
53       .configureSource(nanoapp, handle, enable, bufferDuration,
54                        deliveryInterval);
55 #else
56   return false;
57 #endif  // CHRE_AUDIO_SUPPORT_ENABLED
58 }
59