The Media Kit: Global Functions, Constants, and Defined Types

This section lists parts of the Media Kit that aren't contained in classes.


Global Functions


beep()

Declared in: <media/Beep.h>

      sound_handle beep(void)

beep() plays the system beep. The sound is played in a background thread and beep() returns immediately. If you want to re-synchronize with the sound playback, pass the sound_handle token (returned by this function) as the argument to wait_for_sound(). This will cause your thread to wait until the sound has finished playing.

beep() will mix other sounds, but it never waits if the immediate attempt to play is thwarted.


play_sound()

Declared in: <media/Beep.h>

      sound_handle play_sound(record_ref soundRef,
         bool willMix,
         bool willWait,
         bool background)

Plays the sound file identified by soundRef. The willMix and willWait arguments are used to determine how the function behaves with regard to other sounds:

Note that setting willMix to TRUE doesn't ensure that your sound will play immediately. If the sound playback resources are claimed for exclusive access by some other process, you'll be blocked, even if you're willing to mix.

The background argument, if TRUE, tells the function to spawn a thread in which to play the sound. The function, in this case, returns immediately. If background is FALSE , the sound is played synchronously and play_sound() won't return until the sound has finished.

The sound_handle value that's returned is a token that represents the sound playback. This token is only valid if you're playing in the background; you would use it in a subsequent call to stop_sound() or wait_for_sound(). If the ref doesn't represent a file, or if the sound couldn't be played, for whatever reason, play_sound() returns a negative integer.


stop_sound()

Declared in: <media/Beep.h>

      long stop_sound(sound_handle handle)

Stops the playback of the sound identified by handle, a value that was returned by a previous call to beep() or play_sound(). The return value can be ignored.


wait_for_sound()

Declared in: <media/Beep.h>

      long wait_for_sound(sound_handle handle)

Causes the calling thread to block until the sound identified by handle has finished playing. The handle value should have been returned by a previous call to beep() or play_sound() . Currently, wait_for_sound() always returns B_NO_ERROR.


Constants


Byte Order Constants

Declared in: <media/MediaDefs.h>

Constant Meaning
B_BIG_ENDIAN MSB first
B_LITTLE_ENDIAN LSB first

These constants are used by BAudioSubscriber and BSoundFile objects to describe the order of bytes within a sound sample.


Sound File Formats

Declared in: <media/SoundFile.h>

Constant Meaning
B_UNKNOWN_FILE The file contains "raw" data
B_AIFF_FILE AIFF format
B_WAVE_FILE WAVE format
B_UNIX_FILE Sun/NeXT/SGI etc. format

These constants represent the sound file formats that are recognized by the BSoundFile class.


Media Thread Priority

Declared in: <media/MediaDefs.h>

Constant Value
B_MEDIA_LEVEL Same as B_REAL_TIME_PRIORITY

All threads that are spawned by the Media Kit are given a priority of B_MEDIA_LEVEL; this is the same as B_REAL_TIME_PRIORITY, the highest priority defined by the Kernel Kit.


No-Change Constant

Declared in: <media/MediaDefs.h>

Constant Meaning
B_NO_CHANGE Don't change the value of this parameter

The B_NO_CHANGE constant is used in multiple-parameter-setting functions (such as BAudioSubscriber's SetSampleParameters() to indicate that you don't want a particular parameter to change its current setting (while changing the values of other parameters).


Sample Format Constants

Declared in: <media/MediaDefs.h>

Constant Meaning
B_LINEAR_SAMPLES Linear quantization
B_FLOAT_SAMPLES Floating-point samples
B_MULAW_SAMPLES Mu-law encoding
B_UNDEFINED_SAMPLES Anything else

These constants represent the sample formats that are recognized by the sound hardware.


Subscriber IDs

Declared in: <media/MediaDefs.h>

Constant Meaning
B_SHARED_SUBSCRIBER_ID Share the stream with other subscribers.
B_INVISIBLE_SUBSCRIBER_ID Subscribe to the stream regardless of the clique.
B_NO_SUBSCRIBER_ID The BSubscriber object isn't subscribed.

The first two subscriber ID constants are most commonly used as "clique" values, passed to the EnterStream() function. The final ID, B_NO_SUBSCRIBER_ID, is the default, subscriber-isn't-subscribed subscriber ID value.

The subscriber ID constants are type as subscriber_id values.


Defined Types


sound_handle

Declared in: <media/Beep.h>

      typedef sem_id sound_handle

The sound_handle type is a token that represents sounds that are currently being played through calls to beep() or play_sound().


subscriber_id

Declared in: <media/MediaDefs.h>

      typedef sem_id subscriber_id

The subscriber_id type is a token that uniquely identifies --system-wide--a BSubscriber object for a particular server.






The Be Book, HTML Edition, for Developer Release 8 of the Be Operating System.

Copyright © 1996 Be, Inc. All rights reserved.

Be, the Be logo, BeBox, BeOS, BeWare, and GeekPort are trademarks of Be, Inc.

Last modified September 6, 1996.