huangcm
2025-09-01 53d8e046ac1bf2ebe94f671983e3d3be059df91a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
#include "sles_allinclusive.h"
 
// Handlers should return a mask of the attributes which they actually handled,
// or ATTR_NONE if they did not completely handle the attribute change.
 
#ifdef ANDROID
 
// SL_OBJECTID_AUDIOPLAYER, ATTR_GAIN
unsigned handler_AudioPlayer_gain(IObject *thiz)
{
    CAudioPlayer *ap = (CAudioPlayer *) thiz;
    android_audioPlayer_volumeUpdate(ap);
    return ATTR_GAIN;
}
 
 
// SL_OBJECTID_OUTPUTMIX, ATTR_GAIN
unsigned handler_OutputMix_gain(IObject *thiz)
{
    // FIXME update gains on all players attached to this outputmix
    SL_LOGD("[ FIXME: gain update on an SL_OBJECTID_OUTPUTMIX to be implemented ]");
    return ATTR_GAIN;
}
 
 
// SL_OBJECTID_MIDIPLAYER, ATTR_GAIN
unsigned handler_MidiPlayer_gain(IObject *thiz)
{
    SL_LOGD("[ FIXME: gain update on an SL_OBJECTID_MIDIPLAYER to be implemented ]");
    return ATTR_GAIN;
}
 
 
// XA_OBJECTID_MEDIAPLAYER, ATTR_GAIN
unsigned handler_MediaPlayer_gain(IObject *thiz)
{
    CMediaPlayer *mp = (CMediaPlayer *) thiz;
    android_Player_volumeUpdate(mp);
    return ATTR_GAIN;
}
 
 
// SL_OBJECTID_AUDIOPLAYER, ATTR_POSITION
unsigned handler_AudioPlayer_position(IObject *thiz)
{
    CAudioPlayer *ap;
    ap = (CAudioPlayer *) thiz;
    // FIXME provide means to return result for invalid use cases (e.g. buffer queue data source)
    (void) android_audioPlayer_seek(ap, ap->mSeek.mPos);
    return ATTR_POSITION;
}
 
 
// SL_OBJECTID_MIDIPLAYER, ATTR_POSITION
unsigned handler_MidiPlayer_position(IObject *thiz)
{
    SL_LOGD("[ FIXME: position update on an SL_OBJECTID_MIDIPLAYER to be implemented ]");
    return ATTR_POSITION;
}
 
 
// SL_OBJECTID_AUDIOPLAYER, ATTR_TRANSPORT
unsigned handler_AudioPlayer_transport(IObject *thiz)
{
    CAudioPlayer *ap = (CAudioPlayer *) thiz;
    android_audioPlayer_usePlayEventMask(ap);
    return ATTR_TRANSPORT;
}
 
 
// SL_OBJECTID_AUDIOPLAYER, ATTR_PLAY_STATE
unsigned handler_AudioPlayer_play_state(IObject *thiz)
{
    CAudioPlayer *ap = (CAudioPlayer *) thiz;
    android_audioPlayer_setPlayState(ap);
    return ATTR_PLAY_STATE;
}
 
 
// SL_OBJECTID_AUDIORECORDER, ATTR_TRANSPORT
unsigned handler_AudioRecorder_transport(IObject *thiz)
{
    CAudioRecorder* ar = (CAudioRecorder *) thiz;
    android_audioRecorder_useRecordEventMask(ar);
    return ATTR_TRANSPORT;
}
 
 
// XA_OBJECTID_MEDIAPLAYER, ATTR_TRANSPORT
unsigned handler_MediaPlayer_transport(IObject *thiz)
{
    CMediaPlayer *mp = (CMediaPlayer *) thiz;
    android_Player_usePlayEventMask(mp);
    return ATTR_TRANSPORT;
}
 
 
// XA_OBJECTID_MEDIAPLAYER, ATTR_PLAY_STATE
unsigned handler_MediaPlayer_play_state(IObject *thiz)
{
    CMediaPlayer *mp = (CMediaPlayer *) thiz;
    android::GenericPlayer* avp = mp->mAVPlayer.get();
    if (avp != NULL) {
        android_Player_setPlayState(avp, mp->mPlay.mState, &mp->mAndroidObjState);
    }
    return ATTR_PLAY_STATE;
}
 
 
// SL_OBJECTID_AUDIOPLAYER, ATTR_BQ_ENQUEUE
unsigned handler_AudioPlayer_bq_enqueue(IObject *thiz)
{
    // ( buffer queue count is non-empty and play state == PLAYING ) became true
    CAudioPlayer *ap = (CAudioPlayer *) thiz;
    assert(SL_PLAYSTATE_PLAYING == ap->mPlay.mState);
    android_audioPlayer_bufferQueue_onRefilled_l(ap);
    return ATTR_BQ_ENQUEUE;
}
 
 
// SL_OBJECTID_AUDIOPLAYER, ATTR_ABQ_ENQUEUE
unsigned handler_AudioPlayer_abq_enqueue(IObject *thiz)
{
    // (Android buffer queue count is non-empty and play state == PLAYING ) became true
    CAudioPlayer *ap = (CAudioPlayer *) thiz;
    assert(SL_PLAYSTATE_PLAYING == ap->mPlay.mState);
    android_audioPlayer_androidBufferQueue_onRefilled_l(ap);
    return ATTR_ABQ_ENQUEUE;
}
 
 
// XA_OBJECTID_MEDIAPLAYER, ATTR_ABQ_ENQUEUE
unsigned handler_MediaPlayer_abq_enqueue(IObject *thiz)
{
    CMediaPlayer* mp = (CMediaPlayer *)thiz;
    if (SL_PLAYSTATE_PLAYING == mp->mPlay.mState) {
        android_Player_androidBufferQueue_onRefilled_l(mp);
    }
    return ATTR_ABQ_ENQUEUE;
}
 
// XA_OBJECTID_MEDIAPLAYER, ATTR_POSITION
unsigned handler_MediaPlayer_position(IObject *thiz)
{
    CMediaPlayer *mp = (CMediaPlayer *) thiz;
    // FIXME provide means to return result for invalid use cases (e.g. buffer queue data source)
    (void) android_Player_seek(mp, mp->mSeek.mPos);
    return ATTR_POSITION;
}
 
#else // !defined(ANDROID)
 
// SL_OBJECTID_AUDIOPLAYER, ATTR_GAIN
unsigned handler_AudioPlayer_gain(IObject *thiz)
{
    CAudioPlayer *ap = (CAudioPlayer *) thiz;
    audioPlayerGainUpdate(ap);
    return ATTR_GAIN;
}
 
#endif