layout: doc title: “Starboard Module Reference: audio_sink.h”

Provides an interface to output raw audio data.

Structs

SbAudioSink

An opaque handle to an implementation-private structure representing an audio sink.

Functions

SbAudioSinkCreate

Description

Creates an audio sink for the specified channels and sampling_frequency_hz, acquires all resources needed to operate the audio sink, and returns an opaque handle to the audio sink.
If the particular platform doesn't support the requested audio sink, the function returns kSbAudioSinkInvalid without calling any of the callbacks.

Declaration and definitions

#include "starboard/audio_sink.h"

struct SbAudioSinkPrivate {};

namespace {
struct SbAudioSinkPrivate g_singleton_stub;
}

SbAudioSink SbAudioSinkCreate(
    int channels,
    int sampling_frequency_hz,
    SbMediaAudioSampleType audio_sample_type,
    SbMediaAudioFrameStorageType audio_frame_storage_type,
    SbAudioSinkFrameBuffers frame_buffers,
    int frames_per_channel,
    SbAudioSinkUpdateSourceStatusFunc update_source_status_func,
    SbAudioSinkConsumeFramesFunc consume_frames_func,
    void* context) {
  return &g_singleton_stub;
}

Parameters

SbAudioSinkDestroy

Description

Destroys audio_sink, freeing all associated resources. Before returning, the function waits until all callbacks that are in progress have finished. After the function returns, no further calls are made callbacks passed into SbAudioSinkCreate. In addition, you can not pass audio_sink to any other SbAudioSink functions after SbAudioSinkDestroy has been called on it.
This function can be called on any thread. However, it cannot be called within any of the callbacks passed into SbAudioSinkCreate.

Declaration and definitions

#include "starboard/audio_sink.h"

void SbAudioSinkDestroy(SbAudioSink /*audio_sink*/) {}

Parameters

SbAudioSinkGetMaxChannels

Description

Returns the maximum number of channels supported on the platform. For example, the number would be 2 if the platform only supports stereo.

Declaration and definitions

#include "starboard/audio_sink.h"

int SbAudioSinkGetMaxChannels() {
  return 2;
}

SbAudioSinkGetNearestSupportedSampleFrequency

Description

Returns the supported sample rate closest to sampling_frequency_hz. On platforms that don‘t support all sample rates, it is the caller’s responsibility to resample the audio frames into the supported sample rate returned by this function.

Declaration and definitions

#include "starboard/audio_sink.h"

int SbAudioSinkGetNearestSupportedSampleFrequency(
    int sampling_frequency_hz) {
  return sampling_frequency_hz;
}

Parameters

SbAudioSinkIsAudioFrameStorageTypeSupported

Description

Indicates whether audio_frame_storage_type is supported on this platform.

Declaration and definitions

#include "starboard/audio_sink.h"

bool SbAudioSinkIsAudioFrameStorageTypeSupported(
    SbMediaAudioFrameStorageType audio_frame_storage_type) {
  return true;
}

Parameters

SbAudioSinkIsAudioSampleTypeSupported

Description

Indicates whether audio_sample_type is supported on this platform.

Declaration and definitions

#include "starboard/audio_sink.h"

bool SbAudioSinkIsAudioSampleTypeSupported(
    SbMediaAudioSampleType audio_sample_type) {
  return true;
}

Parameters

SbAudioSinkIsValid

Description

Indicates whether the given audio sink handle is valid.

Declaration and definitions

#include "starboard/audio_sink.h"

bool SbAudioSinkIsValid(SbAudioSink /*audio_sink*/) {
  return true;
}

Parameters