mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 16:54:03 +02:00
Implement onGetEncodingFormat for libvorbis and libopus decoders.
This commit is contained in:
@@ -560,13 +560,34 @@ static void ma_decoding_backend_uninit__libopus(void* pUserData, ma_data_source*
|
|||||||
ma_free(pOpus, pAllocationCallbacks);
|
ma_free(pOpus, pAllocationCallbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ma_encoding_format ma_decoding_backend_get_encoding_format__libopus(void* pUserData, ma_data_source* pBackend)
|
||||||
|
{
|
||||||
|
(void)pUserData;
|
||||||
|
(void)pBackend;
|
||||||
|
|
||||||
|
/*
|
||||||
|
When pBackend is null, return ma_encoding_format_unknown if the backend supports multiple
|
||||||
|
formats. An example might be an FFmpeg backend. If the backend only supports a single format,
|
||||||
|
like this one, return the format directly (if it's not recognized by miniaudio, return
|
||||||
|
ma_encoding_format_unknown).
|
||||||
|
|
||||||
|
When pBackend is non-null, return the encoded format of the data source. If the format is not
|
||||||
|
recognized by miniaudio, return ma_encoding_format_unknown.
|
||||||
|
|
||||||
|
Since this backend only operates on Opus streams, we can just return ma_encoding_format_opus
|
||||||
|
in all cases.
|
||||||
|
*/
|
||||||
|
return ma_encoding_format_opus;
|
||||||
|
}
|
||||||
|
|
||||||
static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_libopus =
|
static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_libopus =
|
||||||
{
|
{
|
||||||
ma_decoding_backend_init__libopus,
|
ma_decoding_backend_init__libopus,
|
||||||
ma_decoding_backend_init_file__libopus,
|
ma_decoding_backend_init_file__libopus,
|
||||||
NULL, /* onInitFileW() */
|
NULL, /* onInitFileW() */
|
||||||
NULL, /* onInitMemory() */
|
NULL, /* onInitMemory() */
|
||||||
ma_decoding_backend_uninit__libopus
|
ma_decoding_backend_uninit__libopus,
|
||||||
|
ma_decoding_backend_get_encoding_format__libopus
|
||||||
};
|
};
|
||||||
const ma_decoding_backend_vtable* ma_decoding_backend_libopus = &g_ma_decoding_backend_vtable_libopus;
|
const ma_decoding_backend_vtable* ma_decoding_backend_libopus = &g_ma_decoding_backend_vtable_libopus;
|
||||||
|
|
||||||
|
|||||||
@@ -580,13 +580,34 @@ static void ma_decoding_backend_uninit__libvorbis(void* pUserData, ma_data_sourc
|
|||||||
ma_free(pVorbis, pAllocationCallbacks);
|
ma_free(pVorbis, pAllocationCallbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ma_encoding_format ma_decoding_backend_get_encoding_format__libvorbis(void* pUserData, ma_data_source* pBackend)
|
||||||
|
{
|
||||||
|
(void)pUserData;
|
||||||
|
(void)pBackend;
|
||||||
|
|
||||||
|
/*
|
||||||
|
When pBackend is null, return ma_encoding_format_unknown if the backend supports multiple
|
||||||
|
formats. An example might be an FFmpeg backend. If the backend only supports a single format,
|
||||||
|
like this one, return the format directly (if it's not recognized by miniaudio, return
|
||||||
|
ma_encoding_format_unknown).
|
||||||
|
|
||||||
|
When pBackend is non-null, return the encoded format of the data source. If the format is not
|
||||||
|
recognized by miniaudio, return ma_encoding_format_unknown.
|
||||||
|
|
||||||
|
Since this backend only operates on Vorbis streams, we can just return ma_encoding_format_vorbis
|
||||||
|
in all cases.
|
||||||
|
*/
|
||||||
|
return ma_encoding_format_vorbis;
|
||||||
|
}
|
||||||
|
|
||||||
static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_libvorbis =
|
static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_libvorbis =
|
||||||
{
|
{
|
||||||
ma_decoding_backend_init__libvorbis,
|
ma_decoding_backend_init__libvorbis,
|
||||||
ma_decoding_backend_init_file__libvorbis,
|
ma_decoding_backend_init_file__libvorbis,
|
||||||
NULL, /* onInitFileW() */
|
NULL, /* onInitFileW() */
|
||||||
NULL, /* onInitMemory() */
|
NULL, /* onInitMemory() */
|
||||||
ma_decoding_backend_uninit__libvorbis
|
ma_decoding_backend_uninit__libvorbis,
|
||||||
|
ma_decoding_backend_get_encoding_format__libvorbis
|
||||||
};
|
};
|
||||||
const ma_decoding_backend_vtable* ma_decoding_backend_libvorbis = &g_ma_decoding_backend_vtable_libvorbis;
|
const ma_decoding_backend_vtable* ma_decoding_backend_libvorbis = &g_ma_decoding_backend_vtable_libvorbis;
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -9993,7 +9993,8 @@ typedef enum
|
|||||||
ma_encoding_format_wav,
|
ma_encoding_format_wav,
|
||||||
ma_encoding_format_flac,
|
ma_encoding_format_flac,
|
||||||
ma_encoding_format_mp3,
|
ma_encoding_format_mp3,
|
||||||
ma_encoding_format_vorbis
|
ma_encoding_format_vorbis,
|
||||||
|
ma_encoding_format_opus
|
||||||
} ma_encoding_format;
|
} ma_encoding_format;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user