📄 xltwavplay.c
字号:
/* $Header: /home/cvs/wavplay/xltwavplay.c,v 1.2 1999/12/04 00:01:20 wwg Exp $ * Warren W. Gay VE3WWG Thu Feb 13 21:11:22 1997 * * X LessTif WAV Play : * * Copyright (C) 1997 Warren W. Gay VE3WWG * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation version 2 of the License. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details (see enclosed file COPYING). * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. * * Send correspondance to: * * Warren W. Gay VE3WWG * * Email: * ve3wwg@yahoo.com * wgay@mackenziefinancial.com * * $Log: xltwavplay.c,v $ * Revision 1.2 1999/12/04 00:01:20 wwg * Implement wavplay-1.4 release changes * * Revision 1.1.1.1 1999/11/21 19:50:56 wwg * Import wavplay-1.3 into CVS * * Revision 1.4 1997/04/17 23:43:08 wwg * Added #include <errno.h> for 1.0pl2 fix. * * Revision 1.3 1997/04/17 00:41:56 wwg * Fixed to use member name .Errno vs original dangerous * .errno reference. This presents a problem on platforms * that make extern errno thread safe, but defining errno * as a macro. * * Revision 1.2 1997/04/15 02:13:35 wwg * A number of small pre-release fixes. * * Revision 1.1 1997/04/13 23:59:08 wwg * Initial revision */#define TIMER1_MS 150 /* TimerProc1() */#define LessTif_Bug_radioBehavior 1 /* XmNradioBehavior busted in RowColumn widget (T/F) */#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <stdarg.h>#include <time.h>#include <signal.h>#include <string.h>#include <getopt.h>#include <errno.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/sem.h>#include <sys/wait.h>#include <sys/stat.h>#include <assert.h>#ifndef NO_EDITRES#include <X11/Xmu/Editres.h>#endif#include <Xm/Xm.h>#include <Xm/MainW.h>#include <Xm/Form.h>#include <Xm/PushB.h>#include <Xm/ArrowB.h>#include <Xm/CascadeB.h>#include <Xm/Text.h>#include <Xm/Label.h>#include <Xm/ToggleB.h>#include <Xm/Separator.h>#include <Xm/MessageB.h>#include <Xm/ScrollBar.h>#include <Xm/RowColumn.h>#include <Xm/FileSB.h>#include <Xm/List.h>#include <Xm/Frame.h>#include "xmsprint.h"#include "xltwavplay.h"#include "wavplay.h"#include "client.h"static char * const rcsid[] = { "@(#)xltwavplay.c $Revision: 1.2 $", _wavplay_h_, "@(#)xltwavplay version " WAVPLAY_VERSION};#ifndef NO_EDITRESextern void _XEditResCheckmessages(void); /* EditRes event handler */#endifextern pid_t svrPID; /* Process ID of the wavplay server */extern int svrIPC; /* Message Queue ID for the wavplay server */int cmdopt_x = 0; /* This is controlled by bOptionsDebug */int bRecorded = 0; /* True after first record event */char *env_WAVPLAYPATH = WAVPLAYPATH; /* Default pathname of executable /usr/local/bin/wavplay */char *env_AUDIODEV = AUDIODEV; /* Default compiled in audio device */unsigned long env_AUDIOLCK = AUDIOLCK; /* Default compiled in locking semaphore *//* FALLBACK RESOURCES : */static String fallback_resources[] = {#ifndef INSTALLED_RESOURCE_FILE /* if not installed as file xltwavplay use.. */ "xltwavplay.geometry: +350+250", "xltwavplay*background: grey70", "xltwavplay*foreground: black", "xltwavplay.*fontList: *helvetica-bold-r-normal--14*", "xltwavplay.main.menubar.spacing: 10", "xltwavplay.main.menubar.filemenucascade.labelString: File", "xltwavplay*filemenu.select_files.labelString: Select Files..", "xltwavplay*filemenu.exit.labelString: Exit", "xltwavplay*filemenu.save_as.labelString: Save " RECORD_PATH " As..", "xltwavplay.main.menubar.optsmenucascade.labelString: Options", "xltwavplay*optsmenu.debug.labelString: Debug Mode", "xltwavplay*optsmenu.sem_reset.labelString: Reset locking semaphores", "xltwavplay.main.menubar.helpmenucascade.labelString: Help", "xltwavplay*helpmenu.about.labelString: About", /* Copyright notice: adjust font to suit */ "xltwavplay*AboutDlg.fontList: -adobe-helvetica-medium-r-normal-*-10-100-75-75-p-*-iso8859-1", "xltwavplay*FilesDlg.dialogTitle: Select file(s) to play", "xltwavplay*FilesDlg.pattern: *.wav", "xltwavplay*FilesDlg.fileTypeMask: FILE_REGULAR", "xltwavplay*SaveAsDlg.dialogTitle: Select a file name to write", "xltwavplay*SaveAsDlg.pattern: *.wav", "xltwavplay*SaveAsDlg.fileTypeMask: FILE_REGULAR", "xltwavplay*listbox_label.labelString: Selection:", "xltwavplay*FileLbl0.labelString: File:", "xltwavplay*TypeLbl0.labelString: Type:", "xltwavplay*DateLbl0.labelString: Date:", "xltwavplay*SizeLbl0.labelString: Size:", "xltwavplay*SamplingRateLbl0.labelString: Sampling Rate:", "xltwavplay*SamplesLbl0.labelString: Samples:", "xltwavplay*TimeLbl0.labelString: Duration:", "xltwavplay*TimeDisplayLbl0.labelString: SMPTE Time:", "xltwavplay*FileLbl1.labelString: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "xltwavplay*FileLbl1.foreground: black", "xltwavplay*TypeLbl1.labelString: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "xltwavplay*TypeLbl1.foreground: black", "xltwavplay*DateLbl1.labelString: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "xltwavplay*DateLbl1.foreground: black", "xltwavplay*SizeLbl1.labelString: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "xltwavplay*SizeLbl1.foreground: black", "xltwavplay*SamplingRateLbl1.labelString: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "xltwavplay*SamplingRateLbl1.foreground: black", "xltwavplay*SamplesLbl1.labelString: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "xltwavplay*SamplesLbl1.foreground: black", "xltwavplay*TimeLbl1.labelString: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "xltwavplay*TimeLbl1.foreground: black", "xltwavplay*TimeDisplayLbl1.labelString: 00:00:00.00", "xltwavplay*Play.labelString: Play", "xltwavplay*StopPlay.labelString: Stop", "xltwavplay*Pause.labelString: Pause", "xltwavplay*Restore.labelString: Restore", "xltwavplay*Record.labelString: Record", "xltwavplay*Stop.labelString: Stop", "xltwavplay*8Bit.labelString: 8 bit", "xltwavplay*16Bit.labelString: 16 bit", "xltwavplay*rate_lbl.labelString: Sampling Rate:", "xltwavplay*rec_rate_tgl.labelString: Record Sampling Rate:",#endif /* ndef INSTALLED_RESOURCE_FILE */ NULL};#define NoTMR 0UL /* Value for "no timer" */static void SampleRateChg_Show(int newValue);/* * WIDGETS: */Widget wParent; /* Parent shell widget */XtAppContext aContext; /* Application context */Widget wMain; /* Main widget */Widget wMenuBar; /* Main menu bar */Widget wFileMenuCascade; /* Cascade button for File Menu */Widget wFileMenu; /* File menu itself */Widget wSelect; /* File->Select */Widget wSaveAs; /* File->SaveAs.. */Widget wExit; /* File->Exit */Widget wOptionsMenuCascade;Widget wOptionsMenu;Widget wOptions_DebugTgl;Boolean bOptionsDebug = False; /* Debug mode when True */Widget wOptions_SemReset; /* Options->Semaphore Reset */Widget wHelpMenuCascade; /* Cascade button for Help Menu */Widget wHelpMenu; /* Help menu itself */Widget wAbout; /* Help->About */Widget wErrDlg; /* Error Dialog Box */XmString sErrDlgTitle; /* Title for the Error Dialog Box */Widget wAboutDlg; /* About Dialog Box */XmString sAboutDlgTitle; /* About Dialog Title String */XmString sAboutDlgMessage; /* About Dialog message and copyright */Widget wFilesDlg; /* File selection dialog */Widget wSaveAsDlg; /* File "Save As..." dialog */Widget wMainForm; /* Main form widget */Widget wLeftRC; /* Left main Row/Column */Widget wListFrame; /* Frame for Selections List Box */Widget wListForm; /* Form within Selections List Box */Widget wSelectionsLbl; /* Label for Selections List Box */Widget wSelectionsListBox; /* The selections List Box */Widget wTimeFrame; /* Frame for Time control */Widget wTimeRC; /* Row Col widget for Time control */Widget wTimeDisplayRC; /* Keeps display next to label */Widget wTimeDisplayLbl0; /* Label for the time */Widget wTimeDisplayLbl1; /* Actual time display */Widget wTimeScrollBar; /* Time scrollbar */Widget wRateSBFrame; /* Frame for the scroll bar */Widget wRateRC; /* Row Col widget for Rate scroll bar */Widget wRateLbl; /* Label for the scroll bar */Widget wRateScrollBar; /* The Sampling Rate Scroll Bar */int SampRate_value = 0; /* Current scroll bar value */Widget wRecRateFrame; /* The record rate frame */Widget wRecRateRC;Widget wRecRateTgl;Widget wRecRate;int RecRateTgl_value = 0;Widget wDetailsFrame; /* Frame for File Info Details */Widget wDetailsRC; /* Horizontal RC for wBotLeftRC* */Widget wBotLeftRC0; /* Holds labels File:, Type: etc. */Widget wFileLbl0;Widget wTypeLbl0;Widget wDateLbl0;Widget wSizeLbl0;Widget wSamplingRateLbl0;Widget wSamplesLbl0;Widget wTimeLbl0;Widget wBotLeftRC1; /* Holds labels to right of wBotLeftRC0 */Widget wFileLbl1;Widget wTypeLbl1;Widget wDateLbl1;Widget wSizeLbl1;Widget wSamplingRateLbl1;Widget wSamplesLbl1;Widget wTimeLbl1;Widget wRightRC; /* Right side Row/Column */Widget wBitsFrame; /* Frame holding BitsRC */Widget wBitsRC; /* RowColumn that holds 8, 12, & 16 bits */Widget w8BitCB; /* 8-bit check box */Widget w16BitCB; /* 16-bit check box */int curBits = 0; /* The current setting */Widget wPlayFrame; /* Frame for play buttons */Widget wPlayRC; /* RC for play buttons */Widget wPlayPB; /* Play push button */Widget wPausePB; /* Pause push button */Widget wStopPlayPB; /* StopPlay push button */Widget wRestorePB; /* Restore push button */Widget wStereoFrame; /* Frame for Stereo Toggle */Widget wStereoCB; /* Stereo Check Box */Widget wRecordFrame;Widget wRecordRC;Widget wRecordPB; /* Record push button */Widget wStopPB; /* Stop push button */XmString sRecorded_wav; /* XmString() of RECORD_PATH *//* Info required by the time display */#define SMPTE_FPS 25typedef struct TimeDisplayInfo { UInt32 sampling_rate; UInt32 sample_num; char sample_info_str[16];} TimeDisplayInfo;TimeDisplayInfo time_display;/* Flag to show when the help text is displayed */int help_text_showing = 1;/* * This is an internal conveniance routine: * In order for EditRes to function, we must register all shell widgets. */#ifndef NO_EDITRESstatic voidRegisterShellWidget(Widget w) { XtAddEventHandler(w,(EventMask)0,True,_XEditResCheckMessages,NULL);}#else#define RegisterShellWidget(w) /* No EDITRES facility */#endif /* ndef NO_EDITRES *//* * This function initiates the creation of an error dialog with * a meaningful error text and an OK button. Note that the dialog * box is not operationaly until we return back to the main loop. */static voidReportError(const char *ErrMsg) { XmString s; /* XmString form of message */ if ( XtIsManaged(wErrDlg) ) return; /* The dialog is already in use */ /* * Set the Error Dialog message text, and manage it so that it pops up: */ s = XmStringCreateLtoR((char *)ErrMsg,XmSTRING_DEFAULT_CHARSET);/* We need an XmString */ XtVaSetValues(wErrDlg,XmNmessageString,s,NULL); /* Put msg in there */ XtManageChild(wErrDlg); /* Make it pop up */ XmStringFree(s); /* Release the string */}/* * Error function to format a message and report it: */static voidv_erf(const char *format,va_list ap) { char buf[1024]; vsprintf(buf,format,ap); /* Format the message */ fputs(buf,stderr); /* Send to stderr */ fputc('\n',stderr); /* ..with a newline */ ReportError(buf); /* Now popup error message if we can */}/* * Format an error report: */voidReportErrorf(const char *format,...) { va_list ap; va_start(ap,format); /* Access the arguments list */ v_erf(format,ap); /* Go report the error */ va_end(ap); /* A formality for stdargs */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -