Update issue 2137

Mono playback implemented; available in preferences
This commit is contained in:
Arnaud Bienner 2012-05-20 20:50:25 +02:00
parent d2f5a7f811
commit 26639503d0
4 changed files with 15 additions and 0 deletions

View File

@ -80,6 +80,7 @@ GstEngine::GstEngine(TaskManager* task_manager)
rg_preamp_(0.0),
rg_compression_(true),
buffer_duration_nanosec_(1 * kNsecPerSec), // 1s
mono_playback_(false),
seek_timer_(new QTimer(this)),
timer_id_(-1),
next_element_id_(0)
@ -173,6 +174,8 @@ void GstEngine::ReloadSettings() {
rg_compression_ = s.value("rgcompression", true).toBool();
buffer_duration_nanosec_ = s.value("bufferduration", 4000).toLongLong() * kNsecPerMsec;
mono_playback_ = s.value("monoplayback", false).toBool();
}
@ -688,6 +691,7 @@ shared_ptr<GstEnginePipeline> GstEngine::CreatePipeline() {
ret->set_output_device(sink_, device_);
ret->set_replaygain(rg_enabled_, rg_mode_, rg_preamp_, rg_compression_);
ret->set_buffer_duration_nanosec(buffer_duration_nanosec_);
ret->set_mono_playback(mono_playback_);
ret->AddBufferConsumer(this);
foreach (BufferConsumer* consumer, buffer_consumers_) {

View File

@ -189,6 +189,8 @@ class GstEngine : public Engine::Base, public BufferConsumer {
qint64 buffer_duration_nanosec_;
bool mono_playback_;
mutable bool can_decode_success_;
mutable bool can_decode_last_;

View File

@ -62,6 +62,7 @@ GstEnginePipeline::GstEnginePipeline(GstEngine* engine)
rg_compression_(true),
buffer_duration_nanosec_(1 * kNsecPerSec),
buffering_(false),
mono_playback_(false),
end_offset_nanosec_(-1),
next_beginning_offset_nanosec_(-1),
next_end_offset_nanosec_(-1),
@ -111,6 +112,10 @@ void GstEnginePipeline::set_buffer_duration_nanosec(qint64 buffer_duration_nanos
buffer_duration_nanosec_ = buffer_duration_nanosec;
}
void GstEnginePipeline::set_mono_playback(bool enabled) {
mono_playback_ = enabled;
}
bool GstEnginePipeline::ReplaceDecodeBin(GstElement* new_bin) {
if (!new_bin) return false;
@ -328,6 +333,7 @@ bool GstEnginePipeline::Init() {
NULL);
GstCaps* caps32 = gst_caps_new_simple ("audio/x-raw-float",
"width", G_TYPE_INT, 32,
!mono_playback_ ? NULL : "channels", G_TYPE_INT, 1,
NULL);
// Link the elements with special caps

View File

@ -52,6 +52,7 @@ class GstEnginePipeline : public QObject {
void set_output_device(const QString& sink, const QString& device);
void set_replaygain(bool enabled, int mode, float preamp, bool compression);
void set_buffer_duration_nanosec(qint64 duration_nanosec);
void set_mono_playback(bool enabled);
// Creates the pipeline, returns false on error
bool InitFromUrl(const QUrl& url, qint64 end_nanosec);
@ -197,6 +198,8 @@ class GstEnginePipeline : public QObject {
quint64 buffer_duration_nanosec_;
bool buffering_;
bool mono_playback_;
// The URL that is currently playing, and the URL that is to be preloaded
// when the current track is close to finishing.
QUrl url_;