handler_bodies.c revision f4647bf85968ab30eb07f9a80b99177d91068f94
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; 84f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten // FIXME should only call when either eventflags or marker position changes 857b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten android_audioPlayer_useEventMask(ap); 867b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_TRANSPORT; 877b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 887b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 897b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 90f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_PLAY_STATE 91f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kastenunsigned handler_AudioPlayer_play_state(IObject *thiz) 92f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten{ 93f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten CAudioPlayer *ap = (CAudioPlayer *) thiz; 94f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten android_audioPlayer_setPlayState(ap); 95f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten return ATTR_PLAY_STATE; 96f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten} 97f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten 98f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten 997b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIORECORDER, ATTR_TRANSPORT 1007b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioRecorder_transport(IObject *thiz) 1017b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 1027b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CAudioRecorder* ar = (CAudioRecorder *) thiz; 1037b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten android_audioRecorder_useEventMask(ar); 1047b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_TRANSPORT; 1057b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 1067b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1077b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 108f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten// XA_OBJECTID_MEDIAPLAYER, ATTR_TRANSPORT or ATTR_PLAY_STATE 1097b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_MediaPlayer_transport(IObject *thiz) 1107b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 1117b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CMediaPlayer *mp = (CMediaPlayer *) thiz; 1127b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten android::GenericPlayer* avp = mp->mAVPlayer.get(); 1137b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten if (avp != NULL) { 1147b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten android_Player_setPlayState(avp, mp->mPlay.mState, &(mp->mAndroidObjState)); 1157b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten } 116f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten return ATTR_TRANSPORT | ATTR_PLAY_STATE; 1177b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 1187b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1197b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1207b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_BQ_ENQUEUE 1217b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioPlayer_bq_enqueue(IObject *thiz) 1227b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 1237b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten // ( buffer queue count is non-empty and play state == PLAYING ) became true 1247b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CAudioPlayer *ap = (CAudioPlayer *) thiz; 125f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten assert(SL_PLAYSTATE_PLAYING == ap->mPlay.mState); 126f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten android_audioPlayer_bufferQueue_onRefilled_l(ap); 1277b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_BQ_ENQUEUE; 1287b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 1297b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1307b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1317b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_ABQ_ENQUEUE 1327b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioPlayer_abq_enqueue(IObject *thiz) 1337b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 1347b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten // (Android buffer queue count is non-empty and play state == PLAYING ) became true 1357b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CAudioPlayer *ap = (CAudioPlayer *) thiz; 136f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten assert(SL_PLAYSTATE_PLAYING == ap->mPlay.mState); 137f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten android_audioPlayer_androidBufferQueue_onRefilled_l(ap); 1387b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_ABQ_ENQUEUE; 1397b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 1407b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1417b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1427b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// XA_OBJECTID_MEDIAPLAYER, ATTR_ABQ_ENQUEUE 1437b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_MediaPlayer_abq_enqueue(IObject *thiz) 1447b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 1457b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CMediaPlayer* mp = (CMediaPlayer *)thiz; 1467b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten if (SL_PLAYSTATE_PLAYING == mp->mPlay.mState) { 1477b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten android_Player_androidBufferQueue_onRefilled_l(mp); 1487b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten } 1497b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_ABQ_ENQUEUE; 1507b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 1517b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1527b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// XA_OBJECTID_MEDIAPLAYER, ATTR_POSITION 1537b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_MediaPlayer_position(IObject *thiz) 1547b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 1557b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CMediaPlayer *mp = (CMediaPlayer *) thiz; 1567b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten android_Player_seek(mp, mp->mSeek.mPos); 1577b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_POSITION; 1587b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 1597b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1607b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten#else // !defined(ANDROID) 1617b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1627b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_GAIN 1637b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioPlayer_gain(IObject *thiz) 1647b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 1657b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CAudioPlayer *ap = (CAudioPlayer *) thiz; 1667b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten audioPlayerGainUpdate(ap); 1677b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_GAIN; 1687b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 1697b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1707b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten#endif 171