Skip to content

Commit 015fed8

Browse files
authored
Merge branch 'main' into add-browsertest-runners-to-ci
2 parents cd31197 + 8b7b5eb commit 015fed8

23 files changed

+166
-453
lines changed

.github/actions/sccache/action.yaml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,29 @@ runs:
1010
- name: Install sccache
1111
shell: bash
1212
run: brew install sccache
13+
# - name: 'Set up Cloud SDK'
14+
# if: inputs.sccache_gcs_key == ''
15+
# uses: 'google-github-actions/setup-gcloud@v3'
16+
# with:
17+
# version: '>= 363.0.0'
1318
- name: Configure sccache
1419
shell: bash
1520
env:
1621
SCCACHE_GCS_KEY: ${{ inputs.sccache_gcs_key }}
1722
run: |
18-
printf "%s" "$SCCACHE_GCS_KEY" > "${HOME}/gcloud.json"
19-
echo "SCCACHE_GCS_RW_MODE=READ_WRITE" >> $GITHUB_ENV
20-
echo "SCCACHE_GCS_KEY_PATH=${HOME}/gcloud.json" >> $GITHUB_ENV
21-
echo "SCCACHE_GCS_BUCKET=cobalt-sccache-tvos-bucket" >> $GITHUB_ENV
23+
if [[ -n "$SCCACHE_GCS_KEY" ]]; then
24+
# If we have a GCS key we use READ_WRITE
25+
printf "%s" "$SCCACHE_GCS_KEY" > "${HOME}/gcloud.json"
26+
echo "SCCACHE_GCS_KEY_PATH=${HOME}/gcloud.json" >> $GITHUB_ENV
27+
echo "SCCACHE_GCS_RW_MODE=READ_WRITE" >> $GITHUB_ENV
28+
echo "SCCACHE_GCS_BUCKET=cobalt-sccache-tvos-bucket" >> $GITHUB_ENV
29+
else
30+
# Read only
31+
echo "SCCACHE_BUCKET=cobalt-sccache-tvos-bucket" >> $GITHUB_ENV
32+
echo "SCCACHE_ENDPOINT=https://storage.googleapis.com" >> $GITHUB_ENV
33+
echo "SCCACHE_S3_NO_CREDENTIALS=true" >> $GITHUB_ENV
34+
echo "SCCACHE_REGION=auto" >> $GITHUB_ENV
35+
fi
2236
echo "SCCACHE=1" >> $GITHUB_ENV
2337
echo "SCCACHE_IDLE_TIMEOUT=0" >> $GITHUB_ENV
2438
- name: Start sccache server

.github/config/android-arm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test_on_device": true,
88
"test_device_family": "android",
99
"test_e2e": true,
10-
"test_yts": false,
10+
"test_yts": true,
1111
"test_yts_playback": true,
1212
"test_browser": false,
1313
"test_yts_wpt": false,

