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>
20 //--------------------------------------------------------------------------------------------------
23 //--------------------------------------------------------------------------------------------------
24 class StreamSourceAppProxy : public BnStreamSource {
27 const void* user, bool userIsAudioPlayer,
30 virtual ~StreamSourceAppProxy();
32 // IStreamSource implementation
33 virtual void setListener(const sp<IStreamListener> &listener);
34 virtual void setBuffers(const Vector<sp<IMemory> > &buffers);
35 virtual void onBufferAvailable(size_t index);
37 // Consumption from ABQ
38 void pullFromBuffQueue();
40 void receivedCmd_l(IStreamListener::Command cmd, const sp<AMessage> &msg = NULL);
41 void receivedBuffer_l(size_t buffIndex, size_t buffLength);
44 // for mListener and mAvailableBuffers
46 sp<IStreamListener> mListener;
47 // array of shared memory buffers
48 Vector<sp<IMemory> > mBuffers;
49 // list of available buffers in shared memory, identified by their index
50 List<size_t> mAvailableBuffers;
53 bool mUserIsAudioPlayer;
54 // the Android Buffer Queue from which data is consumed and written to shared memory
55 IAndroidBufferQueue* mAndroidBufferQueue;
60 DISALLOW_EVIL_CONSTRUCTORS(StreamSourceAppProxy);
64 //--------------------------------------------------------------------------------------------------
65 class StreamPlayer : public GenericMediaPlayer
68 StreamPlayer(AudioPlayback_Parameters* params, bool hasVideo);
69 virtual ~StreamPlayer();
71 // overridden from GenericPlayer
72 virtual void onMessageReceived(const sp<AMessage> &msg);
74 void registerQueueCallback(
75 const void* user, bool userIsAudioPlayer,
78 void queueRefilled_l();
84 // message to asynchronously notify mAppProxy the Android Buffer Queue was refilled
85 kWhatQueueRefilled = 'qrfi'
88 sp<StreamSourceAppProxy> mAppProxy; // application proxy for the android buffer queue source
90 // overridden from GenericMediaPlayer
91 virtual void onPrepare();
93 void onQueueRefilled();
99 DISALLOW_EVIL_CONSTRUCTORS(StreamPlayer);
102 } // namespace android
105 //--------------------------------------------------------------------------------------------------
107 * xxx_l functions are called with a lock on the CAudioPlayer mObject
109 extern void android_StreamPlayer_realize_l(CAudioPlayer *ap, const notif_cbf_t cbf,