Commit 16dcdc05 authored by Miguel Vaello's avatar Miguel Vaello Committed by Meg Ford

Enables recodings in mono

Now is possible to select between mono and stereo mode
through preferences panel.
The stereo channel is still used by default,
almost for now.

https://bugzilla.gnome.org/show_bug.cgi?id=552420Signed-off-by: 's avatarMeg Ford <megford@gnome.org>
parent a08cf2ba
......@@ -15,6 +15,11 @@
<summary>Maps media types to audio encoder preset names.</summary>
<description>Maps media types to audio encoder preset names. If there is no mapping set, the default encoder settings will be used.</description>
</key>
<key name="channel" type="i">
<default>1</default>
<summary>Available channels</summary>
<description>Maps available channels. If there is not no mapping set, stereo channel will be used by default.</description>
</key>
<key name="mic-volume" type="d">
<default>0.75</default>
<summary>Microphone volume level</summary>
......
......@@ -128,6 +128,15 @@ const Application = new Lang.Class({
setPreferences: function(profileName) {
settings.set_int("media-type-preset", profileName);
},
getChannelsPreferences: function() {
let set = settings.get_int("channel");
return set;
},
setChannelsPreferences: function(channel) {
settings.set_int("channel", channel);
},
getMicVolume: function() {
let micVolLevel = settings.get_double("mic-volume");
......
......@@ -827,6 +827,30 @@ const EncoderComboBox = new Lang.Class({
}
});
const ChannelsComboBox = new Lang.Class({
Name: "ChannelsComboBox",
Extends: Gtk.ComboBoxText,
// encoding setting labels in combobox
_init: function() {
this.parent();
let combo = [_("Mono"), _("Stereo")];
for (let i = 0; i < combo.length; i++)
this.append_text(combo[i]);
this.set_property('valign', Gtk.Align.CENTER);
this.set_sensitive(true);
activeProfile = Application.application.getChannelsPreferences();
this.set_active(activeProfile);
this.connect("changed", Lang.bind(this, this._onComboBoxTextChanged));
},
_onComboBoxTextChanged: function() {
activeProfile = this.get_active();
Application.application.setChannelsPreferences(activeProfile);
}
});
const LoadMoreButton = new Lang.Class({
Name: 'LoadMoreButton',
Extends: Gtk.Button,
......
......@@ -28,7 +28,8 @@ const C_ = imports.gettext.pgettext;
const MainWindow = imports.mainWindow;
const Main = imports.main;
let comboBoxText = null;
let formatComboBoxText = null;
let channelsComboBoxText = null;
let recordVolume= null;
let playVolume = null;
......@@ -62,16 +63,24 @@ const Preferences = new Lang.Class({
let formatLabel = new Gtk.Label({ label: _("Preferred format"),
halign: Gtk.Align.END });
formatLabel.get_style_context ().add_class('dim-label');
formatLabel.get_style_context().add_class('dim-label');
grid.attach(formatLabel, 0, 0, 2, 1);
comboBoxText = new MainWindow.EncoderComboBox();
grid.attach(comboBoxText, 2, 0, 2, 1);
formatComboBoxText = new MainWindow.EncoderComboBox();
grid.attach(formatComboBoxText, 2, 0, 2, 1);
let channelsLabel = new Gtk.Label({ label: _("Default mode"),
halign: Gtk.Align.END });
channelsLabel.get_style_context().add_class('dim-label');
grid.attach(channelsLabel, 0, 1, 2, 1);
channelsComboBoxText = new MainWindow.ChannelsComboBox();
grid.attach(channelsComboBoxText, 2, 1, 2, 1);
let volumeLabel = new Gtk.Label({ label: _("Volume"),
halign: Gtk.Align.END });
volumeLabel.get_style_context ().add_class('dim-label');
grid.attach(volumeLabel, 0, 1, 2, 1);
volumeLabel.get_style_context().add_class('dim-label');
grid.attach(volumeLabel, 0, 2, 2, 1);
playVolume = new Gtk.Scale({ orientation: Gtk.Orientation.HORIZONTAL });
this.playRange = Gtk.Adjustment.new(MainWindow.volumeValue[0].play, 0, 1.0, 0.05, 0.0, 0.0);
......@@ -81,12 +90,12 @@ const Preferences = new Lang.Class({
function() {
MainWindow.view.presetVolume(MainWindow.ActiveArea.PLAY, playVolume.get_value());
}));
grid.attach(playVolume, 2, 1, 2, 1);
grid.attach(playVolume, 2, 2, 2, 1);
let micVolLabel = new Gtk.Label({ label: _("Microphone"),
halign: Gtk.Align.END });
micVolLabel.get_style_context ().add_class('dim-label');
grid.attach(micVolLabel, 0, 2, 2, 1);
micVolLabel.get_style_context().add_class('dim-label');
grid.attach(micVolLabel, 0, 3, 2, 1);
recordVolume = new Gtk.Scale({ orientation: Gtk.Orientation.HORIZONTAL });
this.recordRange = Gtk.Adjustment.new(MainWindow.volumeValue[0].record, 0, 1.0, 0.05, 0.0, 0.0);
......@@ -96,7 +105,7 @@ const Preferences = new Lang.Class({
function() {
MainWindow.view.presetVolume(MainWindow.ActiveArea.RECORD, recordVolume.get_value());
}));
grid.attach(recordVolume, 2, 2, 2, 1);
grid.attach(recordVolume, 2, 3, 2, 1);
this.widget.show_all();
},
......
......@@ -46,6 +46,11 @@ const ErrState = {
ON: 1
}
const Channels = {
MONO: 0,
STEREO: 1
}
const _TENTH_SEC = 100000000;
let errorDialogState;
......@@ -81,7 +86,7 @@ const Record = new Lang.Class({
this.pipeline.add(this.srcElement);
this.audioConvert = Gst.ElementFactory.make("audioconvert", "audioConvert");
this.pipeline.add(this.audioConvert);
this.caps = Gst.Caps.from_string("audio/x-raw, channels=2");
this.caps = Gst.Caps.from_string("audio/x-raw, channels=" + this._getChannels());
this.clock = this.pipeline.get_clock();
this.recordBus = this.pipeline.get_bus();
this.recordBus.add_signal_watch();
......@@ -292,6 +297,27 @@ const Record = new Lang.Class({
}
},
_getChannels: function() {
let channels = null;
let channelsPref = Application.application.getChannelsPreferences();
switch(channelsPref) {
case Channels.MONO:
channels = 1;
break;
case Channels.STEREO:
channels = 2;
break;
default:
channels = 2;
}
return channels;
},
_showErrorDialog: function(errorStrOne, errorStrTwo) {
if (errorDialogState == ErrState.OFF) {
let errorDialog = new Gtk.MessageDialog ({ modal: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment