Home | History | Annotate | Download | only in media
      1 /*
      2  * Copyright (C) 2007 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 #ifndef ANDROID_IAUDIOTRACK_H
     18 #define ANDROID_IAUDIOTRACK_H
     19 
     20 #include <stdint.h>
     21 #include <sys/types.h>
     22 
     23 #include <utils/RefBase.h>
     24 #include <utils/Errors.h>
     25 #include <binder/IInterface.h>
     26 #include <binder/IMemory.h>
     27 #include <utils/String8.h>
     28 #include <media/AudioTimestamp.h>
     29 #include <media/VolumeShaper.h>
     30 
     31 namespace android {
     32 
     33 // ----------------------------------------------------------------------------
     34 
     35 class IAudioTrack : public IInterface
     36 {
     37 public:
     38     DECLARE_META_INTERFACE(AudioTrack);
     39 
     40     /* Get this track's control block */
     41     virtual sp<IMemory> getCblk() const = 0;
     42 
     43     /* After it's created the track is not active. Call start() to
     44      * make it active.
     45      */
     46     virtual status_t    start() = 0;
     47 
     48     /* Stop a track. If set, the callback will cease being called and
     49      * obtainBuffer will return an error. Buffers that are already released
     50      * will continue to be processed, unless/until flush() is called.
     51      */
     52     virtual void        stop() = 0;
     53 
     54     /* Flush a stopped or paused track. All pending/released buffers are discarded.
     55      * This function has no effect if the track is not stopped or paused.
     56      */
     57     virtual void        flush() = 0;
     58 
     59     /* Pause a track. If set, the callback will cease being called and
     60      * obtainBuffer will return an error. Buffers that are already released
     61      * will continue to be processed, unless/until flush() is called.
     62      */
     63     virtual void        pause() = 0;
     64 
     65     /* Attach track auxiliary output to specified effect. Use effectId = 0
     66      * to detach track from effect.
     67      */
     68     virtual status_t    attachAuxEffect(int effectId) = 0;
     69 
     70     /* Send parameters to the audio hardware */
     71     virtual status_t    setParameters(const String8& keyValuePairs) = 0;
     72 
     73     /* Return NO_ERROR if timestamp is valid.  timestamp is undefined otherwise. */
     74     virtual status_t    getTimestamp(AudioTimestamp& timestamp) = 0;
     75 
     76     /* Signal the playback thread for a change in control block */
     77     virtual void        signal() = 0;
     78 
     79     /* Sets the volume shaper */
     80     virtual media::VolumeShaper::Status applyVolumeShaper(
     81             const sp<media::VolumeShaper::Configuration>& configuration,
     82             const sp<media::VolumeShaper::Operation>& operation) = 0;
     83 
     84     /* gets the volume shaper state */
     85     virtual sp<media::VolumeShaper::State> getVolumeShaperState(int id) = 0;
     86 };
     87 
     88 // ----------------------------------------------------------------------------
     89 
     90 class BnAudioTrack : public BnInterface<IAudioTrack>
     91 {
     92 public:
     93     virtual status_t    onTransact( uint32_t code,
     94                                     const Parcel& data,
     95                                     Parcel* reply,
     96                                     uint32_t flags = 0);
     97 };
     98 
     99 // ----------------------------------------------------------------------------
    100 
    101 }; // namespace android
    102 
    103 #endif // ANDROID_IAUDIOTRACK_H
    104