summaryrefslogtreecommitdiffstats
path: root/audio/A2dpAudioInterface.h
diff options
context:
space:
mode:
authorDima Zavin <dima@android.com>2011-04-19 16:33:12 -0700
committerDima Zavin <dima@android.com>2011-04-27 10:48:20 -0700
commitf01215993dda68b6b52111d754bd0c7c2d5bcfa3 (patch)
treefca81d5f92d8adcd1a5f1e6c3ba56b39dbfd4aa4 /audio/A2dpAudioInterface.h
parent2dad3e45a052e33463b03810de15b02e9e0e1e4f (diff)
downloadhardware_libhardware_legacy-f01215993dda68b6b52111d754bd0c7c2d5bcfa3.zip
hardware_libhardware_legacy-f01215993dda68b6b52111d754bd0c7c2d5bcfa3.tar.gz
hardware_libhardware_legacy-f01215993dda68b6b52111d754bd0c7c2d5bcfa3.tar.bz2
legacy: move legacy audio code from frameworks/base here
Change-Id: Ic5da0130af44354dffdf85c30cd99f57c6ee163c Signed-off-by: Dima Zavin <dima@android.com>
Diffstat (limited to 'audio/A2dpAudioInterface.h')
-rw-r--r--audio/A2dpAudioInterface.h138
1 files changed, 138 insertions, 0 deletions
diff --git a/audio/A2dpAudioInterface.h b/audio/A2dpAudioInterface.h
new file mode 100644
index 0000000..dbe2c6a
--- /dev/null
+++ b/audio/A2dpAudioInterface.h
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef A2DP_AUDIO_HARDWARE_H
+#define A2DP_AUDIO_HARDWARE_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <utils/threads.h>
+
+#include <hardware_legacy/AudioHardwareBase.h>
+
+
+namespace android {
+
+class A2dpAudioInterface : public AudioHardwareBase
+{
+ class A2dpAudioStreamOut;
+
+public:
+ A2dpAudioInterface(AudioHardwareInterface* hw);
+ virtual ~A2dpAudioInterface();
+ virtual status_t initCheck();
+
+ virtual status_t setVoiceVolume(float volume);
+ virtual status_t setMasterVolume(float volume);
+
+ virtual status_t setMode(int mode);
+
+ // mic mute
+ virtual status_t setMicMute(bool state);
+ virtual status_t getMicMute(bool* state);
+
+ virtual status_t setParameters(const String8& keyValuePairs);
+ virtual String8 getParameters(const String8& keys);
+
+ virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount);
+
+ // create I/O streams
+ virtual AudioStreamOut* openOutputStream(
+ uint32_t devices,
+ int *format=0,
+ uint32_t *channels=0,
+ uint32_t *sampleRate=0,
+ status_t *status=0);
+ virtual void closeOutputStream(AudioStreamOut* out);
+
+ virtual AudioStreamIn* openInputStream(
+ uint32_t devices,
+ int *format,
+ uint32_t *channels,
+ uint32_t *sampleRate,
+ status_t *status,
+ AudioSystem::audio_in_acoustics acoustics);
+ virtual void closeInputStream(AudioStreamIn* in);
+// static AudioHardwareInterface* createA2dpInterface();
+
+protected:
+ virtual status_t dump(int fd, const Vector<String16>& args);
+
+private:
+ class A2dpAudioStreamOut : public AudioStreamOut {
+ public:
+ A2dpAudioStreamOut();
+ virtual ~A2dpAudioStreamOut();
+ status_t set(uint32_t device,
+ int *pFormat,
+ uint32_t *pChannels,
+ uint32_t *pRate);
+ virtual uint32_t sampleRate() const { return 44100; }
+ // SBC codec wants a multiple of 512
+ virtual size_t bufferSize() const { return 512 * 20; }
+ virtual uint32_t channels() const { return AudioSystem::CHANNEL_OUT_STEREO; }
+ virtual int format() const { return AudioSystem::PCM_16_BIT; }
+ virtual uint32_t latency() const { return ((1000*bufferSize())/frameSize())/sampleRate() + 200; }
+ virtual status_t setVolume(float left, float right) { return INVALID_OPERATION; }
+ virtual ssize_t write(const void* buffer, size_t bytes);
+ status_t standby();
+ virtual status_t dump(int fd, const Vector<String16>& args);
+ virtual status_t setParameters(const String8& keyValuePairs);
+ virtual String8 getParameters(const String8& keys);
+ virtual status_t getRenderPosition(uint32_t *dspFrames);
+
+ private:
+ friend class A2dpAudioInterface;
+ status_t init();
+ status_t close();
+ status_t close_l();
+ status_t setAddress(const char* address);
+ status_t setBluetoothEnabled(bool enabled);
+ status_t setSuspended(bool onOff);
+ status_t standby_l();
+
+ private:
+ int mFd;
+ bool mStandby;
+ int mStartCount;
+ int mRetryCount;
+ char mA2dpAddress[20];
+ void* mData;
+ Mutex mLock;
+ bool mBluetoothEnabled;
+ uint32_t mDevice;
+ bool mClosing;
+ bool mSuspended;
+ nsecs_t mLastWriteTime;
+ uint32_t mBufferDurationUs;
+ };
+
+ friend class A2dpAudioStreamOut;
+
+ A2dpAudioStreamOut* mOutput;
+ AudioHardwareInterface *mHardwareInterface;
+ char mA2dpAddress[20];
+ bool mBluetoothEnabled;
+ bool mSuspended;
+};
+
+
+// ----------------------------------------------------------------------------
+
+}; // namespace android
+
+#endif // A2DP_AUDIO_HARDWARE_H