.github/config/android-arm64.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"test_on_device": true,
88
"test_device_family": "android",
99
"test_e2e": true,
10-
"test_yts": false,
1110
"test_browser": false,
11+
"test_yts": true,
1212
"test_root_target": "//cobalt/android:cobalt_apk",
1313
"test_dimensions": {
1414
"device_type": "nvidia_shield",

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ jobs:
456456
targets: ${{ needs.initialize.outputs.targets }}
457457
test_root_target: ${{ needs.initialize.outputs.test_root_target }}
458458
test_targets_json_file: out/${{ matrix.platform }}_${{ matrix.config }}/test_targets.json
459-
enable_sccache: ${{ needs.initialize.outputs.enable_sccache == 'true' && secrets.sccache_gcs_key != '' }}
459+
enable_sccache: ${{ needs.initialize.outputs.enable_sccache == 'true' }}
460460
sccache_gcs_key: ${{ secrets.sccache_gcs_key }}
461461

462462
- name: Release Package

.github/workflows/nightly_trigger_main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: nightly_trigger_main
33
on:
44
schedule:
55
# GMT timezone.
6-
- cron: '0 10 * * *'
6+
- cron: '0 10,12,14 * * *'
77
workflow_dispatch:
88

99
jobs:

cobalt/android/apk/app/src/main/java/dev/cobalt/media/AudioTrackBridge.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import android.media.AudioFormat;
2121
import android.media.AudioManager;
2222
import android.media.AudioTrack;
23+
import android.media.PlaybackParams;
2324
import android.os.Build;
2425
import androidx.annotation.GuardedBy;
2526
import androidx.annotation.RequiresApi;
@@ -227,11 +228,34 @@ public void release() {
227228
mAvSyncPacketBytesRemaining = 0;
228229
}
229230

231+
232+
@CalledByNative
233+
public boolean setPlaybackRate(float playbackRate) {
234+
if (mAudioTrack == null) {
235+
Log.e(TAG, "Unable to setPlaybackRate with NULL audio track.");
236+
return false;
237+
}
238+
if (!mTunnelModeEnabled) {
239+
Log.i(TAG, "Skip SetPlaybackRate for non tunnel mode tracks.");
240+
return true;
241+
}
242+
243+
try {
244+
PlaybackParams params = mAudioTrack.getPlaybackParams();
245+
params.setSpeed(playbackRate);
246+
mAudioTrack.setPlaybackParams(params);
247+
} catch (IllegalArgumentException | IllegalStateException e) {
248+
Log.e(TAG, String.format("Unable to setPlaybackRate, error: %s", e.toString()));
249+
return false;
250+
}
251+
return true;
252+
}
253+
230254
@CalledByNative
231255
public int setVolume(float gain) {
232256
if (mAudioTrack == null) {
233257
Log.e(TAG, "Unable to setVolume with NULL audio track.");
234-
return 0;
258+
return AudioTrack.ERROR_INVALID_OPERATION;
235259
}
236260
return mAudioTrack.setVolume(gain);
237261
}

media/audio/ios/audio_session_manager_ios.mm

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313

1414
namespace media {
1515

16-
// Below constant values are taken from :
16+
// The constant below is taken from:
1717
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/sdk/objc/components/audio/RTCAudioSessionConfiguration.m
1818
const int kRTCAudioSessionPreferredNumberOfChannels = 1;
19-
const double kRTCAudioSessionHighPerformanceSampleRate = 48000.0;
20-
const double kRTCAudioSessionHighPerformanceIOBufferDuration = 0.02;
2119

2220
// static
2321
AudioSessionManagerIOS& AudioSessionManagerIOS::GetInstance() {
@@ -55,12 +53,6 @@
5553
error.localizedDescription);
5654
}
5755

58-
[audio_session
59-
setPreferredSampleRate:kRTCAudioSessionHighPerformanceSampleRate
60-
error:nil];
61-
[audio_session setPreferredIOBufferDuration:
62-
kRTCAudioSessionHighPerformanceIOBufferDuration
63-
error:nil];
6456
// Find the desired input port
6557
NSArray* inputs = [audio_session availableInputs];
6658
AVAudioSessionPortDescription* builtInMic = nil;
@@ -132,9 +124,6 @@
132124
[audio_session setPreferredInputNumberOfChannels:
133125
kRTCAudioSessionPreferredNumberOfChannels
134126
error:nil];
135-
[audio_session setPreferredOutputNumberOfChannels:
136-
kRTCAudioSessionPreferredNumberOfChannels
137-
error:nil];
138127
}
139128

