1 /* 2 * Copyright (C) 2020 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 #pragma once 18 #include <memory> 19 #include <tinyalsa/asoundlib.h> 20 21 namespace android { 22 namespace hardware { 23 namespace audio { 24 namespace V6_0 { 25 namespace implementation { 26 namespace talsa { 27 28 constexpr unsigned int kPcmDevice = 0; 29 constexpr unsigned int kPcmCard = 0; 30 31 typedef struct pcm pcm_t; 32 struct PcmDeleter { void operator()(pcm_t *x) const; }; 33 typedef std::unique_ptr<pcm_t, PcmDeleter> PcmPtr; 34 PcmPtr pcmOpen(unsigned int dev, unsigned int card, unsigned int nChannels, size_t sampleRateHz, size_t frameCount, bool isOut); 35 36 class Mixer { 37 public: 38 Mixer(unsigned card); 39 ~Mixer(); 40 41 operator bool() const { return mMixer != nullptr; } 42 43 Mixer(const Mixer &) = delete; 44 Mixer &operator=(const Mixer &) = delete; 45 Mixer(Mixer &&) = delete; 46 Mixer &operator=(Mixer &&) = delete; 47 48 private: 49 struct mixer *mMixer; 50 }; 51 52 } // namespace talsa 53 } // namespace implementation 54 } // namespace V6_0 55 } // namespace audio 56 } // namespace hardware 57 } // namespace android 58