|
|
@ -67,18 +67,17 @@ class AudioMediaEncoder extends MediaEncoder { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void stop() { |
|
|
|
void stop() { |
|
|
|
mRequestStop = true; |
|
|
|
mRequestStop = true; |
|
|
|
try { |
|
|
|
synchronized (mLock) { |
|
|
|
synchronized (mLock) { |
|
|
|
try { |
|
|
|
mLock.wait(); |
|
|
|
mLock.wait(); |
|
|
|
} |
|
|
|
} catch (InterruptedException e) {} |
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
|
|
|
// Ignore
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void release() { |
|
|
|
void release() { |
|
|
|
super.release(); |
|
|
|
super.release(); |
|
|
|
|
|
|
|
mRequestStop = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class AudioThread extends Thread { |
|
|
|
class AudioThread extends Thread { |
|
|
@ -93,8 +92,7 @@ class AudioMediaEncoder extends MediaEncoder { |
|
|
|
if (bufferSize < minBufferSize) { |
|
|
|
if (bufferSize < minBufferSize) { |
|
|
|
bufferSize = ((minBufferSize / SAMPLES_PER_FRAME) + 1) * SAMPLES_PER_FRAME * 2; |
|
|
|
bufferSize = ((minBufferSize / SAMPLES_PER_FRAME) + 1) * SAMPLES_PER_FRAME * 2; |
|
|
|
} |
|
|
|
} |
|
|
|
mAudioRecord = new AudioRecord( |
|
|
|
mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.CAMCORDER, SAMPLE_RATE, |
|
|
|
MediaRecorder.AudioSource.CAMCORDER, SAMPLE_RATE, |
|
|
|
|
|
|
|
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize); |
|
|
|
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -120,6 +118,8 @@ class AudioMediaEncoder extends MediaEncoder { |
|
|
|
encode(null, 0, getPresentationTime()); |
|
|
|
encode(null, 0, getPresentationTime()); |
|
|
|
drain(false); |
|
|
|
drain(false); |
|
|
|
mAudioRecord.stop(); |
|
|
|
mAudioRecord.stop(); |
|
|
|
|
|
|
|
mAudioRecord.release(); |
|
|
|
|
|
|
|
mAudioRecord = null; |
|
|
|
synchronized (mLock) { |
|
|
|
synchronized (mLock) { |
|
|
|
mLock.notify(); |
|
|
|
mLock.notify(); |
|
|
|
} |
|
|
|
} |
|
|
|