2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <binder/IServiceManager.h>
19 // number of SLuint32 fields to store a buffer event message in an item, by mapping each
20 // to the item key (SLuint32), the item size (SLuint32), and the item data (mask on SLuint32)
21 #define NB_BUFFEREVENT_ITEM_FIELDS 3
23 //--------------------------------------------------------------------------------------------------
26 //--------------------------------------------------------------------------------------------------
27 class StreamSourceAppProxy : public BnStreamSource {
30 const void* user, bool userIsAudioPlayer,
33 virtual ~StreamSourceAppProxy();
35 // store an item structure to indicate a processed buffer
36 static const SLuint32 kItemProcessed[NB_BUFFEREVENT_ITEM_FIELDS];
38 // IStreamSource implementation
39 virtual void setListener(const sp<IStreamListener> &listener);
40 virtual void setBuffers(const Vector<sp<IMemory> > &buffers);
41 virtual void onBufferAvailable(size_t index);
43 // Consumption from ABQ
44 void pullFromBuffQueue();
46 void receivedCmd_l(IStreamListener::Command cmd, const sp<AMessage> &msg = NULL);
47 void receivedBuffer_l(size_t buffIndex, size_t buffLength);
50 // for mListener and mAvailableBuffers
52 sp<IStreamListener> mListener;
53 // array of shared memory buffers
54 Vector<sp<IMemory> > mBuffers;
55 // list of available buffers in shared memory, identified by their index
56 List<size_t> mAvailableBuffers;
59 bool mUserIsAudioPlayer;
60 // the Android Buffer Queue from which data is consumed and written to shared memory
61 IAndroidBufferQueue* mAndroidBufferQueue;
66 DISALLOW_EVIL_CONSTRUCTORS(StreamSourceAppProxy);
70 //--------------------------------------------------------------------------------------------------
71 class StreamPlayer : public GenericMediaPlayer
74 StreamPlayer(AudioPlayback_Parameters* params, bool hasVideo);
75 virtual ~StreamPlayer();
77 // overridden from GenericPlayer
78 virtual void onMessageReceived(const sp<AMessage> &msg);
80 void registerQueueCallback(
81 const void* user, bool userIsAudioPlayer,
84 void queueRefilled_l();
90 // message to asynchronously notify mAppProxy the Android Buffer Queue was refilled
91 kWhatQueueRefilled = 'qrfi'
94 sp<StreamSourceAppProxy> mAppProxy; // application proxy for the android buffer queue source
96 // overridden from GenericMediaPlayer
97 virtual void onPrepare();
99 void onQueueRefilled();
105 DISALLOW_EVIL_CONSTRUCTORS(StreamPlayer);
108 } // namespace android
111 //--------------------------------------------------------------------------------------------------
113 * xxx_l functions are called with a lock on the CAudioPlayer mObject
115 extern void android_StreamPlayer_realize_l(CAudioPlayer *ap, const notif_cbf_t cbf,