@@ -127,7 +127,8 @@ switch(format) {\
127
127
case FORMAT_F32: s->reorder_func = alsa_reorder_f32_out_ ##layout; break;\
128
128
}
129
129
130
- static av_cold int find_reorder_func (AlsaData * s , int codec_id , AVChannelLayout * layout , int out )
130
+ static av_cold int find_reorder_func (AlsaData * s , int codec_id ,
131
+ const AVChannelLayout * layout , int out )
131
132
{
132
133
int format ;
133
134
@@ -172,10 +173,9 @@ static av_cold int find_reorder_func(AlsaData *s, int codec_id, AVChannelLayout
172
173
173
174
av_cold int ff_alsa_open (AVFormatContext * ctx , snd_pcm_stream_t mode ,
174
175
unsigned int * sample_rate ,
175
- int channels , enum AVCodecID * codec_id )
176
+ const AVChannelLayout * layout , enum AVCodecID * codec_id )
176
177
{
177
178
AlsaData * s = ctx -> priv_data ;
178
- AVChannelLayout * layout = & ctx -> streams [0 ]-> codecpar -> ch_layout ;
179
179
const char * audio_device ;
180
180
int res , flags = 0 ;
181
181
snd_pcm_format_t format ;
@@ -193,7 +193,7 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
193
193
av_log (ctx , AV_LOG_ERROR , "sample format 0x%04x is not supported\n" , * codec_id );
194
194
return AVERROR (ENOSYS );
195
195
}
196
- s -> frame_size = av_get_bits_per_sample (* codec_id ) / 8 * channels ;
196
+ s -> frame_size = av_get_bits_per_sample (* codec_id ) / 8 * layout -> nb_channels ;
197
197
198
198
if (ctx -> flags & AVFMT_FLAG_NONBLOCK ) {
199
199
flags = SND_PCM_NONBLOCK ;
@@ -240,10 +240,10 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
240
240
goto fail ;
241
241
}
242
242
243
- res = snd_pcm_hw_params_set_channels (h , hw_params , channels );
243
+ res = snd_pcm_hw_params_set_channels (h , hw_params , layout -> nb_channels );
244
244
if (res < 0 ) {
245
245
av_log (ctx , AV_LOG_ERROR , "cannot set channel count to %d (%s)\n" ,
246
- channels , snd_strerror (res ));
246
+ layout -> nb_channels , snd_strerror (res ));
247
247
goto fail ;
248
248
}
249
249
@@ -277,7 +277,7 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
277
277
278
278
snd_pcm_hw_params_free (hw_params );
279
279
280
- if (channels > 2 && layout -> order != AV_CHANNEL_ORDER_UNSPEC ) {
280
+ if (layout -> nb_channels > 2 && layout -> order != AV_CHANNEL_ORDER_UNSPEC ) {
281
281
if (find_reorder_func (s , * codec_id , layout , mode == SND_PCM_STREAM_PLAYBACK ) < 0 ) {
282
282
char name [128 ];
283
283
av_channel_layout_describe (layout , name , sizeof (name ));
0 commit comments