140129
void AudioSessionManagerIOS::SetActive(bool active) {

starboard/android/shared/audio_track_audio_sink_type.cc

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,19 @@ AudioTrackAudioSink::~AudioTrackAudioSink() {
188188

189189
void AudioTrackAudioSink::SetPlaybackRate(double playback_rate) {
190190
SB_DCHECK_GE(playback_rate, 0.0);
191-
if (playback_rate != 0.0 && playback_rate != 1.0) {
192-
SB_NOTIMPLEMENTED() << "TODO: Only playback rates of 0.0 and 1.0 are "
193-
"currently supported.";
194-
playback_rate = (playback_rate > 0.0) ? 1.0 : 0.0;
191+
SB_DLOG(INFO) << "Set playback rate to " << playback_rate;
192+
193+
{
194+
std::lock_guard lock(mutex_);
195+
playback_rate_ = playback_rate;
196+
}
197+
198+
// AudioTrack doesn't support playback speed of 0.
199+
if (playback_rate > 0.0) {
200+
// AudioTrackBridge.setPlaybackRate() currently is only enabled for tunnel
201+
// mode. It will be no-op for non tunnel player.
202+
bridge_.SetPlaybackRate(playback_rate);
195203
}
196-
std::lock_guard lock(mutex_);
197-
playback_rate_ = playback_rate;
198204
}
199205

200206
// TODO: Break down the function into manageable pieces.
@@ -439,6 +445,21 @@ int AudioTrackAudioSinkType::GetMinBufferSizeInFrames(
439445
int sampling_frequency_hz) {
440446
SB_CHECK(audio_track_audio_sink_type_);
441447
JNIEnv* env = AttachCurrentThread();
448+
449+
const bool force_tunnel_mode =
450+
features::FeatureList::IsEnabled(features::kForceTunnelMode);
451+
if (force_tunnel_mode) {
452+
// AudioTrack.setPlaybackParams() needs extra buffer to support playback
453+
// speed greater than 1.0x.
454+
const double kMaxPlaybackSpeed = 2.0;
455+
return std::max<int>(
456+
AudioOutputManager::GetInstance()->GetMinBufferSizeInFrames(
457+
env, sample_type, channels, sampling_frequency_hz),
458+
audio_track_audio_sink_type_->GetMinBufferSizeInFramesInternal(
459+
channels, sample_type, sampling_frequency_hz) *
460+
kMaxPlaybackSpeed);
461+
}
462+
442463
return std::max(
443464
AudioOutputManager::GetInstance()->GetMinBufferSizeInFrames(
444465
env, sample_type, channels, sampling_frequency_hz),

starboard/android/shared/audio_track_bridge.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "starboard/android/shared/audio_output_manager.h"
2020
#include "starboard/android/shared/media_common.h"
2121
#include "starboard/audio_sink.h"
22+
#include "starboard/common/check_op.h"
2223
#include "starboard/common/log.h"
2324
#include "starboard/shared/starboard/media/media_util.h"
2425

@@ -241,6 +242,21 @@ int AudioTrackBridge::WriteSample(const uint8_t* samples,
241242
return bytes_written;
242243
}
243244

245+
void AudioTrackBridge::SetPlaybackRate(
246+
double playback_rate,
247+
JNIEnv* env /*= AttachCurrentThread()*/) {
248+
SB_DCHECK(env);
249+
SB_DCHECK(is_valid());
250+
// AudioTrack doesn't support playback speed of 0.
251+
SB_DCHECK_GT(playback_rate, 0.0);
252+
253+
jboolean status = Java_AudioTrackBridge_setPlaybackRate(
254+
env, j_audio_track_bridge_, static_cast<float>(playback_rate));
255+
if (!status) {
256+
SB_LOG(ERROR) << "Failed to set playback rate to " << playback_rate;
257+
}
258+
}
259+
244260
void AudioTrackBridge::SetVolume(double volume,
245261
JNIEnv* env /*= AttachCurrentThread()*/) {
246262
SB_DCHECK(env);

starboard/android/shared/audio_track_bridge.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class AudioTrackBridge {
7171
int64_t sync_time,
7272
JNIEnv* env = base::android::AttachCurrentThread());
7373

74+
void SetPlaybackRate(double playback_rate,
75+
JNIEnv* env = base::android::AttachCurrentThread());
7476
void SetVolume(double volume,
7577
JNIEnv* env = base::android::AttachCurrentThread());
7678

0 commit comments

Comments
 (0)