mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-09 17:15:43 +01:00
b8560a6bbb
The initialization procedure consist from default initialization and state restoration. When restore fails for a reason or the config file contains inaccurate information, then init is called. Also, if something fails (init or restore), a file specified using -r option can be created with description what failed. It can be useful when user space decides to notify user to set the sound driver properly. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
92 lines
2.5 KiB
C
92 lines
2.5 KiB
C
extern int debugflag;
|
|
extern int force_restore;
|
|
extern char *command;
|
|
extern char *statefile;
|
|
|
|
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
|
|
#define info(...) do {\
|
|
fprintf(stdout, "%s: %s:%d: ", command, __FUNCTION__, __LINE__); \
|
|
fprintf(stdout, __VA_ARGS__); \
|
|
putc('\n', stdout); \
|
|
} while (0)
|
|
#else
|
|
#define info(args...) do {\
|
|
fprintf(stdout, "%s: %s:%d: ", command, __FUNCTION__, __LINE__); \
|
|
fprintf(stdout, ##args); \
|
|
putc('\n', stdout); \
|
|
} while (0)
|
|
#endif
|
|
|
|
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
|
|
#define error(...) do {\
|
|
fprintf(stderr, "%s: %s:%d: ", command, __FUNCTION__, __LINE__); \
|
|
fprintf(stderr, __VA_ARGS__); \
|
|
putc('\n', stderr); \
|
|
} while (0)
|
|
#else
|
|
#define error(args...) do {\
|
|
fprintf(stderr, "%s: %s:%d: ", command, __FUNCTION__, __LINE__); \
|
|
fprintf(stderr, ##args); \
|
|
putc('\n', stderr); \
|
|
} while (0)
|
|
#endif
|
|
|
|
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
|
|
#define cerror(cond, ...) do {\
|
|
if (cond) { \
|
|
fprintf(stderr, "%s: %s:%d: ", command, __FUNCTION__, __LINE__); \
|
|
fprintf(stderr, __VA_ARGS__); \
|
|
putc('\n', stderr); \
|
|
} \
|
|
} while (0)
|
|
#else
|
|
#define cerror(cond, args...) do {\
|
|
if (cond) { \
|
|
fprintf(stderr, "%s: %s:%d: ", command, __FUNCTION__, __LINE__); \
|
|
fprintf(stderr, ##args); \
|
|
putc('\n', stderr); \
|
|
} \
|
|
} while (0)
|
|
#endif
|
|
|
|
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
|
|
#define dbg(...) do {\
|
|
if (!debugflag) break; \
|
|
fprintf(stderr, "%s: %s:%d: ", command, __FUNCTION__, __LINE__); \
|
|
fprintf(stderr, __VA_ARGS__); \
|
|
putc('\n', stderr); \
|
|
} while (0)
|
|
#else
|
|
#define dbg(args...) do {\
|
|
if (!debugflag) break; \
|
|
fprintf(stderr, "%s: %s:%d: ", command, __FUNCTION__, __LINE__); \
|
|
fprintf(stderr, ##args); \
|
|
putc('\n', stderr); \
|
|
} while (0)
|
|
#endif
|
|
|
|
int init(const char *file, const char *cardname);
|
|
int save_state(const char *file, const char *cardname);
|
|
int load_state(const char *file, const char *initfile, const char *cardname);
|
|
int power(const char *argv[], int argc);
|
|
int generate_names(const char *cfgfile);
|
|
|
|
/* utils */
|
|
|
|
int file_map(const char *filename, char **buf, size_t *bufsize);
|
|
void file_unmap(void *buf, size_t bufsize);
|
|
size_t line_width(const char *buf, size_t bufsize, size_t pos);
|
|
void initfailed(int cardnumber, const char *reason);
|
|
|
|
static inline int hextodigit(int c)
|
|
{
|
|
if (c >= '0' && c <= '9')
|
|
c -= '0';
|
|
else if (c >= 'a' && c <= 'f')
|
|
c = c - 'a' + 10;
|
|
else if (c >= 'A' && c <= 'F')
|
|
c = c - 'A' + 10;
|
|
else
|
|
return -1;
|
|
return c;
|
|
}
|