Skip to content

Commit

Permalink
base: apply NUGU_API macro to support win32
Browse files Browse the repository at this point in the history
change the EXPORT_API macro to NUGU_API to support win32

Signed-off-by: Inho Oh <webispy@gmail.com>
  • Loading branch information
webispy committed May 27, 2024
1 parent 5818eed commit deac58e
Show file tree
Hide file tree
Showing 38 changed files with 880 additions and 836 deletions.
11 changes: 7 additions & 4 deletions include/base/nugu_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef __NUGU_AUDIO_H__
#define __NUGU_AUDIO_H__

#include <nugu.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -108,22 +110,23 @@ typedef struct nugu_audio_property NuguAudioProperty;
* @param[in] attribute audio attribute
* @param[in] str audio attribute's string
*/
void nugu_audio_set_attribute_str(const NuguAudioAttribute attribute,
const char *str);
NUGU_API void nugu_audio_set_attribute_str(const NuguAudioAttribute attribute,
const char *str);

/**
* @brief Get audio attribute string
* @param[in] attribute audio attribute
* @return audio attribute string
*/
const char *nugu_audio_get_attribute_str(const NuguAudioAttribute attribute);
NUGU_API const char *
nugu_audio_get_attribute_str(const NuguAudioAttribute attribute);

/**
* @brief Get audio attribute type from string
* @param[in] str audio attribute's string
* @return audio attribute
*/
NuguAudioAttribute nugu_audio_get_attribute(const char *str);
NUGU_API NuguAudioAttribute nugu_audio_get_attribute(const char *str);

#ifdef __cplusplus
}
Expand Down
33 changes: 18 additions & 15 deletions include/base/nugu_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define __NUGU_BUFFER_H__

#include <stddef.h>
#include <nugu.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -43,7 +44,7 @@ extern "C" {
* @brief Not found return type of nugu_buffer_find_byte()
* @see nugu_buffer_find_byte()
*/
#define NUGU_BUFFER_NOT_FOUND ((size_t)-1)
#define NUGU_BUFFER_NOT_FOUND ((size_t) - 1)

/**
* @brief Buffer object
Expand All @@ -57,7 +58,7 @@ typedef struct _nugu_buffer NuguBuffer;
* @return Buffer object
* @see nugu_buffer_free()
*/
NuguBuffer *nugu_buffer_new(size_t default_size);
NUGU_API NuguBuffer *nugu_buffer_new(size_t default_size);

/**
* @brief Destroy the buffer object
Expand All @@ -68,7 +69,7 @@ NuguBuffer *nugu_buffer_new(size_t default_size);
* manually. If false, always return NULL.
* @see nugu_buffer_new()
*/
void *nugu_buffer_free(NuguBuffer *buf, int is_data_free);
NUGU_API void *nugu_buffer_free(NuguBuffer *buf, int is_data_free);

/**
* @brief Append the data to buffer object
Expand All @@ -77,15 +78,16 @@ void *nugu_buffer_free(NuguBuffer *buf, int is_data_free);
* @param[in] data_len Length of the data
* @return added length (0 = failure)
*/
size_t nugu_buffer_add(NuguBuffer *buf, const void *data, size_t data_len);
NUGU_API size_t nugu_buffer_add(NuguBuffer *buf, const void *data,
size_t data_len);

/**
* @brief Append the data to buffer object
* @param[in] buf buffer object
* @param[in] byte The data to add to the buffer.
* @return added length (0 = failure)
*/
size_t nugu_buffer_add_byte(NuguBuffer *buf, unsigned char byte);
NUGU_API size_t nugu_buffer_add_byte(NuguBuffer *buf, unsigned char byte);

/**
* @brief Append the data to buffer object
Expand All @@ -96,31 +98,32 @@ size_t nugu_buffer_add_byte(NuguBuffer *buf, unsigned char byte);
* @retval 0 success
* @retval -1 failure
*/
int nugu_buffer_set_byte(NuguBuffer *buf, size_t pos, unsigned char byte);
NUGU_API int nugu_buffer_set_byte(NuguBuffer *buf, size_t pos,
unsigned char byte);

/**
* @brief Get the internal buffer
* @param[in] buf buffer object
* @return Internal buffer address. Please do not modify the data manually.
* @see nugu_buffer_peek_byte()
*/
const void *nugu_buffer_peek(NuguBuffer *buf);
NUGU_API const void *nugu_buffer_peek(NuguBuffer *buf);

