我今天已经检查并尝试了多个小时的所有其他线程,但没有一个解决方案有效。
我尝试过滤所有可用的音频选项。我已授予该应用程序适当的权限。
目标:我正在尝试获取此音频流,以便获取音频的频率。
我的东西
public int audioSource = MediaRecorder.AudioSource.MIC;
public int channelConfig = AudioFormat.CHANNEL_IN_MONO;
public int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
public AudioRecord audioRecord = null;
private Thread recordingThread = null;
public int blockSize = 256; // deal with this many samples at a time
public int sampleRate = 8000; // Sample rate in Hz
Run Code Online (Sandbox Code Playgroud)
稍后的...
int bufferSize = AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioEncoding);
AudioRecord audioeeeeRecord = new AudioRecord(audioSource, sampleRate, channelConfig, audioEncoding, bufferSize); // The RAW PCM sample recording
audioRecord = audioeeeeRecord;
if (audioRecord …Run Code Online (Sandbox Code Playgroud) Is it possible to simplify the following match statement using @ syntax?
foo match {
case f: Foo => y(f)
case f if forceY => y(f)
case _ => x
}
Run Code Online (Sandbox Code Playgroud)
哪里forceY是boolean。
我尝试了以下操作,但遇到了编译错误,对于编译器来说,它确实看起来像是可疑的语法。也许这无法表达?
foo match {
case f @(_: Foo | _ if forceY) => y(f)
case _ => x
}
Run Code Online (Sandbox Code Playgroud) 问题
我有一堆junit测试(许多带有自定义的运行器,例如PowerMockRunner或JUnitParamsRunner)都在某个根包下tests(它们tests位于各个深度的子包中)。
我想收集所有测试包,tests并在不同的JVM中并行运行每个测试类。理想情况下,并行化是可配置的,但是number_of_cores的默认设置也完全可以。请注意,我不想在自己的JVM中运行每个方法,而是在每个类中运行。
背景
我通过注释@RunWith(PowerMockRunner.class)和@PowerMockRunnerDelegate(JUnitParamsRunner.class)许多测试将PowerMock与JUnitParams结合使用。我有大约9000个单元测试,可以在“确定的”时间内完成,但是我有8核CPU,并且默认的一次一次测试运行程序未充分利用这些系统。因为我经常运行测试,所以增加了额外的时间,我真的想并行运行测试类。
请注意,不幸的是,在大量测试中,我需要模拟静态方法,这是使用PowerMock的部分原因。
我尝试过的事情
由于必须模拟静态方法,因此无法使用类似的方法com.googlecode.junittoolbox.ParallelSuite(这是我最初的解决方案),因为它在相同的JVM中运行所有内容,并且静态模拟被交错并弄乱了。至少在我看来,基于我得到的错误。
我一点都不了解JUnit堆栈,但是经过一番摸索,看来另一种选择可能是尝试编写并注入自己的JUnit,但是RunnerBuilder我不确定是否可以从一个内部生成另一个JVM进程。RunnerBuilder,不太可能。我认为正确的解决方案是将某种形式的束缚当作一项艰巨的任务来解决。
我还发现了一些Android Studio(Intellij)测试选项,但是唯一可用的fork选项method不是我想要的。我目前正在探索此解决方案,因此也许我会解决,但我想我会并行地询问社区,因为我还没有太多锁定。
更新:终于能够使Android Studio(Intellij)使用选项Test Kind :(All in directory出于某些原因,包选项未进行递归搜索)和选择fork模式来收集我的所有测试Class。但是,它仍然运行顺序找到的每个测试类,并且我看不到有关并行化的选项。这是如此接近我想要的,但不是很... :(
我有一个带有两个模块的android项目(典型的前端应用程序和后端).我有三个build.gradle文件,每个模块一个,根目录一个.
我已经构建我的依赖关系的方式是通过提取所有的版本为独立的变量在根级别build.gradle这样
ext {
// SDK and tools
MIN_SDK_VERSION = 19
TARGET_SDK_VERSION = 23
COMPILE_SDK_VERSION = 23
BUILD_TOOLS_VERSION = '24'
// app dependencies
GOOGLE_API_CLIENT_VERSION = '1.19.0'
GOOGLE_PLAY_SERVICES_VERSION = '8.4.0'
ANDROID_SUPPORT_LIB_VERSION = '23.1.0'
[...]
// backend dependencies
[...]
}
Run Code Online (Sandbox Code Playgroud)
以后在我的说app build.gradle文件中使用
dependencies {
[...]
compile(group: 'com.google.oauth-client', name: 'google-oauth-client', version: rootProject.ext.GOOGLE_API_CLIENT_VERSION)
/////////////////////////////////
// Google Play Services explicit dependency
compile(group: 'com.google.android.gms', name: 'play-services-auth', version: rootProject.ext.GOOGLE_PLAY_SERVICES_VERSION)
compile(group: 'com.google.android.gms', name: 'play-services-plus', version: rootProject.ext.GOOGLE_PLAY_SERVICES_VERSION)
[...]
/////////////////////////////////
// Local Testing
testCompile(group: 'junit', …Run Code Online (Sandbox Code Playgroud) gradle android-build android-studio build.gradle android-gradle-plugin