Skip to content

Commit

Permalink
Merge pull request #27 from marinaserranomontes/develop
Browse files Browse the repository at this point in the history
Cleaning comments
  • Loading branch information
marinaserranomontes committed Sep 22, 2014
2 parents 9db8f4d + 6747cd3 commit d683051
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import java.util.concurrent.locks.ReentrantLock;

import com.opentok.android.BaseAudioDevice;
import com.opentok.android.DefaultAudioDevice;
import com.opentok.android.BaseAudioDevice.AudioSettings;
import com.opentok.android.BaseAudioDevice.OutputMode;

import android.content.BroadcastReceiver;
import android.content.Context;
Expand All @@ -26,7 +29,6 @@ public class CustomAudioDevice extends BaseAudioDevice {
private final static int NUM_CHANNELS_RENDERING = 1;

private final static int MAX_SAMPLES = 2 * 480 * 2; // Max 10 ms @ 48 kHz
// Stereo

private Context m_context;

Expand Down Expand Up @@ -287,7 +289,7 @@ public boolean initRenderer() {
m_bufferedPlaySamples = 0;

m_audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
setCommunicationMode(m_audioMode);
setOutputMode(m_outputMode);

m_shutdownRenderThread = false;
new Thread(m_renderThread).start();
Expand All @@ -306,7 +308,7 @@ public boolean destroyRenderer() {
m_rendererLock.unlock();

unregisterHeadsetReceiver();
setSpeakerphoneOn(false);
m_audioManager.setSpeakerphoneOn(false);
m_audioManager.setMode(AudioManager.MODE_NORMAL);

return true;
Expand Down Expand Up @@ -439,13 +441,6 @@ public void run() {
}
};

public boolean setSpeakerphoneOn(boolean speakerphoneOn) {

m_audioManager.setSpeakerphoneOn(speakerphoneOn);

return true;
}

@Override
public AudioSettings getCaptureSettings() {
return this.m_captureSettings;
Expand All @@ -460,13 +455,13 @@ public AudioSettings getRenderSettings() {
* Communication modes handling
*/

public boolean setCommunicationMode(int mode) {
m_audioMode = mode;
if (mode == VOICE_COMMUNICATION) {
public boolean setOutputMode(OutputMode mode) {
m_outputMode = mode;
if (mode == OutputMode.Handset) {
unregisterHeadsetReceiver();
setSpeakerphoneOn(false);
m_audioManager.setSpeakerphoneOn(false);
} else {
setSpeakerphoneOn(true);
m_audioManager.setSpeakerphoneOn(true);
registerHeadsetReceiver();
}
return true;
Expand All @@ -478,9 +473,9 @@ public void onReceive(Context context, Intent intent) {
if (intent.getAction().compareTo(Intent.ACTION_HEADSET_PLUG) == 0) {
int state = intent.getIntExtra("state", 0);
if (state == 0) {
setSpeakerphoneOn(true);
m_audioManager.setSpeakerphoneOn(true);
} else {
setSpeakerphoneOn(false);
m_audioManager.setSpeakerphoneOn(false);
}
}
}
Expand Down Expand Up @@ -511,16 +506,15 @@ private void unregisterHeadsetReceiver() {

@Override
public void onPause() {
if (m_audioMode == VIDEO_COMMUNICATION) {
if (m_outputMode == OutputMode.SpeakerPhone) {
unregisterHeadsetReceiver();
}
}

@Override
public void onResume() {
if (m_audioMode == VIDEO_COMMUNICATION) {
if (m_outputMode == OutputMode.SpeakerPhone) {
registerHeadsetReceiver();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,6 @@ private void sessionConnect() {
CustomAudioDevice customAudioDevice = new CustomAudioDevice(
AudioDeviceActivity.this);
AudioDeviceManager.setAudioDevice(customAudioDevice);
AudioDeviceManager.getAudioDevice().setCommunicationMode(
CustomAudioDevice.VOICE_COMMUNICATION);

mSession = new Session(AudioDeviceActivity.this,
OpenTokConfig.API_KEY, OpenTokConfig.SESSION_ID);
Expand Down

0 comments on commit d683051

Please sign in to comment.