mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-13 20:56:19 -08:00
fix(playback): track mpv recording auto-stop replies
Entire-Checkpoint: f957cd9849e0
This commit is contained in:
1 parent
0065fc17fe
commit
6d0658b983
2 files changed
+67
-1
No files matched your search
@@ -1731,14 +1731,32 @@ Napi::Value LoadPlayback(const Napi::CallbackInfo& info)
|
||||
}
|
||||
if (recordingActive) {
|
||||
const char* disabledValue = "";
|
||||
const uint64_t stopRecordingRequestId = nextAsyncRequestId();
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(session->mutex);
|
||||
session->pendingRecordingStopRequestId = stopRecordingRequestId;
|
||||
session->pendingRecordingStopStartedAt =
|
||||
session->snapshot.recordingStartedAt;
|
||||
}
|
||||
|
||||
const int stopResult = mpv_set_property_async(
|
||||
session->handle,
|
||||
nextAsyncRequestId(),
|
||||
stopRecordingRequestId,
|
||||
"stream-record",
|
||||
MPV_FORMAT_STRING,
|
||||
const_cast<char**>(&disabledValue)
|
||||
);
|
||||
if (stopResult < 0) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(session->mutex);
|
||||
if (
|
||||
session->pendingRecordingStopRequestId ==
|
||||
stopRecordingRequestId
|
||||
) {
|
||||
session->pendingRecordingStopRequestId = 0;
|
||||
session->pendingRecordingStopStartedAt.clear();
|
||||
}
|
||||
}
|
||||
updateSessionError(session, mpv_error_string(stopResult));
|
||||
throw Napi::Error::New(
|
||||
env,
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
describe('Embedded MPV native source recording invariants', () => {
|
||||
const nativeSource = readFileSync(
|
||||
path.resolve(__dirname, '../../../native/src/embedded_mpv.mm'),
|
||||
'utf8'
|
||||
);
|
||||
|
||||
function functionBody(name: string): string {
|
||||
const start = nativeSource.indexOf(`Napi::Value ${name}(`);
|
||||
expect(start).toBeGreaterThanOrEqual(0);
|
||||
|
||||
const bodyStart = nativeSource.indexOf('{', start);
|
||||
expect(bodyStart).toBeGreaterThanOrEqual(0);
|
||||
|
||||
let depth = 0;
|
||||
for (let index = bodyStart; index < nativeSource.length; index += 1) {
|
||||
if (nativeSource[index] === '{') {
|
||||
depth += 1;
|
||||
}
|
||||
if (nativeSource[index] === '}') {
|
||||
depth -= 1;
|
||||
}
|
||||
if (depth === 0) {
|
||||
return nativeSource.slice(bodyStart, index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Unable to read ${name} body.`);
|
||||
}
|
||||
|
||||
it('tracks LoadPlayback recording auto-stop replies through the reconciler', () => {
|
||||
const body = functionBody('LoadPlayback');
|
||||
|
||||
expect(body).toContain(
|
||||
'const uint64_t stopRecordingRequestId = nextAsyncRequestId();'
|
||||
);
|
||||
expect(body).toContain(
|
||||
'session->pendingRecordingStopRequestId = stopRecordingRequestId;'
|
||||
);
|
||||
expect(body).toContain(
|
||||
'session->pendingRecordingStopStartedAt =\n' +
|
||||
' session->snapshot.recordingStartedAt;'
|
||||
);
|
||||
expect(body).toContain('stopRecordingRequestId,');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user