Skip to content
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

Audio output via stdout and UDP #440

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add check to ensure -O is used with stdout
  • Loading branch information
ars-ka0s committed Sep 25, 2023
commit f698b93aa8d21ef99e51baeb86fbb775d706423b
5 changes: 5 additions & 0 deletions src/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ int audio_open (struct audio_s *pa)
*/
if (strcasecmp(pa->adev[a].adevice_out, "stdout") == 0 || strcmp(pa->adev[a].adevice_out, "-") == 0) {
adev[a].g_audio_out_type = AUDIO_OUT_TYPE_STDOUT;
if (!dw_printf_redirected()) {
text_color_set (DW_COLOR_ERROR);
dw_printf ("stdout must only be used with the -O option\n");
return (-1);
}
} else {
adev[a].g_audio_out_type = AUDIO_OUT_TYPE_SOUNDCARD;
}
Expand Down
5 changes: 5 additions & 0 deletions src/audio_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ int audio_open (struct audio_s *pa)
*/
if (strcasecmp(pa->adev[a].adevice_out, "stdout") == 0 || strcmp(pa->adev[a].adevice_out, "-") == 0) {
A->g_audio_out_type = AUDIO_OUT_TYPE_STDOUT;
if (!dw_printf_redirected()) {
text_color_set (DW_COLOR_ERROR);
dw_printf ("stdout must only be used with the -O option\n");
return (-1);
}
/* Change - to stdout for readability. */
strlcpy (pa->adev[a].adevice_out, "stdout", sizeof(pa->adev[a].adevice_out));
} else {
Expand Down
5 changes: 4 additions & 1 deletion src/textcolor.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,10 @@ int dw_printf (const char *fmt, ...)
return (len);
}


int dw_printf_redirected ()
{
return g_dw_printf_dest != stdout;
}

#if TESTC
main ()
Expand Down
2 changes: 2 additions & 0 deletions src/textcolor.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ int dw_printf (const char *fmt, ...)
__attribute__((format(printf,1,2))); /* gnu C lib. */
#endif

int dw_printf_redirected ();

#endif