From 6c4224d05abcde52a164ef8784d6974a3d458fd4 Mon Sep 17 00:00:00 2001 From: Tom Duncalf Date: Mon, 24 Feb 2020 17:10:42 +0000 Subject: [PATCH] Android: Fixed some compiler warnings when compiling with Oboe enabled --- .../juce_audio_devices/juce_audio_devices.cpp | 5 ++- .../native/juce_android_Oboe.cpp | 35 +++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/modules/juce_audio_devices/juce_audio_devices.cpp b/modules/juce_audio_devices/juce_audio_devices.cpp index a7f816e979..b710fa1695 100644 --- a/modules/juce_audio_devices/juce_audio_devices.cpp +++ b/modules/juce_audio_devices/juce_audio_devices.cpp @@ -169,7 +169,10 @@ #error "Oboe cannot be enabled at the same time as openSL! Please disable JUCE_USE_ANDROID_OPENSLES" #endif - #include + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wunused-parameter" + #include + #pragma clang diagnostic pop #endif #endif diff --git a/modules/juce_audio_devices/native/juce_android_Oboe.cpp b/modules/juce_audio_devices/native/juce_android_Oboe.cpp index 4d2025072a..41bac4a1ac 100644 --- a/modules/juce_audio_devices/native/juce_android_Oboe.cpp +++ b/modules/juce_audio_devices/native/juce_android_Oboe.cpp @@ -511,8 +511,8 @@ private: void open (int deviceId, oboe::Direction direction, oboe::SharingMode sharingMode, int channelCount, oboe::AudioFormat format, - int32 sampleRate, int32 bufferSize, - oboe::AudioStreamCallback* callback = nullptr) + int32 newSampleRate, int32 newBufferSize, + oboe::AudioStreamCallback* newCallback = nullptr) { oboe::DefaultStreamValues::FramesPerBurst = getDefaultFramesPerBurst(); @@ -526,9 +526,9 @@ private: builder.setSharingMode (sharingMode); builder.setChannelCount (channelCount); builder.setFormat (format); - builder.setSampleRate (sampleRate); + builder.setSampleRate (newSampleRate); builder.setPerformanceMode (oboe::PerformanceMode::LowLatency); - builder.setCallback (callback); + builder.setCallback (newCallback); JUCE_OBOE_LOG (String ("Preparing Oboe stream with params:") + "\nAAudio supported = " + String (int (builder.isAAudioSupported())) @@ -538,17 +538,17 @@ private: + "\nSharingMode = " + getOboeString (sharingMode) + "\nChannelCount = " + String (channelCount) + "\nFormat = " + getOboeString (format) - + "\nSampleRate = " + String (sampleRate) + + "\nSampleRate = " + String (newSampleRate) + "\nPerformanceMode = " + getOboeString (oboe::PerformanceMode::LowLatency)); openResult = builder.openStream (&stream); JUCE_OBOE_LOG ("Building Oboe stream with result: " + getOboeString (openResult) + "\nStream state = " + (stream != nullptr ? getOboeString (stream->getState()) : String ("?"))); - if (stream != nullptr && bufferSize != 0) + if (stream != nullptr && newBufferSize != 0) { - JUCE_OBOE_LOG ("Setting the bufferSizeInFrames to " + String (bufferSize)); - stream->setBufferSizeInFrames (bufferSize); + JUCE_OBOE_LOG ("Setting the bufferSizeInFrames to " + String (newBufferSize)); + stream->setBufferSizeInFrames (newBufferSize); } JUCE_OBOE_LOG (String ("Stream details:") @@ -573,6 +573,7 @@ private: if (stream != nullptr) { oboe::Result result = stream->close(); + ignoreUnused (result); JUCE_OBOE_LOG ("Requested Oboe stream close with result: " + getOboeString (result)); } } @@ -665,16 +666,16 @@ private: } // Not strictly required as these should not change, but recommended by Google anyway - void checkStreamSetup (OboeStream* stream, int deviceId, int numChannels, int sampleRate, - int bufferSize, oboe::AudioFormat format) + void checkStreamSetup (OboeStream* stream, int deviceId, int numChannels, int expectedSampleRate, + int expectedBufferSize, oboe::AudioFormat format) { if (auto* nativeStream = stream != nullptr ? stream->getNativeStream() : nullptr) { - ignoreUnused (deviceId, numChannels, sampleRate, bufferSize); + ignoreUnused (deviceId, numChannels, sampleRate, expectedBufferSize); ignoreUnused (streamFormat, bitDepth); jassert (numChannels == nativeStream->getChannelCount()); - jassert (sampleRate == 0 || sampleRate == nativeStream->getSampleRate()); + jassert (expectedSampleRate == 0 || expectedSampleRate == nativeStream->getSampleRate()); jassert (format == nativeStream->getFormat()); } } @@ -874,9 +875,7 @@ private: const int64_t appFrameIndex = isOutput ? nativeStream.getFramesWritten() : nativeStream.getFramesRead(); // Assume that the next frame will be processed at the current time - using namespace std::chrono; - int64_t appFrameAppTime = getCurrentTimeNanos();//duration_cast (steady_clock::now().time_since_epoch()).count(); - int64_t appFrameAppTime2 = duration_cast (steady_clock::now().time_since_epoch()).count(); + int64_t appFrameAppTime = getCurrentTimeNanos(); // Calculate the number of frames between app and hardware int64_t frameIndexDelta = appFrameIndex - hardwareFrameIndex; @@ -903,6 +902,8 @@ private: void onErrorBeforeClose (oboe::AudioStream* stream, oboe::Result error) override { + ignoreUnused (error); + // only output stream should be the master stream receiving callbacks jassert (stream->getDirection() == oboe::Direction::Output); @@ -1202,6 +1203,8 @@ public: for (auto& device : inputDevices) { + ignoreUnused (device); + JUCE_OBOE_LOG ("name = " << device.name); JUCE_OBOE_LOG ("id = " << String (device.id)); JUCE_OBOE_LOG ("sample rates size = " << String (device.sampleRates.size())); @@ -1212,6 +1215,8 @@ public: for (auto& device : outputDevices) { + ignoreUnused (device); + JUCE_OBOE_LOG ("name = " << device.name); JUCE_OBOE_LOG ("id = " << String (device.id)); JUCE_OBOE_LOG ("sample rates size = " << String (device.sampleRates.size()));