/**
* @brief Gets the size of the entire data added to the buffer.
* @param[in] buf buffer object
* @return size of data
* @see nugu_buffer_get_alloc_size()
*/
size_t nugu_buffer_get_size(NuguBuffer *buf);
NUGU_API size_t nugu_buffer_get_size(NuguBuffer *buf);

/**
* @brief Gets the size of the entire data allocated for the buffer.
* @param[in] buf buffer object
* @return size of allocated internal buffer.
* @see nugu_buffer_get_size()
*/
size_t nugu_buffer_get_alloc_size(NuguBuffer *buf);
NUGU_API size_t nugu_buffer_get_alloc_size(NuguBuffer *buf);

/**
* @brief Get the position of the data you want to find.
Expand All @@ -129,15 +132,15 @@ size_t nugu_buffer_get_alloc_size(NuguBuffer *buf);
* @return position. if fail, return NUGU_BUFFER_NOT_FOUND
* @see NUGU_BUFFER_NOT_FOUND
*/
size_t nugu_buffer_find_byte(NuguBuffer *buf, unsigned char want);
NUGU_API size_t nugu_buffer_find_byte(NuguBuffer *buf, unsigned char want);

/**
* @brief Get data at a specific position.
* @param[in] buf buffer object
* @param[in] pos position
* @return byte data
*/
unsigned char nugu_buffer_peek_byte(NuguBuffer *buf, size_t pos);
NUGU_API unsigned char nugu_buffer_peek_byte(NuguBuffer *buf, size_t pos);

/**
* @brief Clear the buffer
Expand All @@ -147,7 +150,7 @@ unsigned char nugu_buffer_peek_byte(NuguBuffer *buf, size_t pos);
* @retval -1 failure
* @see nugu_buffer_clear_from()
*/
int nugu_buffer_clear(NuguBuffer *buf);
NUGU_API int nugu_buffer_clear(NuguBuffer *buf);

/**
* @brief Clear data from a specific position to the end.
Expand All @@ -158,7 +161,7 @@ int nugu_buffer_clear(NuguBuffer *buf);
* @retval -1 failure
* @see nugu_buffer_clear()
*/
int nugu_buffer_clear_from(NuguBuffer *buf, size_t pos);
NUGU_API int nugu_buffer_clear_from(NuguBuffer *buf, size_t pos);

/**
* @brief Delete a certain amount of data and move the remaining data forward.
Expand All @@ -168,15 +171,15 @@ int nugu_buffer_clear_from(NuguBuffer *buf, size_t pos);
* @retval 0 success
* @retval -1 failure
*/
int nugu_buffer_shift_left(NuguBuffer *buf, size_t size);
NUGU_API int nugu_buffer_shift_left(NuguBuffer *buf, size_t size);

/**
* @brief Extract data by a certain size.
* @param[in] buf buffer object
* @param[in] size size to extract
* @return Extracted data. Developer must free the data manually.
*/
void *nugu_buffer_pop(NuguBuffer *buf, size_t size);
NUGU_API void *nugu_buffer_pop(NuguBuffer *buf, size_t size);

/**
* @}
Expand Down
36 changes: 20 additions & 16 deletions include/base/nugu_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef __NUGU_DECODER_H__
#define __NUGU_DECODER_H__

#include <nugu.h>
#include <base/nugu_pcm.h>
#include <base/nugu_buffer.h>

Expand Down Expand Up @@ -60,7 +61,8 @@ typedef struct _nugu_decoder_driver NuguDecoderDriver;
* @see nugu_decoder_get_pcm()
* @see nugu_pcm_new()
*/
NuguDecoder *nugu_decoder_new(NuguDecoderDriver *driver, NuguPcm *sink);
NUGU_API NuguDecoder *nugu_decoder_new(NuguDecoderDriver *driver,
NuguPcm *sink);

/**
* @brief Destroy the decoder object
Expand All @@ -70,7 +72,7 @@ NuguDecoder *nugu_decoder_new(NuguDecoderDriver *driver, NuguPcm *sink);
* @retval -1 failure
* @see nugu_decoder_new()
*/
int nugu_decoder_free(NuguDecoder *dec);
NUGU_API int nugu_decoder_free(NuguDecoder *dec);

