external/alsa-utils
Revisión | bc42704c96c02b138849be4af6c90b4755659b56 (tree) |
---|---|
Tiempo | 2019-03-13 01:36:11 |
Autor | Jaroslav Kysela <perex@pere...> |
Commiter | Jaroslav Kysela |
aplay: fix the multiple open file descriptors for the raw capture
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
@@ -2690,8 +2690,6 @@ static void end_voc(int fd) | ||
2690 | 2690 | bt.datalen_h = (u_char) ((cnt & 0xFF0000) >> 16); |
2691 | 2691 | if (lseek64(fd, length_seek, SEEK_SET) == length_seek) |
2692 | 2692 | xwrite(fd, &bt, sizeof(VocBlockType)); |
2693 | - if (fd != 1) | |
2694 | - close(fd); | |
2695 | 2693 | } |
2696 | 2694 | |
2697 | 2695 | static void end_wave(int fd) |
@@ -2712,8 +2710,6 @@ static void end_wave(int fd) | ||
2712 | 2710 | xwrite(fd, &rifflen, 4); |
2713 | 2711 | if (lseek64(fd, length_seek, SEEK_SET) == length_seek) |
2714 | 2712 | xwrite(fd, &cd, sizeof(WaveChunkHeader)); |
2715 | - if (fd != 1) | |
2716 | - close(fd); | |
2717 | 2713 | } |
2718 | 2714 | |
2719 | 2715 | static void end_au(int fd) |
@@ -2725,8 +2721,6 @@ static void end_au(int fd) | ||
2725 | 2721 | ah.data_size = fdcount > 0xffffffff ? 0xffffffff : BE_INT(fdcount); |
2726 | 2722 | if (lseek64(fd, length_seek, SEEK_SET) == length_seek) |
2727 | 2723 | xwrite(fd, &ah.data_size, sizeof(ah.data_size)); |
2728 | - if (fd != 1) | |
2729 | - close(fd); | |
2730 | 2724 | } |
2731 | 2725 | |
2732 | 2726 | static void header(int rtype, char *name) |
@@ -2938,7 +2932,7 @@ static void playback(char *name) | ||
2938 | 2932 | break; |
2939 | 2933 | } |
2940 | 2934 | |
2941 | - if (fd != 0) | |
2935 | + if (fd != fileno(stdin)) | |
2942 | 2936 | close(fd); |
2943 | 2937 | } |
2944 | 2938 |
@@ -3151,7 +3145,7 @@ static void capture(char *orig_name) | ||
3151 | 3145 | if (!name || !strcmp(name, "-")) { |
3152 | 3146 | fd = fileno(stdout); |
3153 | 3147 | name = "stdout"; |
3154 | - tostdout=1; | |
3148 | + tostdout = 1; | |
3155 | 3149 | if (count > fmt_rec_table[file_type].max_filesize) |
3156 | 3150 | count = fmt_rec_table[file_type].max_filesize; |
3157 | 3151 | } |
@@ -3159,7 +3153,7 @@ static void capture(char *orig_name) | ||
3159 | 3153 | |
3160 | 3154 | do { |
3161 | 3155 | /* open a file to write */ |
3162 | - if(!tostdout) { | |
3156 | + if (!tostdout) { | |
3163 | 3157 | /* upon the second file we start the numbering scheme */ |
3164 | 3158 | if (filecount || use_strftime) { |
3165 | 3159 | filecount = new_capture_file(orig_name, namebuf, |
@@ -3218,8 +3212,10 @@ static void capture(char *orig_name) | ||
3218 | 3212 | } |
3219 | 3213 | |
3220 | 3214 | /* finish sample container */ |
3221 | - if (fmt_rec_table[file_type].end && !tostdout) { | |
3222 | - fmt_rec_table[file_type].end(fd); | |
3215 | + if (!tostdout) { | |
3216 | + if (fmt_rec_table[file_type].end) | |
3217 | + fmt_rec_table[file_type].end(fd); | |
3218 | + close(fd); | |
3223 | 3219 | fd = -1; |
3224 | 3220 | } |
3225 | 3221 |