Skip to content

Commit

Permalink
Merge branch 'release/2024.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
miosakuma committed Mar 13, 2024
2 parents 3bb332a + ed10a5e commit a71d1f7
Show file tree
Hide file tree
Showing 13 changed files with 1,559 additions and 1,134 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/__pycache__
/_install
/_build
/_source
/_package
/test/*.json
!/test/*.example.json
/test/ios/build/
/test/ios/hello/model_coeffs/
/test/android/app/src/main/assets
Expand Down
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"[cpp]": {
"editor.formatOnSave": true
},
"json.schemas": [{
"fileMatch": ["**/test/*.json"],
"schema": {
"allowTrailingCommas": true,
}
}],
"files.associations": {
"*.cs": "csharp",
"CMakeLists.txt": "cmake",
Expand Down Expand Up @@ -131,6 +137,7 @@
"xtree": "cpp",
"xutility": "cpp",
"__nullptr": "cpp",
"__config": "cpp"
"__config": "cpp",
"**/test/*.json": "jsonc"
}
}
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@

## develop

## 2024.4.0 (2024-03-13)

- [ADD] test/hello.cpp に video, audio フラグを追加
- @melpon
- [FIX] Android ハンズフリー機能において Android 11 以前で Bluetooth SCO が切れてしまう問題を改善
- @tnoho

## 2024.3.1 (2024-03-07)

- [FIX] Sora C++ SDK を利用してビルドする時に自動的に _LIBCPP_HARDENING_MODE が定義されるように修正
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SORA_CPP_SDK_VERSION=2024.3.1
SORA_CPP_SDK_VERSION=2024.4.0
WEBRTC_BUILD_VERSION=m121.6167.3.0
BOOST_VERSION=1.84.0
CMAKE_VERSION=3.28.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

import java.util.List;

class SoraBluetoothManager {
private static final String TAG = "SoraBluetoothManager";
class SoraAudioManagerBluetooth {
private static final String TAG = "SoraAudioManagerBluetooth";
// Bluetooth SCO の開始/終了タイムアウト
private static final int BLUETOOTH_SCO_TIMEOUT_MS = 4000;
// SCO 接続試行上限
Expand Down Expand Up @@ -118,7 +118,10 @@ public void onReceive(Context context, Intent intent) {
if (state == BluetoothHeadset.STATE_CONNECTED) {
// Bluetooth ヘッドセットとが接続された
scoConnectionAttempts = 0;
updateAudioDeviceState();
// ここで updateAudioDeviceState() を実行すると startBluetoothSco() が実行される
// しかし、この後 STATE_AUDIO_CONNECTED と STATE_AUDIO_DISCONNECTED がきてしまい切断されるため、
// updateAudioDeviceState() は STATE_AUDIO_DISCONNECTED 時に任せることとしてここでは実行しない
// updateAudioDeviceState();
} else if (state == BluetoothHeadset.STATE_DISCONNECTED) {
// おそらく Bluetooth が通話中に切られた
stopScoAudio();
Expand Down Expand Up @@ -150,14 +153,14 @@ public void onReceive(Context context, Intent intent) {
}
}

static SoraBluetoothManager create(
static SoraAudioManagerBluetooth create(
Context context,
SoraAudioManagerLegacy soraAudioManagerLegacy,
AudioManager audioManager) {
return new SoraBluetoothManager(context, soraAudioManagerLegacy, audioManager);
return new SoraAudioManagerBluetooth(context, soraAudioManagerLegacy, audioManager);
}

protected SoraBluetoothManager(
protected SoraAudioManagerBluetooth(
Context context,
SoraAudioManagerLegacy soraAudioManagerLegacy,
AudioManager audioManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SoraAudioManagerLegacy extends SoraAudioManagerBase {
private static final String TAG = "SoraAudioManagerLegacy";
private enum AudioDevice { SPEAKER_PHONE, WIRED_HEADSET, EARPIECE, BLUETOOTH, NONE }
private final AudioDevice defaultAudioDevice;
private final SoraBluetoothManager bluetoothManager;
private final SoraAudioManagerBluetooth bluetoothManager;
private Set<AudioDevice> audioDevices = new HashSet<>();
private boolean running;
private boolean savedIsSpeakerPhoneOn;
Expand All @@ -40,7 +40,7 @@ static SoraAudioManagerLegacy create(Context context) {
private SoraAudioManagerLegacy(Context context) {
super(context);

bluetoothManager = SoraBluetoothManager.create(context, this, audioManager);
bluetoothManager = SoraAudioManagerBluetooth.create(context, this, audioManager);

// デフォルトのデバイスを設定する
// 受話用のスピーカーがある場合は受話用のスピーカーを使う
Expand Down Expand Up @@ -133,19 +133,19 @@ void updateAudioDeviceState() {
return;
}

if (bluetoothManager.getState() == SoraBluetoothManager.State.HEADSET_AVAILABLE
|| bluetoothManager.getState() == SoraBluetoothManager.State.HEADSET_UNAVAILABLE
|| bluetoothManager.getState() == SoraBluetoothManager.State.SCO_DISCONNECTING) {
if (bluetoothManager.getState() == SoraAudioManagerBluetooth.State.HEADSET_AVAILABLE
|| bluetoothManager.getState() == SoraAudioManagerBluetooth.State.HEADSET_UNAVAILABLE
|| bluetoothManager.getState() == SoraAudioManagerBluetooth.State.SCO_DISCONNECTING) {
// Bluetooth のデバイスを更新する
bluetoothManager.updateDevice();
}

// 存在するオーディオデバイスのリストを生成する
Set<AudioDevice> newAudioDevices = new HashSet<>();

if (bluetoothManager.getState() == SoraBluetoothManager.State.SCO_CONNECTED
|| bluetoothManager.getState() == SoraBluetoothManager.State.SCO_CONNECTING
|| bluetoothManager.getState() == SoraBluetoothManager.State.HEADSET_AVAILABLE) {
if (bluetoothManager.getState() == SoraAudioManagerBluetooth.State.SCO_CONNECTED
|| bluetoothManager.getState() == SoraAudioManagerBluetooth.State.SCO_CONNECTING
|| bluetoothManager.getState() == SoraAudioManagerBluetooth.State.HEADSET_AVAILABLE) {
// Bluetooth デバイスが存在する
newAudioDevices.add(AudioDevice.BLUETOOTH);
}
Expand Down Expand Up @@ -193,28 +193,31 @@ void updateAudioDeviceState() {

// Bluetooth audio を開始する必要があるか
boolean needBluetoothAudioStart =
bluetoothManager.getState() == SoraBluetoothManager.State.HEADSET_AVAILABLE
bluetoothManager.getState() == SoraAudioManagerBluetooth.State.HEADSET_AVAILABLE
&& !isSetHandsfree
&& (lastConnectedAudioDevice == AudioDevice.BLUETOOTH || !hasWiredHeadset);
Log.d(TAG, "Update device state: "
+ "wired headset=" + hasWiredHeadset + ", "
+ "BT state=" + bluetoothManager.getState() + ", "
+ "need BT audio start=" + needBluetoothAudioStart);

// Bluetooth audio を停止する必要があるか
boolean needBluetoothAudioStop =
(bluetoothManager.getState() == SoraBluetoothManager.State.SCO_CONNECTED
|| bluetoothManager.getState() == SoraBluetoothManager.State.SCO_CONNECTING)
(bluetoothManager.getState() == SoraAudioManagerBluetooth.State.SCO_CONNECTED
|| bluetoothManager.getState() == SoraAudioManagerBluetooth.State.SCO_CONNECTING)
&& (isSetHandsfree
|| (lastConnectedAudioDevice == AudioDevice.WIRED_HEADSET && hasWiredHeadset));

Log.d(TAG, "Update device state: "
+ "set handsfree=" + isSetHandsfree + ", "
+ "wired headset=" + hasWiredHeadset + ", "
+ "BT state=" + bluetoothManager.getState() + ", "
+ "need BT audio start=" + needBluetoothAudioStart + ", "
+ "need BT audio stop=" + needBluetoothAudioStop);

if (needBluetoothAudioStop) {
bluetoothManager.stopScoAudio();
bluetoothManager.updateDevice();
}

if (needBluetoothAudioStart && !needBluetoothAudioStop) {
// Bluetooth SCO audio を介しする
// Bluetooth SCO audio を開始する
if (!bluetoothManager.startScoAudio()) {
// 失敗した場合はリストから BLUETOOTH を削除する
audioDevices.remove(AudioDevice.BLUETOOTH);
Expand All @@ -224,10 +227,10 @@ void updateAudioDeviceState() {

// ハンズフリーの解除を待つのは SCO_CONNECTING の間だけ
willOffHandsfree = willOffHandsfree
&& bluetoothManager.getState() == SoraBluetoothManager.State.SCO_CONNECTING;
&& bluetoothManager.getState() == SoraAudioManagerBluetooth.State.SCO_CONNECTING;

final AudioDevice newAudioDevice;
if (bluetoothManager.getState() == SoraBluetoothManager.State.SCO_CONNECTED) {
if (bluetoothManager.getState() == SoraAudioManagerBluetooth.State.SCO_CONNECTED) {
newAudioDevice = AudioDevice.BLUETOOTH;
willOffHandsfree = false;
} else if (!isSetHandsfree && hasWiredHeadset) {
Expand All @@ -237,11 +240,11 @@ void updateAudioDeviceState() {
} else {
newAudioDevice = defaultAudioDevice;
}
setSpeakerphoneOn(newAudioDevice == AudioDevice.SPEAKER_PHONE);
if (newAudioDevice != selectedAudioDevice) {
Log.d(TAG, "New device status: "
+ "available=" + audioDevices + ", "
+ "selected=" + newAudioDevice);
setSpeakerphoneOn(newAudioDevice == AudioDevice.SPEAKER_PHONE);
selectedAudioDevice = newAudioDevice;
if (onChangeRouteObserver != null) {
onChangeRouteObserver.OnChangeRoute();
Expand Down
Loading

0 comments on commit a71d1f7

Please sign in to comment.