/**
* @brief Decode the encoded data and pass the result to sink
Expand All @@ -82,7 +84,8 @@ int nugu_decoder_free(NuguDecoder *dec);
* @retval -1 failure
* @see nugu_decoder_decode()
*/
int nugu_decoder_play(NuguDecoder *dec, const void *data, size_t data_len);
NUGU_API int nugu_decoder_play(NuguDecoder *dec, const void *data,
size_t data_len);

/**
* @brief Set custom data for driver
Expand All @@ -93,15 +96,15 @@ int nugu_decoder_play(NuguDecoder *dec, const void *data, size_t data_len);
* @retval -1 failure
* @see nugu_decoder_get_driver_data()
*/
int nugu_decoder_set_driver_data(NuguDecoder *dec, void *data);
NUGU_API int nugu_decoder_set_driver_data(NuguDecoder *dec, void *data);

/**
* @brief Get custom data for driver
* @param[in] dec decoder object
* @return data
* @see nugu_decoder_set_driver_data()
*/
void *nugu_decoder_get_driver_data(NuguDecoder *dec);
NUGU_API void *nugu_decoder_get_driver_data(NuguDecoder *dec);

/**
* @brief Decode the encoded data
Expand All @@ -111,16 +114,16 @@ void *nugu_decoder_get_driver_data(NuguDecoder *dec);
* @param[out] output_len output buffer length
* @return memory allocated decoded data. Developer must free the data manually.
*/
void *nugu_decoder_decode(NuguDecoder *dec, const void *data, size_t data_len,
size_t *output_len);
NUGU_API void *nugu_decoder_decode(NuguDecoder *dec, const void *data,
size_t data_len, size_t *output_len);

/**
* @brief Get pcm(sink) object
* @param[in] dec decoder object
* @return pcm object
* @see nugu_decoder_new()
*/
NuguPcm *nugu_decoder_get_pcm(NuguDecoder *dec);
NUGU_API NuguPcm *nugu_decoder_get_pcm(NuguDecoder *dec);

/**
* @}
Expand Down Expand Up @@ -177,9 +180,9 @@ struct nugu_decoder_driver_ops {
* @return decoder driver object
* @see nugu_decoder_driver_free()
*/
NuguDecoderDriver *nugu_decoder_driver_new(const char *name,
enum nugu_decoder_type type,
struct nugu_decoder_driver_ops *ops);
NUGU_API NuguDecoderDriver *
nugu_decoder_driver_new(const char *name, enum nugu_decoder_type type,
struct nugu_decoder_driver_ops *ops);

/**
* @brief Destroy the decoder driver
Expand All @@ -188,7 +191,7 @@ NuguDecoderDriver *nugu_decoder_driver_new(const char *name,
* @retval 0 success
* @retval -1 failure
*/
int nugu_decoder_driver_free(NuguDecoderDriver *driver);
NUGU_API int nugu_decoder_driver_free(NuguDecoderDriver *driver);

/**
* @brief Register the driver to driver list
Expand All @@ -197,7 +200,7 @@ int nugu_decoder_driver_free(NuguDecoderDriver *driver);
* @retval 0 success
* @retval -1 failure
*/
int nugu_decoder_driver_register(NuguDecoderDriver *driver);
NUGU_API int nugu_decoder_driver_register(NuguDecoderDriver *driver);

/**
* @brief Remove the driver from driver list
Expand All @@ -206,23 +209,24 @@ int nugu_decoder_driver_register(NuguDecoderDriver *driver);
* @retval 0 success
* @retval -1 failure
*/
int nugu_decoder_driver_remove(NuguDecoderDriver *driver);
NUGU_API int nugu_decoder_driver_remove(NuguDecoderDriver *driver);

/**
* @brief Find a driver by name in the driver list
* @param[in] name decoder driver name
* @return decoder driver object
* @see nugu_decoder_driver_find_bytype()
*/
NuguDecoderDriver *nugu_decoder_driver_find(const char *name);
NUGU_API NuguDecoderDriver *nugu_decoder_driver_find(const char *name);

/**
* @brief Find a driver by type in the driver list
* @param[in] type decoder driver type
* @return decoder driver object
* @see nugu_decoder_driver_find
*/
NuguDecoderDriver *nugu_decoder_driver_find_bytype(enum nugu_decoder_type type);
NUGU_API NuguDecoderDriver *
nugu_decoder_driver_find_bytype(enum nugu_decoder_type type);

/**
* @}
Expand Down
Loading

0 comments on commit deac58e

Please sign in to comment.