content/media/omx/AudioSink.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
michael@0 3 /*
michael@0 4 * Copyright (c) 2014 The Linux Foundation. All rights reserved.
michael@0 5 * Copyright (C) 2007 The Android Open Source Project
michael@0 6 *
michael@0 7 * Licensed under the Apache License, Version 2.0 (the "License");
michael@0 8 * you may not use this file except in compliance with the License.
michael@0 9 * You may obtain a copy of the License at
michael@0 10 *
michael@0 11 * http://www.apache.org/licenses/LICENSE-2.0
michael@0 12 *
michael@0 13 * Unless required by applicable law or agreed to in writing, software
michael@0 14 * distributed under the License is distributed on an "AS IS" BASIS,
michael@0 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
michael@0 16 * See the License for the specific language governing permissions and
michael@0 17 * limitations under the License.
michael@0 18 */
michael@0 19
michael@0 20 #ifndef AUDIO_SINK_H_
michael@0 21 #define AUDIO_SINK_H_
michael@0 22
michael@0 23 #include <utils/Errors.h>
michael@0 24 #include <utils/String8.h>
michael@0 25 #include <system/audio.h>
michael@0 26
michael@0 27 #define DEFAULT_AUDIOSINK_BUFFERCOUNT 4
michael@0 28 #define DEFAULT_AUDIOSINK_BUFFERSIZE 1200
michael@0 29 #define DEFAULT_AUDIOSINK_SAMPLERATE 44100
michael@0 30
michael@0 31 // when the channel mask isn't known, use the channel count to derive a mask in
michael@0 32 // AudioSink::open()
michael@0 33 #define CHANNEL_MASK_USE_CHANNEL_ORDER 0
michael@0 34
michael@0 35 namespace mozilla {
michael@0 36
michael@0 37 /**
michael@0 38 * AudioSink: abstraction layer for audio output
michael@0 39 * Stripped version of Android KK MediaPlayerBase::AudioSink class
michael@0 40 */
michael@0 41
michael@0 42 class AudioSink : public android::RefBase
michael@0 43 {
michael@0 44 typedef android::String8 String8;
michael@0 45 typedef android::status_t status_t;
michael@0 46
michael@0 47 public:
michael@0 48 enum cb_event_t {
michael@0 49 CB_EVENT_FILL_BUFFER, // Request to write more data to buffer.
michael@0 50 CB_EVENT_STREAM_END, // Sent after all the buffers queued in AF and HW
michael@0 51 // are played back (after stop is called)
michael@0 52 CB_EVENT_TEAR_DOWN // The AudioTrack was invalidated due to usecase
michael@0 53 // change. Need to re-evaluate offloading options
michael@0 54 };
michael@0 55
michael@0 56 // Callback returns the number of bytes actually written to the buffer.
michael@0 57 typedef size_t (*AudioCallback)(AudioSink* aAudioSink,
michael@0 58 void* aBuffer,
michael@0 59 size_t aSize,
michael@0 60 void* aCookie,
michael@0 61 cb_event_t aEvent);
michael@0 62 virtual ~AudioSink() {}
michael@0 63 virtual ssize_t FrameSize() const = 0;
michael@0 64 virtual status_t GetPosition(uint32_t* aPosition) const = 0;
michael@0 65 virtual status_t SetVolume(float aVolume) const = 0;
michael@0 66 virtual status_t SetParameters(const String8& aKeyValuePairs)
michael@0 67 {
michael@0 68 return android::NO_ERROR;
michael@0 69 }
michael@0 70
michael@0 71 virtual status_t Open(uint32_t aSampleRate,
michael@0 72 int aChannelCount,
michael@0 73 audio_channel_mask_t aChannelMask,
michael@0 74 audio_format_t aFormat=AUDIO_FORMAT_PCM_16_BIT,
michael@0 75 AudioCallback aCb = nullptr,
michael@0 76 void* aCookie = nullptr,
michael@0 77 audio_output_flags_t aFlags = AUDIO_OUTPUT_FLAG_NONE,
michael@0 78 const audio_offload_info_t* aOffloadInfo = nullptr) = 0;
michael@0 79
michael@0 80 virtual status_t Start() = 0;
michael@0 81 virtual void Stop() = 0;
michael@0 82 virtual void Flush() = 0;
michael@0 83 virtual void Pause() = 0;
michael@0 84 virtual void Close() = 0;
michael@0 85 };
michael@0 86
michael@0 87 } // namespace mozilla
michael@0 88
michael@0 89 #endif // AUDIO_SINK_H_

mercurial