17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate /*
230c83a891Snakanon * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate #include <sys/types.h>
287c478bd9Sstevel@tonic-gate #include <string.h>
297c478bd9Sstevel@tonic-gate #include <stdlib.h>
307c478bd9Sstevel@tonic-gate #include <libintl.h>
317c478bd9Sstevel@tonic-gate #include <signal.h>
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gate #include "bstream.h"
347c478bd9Sstevel@tonic-gate #include "util.h"
357c478bd9Sstevel@tonic-gate #include "misc_scsi.h"
367c478bd9Sstevel@tonic-gate #include "device.h"
377c478bd9Sstevel@tonic-gate #include "main.h"
387c478bd9Sstevel@tonic-gate #include "msgs.h"
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate #define BLOCK_SIZE 2352
417c478bd9Sstevel@tonic-gate #define READ_BURST_SIZE 200
427c478bd9Sstevel@tonic-gate #define SMALL_READ_BURST_SIZE 24 /* < 64K in all cases */
437c478bd9Sstevel@tonic-gate #define READ_OVERLAP 7
447c478bd9Sstevel@tonic-gate #define BLOCKS_COMPARE 3
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate static int abort_read;
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate * These are routines for extracting audio from a cd. During
507c478bd9Sstevel@tonic-gate * extraction we will also convert the audio type from the
517c478bd9Sstevel@tonic-gate * CD to the audio type specified on the command line. This
527c478bd9Sstevel@tonic-gate * handles both newer CD drives which support the MMC2 standard
537c478bd9Sstevel@tonic-gate * and older Sun Toshiba drives which need jitter correction.
547c478bd9Sstevel@tonic-gate */
557c478bd9Sstevel@tonic-gate
567c478bd9Sstevel@tonic-gate static bstreamhandle
open_audio_for_extraction(char * fname)577c478bd9Sstevel@tonic-gate open_audio_for_extraction(char *fname)
587c478bd9Sstevel@tonic-gate {
597c478bd9Sstevel@tonic-gate int at;
607c478bd9Sstevel@tonic-gate char *ext;
617c478bd9Sstevel@tonic-gate
627c478bd9Sstevel@tonic-gate if (audio_type == AUDIO_TYPE_NONE) {
637c478bd9Sstevel@tonic-gate ext = (char *)(strrchr(fname, '.'));
647c478bd9Sstevel@tonic-gate if (ext) {
657c478bd9Sstevel@tonic-gate ext++;
667c478bd9Sstevel@tonic-gate }
677c478bd9Sstevel@tonic-gate if ((ext == NULL) || ((at = get_audio_type(ext)) == -1)) {
687c478bd9Sstevel@tonic-gate err_msg(gettext(
697c478bd9Sstevel@tonic-gate "Cannot understand file extension for %s\n"),
707c478bd9Sstevel@tonic-gate fname);
717c478bd9Sstevel@tonic-gate exit(1);
727c478bd9Sstevel@tonic-gate }
737c478bd9Sstevel@tonic-gate } else {
747c478bd9Sstevel@tonic-gate at = audio_type;
757c478bd9Sstevel@tonic-gate }
767c478bd9Sstevel@tonic-gate if (at == AUDIO_TYPE_SUN)
777c478bd9Sstevel@tonic-gate return (open_au_write_stream(fname));
787c478bd9Sstevel@tonic-gate if (at == AUDIO_TYPE_WAV)
797c478bd9Sstevel@tonic-gate return (open_wav_write_stream(fname));
807c478bd9Sstevel@tonic-gate if (at == AUDIO_TYPE_CDA)
817c478bd9Sstevel@tonic-gate return (open_file_write_stream(fname));
827c478bd9Sstevel@tonic-gate if (at == AUDIO_TYPE_AUR)
837c478bd9Sstevel@tonic-gate return (open_aur_write_stream(fname));
847c478bd9Sstevel@tonic-gate return (NULL);
857c478bd9Sstevel@tonic-gate }
867c478bd9Sstevel@tonic-gate
877c478bd9Sstevel@tonic-gate /* ARGSUSED */
887c478bd9Sstevel@tonic-gate static void
extract_signal_handler(int sig,siginfo_t * info,void * context)897c478bd9Sstevel@tonic-gate extract_signal_handler(int sig, siginfo_t *info, void *context)
907c478bd9Sstevel@tonic-gate {
917c478bd9Sstevel@tonic-gate abort_read = 1;
927c478bd9Sstevel@tonic-gate }
937c478bd9Sstevel@tonic-gate
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate * Older drives use different data buffer and m:s:f channels to transmit audio
967c478bd9Sstevel@tonic-gate * information. These channels may not be in sync with each other with the
977c478bd9Sstevel@tonic-gate * maximum disparity being the size of the data buffer. So handling is needed
987c478bd9Sstevel@tonic-gate * to keep these two channels in sync.
997c478bd9Sstevel@tonic-gate */
1007c478bd9Sstevel@tonic-gate
1017c478bd9Sstevel@tonic-gate static int
handle_jitter(uchar_t * buf,uchar_t * last_end)1027c478bd9Sstevel@tonic-gate handle_jitter(uchar_t *buf, uchar_t *last_end)
1037c478bd9Sstevel@tonic-gate {
1047c478bd9Sstevel@tonic-gate int i;
1057c478bd9Sstevel@tonic-gate for (i = BLOCK_SIZE*(READ_OVERLAP - BLOCKS_COMPARE); i >= 0; i -= 4) {
1067c478bd9Sstevel@tonic-gate if (memcmp(last_end - BLOCK_SIZE * BLOCKS_COMPARE, buf + i,
1077c478bd9Sstevel@tonic-gate BLOCK_SIZE * BLOCKS_COMPARE) == 0) {
1087c478bd9Sstevel@tonic-gate return (i + (BLOCK_SIZE * BLOCKS_COMPARE));
1097c478bd9Sstevel@tonic-gate }
1107c478bd9Sstevel@tonic-gate }
1117c478bd9Sstevel@tonic-gate for (i = BLOCK_SIZE*(READ_OVERLAP - BLOCKS_COMPARE);
112*30699046SRichard Lowe i < 2*READ_OVERLAP*BLOCK_SIZE; i += 4) {
1137c478bd9Sstevel@tonic-gate if (memcmp(last_end - BLOCK_SIZE * BLOCKS_COMPARE, buf + i,
1147c478bd9Sstevel@tonic-gate BLOCK_SIZE * BLOCKS_COMPARE) == 0) {
1157c478bd9Sstevel@tonic-gate return (i + (BLOCK_SIZE * BLOCKS_COMPARE));
1167c478bd9Sstevel@tonic-gate }
1177c478bd9Sstevel@tonic-gate }
1187c478bd9Sstevel@tonic-gate return (-1);
1197c478bd9Sstevel@tonic-gate }
1207c478bd9Sstevel@tonic-gate
1217c478bd9Sstevel@tonic-gate int
read_audio_track(cd_device * dev,struct track_info * ti,bstreamhandle h)1227c478bd9Sstevel@tonic-gate read_audio_track(cd_device *dev, struct track_info *ti, bstreamhandle h)
1237c478bd9Sstevel@tonic-gate {
1247c478bd9Sstevel@tonic-gate uint32_t blocks_to_write, blocks_to_read, blks_to_overlap;
1257c478bd9Sstevel@tonic-gate uint32_t start_blk, end_blk, c_blk;
1267c478bd9Sstevel@tonic-gate uint32_t read_burst_size;
1277c478bd9Sstevel@tonic-gate uchar_t *tmp, *buf, *prev, *previous_end;
1287c478bd9Sstevel@tonic-gate int ret, off;
1297c478bd9Sstevel@tonic-gate struct sigaction sv;
1307c478bd9Sstevel@tonic-gate struct sigaction oldsv;
1317c478bd9Sstevel@tonic-gate
1327c478bd9Sstevel@tonic-gate ret = 0;
1337c478bd9Sstevel@tonic-gate abort_read = 0;
1347c478bd9Sstevel@tonic-gate
1357c478bd9Sstevel@tonic-gate /*
1367c478bd9Sstevel@tonic-gate * It is good to do small sized I/Os as we have seen many devices
1377c478bd9Sstevel@tonic-gate * choke with large I/Os. But if the device does not support
1387c478bd9Sstevel@tonic-gate * reading accurate CDDA then we have to do overlapped I/Os
1397c478bd9Sstevel@tonic-gate * and reducing size might affect performance. So use small
1407c478bd9Sstevel@tonic-gate * I/O size if device supports accurate CDDA.
1417c478bd9Sstevel@tonic-gate */
1427c478bd9Sstevel@tonic-gate if (dev->d_cap & DEV_CAP_ACCURATE_CDDA) {
1437c478bd9Sstevel@tonic-gate read_burst_size = SMALL_READ_BURST_SIZE;
1447c478bd9Sstevel@tonic-gate } else {
1457c478bd9Sstevel@tonic-gate read_burst_size = READ_BURST_SIZE;
1467c478bd9Sstevel@tonic-gate }
1477c478bd9Sstevel@tonic-gate buf = (uchar_t *)my_zalloc(BLOCK_SIZE * read_burst_size);
1487c478bd9Sstevel@tonic-gate prev = (uchar_t *)my_zalloc(BLOCK_SIZE * read_burst_size);
1497c478bd9Sstevel@tonic-gate start_blk = ti->ti_start_address;
1507c478bd9Sstevel@tonic-gate end_blk = ti->ti_start_address + ti->ti_track_size - 1;
1517c478bd9Sstevel@tonic-gate
1527c478bd9Sstevel@tonic-gate /* Even when we need jitter correction, this will be 0 1st time */
1537c478bd9Sstevel@tonic-gate blks_to_overlap = 0;
1547c478bd9Sstevel@tonic-gate off = 0;
1557c478bd9Sstevel@tonic-gate
1567c478bd9Sstevel@tonic-gate /* set up signal handler to write audio TOC if ^C is pressed */
157*30699046SRichard Lowe sv.sa_sigaction = extract_signal_handler;
1587c478bd9Sstevel@tonic-gate (void) sigemptyset(&sv.sa_mask);
1597c478bd9Sstevel@tonic-gate sv.sa_flags = 0;
1607c478bd9Sstevel@tonic-gate (void) sigaction(SIGINT, &sv, &oldsv);
1617c478bd9Sstevel@tonic-gate
1627c478bd9Sstevel@tonic-gate if ((dev->d_cap & DEV_CAP_EXTRACT_CDDA) == 0) {
1637c478bd9Sstevel@tonic-gate err_msg(gettext("Audio extraction method unknown for %s\n"),
1647c478bd9Sstevel@tonic-gate dev->d_name ? dev->d_name : gettext("CD drive"));
1657c478bd9Sstevel@tonic-gate exit(1);
1667c478bd9Sstevel@tonic-gate }
1677c478bd9Sstevel@tonic-gate
1687c478bd9Sstevel@tonic-gate /* if the speed option given, try to change the speed */
1697c478bd9Sstevel@tonic-gate if ((requested_speed != 0) && !cflag) {
1707c478bd9Sstevel@tonic-gate if (verbose)
1717c478bd9Sstevel@tonic-gate (void) printf(gettext("Trying to set speed to %dX.\n"),
1727c478bd9Sstevel@tonic-gate requested_speed);
1737c478bd9Sstevel@tonic-gate if (dev->d_speed_ctrl(dev, SET_READ_SPEED,
1747c478bd9Sstevel@tonic-gate requested_speed) == 0) {
1757c478bd9Sstevel@tonic-gate
1767c478bd9Sstevel@tonic-gate err_msg(gettext("Unable to set speed.\n"));
1777c478bd9Sstevel@tonic-gate exit(1);
1787c478bd9Sstevel@tonic-gate }
1797c478bd9Sstevel@tonic-gate if (verbose) {
1807c478bd9Sstevel@tonic-gate int speed;
1817c478bd9Sstevel@tonic-gate speed = dev->d_speed_ctrl(dev, GET_READ_SPEED, 0);
1827c478bd9Sstevel@tonic-gate if (speed == requested_speed) {
1837c478bd9Sstevel@tonic-gate (void) printf(gettext("Speed set to %dX.\n"),
1847c478bd9Sstevel@tonic-gate speed);
18598584592Sarutz } else if (speed == 0) {
18698584592Sarutz (void) printf(gettext("Could not obtain "
18798584592Sarutz "current Read Speed.\n"));
1887c478bd9Sstevel@tonic-gate } else {
18998584592Sarutz (void) printf(gettext("Speed set to "
19098584592Sarutz "closest approximation of %dX allowed "
19198584592Sarutz "by device (%dX).\n"),
1927c478bd9Sstevel@tonic-gate requested_speed, speed);
1937c478bd9Sstevel@tonic-gate }
1947c478bd9Sstevel@tonic-gate }
1957c478bd9Sstevel@tonic-gate }
1967c478bd9Sstevel@tonic-gate
1977c478bd9Sstevel@tonic-gate print_n_flush(
1987c478bd9Sstevel@tonic-gate gettext("Extracting audio from track %d..."), ti->ti_track_no);
1997c478bd9Sstevel@tonic-gate init_progress();
2007c478bd9Sstevel@tonic-gate
2017c478bd9Sstevel@tonic-gate if (debug)
2027c478bd9Sstevel@tonic-gate (void) printf("\nStarting: %d Ending: %d\n",
2037c478bd9Sstevel@tonic-gate start_blk, end_blk);
2047c478bd9Sstevel@tonic-gate
2057c478bd9Sstevel@tonic-gate blocks_to_write = 0;
2067c478bd9Sstevel@tonic-gate
2077c478bd9Sstevel@tonic-gate for (c_blk = start_blk; c_blk < end_blk; c_blk += blocks_to_write) {
2087c478bd9Sstevel@tonic-gate /* update progress indicator */
2090c83a891Snakanon (void) progress((end_blk - start_blk),
2107c478bd9Sstevel@tonic-gate (int64_t)(c_blk - start_blk));
2117c478bd9Sstevel@tonic-gate blocks_to_read = end_blk - c_blk + blks_to_overlap;
2127c478bd9Sstevel@tonic-gate
2137c478bd9Sstevel@tonic-gate /*
2147c478bd9Sstevel@tonic-gate * Make sure we don't read more blocks than the maximum
2157c478bd9Sstevel@tonic-gate * burst size.
2167c478bd9Sstevel@tonic-gate */
2177c478bd9Sstevel@tonic-gate
2187c478bd9Sstevel@tonic-gate if (blocks_to_read > read_burst_size)
2197c478bd9Sstevel@tonic-gate blocks_to_read = read_burst_size;
2207c478bd9Sstevel@tonic-gate
2217c478bd9Sstevel@tonic-gate if (dev->d_read_audio(dev, c_blk - blks_to_overlap,
2227c478bd9Sstevel@tonic-gate blocks_to_read, buf) == 0)
2237c478bd9Sstevel@tonic-gate goto read_audio_track_done;
2247c478bd9Sstevel@tonic-gate
2257c478bd9Sstevel@tonic-gate /*
2267c478bd9Sstevel@tonic-gate * This drive supports accurate audio extraction don't
2277c478bd9Sstevel@tonic-gate * do jitter correction.
2287c478bd9Sstevel@tonic-gate */
2297c478bd9Sstevel@tonic-gate if ((c_blk == start_blk) ||
2307c478bd9Sstevel@tonic-gate (dev->d_cap & DEV_CAP_ACCURATE_CDDA)) {
2317c478bd9Sstevel@tonic-gate blocks_to_write = blocks_to_read;
2327c478bd9Sstevel@tonic-gate previous_end = buf + (blocks_to_write * BLOCK_SIZE);
2337c478bd9Sstevel@tonic-gate goto skip_jitter_correction;
2347c478bd9Sstevel@tonic-gate }
2357c478bd9Sstevel@tonic-gate
2367c478bd9Sstevel@tonic-gate if (c_blk == start_blk)
2377c478bd9Sstevel@tonic-gate blks_to_overlap = 0;
2387c478bd9Sstevel@tonic-gate else
2397c478bd9Sstevel@tonic-gate blks_to_overlap = READ_OVERLAP;
2407c478bd9Sstevel@tonic-gate off = handle_jitter(buf, previous_end);
2417c478bd9Sstevel@tonic-gate if (off == -1) {
2427c478bd9Sstevel@tonic-gate if (debug)
2437c478bd9Sstevel@tonic-gate (void) printf(
2447c478bd9Sstevel@tonic-gate "jitter control failed\n");
2457c478bd9Sstevel@tonic-gate
2467c478bd9Sstevel@tonic-gate /* recover if jitter correction failed */
2477c478bd9Sstevel@tonic-gate off = BLOCK_SIZE * BLOCKS_COMPARE;
2487c478bd9Sstevel@tonic-gate }
2497c478bd9Sstevel@tonic-gate
2507c478bd9Sstevel@tonic-gate blocks_to_write = blocks_to_read - blks_to_overlap;
2517c478bd9Sstevel@tonic-gate
2527c478bd9Sstevel@tonic-gate while ((off + (blocks_to_write*BLOCK_SIZE)) >
2537c478bd9Sstevel@tonic-gate (blocks_to_read * BLOCK_SIZE)) {
2547c478bd9Sstevel@tonic-gate blocks_to_write--;
2557c478bd9Sstevel@tonic-gate }
2567c478bd9Sstevel@tonic-gate
2577c478bd9Sstevel@tonic-gate if ((blocks_to_write + c_blk) > end_blk) {
2587c478bd9Sstevel@tonic-gate blocks_to_write = end_blk - c_blk;
2597c478bd9Sstevel@tonic-gate }
2607c478bd9Sstevel@tonic-gate
2617c478bd9Sstevel@tonic-gate if (blocks_to_write == 0) {
2627c478bd9Sstevel@tonic-gate c_blk = end_blk - 1;
2637c478bd9Sstevel@tonic-gate blocks_to_write = 1;
2647c478bd9Sstevel@tonic-gate (void) memset(&buf[off], 0, off % BLOCK_SIZE);
2657c478bd9Sstevel@tonic-gate }
2667c478bd9Sstevel@tonic-gate
2677c478bd9Sstevel@tonic-gate previous_end = buf + off + blocks_to_write * BLOCK_SIZE;
2687c478bd9Sstevel@tonic-gate skip_jitter_correction:
2697c478bd9Sstevel@tonic-gate (void) memcpy(prev, buf, read_burst_size * BLOCK_SIZE);
2707c478bd9Sstevel@tonic-gate if (h->bstr_write(h, &buf[off], blocks_to_write*BLOCK_SIZE)
2717c478bd9Sstevel@tonic-gate < 0)
2727c478bd9Sstevel@tonic-gate goto read_audio_track_done;
2737c478bd9Sstevel@tonic-gate tmp = buf;
2747c478bd9Sstevel@tonic-gate buf = prev;
2757c478bd9Sstevel@tonic-gate prev = tmp;
2767c478bd9Sstevel@tonic-gate
2777c478bd9Sstevel@tonic-gate if (abort_read == 1)
2787c478bd9Sstevel@tonic-gate goto read_audio_track_done;
2797c478bd9Sstevel@tonic-gate }
2807c478bd9Sstevel@tonic-gate
2817c478bd9Sstevel@tonic-gate ret = 1;
2827c478bd9Sstevel@tonic-gate (void) str_print(gettext("done.\n"), progress_pos);
2837c478bd9Sstevel@tonic-gate
2847c478bd9Sstevel@tonic-gate read_audio_track_done:
2857c478bd9Sstevel@tonic-gate (void) sigaction(SIGINT, &oldsv, (struct sigaction *)0);
2867c478bd9Sstevel@tonic-gate
2877c478bd9Sstevel@tonic-gate free(buf);
2887c478bd9Sstevel@tonic-gate free(prev);
2897c478bd9Sstevel@tonic-gate return (ret);
2907c478bd9Sstevel@tonic-gate }
2917c478bd9Sstevel@tonic-gate
2927c478bd9Sstevel@tonic-gate void
extract_audio(void)2937c478bd9Sstevel@tonic-gate extract_audio(void)
2947c478bd9Sstevel@tonic-gate {
2957c478bd9Sstevel@tonic-gate bstreamhandle h;
2967c478bd9Sstevel@tonic-gate struct track_info *ti;
2977c478bd9Sstevel@tonic-gate
2987c478bd9Sstevel@tonic-gate (void) check_device(target, CHECK_NO_MEDIA | CHECK_DEVICE_NOT_READY |
2997c478bd9Sstevel@tonic-gate EXIT_IF_CHECK_FAILED);
3007c478bd9Sstevel@tonic-gate
3017c478bd9Sstevel@tonic-gate ti = (struct track_info *)my_zalloc(sizeof (*ti));
3027c478bd9Sstevel@tonic-gate if (!build_track_info(target, extract_track_no, ti)) {
3037c478bd9Sstevel@tonic-gate err_msg(gettext("Cannot get track information for track %d\n"),
3047c478bd9Sstevel@tonic-gate extract_track_no);
3057c478bd9Sstevel@tonic-gate exit(1);
3067c478bd9Sstevel@tonic-gate }
3077c478bd9Sstevel@tonic-gate
3087c478bd9Sstevel@tonic-gate /* Verify track */
3097c478bd9Sstevel@tonic-gate if ((ti->ti_track_size == 0) || ((ti->ti_flags & TI_NWA_VALID) &&
3107c478bd9Sstevel@tonic-gate (ti->ti_start_address == ti->ti_nwa))) {
3117c478bd9Sstevel@tonic-gate err_msg(gettext("Track %d is empty\n"), extract_track_no);
3127c478bd9Sstevel@tonic-gate exit(1);
3137c478bd9Sstevel@tonic-gate }
3147c478bd9Sstevel@tonic-gate if (ti->ti_track_mode & 4) {
3157c478bd9Sstevel@tonic-gate err_msg(gettext("Track %d is not an audio track\n"),
3167c478bd9Sstevel@tonic-gate extract_track_no);
3177c478bd9Sstevel@tonic-gate exit(1);
3187c478bd9Sstevel@tonic-gate }
3197c478bd9Sstevel@tonic-gate if (ti->ti_data_mode == 2) {
3207c478bd9Sstevel@tonic-gate err_msg(gettext("Track format is not supported\n"));
3217c478bd9Sstevel@tonic-gate exit(1);
3227c478bd9Sstevel@tonic-gate }
3237c478bd9Sstevel@tonic-gate
3247c478bd9Sstevel@tonic-gate h = open_audio_for_extraction(extract_file);
3257c478bd9Sstevel@tonic-gate if (h == NULL) {
3267c478bd9Sstevel@tonic-gate err_msg(gettext("Cannot open %s:%s\n"), extract_file,
3277c478bd9Sstevel@tonic-gate get_err_str());
3287c478bd9Sstevel@tonic-gate exit(1);
3297c478bd9Sstevel@tonic-gate }
3307c478bd9Sstevel@tonic-gate if (read_audio_track(target, ti, h) == 0) {
3317c478bd9Sstevel@tonic-gate err_msg(gettext("Extract audio failed\n"));
3327c478bd9Sstevel@tonic-gate h->bstr_close(h);
3337c478bd9Sstevel@tonic-gate exit(1);
3347c478bd9Sstevel@tonic-gate }
3357c478bd9Sstevel@tonic-gate if (h->bstr_close(h) != 0) {
3367c478bd9Sstevel@tonic-gate err_msg(gettext("Error closing audio stream : %s\n"),
3377c478bd9Sstevel@tonic-gate get_err_str());
3387c478bd9Sstevel@tonic-gate exit(1);
3397c478bd9Sstevel@tonic-gate }
3407c478bd9Sstevel@tonic-gate exit(0);
3417c478bd9Sstevel@tonic-gate }
342