Modifies invalid DCHECK in AudioRecordJni::OnCacheDirectBufferAddress()
Ensures that we can restart audio recording on Android without hitting a DCHECK. Also adds a symmetric design for the playout side. BUG=webrtc:5000 TEST=modules_unittests --gtest_filter=AudioDevice* Review URL: https://codereview.webrtc.org/1373443003 Cr-Commit-Position: refs/heads/master@{#10072}
This commit is contained in:
parent
44d5d7ba42
commit
82e20554cb
@ -831,6 +831,15 @@ TEST_F(AudioDeviceTest, StartStopPlayout) {
|
||||
StopPlayout();
|
||||
}
|
||||
|
||||
// Tests that recording can be initiated, started and stopped. No audio callback
|
||||
// is registered in this test.
|
||||
TEST_F(AudioDeviceTest, StartStopRecording) {
|
||||
StartRecording();
|
||||
StopRecording();
|
||||
StartRecording();
|
||||
StopRecording();
|
||||
}
|
||||
|
||||
// Verify that calling StopPlayout() will leave us in an uninitialized state
|
||||
// which will require a new call to InitPlayout(). This test does not call
|
||||
// StartPlayout() while being uninitialized since doing so will hit a
|
||||
|
||||
@ -175,6 +175,7 @@ int32_t AudioRecordJni::StopRecording() {
|
||||
thread_checker_java_.DetachFromThread();
|
||||
initialized_ = false;
|
||||
recording_ = false;
|
||||
direct_buffer_address_= nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -156,6 +156,7 @@ int32_t AudioTrackJni::StopPlayout() {
|
||||
thread_checker_java_.DetachFromThread();
|
||||
initialized_ = false;
|
||||
playing_ = false;
|
||||
direct_buffer_address_ = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -215,6 +216,7 @@ void AudioTrackJni::OnCacheDirectBufferAddress(
|
||||
JNIEnv* env, jobject byte_buffer) {
|
||||
ALOGD("OnCacheDirectBufferAddress");
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
RTC_DCHECK(!direct_buffer_address_);
|
||||
direct_buffer_address_ =
|
||||
env->GetDirectBufferAddress(byte_buffer);
|
||||
jlong capacity = env->GetDirectBufferCapacity(byte_buffer);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user