comparison beosaudio.cpp @ 97:265d01c2248f libavformat

the media node now won't connect itself to the default audio input with -ad wait: (allows redirecting another node to it)
author mmu_man
date Thu, 27 Mar 2003 15:08:16 +0000
parents 2d3083edb99f
children c1c8a0777bdb
comparison
equal deleted inserted replaced
96:2d3083edb99f 97:265d01c2248f
179 bufferSize -= len; 179 bufferSize -= len;
180 } 180 }
181 } 181 }
182 #endif 182 #endif
183 183
184 static int audio_open(AudioData *s, int is_output) 184 static int audio_open(AudioData *s, int is_output, const char *audio_device)
185 { 185 {
186 int p[2]; 186 int p[2];
187 int ret; 187 int ret;
188 media_raw_audio_format format; 188 media_raw_audio_format format;
189 media_multi_audio_format iformat; 189 media_multi_audio_format iformat;
208 s->frame_size = AUDIO_BLOCK_SIZE; 208 s->frame_size = AUDIO_BLOCK_SIZE;
209 /* bump up the priority (avoid realtime though) */ 209 /* bump up the priority (avoid realtime though) */
210 set_thread_priority(find_thread(NULL), B_DISPLAY_PRIORITY+1); 210 set_thread_priority(find_thread(NULL), B_DISPLAY_PRIORITY+1);
211 #ifdef HAVE_BSOUNDRECORDER 211 #ifdef HAVE_BSOUNDRECORDER
212 if (!is_output) { 212 if (!is_output) {
213 s->recorder = new BSoundRecorder(&iformat, false, "ffmpeg input", audiorecord_callback); 213 bool wait_for_input = false;
214 if (audio_device && !strcmp(audio_device, "wait:"))
215 wait_for_input = true;
216 s->recorder = new BSoundRecorder(&iformat, wait_for_input, "ffmpeg input", audiorecord_callback);
217 if (wait_for_input && (s->recorder->InitCheck() == B_OK)) {
218 s->recorder->WaitForIncomingConnection(&iformat);
219 }
214 if (s->recorder->InitCheck() != B_OK || iformat.format != media_raw_audio_format::B_AUDIO_SHORT) { 220 if (s->recorder->InitCheck() != B_OK || iformat.format != media_raw_audio_format::B_AUDIO_SHORT) {
215 delete s->recorder; 221 delete s->recorder;
216 s->recorder = NULL; 222 s->recorder = NULL;
217 if (s->input_sem) 223 if (s->input_sem)
218 delete_sem(s->input_sem); 224 delete_sem(s->input_sem);
281 int ret; 287 int ret;
282 288
283 st = s1->streams[0]; 289 st = s1->streams[0];
284 s->sample_rate = st->codec.sample_rate; 290 s->sample_rate = st->codec.sample_rate;
285 s->channels = st->codec.channels; 291 s->channels = st->codec.channels;
286 ret = audio_open(s, 1); 292 ret = audio_open(s, 1, NULL);
287 if (ret < 0) 293 if (ret < 0)
288 return -EIO; 294 return -EIO;
289 return 0; 295 return 0;
290 } 296 }
291 297
343 return -ENOMEM; 349 return -ENOMEM;
344 } 350 }
345 s->sample_rate = ap->sample_rate; 351 s->sample_rate = ap->sample_rate;
346 s->channels = ap->channels; 352 s->channels = ap->channels;
347 353
348 ret = audio_open(s, 0); 354 ret = audio_open(s, 0, ap->device);
349 if (ret < 0) { 355 if (ret < 0) {
350 av_free(st); 356 av_free(st);
351 return -EIO; 357 return -EIO;
352 } 358 }
353 /* take real parameters */ 359 /* take real parameters */