| 1 | /** |
| 2 | * Copyright (c) 2006-2023 LOVE Development Team |
| 3 | * |
| 4 | * This software is provided 'as-is', without any express or implied |
| 5 | * warranty. In no event will the authors be held liable for any damages |
| 6 | * arising from the use of this software. |
| 7 | * |
| 8 | * Permission is granted to anyone to use this software for any purpose, |
| 9 | * including commercial applications, and to alter it and redistribute it |
| 10 | * freely, subject to the following restrictions: |
| 11 | * |
| 12 | * 1. The origin of this software must not be misrepresented; you must not |
| 13 | * claim that you wrote the original software. If you use this software |
| 14 | * in a product, an acknowledgment in the product documentation would be |
| 15 | * appreciated but is not required. |
| 16 | * 2. Altered source versions must be plainly marked as such, and must not be |
| 17 | * misrepresented as being the original software. |
| 18 | * 3. This notice may not be removed or altered from any source distribution. |
| 19 | **/ |
| 20 | |
| 21 | #include "Audio.h" |
| 22 | #include "common/config.h" |
| 23 | |
| 24 | #if defined(LOVE_IOS) |
| 25 | #include "common/ios.h" |
| 26 | #elif defined(LOVE_ANDROID) |
| 27 | #include "common/android.h" |
| 28 | #endif |
| 29 | |
| 30 | namespace love |
| 31 | { |
| 32 | namespace audio |
| 33 | { |
| 34 | |
| 35 | static bool requestRecPermission = false; |
| 36 | |
| 37 | void setRequestRecordingPermission(bool rec) |
| 38 | { |
| 39 | requestRecPermission = rec; |
| 40 | } |
| 41 | |
| 42 | bool getRequestRecordingPermission() |
| 43 | { |
| 44 | return requestRecPermission; |
| 45 | } |
| 46 | |
| 47 | bool hasRecordingPermission() |
| 48 | { |
| 49 | #if defined(LOVE_ANDROID) |
| 50 | return love::android::hasRecordingPermission(); |
| 51 | #else |
| 52 | // Always available(?) |
| 53 | return true; |
| 54 | #endif |
| 55 | } |
| 56 | |
| 57 | void requestRecordingPermission() |
| 58 | { |
| 59 | #ifdef LOVE_ANDROID |
| 60 | love::android::requestRecordingPermission(); |
| 61 | #endif |
| 62 | } |
| 63 | |
| 64 | void showRecordingPermissionMissingDialog() |
| 65 | { |
| 66 | #ifdef LOVE_ANDROID |
| 67 | love::android::showRecordingPermissionMissingDialog(); |
| 68 | #endif |
| 69 | } |
| 70 | |
| 71 | bool Audio::setMixWithSystem(bool mix) |
| 72 | { |
| 73 | #ifdef LOVE_IOS |
| 74 | return love::ios::setAudioMixWithOthers(mix); |
| 75 | #else |
| 76 | LOVE_UNUSED(mix); |
| 77 | return false; |
| 78 | #endif |
| 79 | } |
| 80 | |
| 81 | StringMap<Audio::DistanceModel, Audio::DISTANCE_MAX_ENUM>::Entry Audio::distanceModelEntries[] = |
| 82 | { |
| 83 | {"none" , Audio::DISTANCE_NONE}, |
| 84 | {"inverse" , Audio::DISTANCE_INVERSE}, |
| 85 | {"inverseclamped" , Audio::DISTANCE_INVERSE_CLAMPED}, |
| 86 | {"linear" , Audio::DISTANCE_LINEAR}, |
| 87 | {"linearclamped" , Audio::DISTANCE_LINEAR_CLAMPED}, |
| 88 | {"exponent" , Audio::DISTANCE_EXPONENT}, |
| 89 | {"exponentclamped" , Audio::DISTANCE_EXPONENT_CLAMPED} |
| 90 | }; |
| 91 | |
| 92 | StringMap<Audio::DistanceModel, Audio::DISTANCE_MAX_ENUM> Audio::distanceModels(Audio::distanceModelEntries, sizeof(Audio::distanceModelEntries)); |
| 93 | |
| 94 | bool Audio::getConstant(const char *in, DistanceModel &out) |
| 95 | { |
| 96 | return distanceModels.find(in, out); |
| 97 | } |
| 98 | |
| 99 | bool Audio::getConstant(DistanceModel in, const char *&out) |
| 100 | { |
| 101 | return distanceModels.find(in, out); |
| 102 | } |
| 103 | |
| 104 | std::vector<std::string> Audio::getConstants(DistanceModel) |
| 105 | { |
| 106 | return distanceModels.getNames(); |
| 107 | } |
| 108 | |
| 109 | } // audio |
| 110 | } // love |
| 111 | |