handler_bodies.c revision 99b927751677abfb60a388d65dfeed1fed1db12c
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; 5499b927751677abfb60a388d65dfeed1fed1db12cGlenn Kasten android_Player_volumeUpdate(mp); 557b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_GAIN; 567b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 577b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 587b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 597b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_POSITION 607b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioPlayer_position(IObject *thiz) 617b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 627b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CAudioPlayer *ap; 637b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten ap = (CAudioPlayer *) thiz; 647b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten android_audioPlayer_seek(ap, ap->mSeek.mPos); 657b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_POSITION; 667b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 677b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 687b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 697b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_MIDIPLAYER, ATTR_POSITION 707b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_MidiPlayer_position(IObject *thiz) 717b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 727b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten SL_LOGD("[ FIXME: position update on an SL_OBJECTID_MIDIPLAYER to be implemented ]"); 737b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_POSITION; 747b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 757b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 767b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 777b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_TRANSPORT 787b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioPlayer_transport(IObject *thiz) 797b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 807b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CAudioPlayer *ap = (CAudioPlayer *) thiz; 81f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten // FIXME should only call when either eventflags or marker position changes 827b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten android_audioPlayer_useEventMask(ap); 837b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_TRANSPORT; 847b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 857b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 867b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 87f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_PLAY_STATE 88f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kastenunsigned handler_AudioPlayer_play_state(IObject *thiz) 89f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten{ 90f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten CAudioPlayer *ap = (CAudioPlayer *) thiz; 91f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten android_audioPlayer_setPlayState(ap); 92f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten return ATTR_PLAY_STATE; 93f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten} 94f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten 95f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten 967b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIORECORDER, ATTR_TRANSPORT 977b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioRecorder_transport(IObject *thiz) 987b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 997b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CAudioRecorder* ar = (CAudioRecorder *) thiz; 1007b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten android_audioRecorder_useEventMask(ar); 1017b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_TRANSPORT; 1027b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 1037b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1047b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 105f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten// XA_OBJECTID_MEDIAPLAYER, ATTR_TRANSPORT or ATTR_PLAY_STATE 1067b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_MediaPlayer_transport(IObject *thiz) 1077b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 1087b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CMediaPlayer *mp = (CMediaPlayer *) thiz; 1097b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten android::GenericPlayer* avp = mp->mAVPlayer.get(); 1107b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten if (avp != NULL) { 1117b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten android_Player_setPlayState(avp, mp->mPlay.mState, &(mp->mAndroidObjState)); 1127b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten } 113f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten return ATTR_TRANSPORT | ATTR_PLAY_STATE; 1147b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 1157b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1167b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1177b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_BQ_ENQUEUE 1187b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioPlayer_bq_enqueue(IObject *thiz) 1197b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 1207b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten // ( buffer queue count is non-empty and play state == PLAYING ) became true 1217b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CAudioPlayer *ap = (CAudioPlayer *) thiz; 122f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten assert(SL_PLAYSTATE_PLAYING == ap->mPlay.mState); 123f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten android_audioPlayer_bufferQueue_onRefilled_l(ap); 1247b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_BQ_ENQUEUE; 1257b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 1267b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1277b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1287b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_ABQ_ENQUEUE 1297b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioPlayer_abq_enqueue(IObject *thiz) 1307b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 1317b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten // (Android buffer queue count is non-empty and play state == PLAYING ) became true 1327b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CAudioPlayer *ap = (CAudioPlayer *) thiz; 133f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten assert(SL_PLAYSTATE_PLAYING == ap->mPlay.mState); 134f4647bf85968ab30eb07f9a80b99177d91068f94Glenn Kasten android_audioPlayer_androidBufferQueue_onRefilled_l(ap); 1357b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_ABQ_ENQUEUE; 1367b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 1377b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1387b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1397b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// XA_OBJECTID_MEDIAPLAYER, ATTR_ABQ_ENQUEUE 1407b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_MediaPlayer_abq_enqueue(IObject *thiz) 1417b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 1427b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CMediaPlayer* mp = (CMediaPlayer *)thiz; 1437b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten if (SL_PLAYSTATE_PLAYING == mp->mPlay.mState) { 1447b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten android_Player_androidBufferQueue_onRefilled_l(mp); 1457b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten } 1467b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_ABQ_ENQUEUE; 1477b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 1487b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1497b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// XA_OBJECTID_MEDIAPLAYER, ATTR_POSITION 1507b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_MediaPlayer_position(IObject *thiz) 1517b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 1527b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CMediaPlayer *mp = (CMediaPlayer *) thiz; 1537b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten android_Player_seek(mp, mp->mSeek.mPos); 1547b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_POSITION; 1557b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 1567b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1577b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten#else // !defined(ANDROID) 1587b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1597b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten// SL_OBJECTID_AUDIOPLAYER, ATTR_GAIN 1607b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kastenunsigned handler_AudioPlayer_gain(IObject *thiz) 1617b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten{ 1627b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten CAudioPlayer *ap = (CAudioPlayer *) thiz; 1637b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten audioPlayerGainUpdate(ap); 1647b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten return ATTR_GAIN; 1657b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten} 1667b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten 1677b726bdcd996f1cab3a584c04ce1afc07bc8fbe7Glenn Kasten#endif 168