From e3ab83869f4b74e485964720f941fed22ce035ea Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 1 Oct 2011 12:33:51 +0000 Subject: implemented converter settings, fixed build git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2364 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/converter/converter.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/plugins/General/converter/converter.cpp') diff --git a/src/plugins/General/converter/converter.cpp b/src/plugins/General/converter/converter.cpp index 23ce7599f..3a205472f 100644 --- a/src/plugins/General/converter/converter.cpp +++ b/src/plugins/General/converter/converter.cpp @@ -22,7 +22,11 @@ #include #include #include +#include +#include #include +#include +#include #include #include "converter.h" @@ -85,10 +89,29 @@ void Converter::add(const QString &url) void Converter::run() { + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); + QString music_path = QDesktopServices::storageLocation(QDesktopServices::MusicLocation); + QString path = settings.value("Converter/out_dir", music_path).toString(); + QString pattern = settings.value("Converter/file_name","%p - %t").toString(); + MetaDataFormatter formatter(pattern); + while(!m_decoders.isEmpty()) { Decoder *decoder = m_decoders.dequeue(); AudioParameters ap = decoder->audioParameters(); + QString url = m_inputs[decoder]->url(); + + QList list = MetaDataManager::instance()->createPlayList(url); + + if(list.isEmpty()) + { + //ignore + } + + QString name = formatter.parse(list[0]->metaData(), list[0]->length()); + QString full_path = path + "/" + name + ".ogg"; + QString command = "oggenc -q 1 -o %f -"; + command.replace("%f", "\"" + full_path + "\""); char wave_header[] = { 0x52, 0x49, 0x46, 0x46, //"RIFF" 0x00, 0x00, 0x00, 0x00, //(file size) - 8 @@ -116,7 +139,7 @@ void Converter::run() memcpy(&wave_header[40], &size, 4); //FILE *enc_pipe = fopen("/mnt/win_e/out.wav", "w"); - FILE *enc_pipe = popen("oggenc -q 1 -o \"/mnt/win_e/out 55.ogg\" -", "w"); + FILE *enc_pipe = popen(qPrintable(command), "w"); if(!enc_pipe) { qWarning("Converter: unable to open pipe"); -- cgit v1.2.3-13-gbd6f