decode.h File Reference

Decode functions and callback prototypes. More...

Go to the source code of this file.

## Typedefs

typedef int(* | FishSoundDecoded_Float) (FishSound *fsound, float *pcm[], long frames, void *user_data)
| Signature of a callback for libfishsound to call when it has decoded PCM audio data, and you want this provided as non-interleaved floats.
typedef int(* | FishSoundDecoded_FloatIlv) (FishSound *fsound, float **pcm, long frames, void *user_data)
| Signature of a callback for libfishsound to call when it has decoded PCM audio data, and you want this provided as interleaved floats.

## Functions

int | fish_sound_set_decoded_float (FishSound *fsound, FishSoundDecoded_Float decoded, void *user_data)
| Set the callback for libfishsound to call when it has a block of decoded PCM audio ready, and you want this provided as non-interleaved floats.
int | fish_sound_set_decoded_float_ilv (FishSound *fsound, FishSoundDecoded_FloatIlv decoded, void *user_data)
| Set the callback for libfishsound to call when it has a block of decoded PCM audio ready, and you want this provided as interleaved floats.
long | fish_sound_decode (FishSound *fsound, unsigned char *buf, long bytes)
| Decode a block of compressed data.

## Detailed Description

Decode functions and callback prototypes.

## Typedef Documentation

## FishSoundDecoded_Float

typedef int(* FishSoundDecoded_Float) (FishSound *fsound, float *pcm[], long frames, void *user_data)

Signature of a callback for libfishsound to call when it has decoded PCM audio data, and you want this provided as non-interleaved floats.

Parameters

  fsound | The FishSound* handle
  pcm | The decoded audio
  frames | The count of frames decoded
  user_data | Arbitrary user data

Return values

  FISH_SOUND_CONTINUE | Continue decoding
  FISH_SOUND_STOP_OK | Stop decoding immediately and return control to the fish_sound_decode() caller
  FISH_SOUND_STOP_ERR | Stop decoding immediately, purge buffered data, and return control to the fish_sound_decode() caller

## FishSoundDecoded_FloatIlv

typedef int(* FishSoundDecoded_FloatIlv) (FishSound *fsound, float **pcm, long frames, void *user_data)

Signature of a callback for libfishsound to call when it has decoded PCM audio data, and you want this provided as interleaved floats.

Parameters

  fsound | The FishSound* handle
  pcm | The decoded audio
  frames | The count of frames decoded
  user_data | Arbitrary user data

Return values

  FISH_SOUND_CONTINUE | Continue decoding
  FISH_SOUND_STOP_OK | Stop decoding immediately and return control to the fish_sound_decode() caller
  FISH_SOUND_STOP_ERR | Stop decoding immediately, purge buffered data, and return control to the fish_sound_decode() caller

## Function Documentation

## fish_sound_decode()

long fish_sound_decode | ( | FishSound * | fsound,
|  | unsigned char * | buf,
|  | long | bytes )

Decode a block of compressed data.

No internal buffering is done, so a complete compressed audio packet must be passed each time.

Parameters

  fsound | A FishSound* handle (created with mode FISH_SOUND_DECODE)
  buf | A buffer containing a compressed audio packet
  bytes | A count of bytes to decode (i.e. the length of buf)

Returns
  The number of bytes consumed

Return values

  FISH_SOUND_ERR_STOP_OK | Decoding was stopped by a FishSoundDecode* callback returning FISH_SOUND_STOP_OK before any input bytes were consumed. This will occur when PCM is decoded from previously buffered input, and stopping is immediately requested.
  FISH_SOUND_ERR_STOP_ERR | Decoding was stopped by a FishSoundDecode* callback returning FISH_SOUND_STOP_ERR before any input bytes were consumed. This will occur when PCM is decoded from previously buffered input, and stopping is immediately requested.
  FISH_SOUND_ERR_BAD | Not a valid FishSound* handle
  FISH_SOUND_ERR_OUT_OF_MEMORY | Out of memory

## fish_sound_set_decoded_float()

int fish_sound_set_decoded_float | ( | FishSound * | fsound,
|  | FishSoundDecoded_Float | decoded,
|  | void * | user_data )

Set the callback for libfishsound to call when it has a block of decoded PCM audio ready, and you want this provided as non-interleaved floats.

Parameters

  fsound | A FishSound* handle (created with mode FISH_SOUND_DECODE)
  decoded | The callback to call
  user_data | Arbitrary user data to pass to the callback

Return values

  0 | Success
  FISH_SOUND_ERR_BAD | Not a valid FishSound* handle
  FISH_SOUND_ERR_OUT_OF_MEMORY | Out of memory

## fish_sound_set_decoded_float_ilv()

int fish_sound_set_decoded_float_ilv | ( | FishSound * | fsound,
|  | FishSoundDecoded_FloatIlv | decoded,
|  | void * | user_data )

Set the callback for libfishsound to call when it has a block of decoded PCM audio ready, and you want this provided as interleaved floats.

Parameters

  fsound | A FishSound* handle (created with mode FISH_SOUND_DECODE)
  decoded | The callback to call
  user_data | Arbitrary user data to pass to the callback

Return values

  0 | Success
  FISH_SOUND_ERR_BAD | Not a valid FishSound* handle
  FISH_SOUND_ERR_OUT_OF_MEMORY | Out of memory