6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /* Command-line audio play utility */
27
28 #include <stdio.h>
29 #include <errno.h>
30 #include <ctype.h>
31 #include <string.h>
32 #include <stdlib.h>
33 #include <fcntl.h>
34 #include <signal.h>
35 #include <locale.h>
36 #include <limits.h> /* All occurances of INT_MAX used to be ~0 (by MCA) */
37 #include <unistd.h>
38 #include <stropts.h>
39 #include <sys/types.h>
40 #include <sys/file.h>
41 #include <sys/stat.h>
42 #include <sys/param.h>
43 #include <sys/ioctl.h>
44 #include <sys/mman.h>
45 #include <netinet/in.h>
785 }
786 }
787 }
788
789 /* Free memory if decoding ADPCM */
790 switch (Decode) {
791 case AUDIO_ENCODING_G721:
792 case AUDIO_ENCODING_G723:
793 freemux();
794 break;
795 default:
796 break;
797 }
798
799 closeinput:;
800 if (mapaddr != 0)
801 (void) munmap(mapaddr, st.st_size);
802 (void) close(ifd); /* close input file */
803 if (Errdetect) {
804 cnt = 0;
805 audio_set_play_error(Audio_fd, (unsigned int *)&cnt);
806 if (cnt) {
807 Error(stderr,
808 MGET("%s: output underflow in %s\n"),
809 Ifile, prog);
810 errorStatus++;
811 }
812 }
813 nextfile:;
814 } while ((argc > 0) && (argc--, (Ifile = *argv++) != NULL));
815
816 /*
817 * Though drain is implicit on close(), it's performed here
818 * to ensure that the volume is reset after all output is complete.
819 */
820 (void) audio_drain(Audio_fd, FALSE);
821
822 /* Flush any remaining audio */
823 (void) ioctl(Audio_fd, I_FLUSH, FLUSHW);
824
825 if (Volume != INT_MAX)
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * Copyright (c) 2018, Joyent, Inc.
28 */
29
30 /* Command-line audio play utility */
31
32 #include <stdio.h>
33 #include <errno.h>
34 #include <ctype.h>
35 #include <string.h>
36 #include <stdlib.h>
37 #include <fcntl.h>
38 #include <signal.h>
39 #include <locale.h>
40 #include <limits.h> /* All occurances of INT_MAX used to be ~0 (by MCA) */
41 #include <unistd.h>
42 #include <stropts.h>
43 #include <sys/types.h>
44 #include <sys/file.h>
45 #include <sys/stat.h>
46 #include <sys/param.h>
47 #include <sys/ioctl.h>
48 #include <sys/mman.h>
49 #include <netinet/in.h>
789 }
790 }
791 }
792
793 /* Free memory if decoding ADPCM */
794 switch (Decode) {
795 case AUDIO_ENCODING_G721:
796 case AUDIO_ENCODING_G723:
797 freemux();
798 break;
799 default:
800 break;
801 }
802
803 closeinput:;
804 if (mapaddr != 0)
805 (void) munmap(mapaddr, st.st_size);
806 (void) close(ifd); /* close input file */
807 if (Errdetect) {
808 cnt = 0;
809 (void) audio_set_play_error(Audio_fd,
810 (unsigned int *)&cnt);
811 if (cnt) {
812 Error(stderr,
813 MGET("%s: output underflow in %s\n"),
814 Ifile, prog);
815 errorStatus++;
816 }
817 }
818 nextfile:;
819 } while ((argc > 0) && (argc--, (Ifile = *argv++) != NULL));
820
821 /*
822 * Though drain is implicit on close(), it's performed here
823 * to ensure that the volume is reset after all output is complete.
824 */
825 (void) audio_drain(Audio_fd, FALSE);
826
827 /* Flush any remaining audio */
828 (void) ioctl(Audio_fd, I_FLUSH, FLUSHW);
829
830 if (Volume != INT_MAX)
|