[gnome-sound-recorder] waveform: load recording peaks in row's construct
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sound-recorder] waveform: load recording peaks in row's construct
- Date: Sat, 15 Aug 2020 08:13:30 +0000 (UTC)
commit fc6e50573d7252ac29a7ed7bc4c65b5a59b57073
Author: Kavan Mevada <kavanmevada gmail com>
Date: Sat Aug 15 12:28:36 2020 +0530
waveform: load recording peaks in row's construct
src/recorder.js | 10 +++++-----
src/recording.js | 4 +---
src/row.js | 12 +++++++++---
3 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/src/recorder.js b/src/recorder.js
index d50bf74..7cbb1c0 100644
--- a/src/recorder.js
+++ b/src/recorder.js
@@ -69,7 +69,7 @@ var Recorder = new GObject.registerClass({
},
}, class Recorder extends GObject.Object {
_init() {
- this.peaks = [];
+ this._peaks = [];
super._init({});
let srcElement, audioConvert, caps;
@@ -100,7 +100,6 @@ var Recorder = new GObject.registerClass({
}
start() {
- this.peaks.length = 0;
let index = 1;
do {
@@ -157,9 +156,10 @@ var Recorder = new GObject.registerClass({
}
- if (this.file && this.file.query_exists(null) && this.peaks.length > 0) {
+ if (this.file && this.file.query_exists(null) && this._peaks.length > 0) {
const recording = new Recording(this.file);
- recording.peaks = this.peaks;
+ recording.peaks = this._peaks;
+ this._peaks.length = 0;
return recording;
}
@@ -233,7 +233,7 @@ var Recorder = new GObject.registerClass({
peak = 0;
this._current_peak = Math.pow(10, peak / 20);
- this.peaks.push(this._current_peak);
+ this._peaks.push(this._current_peak);
this.notify('current-peak');
}
diff --git a/src/recording.js b/src/recording.js
index 9183331..273d2fe 100644
--- a/src/recording.js
+++ b/src/recording.js
@@ -34,8 +34,6 @@ var Recording = new GObject.registerClass({
this._timeModified = GLib.DateTime.new_from_unix_local(timeModified);
this._timeCreated = GLib.DateTime.new_from_unix_local(timeCreated);
- this.readPeaks();
-
var discoverer = new GstPbutils.Discoverer();
discoverer.start();
discoverer.connect('discovered', (_discoverer, audioInfo) => {
@@ -114,7 +112,7 @@ var Recording = new GObject.registerClass({
return CacheDir.get_child(`${this.name}_data`);
}
- readPeaks() {
+ loadPeaks() {
if (this.waveformCache.query_exists(null)) {
this.waveformCache.load_bytes_async(null, (obj, res) => {
const bytes = obj.load_bytes_finish(res)[0];
diff --git a/src/row.js b/src/row.js
index 9a8b2fb..f341a65 100644
--- a/src/row.js
+++ b/src/row.js
@@ -40,6 +40,12 @@ var Row = GObject.registerClass({
margin_right: 12,
}, WaveType.PLAYER);
this._waveformStack.add_named(this.waveform, 'wave');
+ if (this._recording._peaks.length > 0) {
+ this.waveform.peaks = this._recording.peaks;
+ this._waveformStack.visible_child_name = 'wave';
+ } else {
+ this._recording.loadPeaks();
+ }
recording.bind_property('name', this._name, 'label', GObject.BindingFlags.SYNC_CREATE |
GObject.BindingFlags.DEFAULT);
recording.bind_property('name', this._entry, 'text', GObject.BindingFlags.SYNC_CREATE |
GObject.BindingFlags.DEFAULT);
@@ -88,10 +94,10 @@ var Row = GObject.registerClass({
else
this._date.label = displayDateTime(recording.timeModified);
- this.waveform.peaks = this._recording.peaks;
- this._recording.connect('peaks-updated', _ => {
+
+ this._recording.connect('peaks-updated', _recording => {
this._waveformStack.visible_child_name = 'wave';
- this.waveform.peaks = this._recording.peaks;
+ this.waveform.peaks = _recording.peaks;
});
this._recording.connect('peaks-loading', _ => {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]