qs: enhance replay functionality (still disabled by default
This commit is contained in:
@@ -15,7 +15,7 @@ RowLayout {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
height: Style.baseWidgetSize * 3.2 + Style.marginS * 3
|
height: Style.baseWidgetSize * 3.2 + Style.marginS * 3
|
||||||
radius: Style.radiusM
|
radius: Style.radiusM
|
||||||
imagePath: BackgroundService.cachedPath
|
imagePath: BackgroundService.displayPath
|
||||||
fallbackIcon: "wallpaper"
|
fallbackIcon: "wallpaper"
|
||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
|
|
||||||
|
|||||||
@@ -7,17 +7,9 @@ import qs.Utils
|
|||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
// Connections {
|
// Enabling replay may consume noticeably more resources -
|
||||||
// function onSinkChanged() {
|
// around 500MiB of RAM and 4% of CPU on my machine. Use with caution
|
||||||
// if (!isReplayInitStarted && AudioService.sink) {
|
readonly property bool replayEnabled: false
|
||||||
// Logger.i("RecordService", "Audio sink available, starting replay buffer.");
|
|
||||||
// startReplay();
|
|
||||||
// isReplayInitStarted = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// target: AudioService
|
|
||||||
// }
|
|
||||||
|
|
||||||
readonly property string recordingDir: Paths.recordingDir
|
readonly property string recordingDir: Paths.recordingDir
|
||||||
property bool isRecording: false
|
property bool isRecording: false
|
||||||
property bool isReplayInitStarted: false
|
property bool isReplayInitStarted: false
|
||||||
@@ -147,7 +139,7 @@ Singleton {
|
|||||||
replayProcess.running = true;
|
replayProcess.running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopReplay() {
|
function stopReplay(save = true) {
|
||||||
if (!isReplayStarted) {
|
if (!isReplayStarted) {
|
||||||
Logger.w("RecordService", "Replay buffer not active, cannot stop.");
|
Logger.w("RecordService", "Replay buffer not active, cannot stop.");
|
||||||
return ;
|
return ;
|
||||||
@@ -158,7 +150,10 @@ Singleton {
|
|||||||
}
|
}
|
||||||
isReplayStopping = true;
|
isReplayStopping = true;
|
||||||
replayStopTimeout.restart();
|
replayStopTimeout.restart();
|
||||||
replayProcess.signal(10); // SIGUSR1
|
if (save)
|
||||||
|
replayProcess.signal(10);
|
||||||
|
else
|
||||||
|
replayProcess.signal(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onDestruction: function() {
|
Component.onDestruction: function() {
|
||||||
@@ -170,6 +165,32 @@ Singleton {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
function onSinkChanged() {
|
||||||
|
if (!replayEnabled)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
// if (!isReplayInitStarted && AudioService.sink) {
|
||||||
|
// Logger.i("RecordService", "Audio sink available, starting replay buffer.");
|
||||||
|
// startReplay();
|
||||||
|
// isReplayInitStarted = true;
|
||||||
|
// }
|
||||||
|
if (!AudioService.sink) {
|
||||||
|
Logger.w("RecordService", "Audio sink lost.");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if (isReplayStarted) {
|
||||||
|
Logger.i("RecordService", "Audio sink changed, restarting replay buffer.");
|
||||||
|
stopReplay(false);
|
||||||
|
} else {
|
||||||
|
Logger.i("RecordService", "Audio sink available, starting replay buffer.");
|
||||||
|
startReplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
target: AudioService
|
||||||
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: recordProcess
|
id: recordProcess
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user