Skip to content

Commit

Permalink
Merge branch 'release-9.7' into release-9.8
Browse files Browse the repository at this point in the history
  • Loading branch information
z-dule committed Jun 10, 2024
2 parents 3eeda42 + 0053f1b commit c519348
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 107 deletions.
53 changes: 40 additions & 13 deletions android/lib/src/main/java/com/waz/audioeffect/MediaConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ public int decode(String pcmPath) {

while (i < numTracks && !found) {
mediaFormat = extractor.getTrackFormat(i);
mimeType = mediaFormat.getString(MediaFormat.KEY_MIME);
if (mimeType.startsWith("audio/")) {
found = true;
try {
mimeType = mediaFormat.getString(MediaFormat.KEY_MIME);
if (mimeType.startsWith("audio/")) {
found = true;
}
else {
i++;
}
}
else {
i++;
catch (Exception e) {
Log.w(TAG, "decode: no mime type");
}
}

Expand All @@ -73,14 +78,23 @@ public int decode(String pcmPath) {
}

try {
bitRate = mediaFormat.getInteger(MediaFormat.KEY_BIT_RATE, bitRate);
sampleRate = mediaFormat.getInteger(MediaFormat.KEY_SAMPLE_RATE, sampleRate);
channelCount = mediaFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT, channelCount);

bitRate = mediaFormat.getInteger(MediaFormat.KEY_BIT_RATE);
}
catch(Exception e) {
Log.w(TAG, "decode: bitrate key exception: " + e);
}
try {
sampleRate = mediaFormat.getInteger(MediaFormat.KEY_SAMPLE_RATE);
}
catch(Exception e) {
Log.w(TAG, "decode: samplerate key exception: " + e);
}
try {
channelCount = mediaFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
}
catch(Exception e) {
Log.w(TAG, "decode: channel count exception: " + e);
}

extractor.selectTrack(i);
decoder = MediaCodec.createDecoderByType(mimeType);
Expand Down Expand Up @@ -174,7 +188,22 @@ public int encode(String pcmPath) {
int trackId = muxer.addTrack(mediaFormat);
boolean finished = false;
boolean eos = false;
String mimeType = mediaFormat.getString(MediaFormat.KEY_MIME, "audio/mp4a-latm");
String mimeType = "audio/mp4a-latm";
int profileId = MediaCodecInfo.CodecProfileLevel.AACObjectLC;

try {
mediaFormat.getString(MediaFormat.KEY_MIME);
}
catch (Exception e) {
Log.w(TAG, "encode: no mime type");
}

try {
mediaFormat.getInteger(MediaFormat.KEY_AAC_PROFILE);
}
catch (Exception e) {
Log.w(TAG, "encode: no profile");
}

encoder = MediaCodec.createEncoderByType(mimeType);

Expand All @@ -183,9 +212,7 @@ public int encode(String pcmPath) {
format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate);
format.setInteger(MediaFormat.KEY_CHANNEL_COUNT, channelCount);
format.setInteger(MediaFormat.KEY_SAMPLE_RATE, sampleRate);
format.setInteger(MediaFormat.KEY_AAC_PROFILE,
mediaFormat.getInteger(MediaFormat.KEY_AAC_PROFILE,
MediaCodecInfo.CodecProfileLevel.AACObjectLC));
format.setInteger(MediaFormat.KEY_AAC_PROFILE, profileId);

encoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
muxer.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CameraPreviewBuilder shouldFill(boolean shouldFill) {

public PreviewView build() {
PreviewView preview = new PreviewView(context);
preview.setImplementationMode(PreviewView.ImplementationMode.PERFORMANCE);
preview.setImplementationMode(PreviewView.ImplementationMode.COMPATIBLE);
preview.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ public int EnableSpeaker(){
if (hasApi31()) {
List<AudioDeviceInfo> devices = _audio_manager.getAvailableCommunicationDevices();
for (AudioDeviceInfo device : devices) {
if (device == null)
continue;

if (device.getType() == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) {
speakerDevice = device;
break;
Expand Down
3 changes: 0 additions & 3 deletions iosx/src/flowmgr/AVSFlowManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,7 @@ - (instancetype)init:(uint64_t)avs_flags

g_Fm = self;

#if !(TARGET_IPHONE_SIMULATOR)
_capturer = [[AVSCapturer alloc] init];
#endif

}

return self;
Expand Down
2 changes: 2 additions & 0 deletions iosx/src/flowmgr/AVSVideoView.m
Original file line number Diff line number Diff line change
Expand Up @@ -610,12 +610,14 @@ - (void)didMoveToWindow
}
}

#if !TARGET_IPHONE_SIMULATOR
if (self.window) {
[self startRunning];
}
else {
[self stopRunning];
}
#endif
}

- (void)applicationWillResignActive:(NSNotification *)notification
Expand Down
7 changes: 4 additions & 3 deletions src/audio_io/ios/audio_io_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
if (!is_recording_.load()) {
OSStatus result = AudioOutputUnitStart(au_);
if (result != noErr) {
error("audio_io_ios: AudioOutputUnitStart failed:0x08x\n", result);
error("audio_io_ios: AudioOutputUnitStart failed:0x%08x\n", result);
return -1;
}
}
Expand Down Expand Up @@ -550,7 +550,7 @@

int32_t audio_io_ios::init_play_or_record(void)
{
info("audio_io_ios: AudioDeviceIOS::InitPlayOrRecord \n");
info("audio_io_ios: AudioDeviceIOS::InitPlayOrRecord\n");

assert(!au_);

Expand Down Expand Up @@ -579,6 +579,7 @@
want_stereo_playout_, use_stereo_playout);

NSString *cat = [AVAudioSession sharedInstance].category;
info("audio_io_ios: category=%s\n", [cat UTF8String]);
if (cat != AVAudioSessionCategoryPlayAndRecord){
error("audio_io_ios: catagory not "
"AVAudioSessionCategoryPlayAndRecord\n");
Expand Down Expand Up @@ -776,7 +777,7 @@
// Initialize here already to be able to get/set stream properties.
result = AudioUnitInitialize(au_);
if (0 != result) {
error("audio_io_ios: AudioUnitInitialize failed: %d \n", result);
error("audio_io_ios: AudioUnitInitialize failed: 0x%08x\n", result);
return -1;
}

Expand Down
11 changes: 11 additions & 0 deletions src/mediamgr/mediamgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ struct mm {
bool should_reset;
bool alloc_pending;
bool play_ready;
bool speaker_override;

pthread_t thread;

Expand Down Expand Up @@ -721,6 +722,11 @@ static void enable_speaker(struct mm *mm, bool enable)
enum mediamgr_auplay cur_route = mm_platform_get_route();
enum mediamgr_auplay wanted_route = MEDIAMGR_AUPLAY_UNKNOWN;

if (mm->speaker_override) {
info("enable_speaker: speaker manual override, ignoring\n");
return;
}

info("enable_speaker: enable=%d\n", enable);

mm->router.prefer_loudspeaker = enable;
Expand Down Expand Up @@ -898,6 +904,7 @@ static void exit_call(struct mm *mm)
case MM_SYS_STATE_INCOMING:
case MM_SYS_STATE_ENTERING_CALL:
set_sys_state(mm, MM_SYS_STATE_EXITING_CALL);
mm->speaker_override = false;
mm_platform_exit_call();
break;

Expand Down Expand Up @@ -1396,6 +1403,7 @@ static void sys_left_call_handler(struct mm *mm)
set_sys_state(mm, MM_SYS_STATE_NORMAL);
if (mm->call_state == MEDIAMGR_STATE_NORMAL) {
mm->router.prefer_loudspeaker = false;
mm->speaker_override = false;
update_route(mm, MM_DEVICE_CHANGED);
}
}
Expand Down Expand Up @@ -1534,6 +1542,7 @@ static void call_state_handler(struct mm *mm, enum mediamgr_state new_state)

switch (new_state) {
case MEDIAMGR_STATE_NORMAL:
mm->speaker_override = false;
set_state(mm, new_state);
stop_all_media(mm);
audio_release(mm);
Expand Down Expand Up @@ -1751,7 +1760,9 @@ static void mqueue_handler(int id, void *data, void *arg)
case MM_MARSHAL_ENABLE_SPEAKER: {
bool enable = msg->bool_elem.val;

g_mm->speaker_override = false;
enable_speaker(g_mm, enable);
g_mm->speaker_override = true;
}
break;

Expand Down
Loading

0 comments on commit c519348

Please sign in to comment.