| 1316 | } |
| 1317 | |
| 1318 | error_code cellRecClose(s32 isDiscard) |
| 1319 | { |
| 1320 | cellRec.todo("cellRecClose(isDiscard=0x%x)", isDiscard); |
| 1321 | |
| 1322 | auto& rec = g_fxo->get<rec_info>(); |
| 1323 | |
| 1324 | if (rec.state == rec_state::closed) |
| 1325 | { |
| 1326 | return CELL_REC_ERROR_INVALID_STATE; |
| 1327 | } |
| 1328 | |
| 1329 | sysutil_register_cb([=, &rec](ppu_thread& ppu) -> s32 |
| 1330 | { |
| 1331 | bool is_valid_range = true; |
| 1332 | |
| 1333 | if (isDiscard) |
| 1334 | { |
| 1335 | // No need to flush the encoder |
| 1336 | rec.stop_video_provider(false); |
| 1337 | rec.encoder->stop(false); |
| 1338 | |
| 1339 | if (rec.sink) |
| 1340 | { |
| 1341 | rec.sink->stop(true); |
| 1342 | } |
| 1343 | |
| 1344 | if (fs::is_file(rec.param.filename)) |
| 1345 | { |
| 1346 | cellRec.warning("cellRecClose: removing discarded recording '%s'", rec.param.filename); |
| 1347 | |
| 1348 | if (!fs::remove_file(rec.param.filename)) |
| 1349 | { |
| 1350 | cellRec.error("cellRecClose: failed to remove recording '%s'", rec.param.filename); |
| 1351 | } |
| 1352 | } |
| 1353 | } |
| 1354 | else |
| 1355 | { |
| 1356 | // Flush to make sure we encode all remaining frames |
| 1357 | rec.stop_video_provider(true); |
| 1358 | rec.encoder->stop(true); |
| 1359 | rec.recording_time_total = rec.encoder->get_timestamp_ms(rec.encoder->last_video_pts()); |
| 1360 | |
| 1361 | if (rec.sink) |
| 1362 | { |
| 1363 | rec.sink->stop(true); |
| 1364 | } |
| 1365 | |
| 1366 | const s64 start_pts = rec.encoder->get_pts(rec.param.scene_metadata.start_time); |
| 1367 | const s64 end_pts = rec.encoder->get_pts(rec.param.scene_metadata.end_time); |
| 1368 | const s64 last_pts = rec.encoder->last_video_pts(); |
| 1369 | |
| 1370 | is_valid_range = start_pts >= 0 && end_pts <= last_pts; |
| 1371 | } |
| 1372 | |
| 1373 | vm::dealloc(rec.video_input_buffer.addr(), vm::main); |
| 1374 | vm::dealloc(rec.audio_input_buffer.addr(), vm::main); |
| 1375 |
nothing calls this directly
no test coverage detected