* set app_camera default resolution to 1080p , fix app_photo play audio coredump

This commit is contained in:
lxowalle
2026-01-17 12:13:33 +08:00
parent 7f91cd1257
commit fda50d3751
3 changed files with 16 additions and 4 deletions

View File

@@ -1161,8 +1161,8 @@ namespace maix::video
err::check_null_raise(audio_frame = av_frame_alloc(), "Could not allocate audio frame");
err::check_null_raise(swr_ctx = swr_alloc(), "Could not allocate resampler context");
#if CONFIG_FFMPEG_VERSION_MAJOR == 6 && CONFIG_FFMPEG_VERSION_MINOR == 1 && CONFIG_FFMPEG_VERSION_PATCH == 1
av_opt_set_chlayout(swr_ctx, "in_channel_layout", &audio_codec_ctx->ch_layout, 0);
av_opt_set_chlayout(swr_ctx, "out_channel_layout", &audio_codec_ctx->ch_layout, 0);
av_opt_set_chlayout(swr_ctx, "in_chlayout", &audio_codec_ctx->ch_layout, 0);
av_opt_set_chlayout(swr_ctx, "out_chlayout", &audio_codec_ctx->ch_layout, 0);
resample_channels = audio_codec_ctx->ch_layout.nb_channels;
#else
av_opt_set_int(swr_ctx, "in_channel_layout", audio_codec_ctx->channel_layout, 0);

View File

@@ -234,10 +234,21 @@ int app_pre_init(void)
{
auto sensor_size = camera::get_sensor_size();
__config_camera_resolution_list(&priv.ui_camera_cfg, sensor_size[0], sensor_size[1]);
#if PLATFORM_MAIXCAM2
auto cam2_w = sensor_size[0];
auto cam2_h = sensor_size[1];
cam2_w = max(min(cam2_w, 1920), 0);
cam2_h = max(min(cam2_h, 1080), 0);
auto index = __get_camera_resolution_index(&priv.ui_camera_cfg, cam2_w, cam2_h);
priv.camera_resolution_w = cam2_w;
priv.camera_resolution_h = cam2_h;
priv.resolution_index = index; // 0: 2560x1440; 1: 1920x1080; 2: 1280x720; 3: 640x480
#else
auto index = __get_camera_resolution_index(&priv.ui_camera_cfg, sensor_size[0], sensor_size[1]);
priv.camera_resolution_w = sensor_size[0];
priv.camera_resolution_h = sensor_size[1];
priv.resolution_index = index; // 0: 2560x1440; 1: 1920x1080; 2: 1280x720; 3: 640x480
#endif
priv.encoder_bitrate = 3 * 1000 * 1000;
priv.camera_fps = 30;
priv.audio_en = true;

View File

@@ -989,7 +989,7 @@ _retry:
int channel = priv.decoder->audio_channels();
audio::Format format = priv.decoder->audio_format();
log::info("audio_sample_rate:%d audio_format:%d audio_channels:%d", sample_rate, channel, format);
priv.audio_player = new audio::Player("", sample_rate, format, channel);
priv.audio_player = new audio::Player("", sample_rate, format, channel, false);
err::check_null_raise(priv.audio_player, "Audio player init failed!");
}
@@ -1050,7 +1050,7 @@ static void play_video(void)
int channel = priv.decoder->audio_channels();
audio::Format format = priv.decoder->audio_format();
log::info("audio_sample_rate:%d audio_format:%d audio_channels:%d", sample_rate, channel, format);
priv.audio_player = new audio::Player("", sample_rate, format, channel);
priv.audio_player = new audio::Player("", sample_rate, format, channel, false);
err::check_null_raise(priv.audio_player, "Audio player init failed!");
}
}
@@ -1127,6 +1127,7 @@ static void play_video(void)
}
// log::info("playback video use %lld ms, video list size:%d", time::ticks_ms() - t, priv.video_list->size());
// t = time::ticks_ms();
while (priv.audio_list->size() > 0) {
video::Context *audio_ctx = *priv.audio_list->begin();
if (audio_ctx) {