2 * OpenSound media addon for BeOS and Haiku
4 * Copyright (c) 2007, François Revol (revol@free.fr)
5 * Distributed under the terms of the MIT License.
8 #include "OpenSoundDeviceEngine.h"
11 #include "driver_io.h"
12 #include <MediaDefs.h>
17 #include "SupportFunctions.h"
19 OpenSoundDeviceEngine::~OpenSoundDeviceEngine()
27 OpenSoundDeviceEngine::OpenSoundDeviceEngine(oss_audioinfo
*info
)
33 , fDriverBufferSize(0)
36 fInitCheckStatus
= B_NO_INIT
;
37 memcpy(&fAudioInfo
, info
, sizeof(oss_audioinfo
));
42 SetFormat(OpenSoundDevice::select_oss_format(info->oformats));
43 SetChannels(info->max_channels);
44 SetSpeed(info->max_rate);
46 fInitCheckStatus
= B_OK
;
50 status_t
OpenSoundDeviceEngine::InitCheck(void) const
53 return fInitCheckStatus
;
57 status_t
OpenSoundDeviceEngine::Open(int mode
)
64 if (!(Caps() & DSP_CAP_INPUT
))
69 if (!(Caps() & DSP_CAP_OUTPUT
))
74 if (!(Caps() & DSP_CAP_OUTPUT
) || !(Caps() & DSP_CAP_INPUT
))
81 // O_EXCL = bypass soft mixer = direct access
86 fFD
= open(fAudioInfo
.devnode
, omode
);
88 fInitCheckStatus
= errno
;
91 // disable format convertions
93 if (ioctl(fFD
, SNDCTL_DSP_COOKEDMODE
, &v
, sizeof(int)) < 0) {
94 fInitCheckStatus
= errno
;
99 // set driver buffer size by using the "fragments" API
100 // TODO: export this setting as a BParameter?
101 uint32 bufferCount
= 4;
102 uint32 bufferSize
= 0x000b; // 1024 bytes
103 v
= (bufferCount
<< 16) | bufferSize
;
104 if (ioctl(fFD
, SNDCTL_DSP_SETFRAGMENT
, &v
, sizeof(int)) < 0) {
105 fInitCheckStatus
= errno
;
110 fDriverBufferSize
= 2048;
111 // preliminary, adjusted in AcceptFormat()
116 status_t
OpenSoundDeviceEngine::Close(void)
123 fMediaFormat
= media_format();
128 ssize_t
OpenSoundDeviceEngine::Read(void *buffer
, size_t size
)
132 done
= read(fFD
, buffer
, size
);
140 OpenSoundDeviceEngine::Write(const void *buffer
, size_t size
)
146 ssize_t done
= write(fFD
, buffer
, size
);
155 OpenSoundDeviceEngine::UpdateInfo()
162 if (ioctl(fFD
, SNDCTL_ENGINEINFO
, &fAudioInfo
, sizeof(oss_audioinfo
)) < 0)
170 OpenSoundDeviceEngine::PlaybackLatency()
172 bigtime_t latency
= time_for_buffer(fDriverBufferSize
, fMediaFormat
);
173 bigtime_t cardLatency
= CardLatency();
174 if (cardLatency
== 0) {
175 // that's unrealistic, take matters into own hands
176 cardLatency
= latency
/ 3;
178 latency
+= cardLatency
;
179 // PRINT(("PlaybackLatency: odelay %d latency %Ld card %Ld\n",
180 // fDriverBufferSize, latency, CardLatency()));
186 OpenSoundDeviceEngine::RecordingLatency()
192 int OpenSoundDeviceEngine::GetChannels(void)
196 if (ioctl(fFD
, SNDCTL_DSP_CHANNELS
, &chans
, sizeof(int)) < 0) {
197 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
198 __FUNCTION__
, "SNDCTL_DSP_CHANNELS", strerror(errno
)));
204 status_t
OpenSoundDeviceEngine::SetChannels(int chans
)
207 if (ioctl(fFD
, SNDCTL_DSP_CHANNELS
, &chans
, sizeof(int)) < 0) {
208 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
209 __FUNCTION__
, "SNDCTL_DSP_CHANNELS", strerror(errno
)));
212 PRINT(("OpenSoundDeviceEngine::%s: %d\n", __FUNCTION__
, chans
));
216 //XXX: either GetFormat*s*() or cache SetFormat()!
217 int OpenSoundDeviceEngine::GetFormat(void)
221 if (ioctl(fFD
, SNDCTL_DSP_GETFMTS
, &fmt
, sizeof(int)) < 0) {
222 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
223 __FUNCTION__
, "SNDCTL_DSP_GETFMTS", strerror(errno
)));
229 status_t
OpenSoundDeviceEngine::SetFormat(int fmt
)
232 if (ioctl(fFD
, SNDCTL_DSP_SETFMT
, &fmt
, sizeof(int)) < 0) {
233 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
234 __FUNCTION__
, "SNDCTL_DSP_SETFMT", strerror(errno
)));
237 PRINT(("OpenSoundDeviceEngine::%s: 0x%08x\n", __FUNCTION__
, fmt
));
241 int OpenSoundDeviceEngine::GetSpeed(void)
245 if (ioctl(fFD
, SNDCTL_DSP_SPEED
, &speed
, sizeof(int)) < 0) {
246 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
247 __FUNCTION__
, "SNDCTL_DSP_SPEED", strerror(errno
)));
253 status_t
OpenSoundDeviceEngine::SetSpeed(int speed
)
256 if (ioctl(fFD
, SNDCTL_DSP_SPEED
, &speed
, sizeof(int)) < 0) {
257 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
258 __FUNCTION__
, "SNDCTL_DSP_SPEED", strerror(errno
)));
261 PRINT(("OpenSoundDeviceEngine::%s: %d\n", __FUNCTION__
, speed
));
266 size_t OpenSoundDeviceEngine::GetISpace(audio_buf_info
*info
)
268 audio_buf_info abinfo
;
272 memset(info
, 0, sizeof(audio_buf_info
));
273 if (!(fOpenMode
& OPEN_READ
))
275 if (ioctl(fFD
, SNDCTL_DSP_GETISPACE
, info
, sizeof(audio_buf_info
)) < 0) {
276 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
277 __FUNCTION__
, "SNDCTL_DSP_GETISPACE", strerror(errno
)));
280 //PRINT(("OpenSoundDeviceEngine::%s: ISPACE: { bytes=%d, fragments=%d, fragsize=%d, fragstotal=%d }\n", __FUNCTION__, info->bytes, info->fragments, info->fragsize, info->fragstotal));
285 size_t OpenSoundDeviceEngine::GetOSpace(audio_buf_info
*info
)
287 audio_buf_info abinfo
;
291 memset(info
, 0, sizeof(audio_buf_info
));
292 if (!(fOpenMode
& OPEN_WRITE
))
294 if (ioctl(fFD
, SNDCTL_DSP_GETOSPACE
, info
, sizeof(audio_buf_info
)) < 0) {
295 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
296 __FUNCTION__
, "SNDCTL_DSP_GETOSPACE", strerror(errno
)));
299 //PRINT(("OpenSoundDeviceEngine::%s: OSPACE: { bytes=%d, fragments=%d, fragsize=%d, fragstotal=%d }\n", __FUNCTION__, info->bytes, info->fragments, info->fragsize, info->fragstotal));
305 OpenSoundDeviceEngine::GetCurrentIPtr(int32
*fifoed
, oss_count_t
*info
)
312 memset(info
, 0, sizeof(oss_count_t
));
313 if (!(fOpenMode
& OPEN_READ
))
315 if (ioctl(fFD
, SNDCTL_DSP_CURRENT_IPTR
, info
, sizeof(oss_count_t
)) < 0) {
316 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
317 __FUNCTION__
, "SNDCTL_DSP_CURRENT_IPTR", strerror(errno
)));
319 // fallback: try GET*PTR
320 if (ioctl(fFD
, SNDCTL_DSP_GETIPTR
, &cinfo
, sizeof(count_info
)) < 0) {
321 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
322 __FUNCTION__
, "SNDCTL_DSP_GETIPTR", strerror(errno
)));
325 // it's probably wrong...
326 info
->samples
= cinfo
.bytes
/ (fMediaFormat
.u
.raw_audio
.channel_count
327 * (fMediaFormat
.AudioFormat() & media_raw_audio_format::B_AUDIO_SIZE_MASK
));
328 info
->fifo_samples
= 0;
330 PRINT(("OpenSoundDeviceEngine::%s: IPTR: { samples=%Ld, fifo_samples=%d }\n", __FUNCTION__
, info
->samples
, info
->fifo_samples
));
332 *fifoed
= info
->fifo_samples
;
333 return info
->samples
;
338 OpenSoundDeviceEngine::GetCurrentOPtr(int32
* fifoed
, size_t* fragmentPos
)
342 if (!(fOpenMode
& OPEN_WRITE
)) {
349 memset(&info
, 0, sizeof(oss_count_t
));
351 if (ioctl(fFD
, SNDCTL_DSP_CURRENT_OPTR
, &info
, sizeof(oss_count_t
)) < 0) {
352 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
353 __FUNCTION__
, "SNDCTL_DSP_CURRENT_OPTR", strerror(errno
)));
358 if (fragmentPos
!= NULL
) {
360 if (ioctl(fFD
, SNDCTL_DSP_GETOPTR
, &cinfo
, sizeof(count_info
)) < 0) {
361 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
362 __FUNCTION__
, "SNDCTL_DSP_GETOPTR", strerror(errno
)));
365 *fragmentPos
= cinfo
.ptr
;
368 // PRINT(("OpenSoundDeviceEngine::%s: OPTR: { samples=%Ld, "
369 // "fifo_samples=%d }\n", __FUNCTION__, info->samples,
370 // info->fifo_samples));
372 *fifoed
= info
.fifo_samples
;
378 OpenSoundDeviceEngine::GetIOverruns()
382 memset(&info
, 0, sizeof(info
));
383 if (!(fOpenMode
& OPEN_WRITE
))
385 if (ioctl(fFD
, SNDCTL_DSP_GETERROR
, &info
, sizeof(info
)) < 0) {
386 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
387 __FUNCTION__
, "SNDCTL_DSP_GETERROR", strerror(errno
)));
390 PRINT(("OpenSoundDeviceEngine::%s: IOVERRUNS: { overruns=%d }\n", __FUNCTION__
, info
.rec_overruns
));
391 return info
.rec_overruns
;
396 OpenSoundDeviceEngine::GetOUnderruns()
400 memset(&info
, 0, sizeof(info
));
401 if (!(fOpenMode
& OPEN_WRITE
))
403 if (ioctl(fFD
, SNDCTL_DSP_GETERROR
, &info
, sizeof(info
)) < 0) {
404 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
405 __FUNCTION__
, "SNDCTL_DSP_GETERROR", strerror(errno
)));
408 //PRINT(("OpenSoundDeviceEngine::%s: OUNDERRUNS: { underruns=%d }\n", __FUNCTION__, info.play_underruns));
409 return info
.play_underruns
;
414 OpenSoundDeviceEngine::DriverBufferSize() const
416 return fDriverBufferSize
;
420 status_t
OpenSoundDeviceEngine::StartRecording(void)
425 group
.mode
= PCM_ENABLE_INPUT
;
426 if (ioctl(fFD
, SNDCTL_DSP_SYNCGROUP
, &group
, sizeof(group
)) < 0) {
427 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
428 __FUNCTION__
, "SNDCTL_DSP_SYNCGROUP", strerror(errno
)));
431 if (ioctl(fFD
, SNDCTL_DSP_SYNCSTART
, &group
.id
, sizeof(group
.id
)) < 0) {
432 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
433 __FUNCTION__
, "SNDCTL_DSP_SYNCSTART", strerror(errno
)));
441 OpenSoundDeviceEngine::WildcardFormatFor(int fmt
, media_format
&format
,
446 fmt
&= rec
? Info()->iformats
: Info()->oformats
;
448 return B_MEDIA_BAD_FORMAT
;
449 err
= OpenSoundDevice::get_media_format_for(fmt
, format
);
453 string_for_format(format
, buf
, 1024);
454 if (format
.type
== B_MEDIA_RAW_AUDIO
) {
455 format
.u
.raw_audio
= media_multi_audio_format::wildcard
;
456 format
.u
.raw_audio
.byte_order
= B_MEDIA_HOST_ENDIAN
;
457 // single rate supported
458 if (Info()->min_rate
== Info()->max_rate
)
459 format
.u
.raw_audio
.frame_rate
= OpenSoundDevice::convert_oss_rate_to_media_rate(Info()->max_rate
); // measured in Hertz
460 } else if (format
.type
== B_MEDIA_ENCODED_AUDIO
) {
461 format
.u
.encoded_audio
.output
= media_multi_audio_format::wildcard
;
462 //format.u.encoded_audio.output.byte_order = B_MEDIA_HOST_ENDIAN;
463 // single rate supported
464 //if (Info()->min_rate == Info()->max_rate)
465 // format.u.encoded_audio.output.frame_rate = OpenSoundDevice::convert_oss_rate_to_media_rate(Info()->max_rate); // measured in Hertz
468 PRINT(("%s: %s\n", __FUNCTION__
, buf
));
473 status_t
OpenSoundDeviceEngine::PreferredFormatFor(int fmt
, media_format
&format
, bool rec
)
477 fmt
&= rec
? Info()->iformats
: Info()->oformats
;
479 return B_MEDIA_BAD_FORMAT
;
480 err
= WildcardFormatFor(fmt
, format
);
483 if (format
.type
== B_MEDIA_RAW_AUDIO
) {
484 media_multi_audio_format
&raw
= format
.u
.raw_audio
;
485 //format.u.raw_audio.channel_count = Info()->max_channels;
486 raw
.byte_order
= B_MEDIA_HOST_ENDIAN
;
487 raw
.frame_rate
= OpenSoundDevice::convert_oss_rate_to_media_rate(Info()->max_rate
); // measured in Hertz
488 raw
.buffer_size
= DEFAULT_BUFFER_SIZE
;
490 raw.buffer_size = 2048;*/
492 format.u.raw_audio.byte_order = B_MEDIA_HOST_ENDIAN;
493 format.u.raw_audio.frame_rate = OpenSoundDevice::convert_oss_rate_to_media_rate(Info()->max_rate); // measured in Hertz
494 format.u.raw_audio.buffer_size = DEFAULT_BUFFER_SIZE;
496 } else if (format
.type
== B_MEDIA_ENCODED_AUDIO
) {
497 media_raw_audio_format
&raw
= format
.u
.encoded_audio
.output
;
498 //format.u.encoded_audio.output.channel_count = Info()->max_channels;
499 raw
.byte_order
= B_MEDIA_HOST_ENDIAN
;
500 // single rate supported
501 if (Info()->min_rate
== Info()->max_rate
)
502 raw
.frame_rate
= OpenSoundDevice::convert_oss_rate_to_media_rate(Info()->max_rate
); // measured in Hertz
503 raw
.buffer_size
= DEFAULT_BUFFER_SIZE
;
507 string_for_format(format
, buf
, 1024);
508 PRINT(("%s: %s\n", __FUNCTION__
, buf
));
513 status_t
OpenSoundDeviceEngine::AcceptFormatFor(int fmt
, media_format
&format
, bool rec
)
519 fmt
&= rec
? Info()->iformats
: Info()->oformats
;
522 return B_MEDIA_BAD_FORMAT
;
524 err
= WildcardFormatFor(fmt
, wc
);
528 err
= Open(rec
? OPEN_READ
: OPEN_WRITE
);
532 if (format
.type
== B_MEDIA_RAW_AUDIO
) {
533 media_multi_audio_format
&raw
= format
.u
.raw_audio
;
536 raw
.channel_count
= MAX((unsigned)(Info()->min_channels
), MIN((unsigned)(Info()->max_channels
), raw
.channel_count
));
537 err
= SetChannels(raw
.channel_count
);
543 PRINT(("%s:step1 fmt=0x%08x, raw.format=0x%08" B_PRIx32
"\n",
544 __FUNCTION__
, fmt
, raw
.format
));
545 // if specified, try it
547 afmt
= OpenSoundDevice::convert_media_format_to_oss_format(raw
.format
);
549 PRINT(("%s:step2 afmt=0x%08x\n", __FUNCTION__
, afmt
));
550 // select the best as default
552 afmt
= OpenSoundDevice::select_oss_format(fmt
);
553 raw
.format
= OpenSoundDevice::convert_oss_format_to_media_format(afmt
);
555 //return B_MEDIA_BAD_FORMAT;
557 PRINT(("%s:step3 afmt=0x%08x\n", __FUNCTION__
, afmt
));
559 raw
.format
= OpenSoundDevice::convert_oss_format_to_media_format(afmt
);
560 PRINT(("%s:step4 afmt=0x%08x, raw.format=0x%08" B_PRIx32
"\n",
561 __FUNCTION__
, afmt
, raw
.format
));
562 raw
.valid_bits
= OpenSoundDevice::convert_oss_format_to_valid_bits(afmt
);
564 err
= SetFormat(afmt
);
571 raw
.byte_order
= OpenSoundDevice::convert_oss_format_to_endian(afmt
);
574 raw
.frame_rate
= OpenSoundDevice::select_oss_rate(Info(), raw
.frame_rate
); // measured in Hertz
575 //raw.frame_rate = OpenSoundDevice::convert_oss_rate_to_media_rate(Info()->max_rate); // measured in Hertz
576 err
= SetSpeed(OpenSoundDevice::convert_media_rate_to_oss_rate(raw
.frame_rate
));
582 // retrieve the driver buffer size (it's important to do this
583 // after all the other setup, since OSS may have adjusted it, and
584 // also weird things happen if this ioctl() is done before other
586 audio_buf_info abinfo
;
587 memset(&abinfo
, 0, sizeof(audio_buf_info
));
588 if (ioctl(fFD
, SNDCTL_DSP_GETOSPACE
, &abinfo
, sizeof(audio_buf_info
)) < 0) {
589 fprintf(stderr
, "failed to retrieve driver buffer size!\n");
592 fDriverBufferSize
= abinfo
.bytes
;
594 raw
.buffer_size
= fDriverBufferSize
;
596 } else if (format
.type
== B_MEDIA_ENCODED_AUDIO
) {
597 media_raw_audio_format
&raw
= format
.u
.encoded_audio
.output
;
598 // XXX: do we really have to do this ?
599 raw
.channel_count
= MAX((unsigned)(Info()->min_channels
), MIN((unsigned)(Info()->max_channels
), raw
.channel_count
));
600 raw
.byte_order
= B_MEDIA_HOST_ENDIAN
;
601 raw
.frame_rate
= OpenSoundDevice::select_oss_rate(Info(), raw
.frame_rate
); // measured in Hertz
602 //raw.frame_rate = OpenSoundDevice::convert_oss_rate_to_media_rate(Info()->max_rate); // measured in Hertz
603 raw
.buffer_size
= DEFAULT_BUFFER_SIZE
;
606 PRINT(("%s: unknown media type\n", __FUNCTION__
));
611 fMediaFormat
= format
;
613 string_for_format(format
, buf
, 1024);
614 PRINT(("%s: %s\n", __FUNCTION__
, buf
));
619 status_t
OpenSoundDeviceEngine::SpecializeFormatFor(int fmt
, media_format
&format
, bool rec
)
624 fmt
&= rec
? Info()->iformats
: Info()->oformats
;
626 return B_MEDIA_BAD_FORMAT
;
628 err
= WildcardFormatFor(fmt
, wc
);
632 err
= Open(rec
? OPEN_READ
: OPEN_WRITE
);
636 if (format
.type
== B_MEDIA_RAW_AUDIO
) {
637 media_multi_audio_format
&raw
= format
.u
.raw_audio
;
639 PRINT(("%s:step1 fmt=0x%08x, raw.format=0x%08" B_PRIx32
"\n",
640 __FUNCTION__
, fmt
, raw
.format
));
641 // select the best as default
643 afmt
= OpenSoundDevice::select_oss_format(fmt
);
644 raw
.format
= OpenSoundDevice::convert_oss_format_to_media_format(afmt
);
646 // if specified, try it
648 afmt
= OpenSoundDevice::convert_media_format_to_oss_format(raw
.format
);
650 PRINT(("%s:step2 afmt=0x%08x\n", __FUNCTION__
, afmt
));
653 return B_MEDIA_BAD_FORMAT
;
656 raw
.format
= OpenSoundDevice::convert_oss_format_to_media_format(afmt
);
657 PRINT(("%s:step4 afmt=0x%08x, raw.format=0x%08" B_PRIx32
"\n",
658 __FUNCTION__
, afmt
, raw
.format
));
660 raw
.valid_bits
= OpenSoundDevice::convert_oss_format_to_valid_bits(afmt
);
661 if (raw
.valid_bits
!= OpenSoundDevice::convert_oss_format_to_valid_bits(afmt
)) {
663 return B_MEDIA_BAD_FORMAT
;
666 err
= SetFormat(afmt
);
674 raw
.byte_order
= OpenSoundDevice::convert_oss_format_to_endian(afmt
);
675 if ((int)raw
.byte_order
!= OpenSoundDevice::convert_oss_format_to_endian(afmt
)) {
677 return B_MEDIA_BAD_FORMAT
;
681 if (raw
.channel_count
== 0)
682 raw
.channel_count
= (unsigned)Info()->min_channels
;
683 if ((int)raw
.channel_count
< Info()->min_channels
684 || (int)raw
.channel_count
> Info()->max_channels
)
685 return B_MEDIA_BAD_FORMAT
;
686 err
= SetChannels(raw
.channel_count
);
694 raw
.frame_rate
= Info()->max_rate
;
695 //raw.frame_rate = OpenSoundDevice::convert_oss_rate_to_media_rate(Info()->max_rate); // measured in Hertz
696 err
= SetSpeed(OpenSoundDevice::convert_media_rate_to_oss_rate(raw
.frame_rate
));
703 raw
.buffer_size
= DEFAULT_BUFFER_SIZE
704 * (raw
.format
& media_raw_audio_format::B_AUDIO_SIZE_MASK
)
707 audio_buf_info abinfo
;
708 if (ioctl(fFD
, rec
?SNDCTL_DSP_GETISPACE
:SNDCTL_DSP_GETOSPACE
, &abinfo
, sizeof(abinfo
)) < 0) {
709 PRINT(("OpenSoundDeviceEngine::%s: %s: %s\n",
710 __FUNCTION__
, "SNDCTL_DSP_GET?SPACE", strerror(errno
)));
713 PRINT(("OSS: %cSPACE: { bytes=%d, fragments=%d, fragsize=%d, fragstotal=%d }\n", rec
?'I':'O', abinfo
.bytes
, abinfo
.fragments
, abinfo
.fragsize
, abinfo
.fragstotal
));
714 // cache the first one in the Device
715 // so StartThread() knows the number of frags
716 //if (!fFragments.fragstotal)
717 // memcpy(&fFragments, &abinfo, sizeof(abinfo));
719 // make sure buffer size is less than the driver's own buffer ( /2 to keep some margin )
720 if (/*rec && raw.buffer_size &&*/ (int)raw
.buffer_size
> abinfo
.fragsize
* abinfo
.fragstotal
/ 4)
721 return B_MEDIA_BAD_FORMAT
;
722 if (!raw
.buffer_size
)
723 raw
.buffer_size
= abinfo
.fragsize
;//XXX
724 /* * (raw.format & media_raw_audio_format::B_AUDIO_SIZE_MASK)
725 * raw.channel_count;*/
726 } else if (format
.type
== B_MEDIA_ENCODED_AUDIO
) {
727 media_raw_audio_format
&raw
= format
.u
.encoded_audio
.output
;
728 // XXX: do we really have to do this ?
729 raw
.channel_count
= MAX((unsigned)(Info()->min_channels
), MIN((unsigned)(Info()->max_channels
), raw
.channel_count
));
730 raw
.byte_order
= B_MEDIA_HOST_ENDIAN
;
731 raw
.frame_rate
= OpenSoundDevice::select_oss_rate(Info(), raw
.frame_rate
); // measured in Hertz
732 //raw.frame_rate = OpenSoundDevice::convert_oss_rate_to_media_rate(Info()->max_rate); // measured in Hertz
733 raw
.buffer_size
= DEFAULT_BUFFER_SIZE
;
740 fMediaFormat
= format
;
742 string_for_format(format
, buf
, 1024);
743 PRINT(("%s: %s\n", __FUNCTION__
, buf
));