handler_bodies.c revision 7b726bdcd996f1cab3a584c04ce1afc07bc8fbe7
17b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten/*
27b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten * Copyright (C) 2011 The Android Open Source Project
37b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten *
47b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten * Licensed under the Apache License, Version 2.0 (the "License");
57b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten * you may not use this file except in compliance with the License.
67b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten * You may obtain a copy of the License at
77b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten *
87b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten *      http://www.apache.org/licenses/LICENSE-2.0
97b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten *
107b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten * Unless required by applicable law or agreed to in writing, software
117b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten * distributed under the License is distributed on an "AS IS" BASIS,
127b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
137b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten * See the License for the specific language governing permissions and
147b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten * limitations under the License.
157b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten */
167b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
177b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten#include "sles_allinclusive.h"
187b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
197b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// Handlers should return a mask of the attributes which they actually handled,
207b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// or ATTR_NONE if they did not completely handle the attribute change.
217b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
227b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten#ifdef ANDROID
237b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
247b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_GAIN
257b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioPlayer_gain(IObject *thiz)
267b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{
277b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    CAudioPlayer *ap = (CAudioPlayer *) thiz;
287b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    android_audioPlayer_volumeUpdate(ap);
297b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    return ATTR_GAIN;
307b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten}
317b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
327b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
337b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_OUTPUTMIX, ATTR_GAIN
347b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_OutputMix_gain(IObject *thiz)
357b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{
367b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    // FIXME update gains on all players attached to this outputmix
377b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    SL_LOGD("[ FIXME: gain update on an SL_OBJECTID_OUTPUTMIX to be implemented ]");
387b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    return ATTR_GAIN;
397b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten}
407b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
417b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
427b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_MIDIPLAYER, ATTR_GAIN
437b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_MidiPlayer_gain(IObject *thiz)
447b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{
457b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    SL_LOGD("[ FIXME: gain update on an SL_OBJECTID_MIDIPLAYER to be implemented ]");
467b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    return ATTR_GAIN;
477b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten}
487b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
497b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
507b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// XA_OBJECTID_MEDIAPLAYER, ATTR_GAIN
517b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_MediaPlayer_gain(IObject *thiz)
527b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{
537b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    CMediaPlayer *mp = (CMediaPlayer *) thiz;
547b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    android::GenericPlayer* avp = mp->mAVPlayer.get();
557b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    if (avp != NULL) {
567b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten        android_Player_volumeUpdate(avp, &mp->mVolume);
577b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    }
587b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    return ATTR_GAIN;
597b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten}
607b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
617b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
627b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_POSITION
637b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioPlayer_position(IObject *thiz)
647b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{
657b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    CAudioPlayer *ap;
667b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    ap = (CAudioPlayer *) thiz;
677b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    android_audioPlayer_seek(ap, ap->mSeek.mPos);
687b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    return ATTR_POSITION;
697b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten}
707b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
717b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
727b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_MIDIPLAYER, ATTR_POSITION
737b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_MidiPlayer_position(IObject *thiz)
747b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{
757b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    SL_LOGD("[ FIXME: position update on an SL_OBJECTID_MIDIPLAYER to be implemented ]");
767b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    return ATTR_POSITION;
777b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten}
787b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
797b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
807b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_TRANSPORT
817b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioPlayer_transport(IObject *thiz)
827b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{
837b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    CAudioPlayer *ap = (CAudioPlayer *) thiz;
847b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    // FIXME should only call when state changes
857b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    android_audioPlayer_setPlayState(ap, false /*lockAP*/);
867b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    // FIXME ditto, but for either eventflags or marker position
877b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    android_audioPlayer_useEventMask(ap);
887b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    return ATTR_TRANSPORT;
897b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten}
907b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
917b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
927b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIORECORDER, ATTR_TRANSPORT
937b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioRecorder_transport(IObject *thiz)
947b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{
957b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    CAudioRecorder* ar = (CAudioRecorder *) thiz;
967b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    android_audioRecorder_useEventMask(ar);
977b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    return ATTR_TRANSPORT;
987b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten}
997b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
1007b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
1017b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// XA_OBJECTID_MEDIAPLAYER, ATTR_TRANSPORT
1027b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_MediaPlayer_transport(IObject *thiz)
1037b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{
1047b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    CMediaPlayer *mp = (CMediaPlayer *) thiz;
1057b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    android::GenericPlayer* avp = mp->mAVPlayer.get();
1067b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    if (avp != NULL) {
1077b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten        android_Player_setPlayState(avp, mp->mPlay.mState, &(mp->mAndroidObjState));
1087b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    }
1097b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    return ATTR_TRANSPORT;
1107b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten}
1117b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
1127b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
1137b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_BQ_ENQUEUE
1147b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioPlayer_bq_enqueue(IObject *thiz)
1157b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{
1167b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    // ( buffer queue count is non-empty and play state == PLAYING ) became true
1177b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    CAudioPlayer *ap = (CAudioPlayer *) thiz;
1187b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    if (SL_PLAYSTATE_PLAYING == ap->mPlay.mState) {
1197b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten        android_audioPlayer_bufferQueue_onRefilled_l(ap);
1207b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    }
1217b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    return ATTR_BQ_ENQUEUE;
1227b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten}
1237b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
1247b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
1257b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_ABQ_ENQUEUE
1267b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioPlayer_abq_enqueue(IObject *thiz)
1277b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{
1287b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    // (Android buffer queue count is non-empty and play state == PLAYING ) became true
1297b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    CAudioPlayer *ap = (CAudioPlayer *) thiz;
1307b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    if (SL_PLAYSTATE_PLAYING == ap->mPlay.mState) {
1317b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten        android_audioPlayer_androidBufferQueue_onRefilled_l(ap);
1327b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    }
1337b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    return ATTR_ABQ_ENQUEUE;
1347b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten}
1357b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
1367b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
1377b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// XA_OBJECTID_MEDIAPLAYER, ATTR_ABQ_ENQUEUE
1387b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_MediaPlayer_abq_enqueue(IObject *thiz)
1397b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{
1407b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    CMediaPlayer* mp = (CMediaPlayer *)thiz;
1417b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    if (SL_PLAYSTATE_PLAYING == mp->mPlay.mState) {
1427b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten        android_Player_androidBufferQueue_onRefilled_l(mp);
1437b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    }
1447b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    return ATTR_ABQ_ENQUEUE;
1457b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten}
1467b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
1477b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// XA_OBJECTID_MEDIAPLAYER, ATTR_POSITION
1487b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_MediaPlayer_position(IObject *thiz)
1497b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{
1507b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    CMediaPlayer *mp = (CMediaPlayer *) thiz;
1517b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    android_Player_seek(mp, mp->mSeek.mPos);
1527b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    return ATTR_POSITION;
1537b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten}
1547b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
1557b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten#else // !defined(ANDROID)
1567b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
1577b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_GAIN
1587b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioPlayer_gain(IObject *thiz)
1597b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{
1607b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    CAudioPlayer *ap = (CAudioPlayer *) thiz;
1617b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    audioPlayerGainUpdate(ap);
1627b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten    return ATTR_GAIN;
1637b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten}
1647b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten
1657b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten#endif
166