From a3b92e05da78d2b45a185a6760d840c72fe5dce6 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 23 Jan 2015 11:48:23 -0800 Subject: [PATCH] support 44.1 for the note 4 --- cmake/android/AndroidManifest.xml.in | 1 + cmake/android/QtCreateAPK.cmake | 2 +- cmake/android/deployment-file.json.in | 1 - gvr-interface/src/RenderingClient.cpp | 4 +++ libraries/audio-client/src/AudioClient.cpp | 42 ++++++++++++++++------ 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/cmake/android/AndroidManifest.xml.in b/cmake/android/AndroidManifest.xml.in index 3f231d427c..1e944ae623 100755 --- a/cmake/android/AndroidManifest.xml.in +++ b/cmake/android/AndroidManifest.xml.in @@ -61,6 +61,7 @@ Remove the comment if you do not require these default permissions. --> + diff --git a/cmake/android/QtCreateAPK.cmake b/cmake/android/QtCreateAPK.cmake index e43a03eab9..2a79d34857 100644 --- a/cmake/android/QtCreateAPK.cmake +++ b/cmake/android/QtCreateAPK.cmake @@ -107,7 +107,7 @@ macro(qt_create_apk) # use androiddeployqt to create the apk add_custom_target(${TARGET_NAME}-apk - COMMAND ${ANDROID_DEPLOY_QT} --input "${TARGET_NAME}-deployment.json" --output "${ANDROID_APK_OUTPUT_DIR}" --android-platform android-${ANDROID_API_LEVEL} --install --deployment bundled "\\$(ARGS)" + COMMAND ${ANDROID_DEPLOY_QT} --input "${TARGET_NAME}-deployment.json" --output "${ANDROID_APK_OUTPUT_DIR}" --android-platform android-${ANDROID_API_LEVEL} --install --verbose --deployment bundled "\\$(ARGS)" DEPENDS ${TARGET_NAME} ) endmacro() \ No newline at end of file diff --git a/cmake/android/deployment-file.json.in b/cmake/android/deployment-file.json.in index de5b1d9ac2..81ed8a6ecc 100644 --- a/cmake/android/deployment-file.json.in +++ b/cmake/android/deployment-file.json.in @@ -9,6 +9,5 @@ "target-architecture": "@ANDROID_ABI@", "application-binary": "@EXECUTABLE_DESTINATION_PATH@", "android-extra-libs": "@_DEPS@", - "android-extra-plugins": "", "android-package-source-directory": "@ANDROID_APK_BUILD_DIR@" } diff --git a/gvr-interface/src/RenderingClient.cpp b/gvr-interface/src/RenderingClient.cpp index 3feb340407..5683c8e01e 100644 --- a/gvr-interface/src/RenderingClient.cpp +++ b/gvr-interface/src/RenderingClient.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -38,6 +39,9 @@ RenderingClient::RenderingClient(QObject *parent) : connect(audioThread, &QThread::started, audioClient.data(), &AudioClient::start); audioThread->start(); + + connect(DependencyManager::get().data(), &AddressManager::locationChangeRequired, + this, &RenderingClient::goToLocation); } RenderingClient::~RenderingClient() { diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 3dc90508c5..13d1a58967 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -67,7 +67,7 @@ AudioClient::AudioClient() : _receivedAudioStream(0, RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES, InboundAudioStream::Settings()), _isStereoInput(false), _outputBufferSizeFrames(DEFAULT_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES), - _outputStarveDetectionEnabled(true), + _outputStarveDetectionEnabled(false), _outputStarveDetectionStartTimeMsec(0), _outputStarveDetectionCount(0), _outputStarveDetectionPeriodMsec(DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_PERIOD), @@ -282,18 +282,35 @@ bool adjustedFormatForAudioDevice(const QAudioDeviceInfo& audioDevice, adjustedAudioFormat.setChannelCount(1); } } - + + const int FORTY_FOUR = 44100; + + adjustedAudioFormat = desiredAudioFormat; + +#ifdef Q_OS_ANDROID + adjustedAudioFormat.setSampleRate(FORTY_FOUR); +#else + const int HALF_FORTY_FOUR = FORTY_FOUR / 2; + if (audioDevice.supportedSampleRates().contains(AudioConstants::SAMPLE_RATE * 2)) { // use 48, which is a sample downsample, upsample - adjustedAudioFormat = desiredAudioFormat; adjustedAudioFormat.setSampleRate(AudioConstants::SAMPLE_RATE * 2); - + } else if (audioDevice.supportedSampleRates().contains(HALF_FORTY_FOUR)) { + // use 22050, resample but closer to 24 + adjustedAudioFormat.setSampleRate(HALF_FORTY_FOUR); + } else if (audioDevice.supportedSampleRates().contains(FORTY_FOUR)) { + // use 48000, libsoxr will resample + adjustedAudioFormat.setSampleRate(FORTY_FOUR); + } +#endif + + if (adjustedAudioFormat != desiredAudioFormat) { // return the nearest in case it needs 2 channels adjustedAudioFormat = audioDevice.nearestFormat(adjustedAudioFormat); return true; + } else { + return false; } - - return false; } else { // set the adjustedAudioFormat to the desiredAudioFormat, since it will work adjustedAudioFormat = desiredAudioFormat; @@ -991,7 +1008,7 @@ bool AudioClient::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceIn } // if the user wants stereo but this device can't provide then bail - if (!_isStereoInput || _inputFormat.channelCount() == 2) { + if (!_isStereoInput || _inputFormat.channelCount() == 2) { _audioInput = new QAudioInput(inputDeviceInfo, _inputFormat, this); _numInputCallbackBytes = calculateNumberOfInputCallbackBytes(_inputFormat); _audioInput->setBufferSize(_numInputCallbackBytes); @@ -999,10 +1016,15 @@ bool AudioClient::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceIn // how do we want to handle input working, but output not working? int numFrameSamples = calculateNumberOfFrameSamples(_numInputCallbackBytes); _inputRingBuffer.resizeForFrameSize(numFrameSamples); - _inputDevice = _audioInput->start(); - connect(_inputDevice, SIGNAL(readyRead()), this, SLOT(handleAudioInput())); - supportedFormat = true; + _inputDevice = _audioInput->start(); + + if (_inputDevice) { + connect(_inputDevice, SIGNAL(readyRead()), this, SLOT(handleAudioInput())); + supportedFormat = true; + } else { + qDebug() << "Error starting audio input -" << _audioInput->error(); + } } } }