Skip to content

Commit

Permalink
ffmpeg export: don't error on windows
Browse files Browse the repository at this point in the history
the feature is still not implemented, but at least now it compiles with
a message saying it's not yet supported
  • Loading branch information
yohannd1 committed Dec 29, 2024
1 parent 098fe50 commit 22ca606
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/engine/wavOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@

#include "engine.h"
#include "../ta-log.h"
#include "../subprocess.h"
#include "../stringutils.h"
#include "../subprocess.h"

#ifndef _WIN32
#include <fcntl.h>
#include <unistd.h>
#endif

#ifdef HAVE_SNDFILE
#include "sfWrapper.h"
Expand Down Expand Up @@ -132,6 +135,7 @@ class SndfileWavWriter {
}
};

#ifndef _WIN32
class ProcWriter {
private:
Subprocess* proc;
Expand Down Expand Up @@ -192,6 +196,7 @@ class ProcWriter {
}
}
};
#endif

#ifdef HAVE_SNDFILE
void DivEngine::runExportThread() {
Expand Down Expand Up @@ -295,6 +300,9 @@ void DivEngine::runExportThread() {
}
doExport(&wr);
} else {
#ifdef _WIN32
logE("ffmpeg export is not yet supported");
#else
String inputFormatArg=(exportFormat==DIV_EXPORT_FORMAT_S16)?"s16le":"f32le";

// build command vector
Expand Down Expand Up @@ -342,6 +350,7 @@ void DivEngine::runExportThread() {

// be sure we closed the write pipe to avoid stalling ffmpeg
proc.closeStdinPipe(false);
#endif
}

logI("exporting done!");
Expand Down
11 changes: 11 additions & 0 deletions src/gui/exportOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
void FurnaceGUI::drawExportAudio(bool onWindow) {
exitDisabledTimer=1;

#ifdef _WIN32
const bool allowNonWav=false;
#else
const bool allowNonWav=true;
#endif

const auto formatEF = [](const FurnaceGUIExportFormat& ef) {
return fmt::sprintf("%s (%s)",_(ef.name),ef.fileExt);
};
Expand All @@ -34,13 +40,18 @@ void FurnaceGUI::drawExportAudio(bool onWindow) {
if (ImGui::BeginCombo(_("file format"),formatEF(currentFormat).c_str())) {
for (int i=0; i<EXPORT_FORMAT_COUNT; i++) {
const FurnaceGUIExportFormat& ef=exportFormats[i];
if (!allowNonWav && i>0) ImGui::BeginDisabled();
if (ImGui::Selectable(formatEF(ef).c_str())) {
curAudioExportFormat=i;
audioExportOptions.fileExt=ef.fileExt;
}
if (!allowNonWav && i>0) ImGui::EndDisabled();
}
ImGui::EndCombo();
}
#ifdef _WIN32
ImGui::Text("Note: non-wav file formats are not yet supported on windows. Sorry!");
#endif

if (curAudioExportFormat>0) {
ImGui::InputText(_("extra ffmpeg flags"),&audioExportOptions.ffmpegFlags,ImGuiInputTextFlags_UndoRedo);
Expand Down
6 changes: 4 additions & 2 deletions src/subprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include <unistd.h>
#include <sys/wait.h>
#include "subprocess.h"
#include "ta-log.h"

#ifndef _WIN32
#include <unistd.h>
#include <sys/wait.h>
#include <poll.h>
#include <signal.h>

Expand Down Expand Up @@ -204,3 +205,4 @@ bool Subprocess::waitStdinOrExit() {
}
}
}
#endif
2 changes: 2 additions & 0 deletions src/subprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "ta-utils.h"

#ifndef _WIN32 // TODO: windows impl
class Subprocess {
public:
struct Pipe {
Expand Down Expand Up @@ -78,5 +79,6 @@ class Subprocess {
bool waitForExitCode(int *outCode);
bool getExitCodeNoWait(int *outCode);
};
#endif

#endif

0 comments on commit 22ca606

Please sign in to comment.