Home | History | Annotate | Download | only in audio
      1 /*
      2  * Copyright (C) 2011 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 #define LOG_TAG "AudioPolicyCompatClient"
     18 //#define LOG_NDEBUG 0
     19 
     20 #include <stdint.h>
     21 
     22 #include <hardware/hardware.h>
     23 #include <system/audio.h>
     24 #include <system/audio_policy.h>
     25 #include <hardware/audio_policy.h>
     26 
     27 #include <hardware_legacy/AudioSystemLegacy.h>
     28 
     29 #include "AudioPolicyCompatClient.h"
     30 
     31 namespace android_audio_legacy {
     32 
     33 audio_module_handle_t AudioPolicyCompatClient::loadHwModule(const char *moduleName)
     34 {
     35     return mServiceOps->load_hw_module(mService, moduleName);
     36 }
     37 
     38 audio_io_handle_t AudioPolicyCompatClient::openOutput(audio_module_handle_t module,
     39                                                       audio_devices_t *pDevices,
     40                                                       uint32_t *pSamplingRate,
     41                                                       audio_format_t *pFormat,
     42                                                       audio_channel_mask_t *pChannelMask,
     43                                                       uint32_t *pLatencyMs,
     44                                                       audio_output_flags_t flags,
     45                                                       const audio_offload_info_t *offloadInfo)
     46 {
     47     return mServiceOps->open_output_on_module(mService, module, pDevices, pSamplingRate,
     48                                               pFormat, pChannelMask, pLatencyMs,
     49                                               flags, offloadInfo);
     50 }
     51 
     52 audio_io_handle_t AudioPolicyCompatClient::openDuplicateOutput(audio_io_handle_t output1,
     53                                                           audio_io_handle_t output2)
     54 {
     55     return mServiceOps->open_duplicate_output(mService, output1, output2);
     56 }
     57 
     58 status_t AudioPolicyCompatClient::closeOutput(audio_io_handle_t output)
     59 {
     60     return mServiceOps->close_output(mService, output);
     61 }
     62 
     63 status_t AudioPolicyCompatClient::suspendOutput(audio_io_handle_t output)
     64 {
     65     return mServiceOps->suspend_output(mService, output);
     66 }
     67 
     68 status_t AudioPolicyCompatClient::restoreOutput(audio_io_handle_t output)
     69 {
     70     return mServiceOps->restore_output(mService, output);
     71 }
     72 
     73 audio_io_handle_t AudioPolicyCompatClient::openInput(audio_module_handle_t module,
     74                                                      audio_devices_t *pDevices,
     75                                                      uint32_t *pSamplingRate,
     76                                                      audio_format_t *pFormat,
     77                                                      audio_channel_mask_t *pChannelMask)
     78 {
     79     return mServiceOps->open_input_on_module(mService, module, pDevices,
     80                                              pSamplingRate, pFormat, pChannelMask);
     81 }
     82 
     83 status_t AudioPolicyCompatClient::closeInput(audio_io_handle_t input)
     84 {
     85     return mServiceOps->close_input(mService, input);
     86 }
     87 
     88 status_t AudioPolicyCompatClient::setStreamOutput(AudioSystem::stream_type stream,
     89                                              audio_io_handle_t output)
     90 {
     91     return mServiceOps->set_stream_output(mService, (audio_stream_type_t)stream,
     92                                           output);
     93 }
     94 
     95 status_t AudioPolicyCompatClient::moveEffects(int session, audio_io_handle_t srcOutput,
     96                                                audio_io_handle_t dstOutput)
     97 {
     98     return mServiceOps->move_effects(mService, session, srcOutput, dstOutput);
     99 }
    100 
    101 String8 AudioPolicyCompatClient::getParameters(audio_io_handle_t ioHandle, const String8& keys)
    102 {
    103     char *str;
    104     String8 out_str8;
    105 
    106     str = mServiceOps->get_parameters(mService, ioHandle, keys.string());
    107     out_str8 = String8(str);
    108     free(str);
    109 
    110     return out_str8;
    111 }
    112 
    113 void AudioPolicyCompatClient::setParameters(audio_io_handle_t ioHandle,
    114                                             const String8& keyValuePairs,
    115                                             int delayMs)
    116 {
    117     mServiceOps->set_parameters(mService, ioHandle, keyValuePairs.string(),
    118                            delayMs);
    119 }
    120 
    121 status_t AudioPolicyCompatClient::setStreamVolume(
    122                                              AudioSystem::stream_type stream,
    123                                              float volume,
    124                                              audio_io_handle_t output,
    125                                              int delayMs)
    126 {
    127     return mServiceOps->set_stream_volume(mService, (audio_stream_type_t)stream,
    128                                           volume, output, delayMs);
    129 }
    130 
    131 status_t AudioPolicyCompatClient::startTone(ToneGenerator::tone_type tone,
    132                                        AudioSystem::stream_type stream)
    133 {
    134     return mServiceOps->start_tone(mService,
    135                                    AUDIO_POLICY_TONE_IN_CALL_NOTIFICATION,
    136                                    (audio_stream_type_t)stream);
    137 }
    138 
    139 status_t AudioPolicyCompatClient::stopTone()
    140 {
    141     return mServiceOps->stop_tone(mService);
    142 }
    143 
    144 status_t AudioPolicyCompatClient::setVoiceVolume(float volume, int delayMs)
    145 {
    146     return mServiceOps->set_voice_volume(mService, volume, delayMs);
    147 }
    148 
    149 }; // namespace android_audio_legacy
    150