diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2011-11-08 09:32:33 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2011-11-08 09:32:33 +0000 |
| commit | c495f5b07fbb6626675e432edd5742c086abef13 (patch) | |
| tree | e2450245bb28859ff8232d61c11f4d316a02df4a /src/plugins/General/converter | |
| parent | 0b7152dfe25d34899f0db73558f05064777f536b (diff) | |
| download | qmmp-c495f5b07fbb6626675e432edd5742c086abef13.tar.gz qmmp-c495f5b07fbb6626675e432edd5742c086abef13.tar.bz2 qmmp-c495f5b07fbb6626675e432edd5742c086abef13.zip | |
conveter plugin: file based input support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2503 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/converter')
14 files changed, 116 insertions, 33 deletions
diff --git a/src/plugins/General/converter/converter.cpp b/src/plugins/General/converter/converter.cpp index be34cf433..a923a0964 100644 --- a/src/plugins/General/converter/converter.cpp +++ b/src/plugins/General/converter/converter.cpp @@ -20,6 +20,7 @@ #include <stdio.h> #include <QStringList> +#include <QDesktopServices> #include <qmmp/inputsourcefactory.h> #include <qmmp/decoderfactory.h> #include <qmmp/metadatamanager.h> @@ -190,6 +191,9 @@ void Converter::run() QString command = preset["command"].toString(); command.replace("%o", "\"" + full_path + "\""); + QString tmp_path = QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/tmp.wav"; + bool use_file = command.contains("%i"); + command.replace("%i", "\"" + tmp_path + "\""); qDebug("Converter: starting task '%s'", qPrintable(preset["name"].toString())); @@ -222,8 +226,7 @@ void Converter::run() memcpy(&wave_header[34], &bps, 2); memcpy(&wave_header[40], &size, 4); - //FILE *enc_pipe = fopen("/mnt/win_e/out.wav", "w"); - FILE *enc_pipe = popen(qPrintable(command), "w"); + FILE *enc_pipe = use_file ? fopen(qPrintable(tmp_path), "w+b") : popen(qPrintable(command), "w"); if(!enc_pipe) { qWarning("Converter: unable to open pipe"); @@ -235,16 +238,15 @@ void Converter::run() size_t to_write = sizeof(wave_header); if(to_write != fwrite(&wave_header, 1, to_write, enc_pipe)) { - qWarning("Converter: output file write erro"); + qWarning("Converter: output file write error"); m_inputs.take(decoder)->deleteLater(); delete decoder; - pclose(enc_pipe); + use_file ? fclose(enc_pipe) : pclose(enc_pipe); continue; } convert(decoder, enc_pipe, preset["use_16bit"].toBool()); - pclose(enc_pipe); - //fclose(enc_pipe); + use_file ? fclose(enc_pipe) : pclose(enc_pipe); m_inputs.take(decoder)->deleteLater(); delete decoder; m_mutex.lock(); @@ -258,6 +260,22 @@ void Converter::run() qDebug("Converter: task '%s' finished with success", qPrintable(preset["name"].toString())); m_mutex.unlock(); + if(use_file) + { + qDebug("Converter: starting file encoding..."); + emit desriptionChanged(tr("Encoding...")); + enc_pipe = popen(qPrintable(command), "w"); + if(!enc_pipe) + { + qWarning("Converter: unable to start encoder"); + QFile::remove(tmp_path); + continue; + } + pclose(enc_pipe); + qDebug("Converter: encoding finished"); + QFile::remove(tmp_path); + } + if(preset["tags"].toBool()) { qDebug("Converter: writing tags"); diff --git a/src/plugins/General/converter/translations/converter_plugin_cs.ts b/src/plugins/General/converter/translations/converter_plugin_cs.ts index 837c67c07..96d5f227b 100644 --- a/src/plugins/General/converter/translations/converter_plugin_cs.ts +++ b/src/plugins/General/converter/translations/converter_plugin_cs.ts @@ -4,15 +4,20 @@ <context> <name>Converter</name> <message> - <location filename="../converter.cpp" line="168"/> + <location filename="../converter.cpp" line="169"/> <source>Track: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../converter.cpp" line="170"/> + <location filename="../converter.cpp" line="171"/> <source>Preset: %1</source> <translation type="unfinished"></translation> </message> + <message> + <location filename="../converter.cpp" line="266"/> + <source>Encoding...</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>ConverterDialog</name> diff --git a/src/plugins/General/converter/translations/converter_plugin_de.ts b/src/plugins/General/converter/translations/converter_plugin_de.ts index c586ef2d2..af9a08ab4 100644 --- a/src/plugins/General/converter/translations/converter_plugin_de.ts +++ b/src/plugins/General/converter/translations/converter_plugin_de.ts @@ -4,15 +4,20 @@ <context> <name>Converter</name> <message> - <location filename="../converter.cpp" line="168"/> + <location filename="../converter.cpp" line="169"/> <source>Track: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../converter.cpp" line="170"/> + <location filename="../converter.cpp" line="171"/> <source>Preset: %1</source> <translation type="unfinished"></translation> </message> + <message> + <location filename="../converter.cpp" line="266"/> + <source>Encoding...</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>ConverterDialog</name> diff --git a/src/plugins/General/converter/translations/converter_plugin_es.ts b/src/plugins/General/converter/translations/converter_plugin_es.ts index 074ea5f54..7052c5e06 100644 --- a/src/plugins/General/converter/translations/converter_plugin_es.ts +++ b/src/plugins/General/converter/translations/converter_plugin_es.ts @@ -4,15 +4,20 @@ <context> <name>Converter</name> <message> - <location filename="../converter.cpp" line="168"/> + <location filename="../converter.cpp" line="169"/> <source>Track: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../converter.cpp" line="170"/> + <location filename="../converter.cpp" line="171"/> <source>Preset: %1</source> <translation type="unfinished"></translation> </message> + <message> + <location filename="../converter.cpp" line="266"/> + <source>Encoding...</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>ConverterDialog</name> diff --git a/src/plugins/General/converter/translations/converter_plugin_it.ts b/src/plugins/General/converter/translations/converter_plugin_it.ts index e93271c7f..6f5630760 100644 --- a/src/plugins/General/converter/translations/converter_plugin_it.ts +++ b/src/plugins/General/converter/translations/converter_plugin_it.ts @@ -4,15 +4,20 @@ <context> <name>Converter</name> <message> - <location filename="../converter.cpp" line="168"/> + <location filename="../converter.cpp" line="169"/> <source>Track: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../converter.cpp" line="170"/> + <location filename="../converter.cpp" line="171"/> <source>Preset: %1</source> <translation type="unfinished"></translation> </message> + <message> + <location filename="../converter.cpp" line="266"/> + <source>Encoding...</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>ConverterDialog</name> diff --git a/src/plugins/General/converter/translations/converter_plugin_ja.ts b/src/plugins/General/converter/translations/converter_plugin_ja.ts index 374aab737..a29a7553b 100644 --- a/src/plugins/General/converter/translations/converter_plugin_ja.ts +++ b/src/plugins/General/converter/translations/converter_plugin_ja.ts @@ -4,15 +4,20 @@ <context> <name>Converter</name> <message> - <location filename="../converter.cpp" line="168"/> + <location filename="../converter.cpp" line="169"/> <source>Track: %1</source> <translation>トラック: %1</translation> </message> <message> - <location filename="../converter.cpp" line="170"/> + <location filename="../converter.cpp" line="171"/> <source>Preset: %1</source> <translation>プリセット: %1</translation> </message> + <message> + <location filename="../converter.cpp" line="266"/> + <source>Encoding...</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>ConverterDialog</name> diff --git a/src/plugins/General/converter/translations/converter_plugin_lt.ts b/src/plugins/General/converter/translations/converter_plugin_lt.ts index e529bc420..c84e49732 100644 --- a/src/plugins/General/converter/translations/converter_plugin_lt.ts +++ b/src/plugins/General/converter/translations/converter_plugin_lt.ts @@ -4,15 +4,20 @@ <context> <name>Converter</name> <message> - <location filename="../converter.cpp" line="168"/> + <location filename="../converter.cpp" line="169"/> <source>Track: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../converter.cpp" line="170"/> + <location filename="../converter.cpp" line="171"/> <source>Preset: %1</source> <translation type="unfinished"></translation> </message> + <message> + <location filename="../converter.cpp" line="266"/> + <source>Encoding...</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>ConverterDialog</name> diff --git a/src/plugins/General/converter/translations/converter_plugin_nl.ts b/src/plugins/General/converter/translations/converter_plugin_nl.ts index 259f697f7..11b2a915d 100644 --- a/src/plugins/General/converter/translations/converter_plugin_nl.ts +++ b/src/plugins/General/converter/translations/converter_plugin_nl.ts @@ -4,15 +4,20 @@ <context> <name>Converter</name> <message> - <location filename="../converter.cpp" line="168"/> + <location filename="../converter.cpp" line="169"/> <source>Track: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../converter.cpp" line="170"/> + <location filename="../converter.cpp" line="171"/> <source>Preset: %1</source> <translation type="unfinished"></translation> </message> + <message> + <location filename="../converter.cpp" line="266"/> + <source>Encoding...</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>ConverterDialog</name> diff --git a/src/plugins/General/converter/translations/converter_plugin_pl.ts b/src/plugins/General/converter/translations/converter_plugin_pl.ts index 3e18f460f..e419a3125 100644 --- a/src/plugins/General/converter/translations/converter_plugin_pl.ts +++ b/src/plugins/General/converter/translations/converter_plugin_pl.ts @@ -4,15 +4,20 @@ <context> <name>Converter</name> <message> - <location filename="../converter.cpp" line="168"/> + <location filename="../converter.cpp" line="169"/> <source>Track: %1</source> <translation>Utwór: %1</translation> </message> <message> - <location filename="../converter.cpp" line="170"/> + <location filename="../converter.cpp" line="171"/> <source>Preset: %1</source> <translation></translation> </message> + <message> + <location filename="../converter.cpp" line="266"/> + <source>Encoding...</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>ConverterDialog</name> diff --git a/src/plugins/General/converter/translations/converter_plugin_ru.ts b/src/plugins/General/converter/translations/converter_plugin_ru.ts index c46e0640a..6c545cef9 100644 --- a/src/plugins/General/converter/translations/converter_plugin_ru.ts +++ b/src/plugins/General/converter/translations/converter_plugin_ru.ts @@ -4,15 +4,20 @@ <context> <name>Converter</name> <message> - <location filename="../converter.cpp" line="168"/> + <location filename="../converter.cpp" line="169"/> <source>Track: %1</source> <translation>Трек: %1</translation> </message> <message> - <location filename="../converter.cpp" line="170"/> + <location filename="../converter.cpp" line="171"/> <source>Preset: %1</source> <translation>Предустановка: %1</translation> </message> + <message> + <location filename="../converter.cpp" line="266"/> + <source>Encoding...</source> + <translation>Кодирование...</translation> + </message> </context> <context> <name>ConverterDialog</name> @@ -226,7 +231,7 @@ using external command-line encoders</source> <message> <location filename="../preseteditor.ui" line="83"/> <source>Write tags</source> - <translation>Прописывать теги</translation> + <translation>Добавлять теги</translation> </message> <message> <location filename="../preseteditor.ui" line="90"/> diff --git a/src/plugins/General/converter/translations/converter_plugin_tr.ts b/src/plugins/General/converter/translations/converter_plugin_tr.ts index b172a2b62..8a474c3e8 100644 --- a/src/plugins/General/converter/translations/converter_plugin_tr.ts +++ b/src/plugins/General/converter/translations/converter_plugin_tr.ts @@ -4,15 +4,20 @@ <context> <name>Converter</name> <message> - <location filename="../converter.cpp" line="168"/> + <location filename="../converter.cpp" line="169"/> <source>Track: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../converter.cpp" line="170"/> + <location filename="../converter.cpp" line="171"/> <source>Preset: %1</source> <translation type="unfinished"></translation> </message> + <message> + <location filename="../converter.cpp" line="266"/> + <source>Encoding...</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>ConverterDialog</name> diff --git a/src/plugins/General/converter/translations/converter_plugin_uk_UA.ts b/src/plugins/General/converter/translations/converter_plugin_uk_UA.ts index dfd4bdde7..4e54ae825 100644 --- a/src/plugins/General/converter/translations/converter_plugin_uk_UA.ts +++ b/src/plugins/General/converter/translations/converter_plugin_uk_UA.ts @@ -4,15 +4,20 @@ <context> <name>Converter</name> <message> - <location filename="../converter.cpp" line="168"/> + <location filename="../converter.cpp" line="169"/> <source>Track: %1</source> <translation>Доріжка: %1</translation> </message> <message> - <location filename="../converter.cpp" line="170"/> + <location filename="../converter.cpp" line="171"/> <source>Preset: %1</source> <translation>Предвстановлення: %1</translation> </message> + <message> + <location filename="../converter.cpp" line="266"/> + <source>Encoding...</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>ConverterDialog</name> diff --git a/src/plugins/General/converter/translations/converter_plugin_zh_CN.ts b/src/plugins/General/converter/translations/converter_plugin_zh_CN.ts index 3e3e6206b..f51cb88f3 100644 --- a/src/plugins/General/converter/translations/converter_plugin_zh_CN.ts +++ b/src/plugins/General/converter/translations/converter_plugin_zh_CN.ts @@ -4,15 +4,20 @@ <context> <name>Converter</name> <message> - <location filename="../converter.cpp" line="168"/> + <location filename="../converter.cpp" line="169"/> <source>Track: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../converter.cpp" line="170"/> + <location filename="../converter.cpp" line="171"/> <source>Preset: %1</source> <translation type="unfinished"></translation> </message> + <message> + <location filename="../converter.cpp" line="266"/> + <source>Encoding...</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>ConverterDialog</name> diff --git a/src/plugins/General/converter/translations/converter_plugin_zh_TW.ts b/src/plugins/General/converter/translations/converter_plugin_zh_TW.ts index 2731c1b7d..c2d4d0dc4 100644 --- a/src/plugins/General/converter/translations/converter_plugin_zh_TW.ts +++ b/src/plugins/General/converter/translations/converter_plugin_zh_TW.ts @@ -4,15 +4,20 @@ <context> <name>Converter</name> <message> - <location filename="../converter.cpp" line="168"/> + <location filename="../converter.cpp" line="169"/> <source>Track: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../converter.cpp" line="170"/> + <location filename="../converter.cpp" line="171"/> <source>Preset: %1</source> <translation type="unfinished"></translation> </message> + <message> + <location filename="../converter.cpp" line="266"/> + <source>Encoding...</source> + <translation type="unfinished"></translation> + </message> </context> <context> <name>ConverterDialog</name> |
