diff --git a/src/wav.c b/src/wav.c index eb2ba03962..380796c0f0 100644 --- a/src/wav.c +++ b/src/wav.c @@ -654,8 +654,11 @@ static int wav_read_fmt(sox_format_t *ft, uint32_t len) if (err) return SOX_EOF; - if (wav->bitsPerSample == 0) - { + if (wav->bitsPerSample == 0 +#ifdef HAVE_LIBGSM + && wav->formatTag != WAVE_FORMAT_GSM610 +#endif + ){ lsx_fail_errno(ft, SOX_EHDR, "WAV file bits per sample is zero"); return SOX_EOF; } @@ -1354,8 +1357,10 @@ static int wavwritehdr(sox_format_t * ft, int second_header) (dwSamplesWritten + wSamplesPerBlock - 1) / wSamplesPerBlock; dwDataLength = blocksWritten * wBlockAlign; +#ifdef HAVE_LIBGSM if (wFormatTag == WAVE_FORMAT_GSM610) dwDataLength = (dwDataLength+1) & ~1u; /* round up to even */ +#endif if (wFormatTag == WAVE_FORMAT_PCM && (wBitsPerSample > 16 || wChannels > 2) && strcmp(ft->filetype, "wavpcm")) { @@ -1450,9 +1455,11 @@ static int wavwritehdr(sox_format_t * ft, int second_header) lsx_writew(ft, (uint16_t)(lsx_ms_adpcm_i_coef[i][1])); } break; +#ifdef HAVE_LIBGSM case WAVE_FORMAT_GSM610: lsx_writew(ft, wSamplesPerBlock); break; +#endif default: break; } @@ -1560,7 +1567,9 @@ static int stopwrite(sox_format_t * ft) /* Add a pad byte if the number of data bytes is odd. See wavwritehdr() above for the calculation. */ +#ifdef HAVE_LIBGSM if (wav->formatTag != WAVE_FORMAT_GSM610) +#endif lsx_padbytes(ft, (size_t)((wav->numSamples + wav->samplesPerBlock - 1)/wav->samplesPerBlock*wav->blockAlign) % 2); free(wav->packet); @@ -1600,6 +1609,7 @@ static int seek(sox_format_t * ft, uint64_t offset) if (ft->encoding.bits_per_sample & 7) lsx_fail_errno(ft, SOX_ENOTSUP, "seeking not supported with this encoding"); +#ifdef HAVE_LIBGSM else if (wav->formatTag == WAVE_FORMAT_GSM610) { int alignment; size_t gsmoff; @@ -1619,7 +1629,9 @@ static int seek(sox_format_t * ft, uint64_t offset) new_offset += (wav->samplesPerBlock - alignment); wav->numSamples = ft->signal.length - (new_offset / ft->signal.channels); } - } else { + } +#endif /* HAVE_LIBGSM */ + else { double wide_sample = offset - (offset % ft->signal.channels); double to_d = wide_sample * ft->encoding.bits_per_sample / 8; off_t to = to_d;