static int open_output(void) { int include_enc, exclude_enc; #ifdef AU_FLAC_DLL if (g_load_libFLAC_dll("libFLAC.dll")) { return -1; } #endif #ifdef AU_OGGFLAC_DLL if (g_load_libOggFLAC_dll("libOggFLAC.dll")) { #ifdef AU_FLAC_DLL g_free_libFLAC_dll (); #endif return -1; } #endif include_enc = exclude_enc = 0; /* only 16 bit is supported */ include_enc |= PE_16BIT | PE_SIGNED; exclude_enc |= PE_BYTESWAP | PE_24BIT; dpm.encoding = validate_encoding(dpm.encoding, include_enc, exclude_enc); #ifdef AU_OGGFLAC if (flac_options.isogg) { ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "*** cannot write back seekpoints when encoding to Ogg yet ***"); ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "*** and stream end will not be written. ***"); } #endif #ifndef __W32G__ if(dpm.name == NULL) { dpm.flag |= PF_AUTO_SPLIT_FILE; } else { dpm.flag &= ~PF_AUTO_SPLIT_FILE; if(flac_output_open(dpm.name, NULL) == -1) return -1; } #else if(w32g_auto_output_mode > 0) { dpm.flag |= PF_AUTO_SPLIT_FILE; dpm.name = NULL; } else { dpm.flag &= ~PF_AUTO_SPLIT_FILE; if (flac_output_open(dpm.name, NULL) == -1) return -1; } #endif return 0; }
static void close_output(void) { FLAC_ctx *ctx; ctx = flac_ctx; if (ctx == NULL) return; if (dpm.fd < 0) { flac_session_close(); return; } if (flac_options.isogg) { if ((ctx->state.ogg = FLAC__stream_encoder_get_state(ctx->encoder.ogg.stream)) != FLAC__STREAM_ENCODER_OK) { ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "OggFLAC stream encoder is invalid (%s)", FLAC__StreamEncoderStateString[ctx->state.ogg]); /* fall through */ } } else if (flac_options.seekable) { if ((ctx->state.s_flac = FLAC__stream_encoder_get_state(ctx->encoder.flac.s_stream)) != FLAC__STREAM_ENCODER_OK) { ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "FLAC stream encoder is invalid (%s)", FLAC__StreamEncoderStateString[ctx->state.s_flac]); /* fall through */ } } else { if ((ctx->state.flac = FLAC__stream_encoder_get_state(ctx->encoder.flac.stream)) != FLAC__STREAM_ENCODER_OK) { ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "FLAC stream encoder is invalid (%s)", FLAC__StreamEncoderStateString[ctx->state.flac]); /* fall through */ } } ctl->cmsg(CMSG_INFO, VERB_NORMAL, "Wrote %lu/%lu bytes(%g%% compressed)", ctx->out_bytes, ctx->in_bytes, ((double)ctx->out_bytes / (double)ctx->in_bytes) * 100.); flac_session_close(); #ifdef AU_FLAC_DLL g_free_libFLAC_dll (); #endif #ifdef AU_OGGFLAC_DLL g_free_libOggFLAC_dll (); #endif }