Commit c2c7ad1d authored by Stefan Westerfeld's avatar Stefan Westerfeld

HLSOutputStream: more error handling

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 5100e1af
...@@ -156,10 +156,7 @@ HLSOutputStream::open_audio (AVCodec *codec, AVDictionary *opt_arg) ...@@ -156,10 +156,7 @@ HLSOutputStream::open_audio (AVCodec *codec, AVDictionary *opt_arg)
ret = avcodec_open2 (m_enc, codec, &opt); ret = avcodec_open2 (m_enc, codec, &opt);
av_dict_free (&opt); av_dict_free (&opt);
if (ret < 0) if (ret < 0)
{ return Error (string_printf ("could not open audio codec: %s", av_err2str (ret)));
fprintf(stderr, "Could not open audio codec: %s\n", av_err2str(ret));
exit(1);
}
if (m_enc->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) if (m_enc->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)
nb_samples = 10000; nb_samples = 10000;
...@@ -178,18 +175,12 @@ HLSOutputStream::open_audio (AVCodec *codec, AVDictionary *opt_arg) ...@@ -178,18 +175,12 @@ HLSOutputStream::open_audio (AVCodec *codec, AVDictionary *opt_arg)
/* copy the stream parameters to the muxer */ /* copy the stream parameters to the muxer */
ret = avcodec_parameters_from_context (m_st->codecpar, m_enc); ret = avcodec_parameters_from_context (m_st->codecpar, m_enc);
if (ret < 0) if (ret < 0)
{ return Error ("could not copy the stream parameters");
fprintf(stderr, "Could not copy the stream parameters\n");
exit(1);
}
/* create resampler context */ /* create resampler context */
m_swr_ctx = swr_alloc(); m_swr_ctx = swr_alloc();
if (!m_swr_ctx) if (!m_swr_ctx)
{ return Error ("could not allocate resampler context");
fprintf(stderr, "Could not allocate resampler context\n");
exit(1);
}
/* set options */ /* set options */
av_opt_set_int (m_swr_ctx, "in_channel_count", m_enc->channels, 0); av_opt_set_int (m_swr_ctx, "in_channel_count", m_enc->channels, 0);
...@@ -201,10 +192,8 @@ HLSOutputStream::open_audio (AVCodec *codec, AVDictionary *opt_arg) ...@@ -201,10 +192,8 @@ HLSOutputStream::open_audio (AVCodec *codec, AVDictionary *opt_arg)
/* initialize the resampling context */ /* initialize the resampling context */
if ((ret = swr_init(m_swr_ctx)) < 0) if ((ret = swr_init(m_swr_ctx)) < 0)
{ return Error ("failed to initialize the resampling context");
fprintf(stderr, "Failed to initialize the resampling context\n");
exit(1);
}
return Error::Code::NONE; return Error::Code::NONE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment