| 50 | #include "alsa.h" |
| 51 | |
| 52 | static av_cold int audio_write_header(AVFormatContext *s1) |
| 53 | { |
| 54 | AlsaData *s = s1->priv_data; |
| 55 | AVStream *st = NULL; |
| 56 | unsigned int sample_rate; |
| 57 | enum AVCodecID codec_id; |
| 58 | int res; |
| 59 | |
| 60 | if (s1->nb_streams != 1 || s1->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) { |
| 61 | av_log(s1, AV_LOG_ERROR, "Only a single audio stream is supported.\n"); |
| 62 | return AVERROR(EINVAL); |
| 63 | } |
| 64 | st = s1->streams[0]; |
| 65 | |
| 66 | sample_rate = st->codecpar->sample_rate; |
| 67 | codec_id = st->codecpar->codec_id; |
| 68 | res = ff_alsa_open(s1, SND_PCM_STREAM_PLAYBACK, &sample_rate, |
| 69 | &st->codecpar->ch_layout, &codec_id); |
| 70 | if (sample_rate != st->codecpar->sample_rate) { |
| 71 | av_log(s1, AV_LOG_ERROR, |
| 72 | "sample rate %d not available, nearest is %d\n", |
| 73 | st->codecpar->sample_rate, sample_rate); |
| 74 | goto fail; |
| 75 | } |
| 76 | avpriv_set_pts_info(st, 64, 1, sample_rate); |
| 77 | |
| 78 | return res; |
| 79 | |
| 80 | fail: |
| 81 | snd_pcm_close(s->h); |
| 82 | return AVERROR(EIO); |
| 83 | } |
| 84 | |
| 85 | static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt) |
| 86 | { |
nothing calls this directly
no test coverage detected