Home | History | Annotate | Download | only in src
      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 #include "sles_allinclusive.h"
     18 
     19 // Handlers should return a mask of the attributes which they actually handled,
     20 // or ATTR_NONE if they did not completely handle the attribute change.
     21 
     22 #ifdef ANDROID
     23 
     24 // SL_OBJECTID_AUDIOPLAYER, ATTR_GAIN
     25 unsigned handler_AudioPlayer_gain(IObject *thiz)
     26 {
     27     CAudioPlayer *ap = (CAudioPlayer *) thiz;
     28     android_audioPlayer_volumeUpdate(ap);
     29     return ATTR_GAIN;
     30 }
     31 
     32 
     33 // SL_OBJECTID_OUTPUTMIX, ATTR_GAIN
     34 unsigned handler_OutputMix_gain(IObject *thiz)
     35 {
     36     // FIXME update gains on all players attached to this outputmix
     37     SL_LOGD("[ FIXME: gain update on an SL_OBJECTID_OUTPUTMIX to be implemented ]");
     38     return ATTR_GAIN;
     39 }
     40 
     41 
     42 // SL_OBJECTID_MIDIPLAYER, ATTR_GAIN
     43 unsigned handler_MidiPlayer_gain(IObject *thiz)
     44 {
     45     SL_LOGD("[ FIXME: gain update on an SL_OBJECTID_MIDIPLAYER to be implemented ]");
     46     return ATTR_GAIN;
     47 }
     48 
     49 
     50 // XA_OBJECTID_MEDIAPLAYER, ATTR_GAIN
     51 unsigned handler_MediaPlayer_gain(IObject *thiz)
     52 {
     53     CMediaPlayer *mp = (CMediaPlayer *) thiz;
     54     android_Player_volumeUpdate(mp);
     55     return ATTR_GAIN;
     56 }
     57 
     58 
     59 // SL_OBJECTID_AUDIOPLAYER, ATTR_POSITION
     60 unsigned handler_AudioPlayer_position(IObject *thiz)
     61 {
     62     CAudioPlayer *ap;
     63     ap = (CAudioPlayer *) thiz;
     64     // FIXME provide means to return result for invalid use cases (e.g. buffer queue data source)
     65     (void) android_audioPlayer_seek(ap, ap->mSeek.mPos);
     66     return ATTR_POSITION;
     67 }
     68 
     69 
     70 // SL_OBJECTID_MIDIPLAYER, ATTR_POSITION
     71 unsigned handler_MidiPlayer_position(IObject *thiz)
     72 {
     73     SL_LOGD("[ FIXME: position update on an SL_OBJECTID_MIDIPLAYER to be implemented ]");
     74     return ATTR_POSITION;
     75 }
     76 
     77 
     78 // SL_OBJECTID_AUDIOPLAYER, ATTR_TRANSPORT
     79 unsigned handler_AudioPlayer_transport(IObject *thiz)
     80 {
     81     CAudioPlayer *ap = (CAudioPlayer *) thiz;
     82     android_audioPlayer_usePlayEventMask(ap);
     83     return ATTR_TRANSPORT;
     84 }
     85 
     86 
     87 // SL_OBJECTID_AUDIOPLAYER, ATTR_PLAY_STATE
     88 unsigned handler_AudioPlayer_play_state(IObject *thiz)
     89 {
     90     CAudioPlayer *ap = (CAudioPlayer *) thiz;
     91     android_audioPlayer_setPlayState(ap);
     92     return ATTR_PLAY_STATE;
     93 }
     94 
     95 
     96 // SL_OBJECTID_AUDIORECORDER, ATTR_TRANSPORT
     97 unsigned handler_AudioRecorder_transport(IObject *thiz)
     98 {
     99     CAudioRecorder* ar = (CAudioRecorder *) thiz;
    100     android_audioRecorder_useRecordEventMask(ar);
    101     return ATTR_TRANSPORT;
    102 }
    103 
    104 
    105 // XA_OBJECTID_MEDIAPLAYER, ATTR_TRANSPORT
    106 unsigned handler_MediaPlayer_transport(IObject *thiz)
    107 {
    108     CMediaPlayer *mp = (CMediaPlayer *) thiz;
    109     android_Player_usePlayEventMask(mp);
    110     return ATTR_TRANSPORT;
    111 }
    112 
    113 
    114 // XA_OBJECTID_MEDIAPLAYER, ATTR_PLAY_STATE
    115 unsigned handler_MediaPlayer_play_state(IObject *thiz)
    116 {
    117     CMediaPlayer *mp = (CMediaPlayer *) thiz;
    118     android::GenericPlayer* avp = mp->mAVPlayer.get();
    119     if (avp != NULL) {
    120         android_Player_setPlayState(avp, mp->mPlay.mState, &mp->mAndroidObjState);
    121     }
    122     return ATTR_PLAY_STATE;
    123 }
    124 
    125 
    126 // SL_OBJECTID_AUDIOPLAYER, ATTR_BQ_ENQUEUE
    127 unsigned handler_AudioPlayer_bq_enqueue(IObject *thiz)
    128 {
    129     // ( buffer queue count is non-empty and play state == PLAYING ) became true
    130     CAudioPlayer *ap = (CAudioPlayer *) thiz;
    131     assert(SL_PLAYSTATE_PLAYING == ap->mPlay.mState);
    132     android_audioPlayer_bufferQueue_onRefilled_l(ap);
    133     return ATTR_BQ_ENQUEUE;
    134 }
    135 
    136 
    137 // SL_OBJECTID_AUDIOPLAYER, ATTR_ABQ_ENQUEUE
    138 unsigned handler_AudioPlayer_abq_enqueue(IObject *thiz)
    139 {
    140     // (Android buffer queue count is non-empty and play state == PLAYING ) became true
    141     CAudioPlayer *ap = (CAudioPlayer *) thiz;
    142     assert(SL_PLAYSTATE_PLAYING == ap->mPlay.mState);
    143     android_audioPlayer_androidBufferQueue_onRefilled_l(ap);
    144     return ATTR_ABQ_ENQUEUE;
    145 }
    146 
    147 
    148 // XA_OBJECTID_MEDIAPLAYER, ATTR_ABQ_ENQUEUE
    149 unsigned handler_MediaPlayer_abq_enqueue(IObject *thiz)
    150 {
    151     CMediaPlayer* mp = (CMediaPlayer *)thiz;
    152     if (SL_PLAYSTATE_PLAYING == mp->mPlay.mState) {
    153         android_Player_androidBufferQueue_onRefilled_l(mp);
    154     }
    155     return ATTR_ABQ_ENQUEUE;
    156 }
    157 
    158 // XA_OBJECTID_MEDIAPLAYER, ATTR_POSITION
    159 unsigned handler_MediaPlayer_position(IObject *thiz)
    160 {
    161     CMediaPlayer *mp = (CMediaPlayer *) thiz;
    162     // FIXME provide means to return result for invalid use cases (e.g. buffer queue data source)
    163     (void) android_Player_seek(mp, mp->mSeek.mPos);
    164     return ATTR_POSITION;
    165 }
    166 
    167 #else // !defined(ANDROID)
    168 
    169 // SL_OBJECTID_AUDIOPLAYER, ATTR_GAIN
    170 unsigned handler_AudioPlayer_gain(IObject *thiz)
    171 {
    172     CAudioPlayer *ap = (CAudioPlayer *) thiz;
    173     audioPlayerGainUpdate(ap);
    174     return ATTR_GAIN;
    175 }
    176 
    177 #endif
    178