---
name: "roar_str2codec"
section: "3"
platform: "linux"
package: "libroar-dev"
version: "1.0~beta12-4"
release: "Debian 11 (Bullseye)"
platforms: ["linux"]
url: "https://new.carta.tech/roar_str2codec"
---

# roar\_str2codec(3)

Get codec ID by codec name roar\_codec2str - Get codec name by ID

## NAME

roar\_str2codec - Get codec ID by codec name

roar\_codec2str - Get codec name by ID

## SYNOPSIS

 \#include \<roaraudio.h\>

 int    roar\_str2codec (char \* codec);\
  char \* roar\_codec2str (int    codec);

## DESCRIPTION

**roar\_str2codec** converts a string to a RoarAudio Codec ID. It also supports some common aliases. **roar\_codec2str** is the reverse operation of **roar\_str2codec**: It gets a name by the ID given. If a **codec** is valid the following should be true:\
  roar\_str2codec(roar\_codec2str(codec)) == codec

Note that because of aliasing and case insensitivity the revers operation needs not to be true.

## THREAD SAFETY

Because **roar\_codec2str** returns a static unique pointer for each codec it is fully thread safe.

## RETURN VALUE

On success **roar\_str2codec** returns a codec ID.  On error, -1 is returned. **roar\_codec2str** returns the name of the codec or NULL on error. You must not free this pointer or write to it.

## EXAMPLES

FIXME

## SEE ALSO

[**libroar**(7)](/libroar/7.md), [**RoarAudio**(7)](/RoarAudio/7.md).
