12e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent/* 22e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent * Copyright (C) 2007 The Android Open Source Project 32e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent * 42e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent * Licensed under the Apache License, Version 2.0 (the "License"); 52e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent * you may not use this file except in compliance with the License. 62e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent * You may obtain a copy of the License at 72e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent * 82e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent * http://www.apache.org/licenses/LICENSE-2.0 92e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent * 102e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent * Unless required by applicable law or agreed to in writing, software 112e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent * distributed under the License is distributed on an "AS IS" BASIS, 122e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent * See the License for the specific language governing permissions and 142e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent * limitations under the License. 152e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent */ 162e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 172e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent#ifndef SOUNDPOOL_H_ 182e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent#define SOUNDPOOL_H_ 192e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 202e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent#include <utils/threads.h> 212e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent#include <utils/List.h> 222e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent#include <utils/Vector.h> 232e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent#include <utils/KeyedVector.h> 242e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent#include <media/AudioTrack.h> 252e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 262e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentnamespace android { 272e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 282e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentstatic const int IDLE_PRIORITY = -1; 292e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 302e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent// forward declarations 312e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentclass SoundEvent; 322e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentclass SoundPoolThread; 332e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentclass SoundPool; 342e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 352e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent// for queued events 362e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentclass SoundPoolEvent { 372e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentpublic: 382e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent SoundPoolEvent(int msg, int arg1=0, int arg2=0) : 392e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent mMsg(msg), mArg1(arg1), mArg2(arg2) {} 402e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mMsg; 412e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mArg1; 422e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mArg2; 432e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent enum MessageType { INVALID, SAMPLE_LOADED }; 442e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent}; 452e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 462e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent// callback function prototype 472e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurenttypedef void SoundPoolCallback(SoundPoolEvent event, SoundPool* soundPool, void* user); 482e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 492e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent// tracks samples used by application 502e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentclass Sample : public RefBase { 512e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentpublic: 522e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent enum sample_state { UNLOADED, LOADING, READY, UNLOADING }; 532e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent Sample(int sampleID, const char* url); 542e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent Sample(int sampleID, int fd, int64_t offset, int64_t length); 552e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent ~Sample(); 562e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int sampleID() { return mSampleID; } 572e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int numChannels() { return mNumChannels; } 582e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int sampleRate() { return mSampleRate; } 592e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent audio_format_t format() { return mFormat; } 602e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent size_t size() { return mSize; } 612e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int state() { return mState; } 622e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent uint8_t* data() { return static_cast<uint8_t*>(mData->pointer()); } 632e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent status_t doLoad(); 642e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void startLoad() { mState = LOADING; } 652e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent sp<IMemory> getIMemory() { return mData; } 662e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 672e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent // hack 688af901cdea0af7e536579dee6d56e69987035a01Glenn Kasten void init(int numChannels, int sampleRate, audio_format_t format, size_t size, 698af901cdea0af7e536579dee6d56e69987035a01Glenn Kasten sp<IMemory> data ) { 708af901cdea0af7e536579dee6d56e69987035a01Glenn Kasten mNumChannels = numChannels; mSampleRate = sampleRate; mFormat = format; mSize = size; 718af901cdea0af7e536579dee6d56e69987035a01Glenn Kasten mData = data; } 722e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 732e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentprivate: 742e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void init(); 752e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 762e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent size_t mSize; 772e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent volatile int32_t mRefCount; 782e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent uint16_t mSampleID; 792e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent uint16_t mSampleRate; 802e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent uint8_t mState : 3; 812e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent uint8_t mNumChannels : 2; 822e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent audio_format_t mFormat; 832e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mFd; 842e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int64_t mOffset; 852e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int64_t mLength; 862e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent char* mUrl; 872e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent sp<IMemory> mData; 882e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent}; 892e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 902e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent// stores pending events for stolen channels 912e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentclass SoundEvent 922e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent{ 932e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentpublic: 942e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent SoundEvent() : mChannelID(0), mLeftVolume(0), mRightVolume(0), 952e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent mPriority(IDLE_PRIORITY), mLoop(0), mRate(0) {} 962e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void set(const sp<Sample>& sample, int channelID, float leftVolume, 972e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent float rightVolume, int priority, int loop, float rate); 982e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent sp<Sample> sample() { return mSample; } 992e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int channelID() { return mChannelID; } 1002e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent float leftVolume() { return mLeftVolume; } 1012e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent float rightVolume() { return mRightVolume; } 1022e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int priority() { return mPriority; } 1032e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int loop() { return mLoop; } 1042e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent float rate() { return mRate; } 1052e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void clear() { mChannelID = 0; mSample.clear(); } 1062e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 1072e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentprotected: 1082e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent sp<Sample> mSample; 1092e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mChannelID; 1102e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent float mLeftVolume; 1112e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent float mRightVolume; 1122e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mPriority; 1132e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mLoop; 1142e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent float mRate; 1152e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent}; 1162e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 1172e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent// for channels aka AudioTracks 1182e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentclass SoundChannel : public SoundEvent { 1192e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentpublic: 1202e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent enum state { IDLE, RESUMING, STOPPING, PAUSED, PLAYING }; 1212e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent SoundChannel() : mAudioTrack(NULL), mState(IDLE), mNumChannels(1), 1222e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent mPos(0), mToggle(0), mAutoPaused(false) {} 1232e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent ~SoundChannel(); 1242e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void init(SoundPool* soundPool); 1252e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void play(const sp<Sample>& sample, int channelID, float leftVolume, float rightVolume, 1262e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int priority, int loop, float rate); 1272e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void setVolume_l(float leftVolume, float rightVolume); 1282e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void setVolume(float leftVolume, float rightVolume); 1292e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void stop_l(); 1302e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void stop(); 1312e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void pause(); 1322e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void autoPause(); 1332e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void resume(); 1342e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void autoResume(); 1352e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void setRate(float rate); 1362e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int state() { return mState; } 1372e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void setPriority(int priority) { mPriority = priority; } 1382e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void setLoop(int loop); 1392e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int numChannels() { return mNumChannels; } 1402e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void clearNextEvent() { mNextEvent.clear(); } 1412e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void nextEvent(); 1422e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int nextChannelID() { return mNextEvent.channelID(); } 1432e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void dump(); 1442e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 1452e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentprivate: 1462e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent static void callback(int event, void* user, void *info); 1472e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void process(int event, void *info, unsigned long toggle); 1482e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent bool doStop_l(); 1492e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 1502e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent SoundPool* mSoundPool; 1512e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent AudioTrack* mAudioTrack; 1522e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent SoundEvent mNextEvent; 1532e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent Mutex mLock; 1542e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mState; 1552e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mNumChannels; 1562e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mPos; 1572e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mAudioBufferSize; 1582e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent unsigned long mToggle; 1592e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent bool mAutoPaused; 1602e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent}; 1612e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 1622e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent// application object for managing a pool of sounds 1632e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentclass SoundPool { 1642e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent friend class SoundPoolThread; 1652e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent friend class SoundChannel; 1662e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentpublic: 1672e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent SoundPool(int maxChannels, audio_stream_type_t streamType, int srcQuality); 1682e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent ~SoundPool(); 1692e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int load(const char* url, int priority); 1702e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int load(int fd, int64_t offset, int64_t length, int priority); 1712e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent bool unload(int sampleID); 1722e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int play(int sampleID, float leftVolume, float rightVolume, int priority, 1732e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int loop, float rate); 1742e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void pause(int channelID); 1752e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void autoPause(); 1762e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void resume(int channelID); 1772e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void autoResume(); 1782e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void stop(int channelID); 1792e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void setVolume(int channelID, float leftVolume, float rightVolume); 1802e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void setPriority(int channelID, int priority); 1812e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void setLoop(int channelID, int loop); 1822e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void setRate(int channelID, float rate); 1832e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent audio_stream_type_t streamType() const { return mStreamType; } 1842e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int srcQuality() const { return mSrcQuality; } 1852e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 1862e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent // called from SoundPoolThread 1872e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void sampleLoaded(int sampleID); 1882e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 1892e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent // called from AudioTrack thread 1902e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void done_l(SoundChannel* channel); 1912e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 1922e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent // callback function 1932e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void setCallback(SoundPoolCallback* callback, void* user); 1942e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void* getUserData() { return mUserData; } 1952e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 1962e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurentprivate: 1972e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent SoundPool() {} // no default constructor 1982e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent bool startThreads(); 1992e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void doLoad(sp<Sample>& sample); 2002e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent sp<Sample> findSample(int sampleID) { return mSamples.valueFor(sampleID); } 2012e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent SoundChannel* findChannel (int channelID); 2022e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent SoundChannel* findNextChannel (int channelID); 2032e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent SoundChannel* allocateChannel_l(int priority); 2042e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void moveToFront_l(SoundChannel* channel); 2052e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void notify(SoundPoolEvent event); 2062e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void dump(); 2072e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 2082e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent // restart thread 2092e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void addToRestartList(SoundChannel* channel); 2102e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void addToStopList(SoundChannel* channel); 2112e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent static int beginThread(void* arg); 2122e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int run(); 2132e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void quit(); 2142e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 2152e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent Mutex mLock; 2162e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent Mutex mRestartLock; 2172e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent Condition mCondition; 2182e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent SoundPoolThread* mDecodeThread; 2192e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent SoundChannel* mChannelPool; 2202e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent List<SoundChannel*> mChannels; 2212e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent List<SoundChannel*> mRestart; 2222e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent List<SoundChannel*> mStop; 2232e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent DefaultKeyedVector< int, sp<Sample> > mSamples; 2242e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mMaxChannels; 2252e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent audio_stream_type_t mStreamType; 2262e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mSrcQuality; 2272e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mAllocated; 2282e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mNextSampleID; 2292e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent int mNextChannelID; 2302e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent bool mQuit; 2312e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 2322e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent // callback 2332e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent Mutex mCallbackLock; 2342e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent SoundPoolCallback* mCallback; 2352e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent void* mUserData; 2362e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent}; 2372e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 2382e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent} // end namespace android 2392e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent 2402e66a7896c9a9da3a15fc6cff9be28b4174d8719Eric Laurent#endif /*SOUNDPOOL_H_*/ 241