Home | History | Annotate | Download | only in audio
      1 /*
      2  * Copyright (C) 2012 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
      5  * use this file except in compliance with the License. You may obtain a copy of
      6  * 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, WITHOUT
     12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     13  * License for the specific language governing permissions and limitations under
     14  * the License.
     15  */
     16 
     17 #include "Log.h"
     18 #include "audio/AudioRemote.h"
     19 #include "audio/RemoteAudio.h"
     20 
     21 bool AudioRemote::prepare(AudioHardware::SamplingRate samplingRate, int volume, int mode)
     22 {
     23     if (mRemote == NULL) {
     24         LOGE("AudioRemote::prepare mRemote NULL");
     25         return false;
     26     }
     27     mSamplingRate = samplingRate;
     28     mVolume = volume;
     29     mMode = mode;
     30     return true;
     31 }
     32 
     33 AudioRemote::AudioRemote(android::sp<RemoteAudio>& remote)
     34     : mRemote(remote)
     35 {
     36 
     37 }
     38 
     39 AudioRemotePlayback::AudioRemotePlayback(android::sp<RemoteAudio>& remote)
     40     : AudioRemote(remote)
     41 {
     42 
     43 }
     44 
     45 bool AudioRemotePlayback::startPlaybackOrRecord(android::sp<Buffer>& buffer, int numberRepetition)
     46 {
     47     //TODO not supported for the moment
     48     return false;
     49 }
     50 
     51 bool AudioRemotePlayback::waitForCompletion()
     52 {
     53     return mRemote->waitForPlaybackCompletion();
     54 }
     55 
     56 void AudioRemotePlayback::stopPlaybackOrRecord()
     57 {
     58     mRemote->stopPlayback();
     59 }
     60 
     61 bool AudioRemotePlayback::startPlaybackForRemoteData(int id, bool stereo, int numberRepetition)
     62 {
     63     return mRemote->startPlayback(stereo, mSamplingRate, mMode, mVolume, id, numberRepetition);
     64 }
     65 
     66 AudioRemoteRecording::AudioRemoteRecording(android::sp<RemoteAudio>& remote)
     67     : AudioRemote(remote)
     68 {
     69 
     70 }
     71 
     72 bool AudioRemoteRecording::startPlaybackOrRecord(android::sp<Buffer>& buffer,
     73         int /*numberRepetition*/)
     74 {
     75     bool stereo = buffer->isStereo();
     76     return mRemote->startRecording(stereo, mSamplingRate, mMode, mVolume, buffer);
     77 }
     78 
     79 bool AudioRemoteRecording::waitForCompletion()
     80 {
     81     return mRemote->waitForRecordingCompletion();
     82 }
     83 
     84 void AudioRemoteRecording::stopPlaybackOrRecord()
     85 {
     86     mRemote->stopRecording();
     87 }
     88 
     89 
     90 
     91