2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
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.
18 #include "CAudioIODef.h"
22 using namespace tizen_media_audio;
25 static const char* STREAM_NAME_INPUT = "CAPTURE";
26 static const char* STREAM_NAME_INPUT_LOW_LATENCY = "LOW LATENCY CAPTURE";
27 static const char* STREAM_NAME_INPUT_HIGH_LATENCY = "HIGH LATENCY CAPTURE";
28 static const char* STREAM_NAME_INPUT_VOIP = "VOIP CAPTURE";
30 static const char* STREAM_NAME_OUTPUT = "PLAYBACK";
31 static const char* STREAM_NAME_OUTPUT_LOW_LATENCY = "LOW LATENCY PLAYBACK";
32 static const char* STREAM_NAME_OUTPUT_HIGH_LATENCY = "HIGH LATENCY PLAYBACK";
33 static const char* STREAM_NAME_OUTPUT_VOIP = "VOIP PLAYBACK";
36 CPulseStreamSpec::CPulseStreamSpec() throw (CAudioError)
37 : mLatency(STREAM_LATENCY_INPUT_MID), mStreamName(NULL) {
41 CPulseStreamSpec::CPulseStreamSpec(EStreamLatency latency, CAudioInfo& audioInfo) throw (CAudioError)
42 : mLatency(latency), mAudioInfo(audioInfo), mStreamName(NULL) {
46 CPulseStreamSpec::CPulseStreamSpec(EStreamLatency latency, CAudioInfo& audioInfo, int customLatency) throw (CAudioError)
47 : mLatency(latency), mAudioInfo(audioInfo), mStreamName(NULL) {
51 CPulseStreamSpec::~CPulseStreamSpec() {
54 void CPulseStreamSpec::_adjustSpec() throw (CAudioError) {
56 mSampleSpec.rate = mAudioInfo.getSampleRate();
58 // Convert channels for PA
59 switch (mAudioInfo.getChannel()) {
60 case CAudioInfo::CHANNEL_MONO:
61 mSampleSpec.channels = 1;
64 case CAudioInfo::CHANNEL_STEREO:
66 mSampleSpec.channels = 2;
70 // Convert format for PA
71 switch (mAudioInfo.getSampleType()) {
72 case CAudioInfo::SAMPLE_TYPE_U8:
73 mSampleSpec.format = PA_SAMPLE_U8;
76 case CAudioInfo::SAMPLE_TYPE_S16_LE:
78 mSampleSpec.format = PA_SAMPLE_S16LE;
83 pa_channel_map_init_auto(&mChannelMap, mSampleSpec.channels, PA_CHANNEL_MAP_ALSA);
87 case STREAM_LATENCY_OUTPUT_MID:
88 mStreamName = STREAM_NAME_OUTPUT;
91 case STREAM_LATENCY_OUTPUT_HIGH:
92 mStreamName = STREAM_NAME_OUTPUT_HIGH_LATENCY;
95 case STREAM_LATENCY_OUTPUT_LOW:
96 mStreamName = STREAM_NAME_OUTPUT_LOW_LATENCY;
99 case STREAM_LATENCY_OUTPUT_VOIP:
100 mStreamName = STREAM_NAME_OUTPUT_VOIP;
103 case STREAM_LATENCY_INPUT_HIGH:
104 mStreamName = STREAM_NAME_INPUT_HIGH_LATENCY;
107 case STREAM_LATENCY_INPUT_LOW:
108 mStreamName = STREAM_NAME_INPUT_LOW_LATENCY;
111 case STREAM_LATENCY_INPUT_VOIP:
112 mStreamName = STREAM_NAME_INPUT_VOIP;
115 case STREAM_LATENCY_INPUT_MID:
117 mStreamName = STREAM_NAME_INPUT;
122 CPulseStreamSpec::EStreamLatency CPulseStreamSpec::getStreamLatency() {
126 CAudioInfo CPulseStreamSpec::getAudioInfo() {
130 pa_sample_spec CPulseStreamSpec::getSampleSpec() {
134 pa_channel_map CPulseStreamSpec::getChannelMap() {
138 const char* CPulseStreamSpec::getStreamName() {