Skip to content

Use "-" char as filename for reading from stdin #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"-p\tDestination UDP port\n"\
"-a\tAudio driver [" HELP_AUDIO_DRIVERS "]\n" HELP_AUDIO_DEVICE\
"-c\tSound channels [stereo,mono,left,right] (default stereo)\n"\
"-f\tFull path to 48kHz raw audio file\n"\
"-f\tFull path to 48kHz raw audio file. Use \"-\" for stdin. \n"\
"-l\tLog sound levels to console (stderr)\n"\
"-d\tLog NMEA sentences to console (stderr)\n"\
"-H\tDisplay this help\n"
Expand Down
10 changes: 9 additions & 1 deletion src/sounddecoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,15 @@ int initSoundDecoder(const Sound_Channels _channels, const Sound_Driver _driver,
case DRIVER_FILE:
strncpy(soundFile, file, MAX_FILENAME_SIZE);
soundFile[MAX_FILENAME_SIZE]=0;
fp = fopen(soundFile, "rb");
if(soundFile[0]=='-'){
fp=stdin;
#ifdef WIN32
setmode(fileno(stdin), O_BINARY); // Binary mode
#endif
}
else{
fp = fopen(soundFile, "rb");
}
if (fp) {
buffer_l = 1024;
int extra = buffer_l % 5;
Expand Down