From 5f524e300409f0a7b54c5fe9ee194bad1fc39516 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Thu, 31 Jul 2025 15:37:33 +0300 Subject: [PATCH 01/34] pcm: add a loop to snd_pcm_avail_delay() to avoid bogus delay values snd_pcm_avail_delay() is expected to report avail and delay values in atomic fashion. However the function does two separate syscalls and it cannot guarantee the avail value is the same as was used to calculate the delay. This is a problem as the reported delay is always relative to avail frames value. If application (like e.g. alsa_conformance_test) uses snd_pcm_avail_delay() to estimate the effective play position, it can observe bogus delay values (and effective play position going backwards) if snd_pcm_avail_delay() is called during a DMA burst where hw_ptr moves quickly. This commit adds a loop similar to that used in snd_pcm_hw_htimestamp() to wait until we get a stable avail reading, and only then extract the delay. This will avoid bogus values if function is called during DMA bursts. Closes: https://github.com/alsa-project/alsa-lib/pull/469 Closes: https://github.com/alsa-project/alsa-lib/issues/468 Signed-off-by: Kai Vehmanen Signed-off-by: Jaroslav Kysela --- src/pcm/pcm.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index da339ace..c59ea3b6 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -3107,7 +3107,7 @@ int snd_pcm_avail_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp) { snd_pcm_sframes_t sf; - int err; + int err, ok = 0; assert(pcm && availp && delayp); if (CHECK_SANITY(! pcm->setup)) { @@ -3118,15 +3118,25 @@ int snd_pcm_avail_delay(snd_pcm_t *pcm, err = __snd_pcm_hwsync(pcm); if (err < 0) goto unlock; - sf = __snd_pcm_avail_update(pcm); - if (sf < 0) { - err = (int)sf; - goto unlock; + + /* + * Delay value is relative to avail, so we have to + * loop to avoid reporting stale delay data. + */ + while (1) { + sf = __snd_pcm_avail_update(pcm); + if (sf < 0) { + err = (int)sf; + goto unlock; + } + if (ok && sf == *availp) + break; + *availp = sf; + err = __snd_pcm_delay(pcm, delayp); + if (err < 0) + goto unlock; + ok = 1; } - err = __snd_pcm_delay(pcm, delayp); - if (err < 0) - goto unlock; - *availp = sf; err = 0; unlock: snd_pcm_unlock(pcm->fast_op_arg); From 4ad4d9590ab22276631f84ca59e67af53e5c5776 Mon Sep 17 00:00:00 2001 From: wyjstrong Date: Tue, 29 Jul 2025 14:58:43 +0800 Subject: [PATCH 02/34] Force to use alphasort64() sorting function for Harmony OS Closes: https://github.com/alsa-project/alsa-lib/pull/467 Signed-off-by: wyjstrong Signed-off-by: Jaroslav Kysela --- src/conf.c | 9 ++++++++- src/ucm/parser.c | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/conf.c b/src/conf.c index 468d41f5..905c8f4d 100644 --- a/src/conf.c +++ b/src/conf.c @@ -4140,7 +4140,14 @@ static int config_file_load(snd_config_t *root, const char *fn, int errors) if (!S_ISDIR(st.st_mode)) return config_file_open(root, fn); #ifndef DOC_HIDDEN -#if defined(_GNU_SOURCE) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__sun) && !defined(__ANDROID__) +#if defined(_GNU_SOURCE) && \ + !defined(__NetBSD__) && \ + !defined(__FreeBSD__) && \ + !defined(__OpenBSD__) && \ + !defined(__DragonFly__) && \ + !defined(__sun) && \ + !defined(__ANDROID__) && \ + !defined(__OHOS__) #define SORTFUNC versionsort64 #else #define SORTFUNC alphasort64 diff --git a/src/ucm/parser.c b/src/ucm/parser.c index 488a5c62..ac4a5fbc 100644 --- a/src/ucm/parser.c +++ b/src/ucm/parser.c @@ -2928,7 +2928,14 @@ int uc_mgr_scan_master_configs(const char **_list[]) snprintf(filename, sizeof(filename), "%s/ucm2/conf.virt.d", snd_config_topdir()); -#if defined(_GNU_SOURCE) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__sun) && !defined(__ANDROID__) +#if defined(_GNU_SOURCE) && \ + !defined(__NetBSD__) && \ + !defined(__FreeBSD__) && \ + !defined(__OpenBSD__) && \ + !defined(__DragonFly__) && \ + !defined(__sun) && \ + !defined(__ANDROID__) && \ + !defined(__OHOS__) #define SORTFUNC versionsort64 #else #define SORTFUNC alphasort64 From 782b0597c25845cf8c48b3fe906e8374d1175f36 Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Sun, 15 Jun 2025 10:10:52 +0200 Subject: [PATCH 03/34] ucm: use close_range on _GNU_SOURCE Closes: https://github.com/alsa-project/alsa-lib/pull/459 Signed-off-by: Jochen Sprickerhof Signed-off-by: Jaroslav Kysela --- src/ucm/ucm_exec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ucm/ucm_exec.c b/src/ucm/ucm_exec.c index 276cf592..b79a84ae 100644 --- a/src/ucm/ucm_exec.c +++ b/src/ucm/ucm_exec.c @@ -254,8 +254,12 @@ int uc_mgr_exec(const char *prog) close(f); +#if defined(_GNU_SOURCE) + close_range(3, maxfd, 0); +#else for (f = 3; f < maxfd; f++) close(f); +#endif /* install default handlers for the forked process */ signal(SIGINT, SIG_DFL); From 3a9771812405be210e760e4e6667f2c023fe82f4 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sun, 6 Jul 2025 05:07:45 +0100 Subject: [PATCH 04/34] test: update midifile library to ANSI C The midifile library used by the playmidi1 program dates from 1989, and used pre-ANSI function definitions and prototypes. GCC 15 now defaults to C23 where () means the same as (void) in prototypes, which causes type mismatch errors. Update the code to use ANSI function definitions and prototypes, so it'll compile happily as anything from ANSI C to C23. This revealed that playmidi1's do_tempo had the wrong argument type, so correct that as well. Closes: https://github.com/alsa-project/alsa-lib/pull/463 Signed-off-by: Adam Sampson Signed-off-by: Jaroslav Kysela --- test/midifile.c | 246 +++++++++++++++++++---------------------------- test/midifile.h | 71 +++++++------- test/playmidi1.c | 4 +- 3 files changed, 140 insertions(+), 181 deletions(-) diff --git a/test/midifile.c b/test/midifile.c index 4862b199..8580108e 100644 --- a/test/midifile.c +++ b/test/midifile.c @@ -79,34 +79,34 @@ /* public stuff */ /* Functions to be called while processing the MIDI file. */ -int (*Mf_getc) () = NULLFUNC; -void (*Mf_error) () = NULLFUNC; -void (*Mf_header) () = NULLFUNC; -void (*Mf_trackstart) () = NULLFUNC; -void (*Mf_trackend) () = NULLFUNC; -void (*Mf_noteon) () = NULLFUNC; -void (*Mf_noteoff) () = NULLFUNC; -void (*Mf_pressure) () = NULLFUNC; -void (*Mf_parameter) () = NULLFUNC; -void (*Mf_pitchbend) () = NULLFUNC; -void (*Mf_program) () = NULLFUNC; -void (*Mf_chanpressure) () = NULLFUNC; -void (*Mf_sysex) () = NULLFUNC; -void (*Mf_arbitrary) () = NULLFUNC; -void (*Mf_metamisc) () = NULLFUNC; -void (*Mf_seqnum) () = NULLFUNC; -void (*Mf_eot) () = NULLFUNC; -void (*Mf_smpte) () = NULLFUNC; -void (*Mf_tempo) () = NULLFUNC; -void (*Mf_timesig) () = NULLFUNC; -void (*Mf_keysig) () = NULLFUNC; -void (*Mf_seqspecific) () = NULLFUNC; -void (*Mf_text) () = NULLFUNC; +int (*Mf_getc) (void) = NULLFUNC; +void (*Mf_error) (char *s) = NULLFUNC; +void (*Mf_header) (int format, int ntrks, int division) = NULLFUNC; +void (*Mf_trackstart) (void) = NULLFUNC; +void (*Mf_trackend) (void) = NULLFUNC; +void (*Mf_noteon) (int chan, int c1, int c2) = NULLFUNC; +void (*Mf_noteoff) (int chan, int c1, int c2) = NULLFUNC; +void (*Mf_pressure) (int chan, int c1, int c2) = NULLFUNC; +void (*Mf_parameter) (int chan, int c1, int c2) = NULLFUNC; +void (*Mf_pitchbend) (int chan, int c1, int c2) = NULLFUNC; +void (*Mf_program) (int chan, int c1) = NULLFUNC; +void (*Mf_chanpressure) (int chan, int c1) = NULLFUNC; +void (*Mf_sysex) (int len, char *msg) = NULLFUNC; +void (*Mf_arbitrary) (int len, char *msg) = NULLFUNC; +void (*Mf_metamisc) (int type, int len, char *msg) = NULLFUNC; +void (*Mf_seqnum) (int num) = NULLFUNC; +void (*Mf_eot) (void) = NULLFUNC; +void (*Mf_smpte) (char m0, char m1, char m2, char m3, char m4) = NULLFUNC; +void (*Mf_tempo) (long tempo) = NULLFUNC; +void (*Mf_timesig) (char m0, char m1, char m2, char m3) = NULLFUNC; +void (*Mf_keysig) (char m0, char m1) = NULLFUNC; +void (*Mf_seqspecific) (int len, char *msg) = NULLFUNC; +void (*Mf_text) (int type, int len, char *msg) = NULLFUNC; /* Functions to implement in order to write a MIDI file */ -int (*Mf_putc) () = NULLFUNC; -int (*Mf_writetrack) () = NULLFUNC; -int (*Mf_writetempotrack) () = NULLFUNC; +int (*Mf_putc) (unsigned char c) = NULLFUNC; +int (*Mf_writetrack) (int track) = NULLFUNC; +int (*Mf_writetempotrack) (void) = NULLFUNC; int Mf_nomerge = 0; /* 1 => continue'ed system exclusives are */ /* not collapsed. */ @@ -132,29 +132,34 @@ static int tempo_history_count = 0; static long Mf_toberead = 0L; static long Mf_numbyteswritten = 0L; -static long readvarinum (); -static long read32bit (); -static long to32bit (); -static int read16bit (); -static int to16bit (); -static char *msg (); -static void readheader (); -static int readtrack (); -static void badbyte (); -static void metaevent (); -static void sysex (); -static void chanmessage (); -static void msginit (); -static int msgleng (); -static void msgadd (); -static void biggermsg (); -static int eputc (); +static long readvarinum (void); +static long read32bit (void); +static long to32bit (int, int, int, int); +static int read16bit (void); +static int to16bit (int, int); +static char *msg (void); +static void readheader (void); +static int readtrack (void); +static void badbyte (int); +static void metaevent (int); +static void sysex (void); +static void chanmessage (int, int, int); +static void msginit (void); +static int msgleng (void); +static void msgadd (int); +static void biggermsg (void); +static int eputc (unsigned char); double mf_ticks2sec (unsigned long ticks, int division, unsigned long tempo); -int mf_write_meta_event (); -void mf_write_tempo (); -void mf_write_seqnum (); -void WriteVarLen (); +void write32bit (unsigned long data); +void write16bit (int data); +void mf_write_track_chunk (int which_track, FILE *fp); +void mf_write_header_chunk (int format, int ntracks, int division); +int mf_write_meta_event (unsigned long delta_time, unsigned char type, + unsigned char *data, unsigned long size); +void mf_write_tempo (unsigned long delta_time, unsigned long tempo); +void mf_write_seqnum (unsigned long delta_time, unsigned int seqnum); +void WriteVarLen (unsigned long value); #ifdef READ_MODS #include "mp_mod.c" @@ -163,7 +168,7 @@ static int mod_file_flag = 0; static int force_exit; void -mfread () +mfread (void) { force_exit = 0; if (Mf_getc == NULLFUNC) @@ -181,15 +186,13 @@ mfread () /* for backward compatibility with the original lib */ void -midifile () +midifile (void) { mfread (); } -static -int -readmt (s) /* read through the "MThd" or "MTrk" header string */ - char *s; +static int +readmt (char *s) /* read through the "MThd" or "MTrk" header string */ { int n = 0; char *p = s; @@ -211,9 +214,8 @@ readmt (s) /* read through the "MThd" or "MTrk" header string */ return (c); } -static -int -egetc () /* read a single character and abort on EOF */ +static int +egetc (void) /* read a single character and abort on EOF */ { int c = (*Mf_getc) (); @@ -225,9 +227,8 @@ egetc () /* read a single character and abort on EOF */ return (c); } -static -void -readheader () /* read a header chunk */ +static void +readheader (void) /* read a header chunk */ { int format, ntrks, division; @@ -280,9 +281,8 @@ readheader () /* read a header chunk */ /*#define DEBUG_TIMES*/ -static -unsigned long -find_tempo() +static unsigned long +find_tempo(void) { int i; unsigned long old_tempo = Mf_currtempo; @@ -307,9 +307,8 @@ printf("[revised_time %lu, new_tempo %lu]\n", revised_time, new_tempo); return(new_tempo); } -static -int -readtrack () /* read a track chunk */ +static int +readtrack (void) /* read a track chunk */ { /* This array is indexed by the high half of a status byte. It's */ /* value is either the number of bytes needed (1 or 2) for a channel */ @@ -499,10 +498,8 @@ old_f_realtime, delta_secs * 1600.0); return (1); } -static -void -badbyte (c) - int c; +static void +badbyte (int c) { char buff[32]; @@ -510,8 +507,7 @@ badbyte (c) mferror (buff); } -static -void +static void metaevent (int type) { int leng = msgleng (); @@ -577,19 +573,15 @@ metaevent (int type) } } -static -void -sysex () +static void +sysex (void) { if (Mf_sysex) (*Mf_sysex) (msgleng (), msg ()); } -static -void -chanmessage (status, c1, c2) - int status; - int c1, c2; +static void +chanmessage (int status, int c1, int c2) { int chan = status & 0xf; @@ -635,7 +627,7 @@ chanmessage (status, c1, c2) /* number of characters it took. */ static long -readvarinum () +readvarinum (void) { long value; int c; @@ -668,14 +660,13 @@ to32bit (int c1, int c2, int c3, int c4) } static int -to16bit (c1, c2) - int c1, c2; +to16bit (int c1, int c2) { return ((c1 & 0xff) << 8) + (c2 & 0xff); } static long -read32bit () +read32bit (void) { int c1, c2, c3, c4; @@ -687,7 +678,7 @@ read32bit () } static int -read16bit () +read16bit (void) { int c1, c2; c1 = egetc (); @@ -697,8 +688,7 @@ read16bit () /* static */ void -mferror (s) - char *s; +mferror (char *s) { if (Mf_error) (*Mf_error) (s); @@ -714,30 +704,26 @@ static char *Msgbuff = NULL; /* message buffer */ static int Msgsize = 0; /* Size of currently allocated Msg */ static int Msgindex = 0; /* index of next available location in Msg */ -static -void -msginit () +static void +msginit (void) { Msgindex = 0; } static char * -msg () +msg (void) { return (Msgbuff); } -static -int -msgleng () +static int +msgleng (void) { return (Msgindex); } -static -void -msgadd (c) - int c; +static void +msgadd (int c) { /* If necessary, allocate larger message buffer. */ if (Msgindex >= Msgsize) @@ -745,11 +731,9 @@ msgadd (c) Msgbuff[Msgindex++] = c; } -static -void -biggermsg () +static void +biggermsg (void) { -/* char *malloc(); */ char *newmess; char *oldmess = Msgbuff; int oldleng = Msgsize; @@ -805,12 +789,9 @@ static int laststatus = 0; * to work with Mf_putc. */ void -mfwrite (format, ntracks, division, fp) - int format, ntracks, division; - FILE *fp; +mfwrite (int format, int ntracks, int division, FILE *fp) { int i; - void mf_write_track_chunk (), mf_write_header_chunk (); if (Mf_putc == NULLFUNC) mferror ("mfmf_write() called without setting Mf_putc"); @@ -837,14 +818,10 @@ mfwrite (format, ntracks, division, fp) } void -mf_write_track_chunk (which_track, fp) - int which_track; - FILE *fp; +mf_write_track_chunk (int which_track, FILE *fp) { unsigned long trkhdr, trklength; long offset, place_marker; - void write16bit (), write32bit (); - laststatus = 0; @@ -910,11 +887,9 @@ mf_write_track_chunk (which_track, fp) void -mf_write_header_chunk (format, ntracks, division) - int format, ntracks, division; +mf_write_header_chunk (int format, int ntracks, int division) { unsigned long ident, length; - void write16bit (), write32bit (); ident = MThd; /* Head chunk identifier */ length = 6; /* Chunk length */ @@ -948,11 +923,8 @@ mf_write_header_chunk (format, ntracks, division) * size - The length of the meta-event data. */ int -mf_write_midi_event (delta_time, type, chan, data, size) - unsigned long delta_time; - int chan, type; - unsigned long size; - char *data; +mf_write_midi_event (unsigned long delta_time, int type, int chan, + char *data, unsigned long size) { int i; unsigned char c; @@ -999,11 +971,9 @@ mf_write_midi_event (delta_time, type, chan, data, size) * data. * size - The length of the meta-event data. */ -int -mf_write_meta_event (delta_time, type, data, size) - unsigned long delta_time; - unsigned char *data, type; - unsigned long size; +int +mf_write_meta_event (unsigned long delta_time, unsigned char type, + unsigned char *data, unsigned long size) { int i; @@ -1027,9 +997,7 @@ mf_write_meta_event (delta_time, type, data, size) } /* end mf_write_meta_event */ void -mf_write_tempo (delta_time, tempo) - unsigned long delta_time; - unsigned long tempo; +mf_write_tempo (unsigned long delta_time, unsigned long tempo) { /* Write tempo */ /* all tempos are written as 120 beats/minute, */ @@ -1046,9 +1014,7 @@ mf_write_tempo (delta_time, tempo) } void -mf_write_seqnum (delta_time, seqnum) - unsigned long delta_time; - unsigned seqnum; +mf_write_seqnum (unsigned long delta_time, unsigned int seqnum) { WriteVarLen (delta_time); @@ -1060,10 +1026,7 @@ mf_write_seqnum (delta_time, seqnum) } unsigned long -mf_sec2ticks (secs, division, tempo) - int division; - unsigned long tempo; - double secs; +mf_sec2ticks (double secs, int division, unsigned long tempo) { return (unsigned long) (((secs * 1000.0) / 4.0 * division) / tempo); } @@ -1072,8 +1035,7 @@ mf_sec2ticks (secs, division, tempo) * Write multi-length bytes to MIDI format files */ void -WriteVarLen (value) - unsigned long value; +WriteVarLen (unsigned long value) { unsigned long buffer; @@ -1102,10 +1064,7 @@ WriteVarLen (value) * */ double -mf_ticks2sec (ticks, division, tempo) - int division; - unsigned long tempo; - unsigned long ticks; +mf_ticks2sec (unsigned long ticks, int division, unsigned long tempo) { double smpte_format, smpte_resolution; @@ -1133,8 +1092,7 @@ mf_ticks2sec (ticks, division, tempo) * */ void -write32bit (data) - unsigned long data; +write32bit (unsigned long data) { eputc ((unsigned) ((data >> 24) & 0xff)); eputc ((unsigned) ((data >> 16) & 0xff)); @@ -1143,8 +1101,7 @@ write32bit (data) } void -write16bit (data) - int data; +write16bit (int data) { eputc ((unsigned) ((data & 0xff00) >> 8)); eputc ((unsigned) (data & 0xff)); @@ -1152,8 +1109,7 @@ write16bit (data) /* write a single character and abort on error */ static int -eputc (c) - unsigned char c; +eputc (unsigned char c) { int return_val; diff --git a/test/midifile.h b/test/midifile.h index 7dd4626e..5d408421 100644 --- a/test/midifile.h +++ b/test/midifile.h @@ -1,27 +1,27 @@ /* definitions for MIDI file parsing code */ -extern int (*Mf_getc)(); -extern void (*Mf_header)(); -extern void (*Mf_trackstart)(); -extern void (*Mf_trackend)(); -extern void (*Mf_noteon)(); -extern void (*Mf_noteoff)(); -extern void (*Mf_pressure)(); -extern void (*Mf_parameter)(); -extern void (*Mf_pitchbend)(); -extern void (*Mf_program)(); -extern void (*Mf_chanpressure)(); -extern void (*Mf_sysex)(); -extern void (*Mf_metamisc)(); -extern void (*Mf_seqspecific)(); -extern void (*Mf_seqnum)(); -extern void (*Mf_text)(); -extern void (*Mf_eot)(); -extern void (*Mf_timesig)(); -extern void (*Mf_smpte)(); -extern void (*Mf_tempo)(); -extern void (*Mf_keysig)(); -extern void (*Mf_arbitrary)(); -extern void (*Mf_error)(); +extern int (*Mf_getc)(void); +extern void (*Mf_error)(char *s); +extern void (*Mf_header)(int format, int ntrks, int division); +extern void (*Mf_trackstart)(void); +extern void (*Mf_trackend)(void); +extern void (*Mf_noteon)(int chan, int c1, int c2); +extern void (*Mf_noteoff)(int chan, int c1, int c2); +extern void (*Mf_pressure)(int chan, int c1, int c2); +extern void (*Mf_parameter)(int chan, int c1, int c2); +extern void (*Mf_pitchbend)(int chan, int c1, int c2); +extern void (*Mf_program)(int chan, int c1); +extern void (*Mf_chanpressure)(int chan, int c1); +extern void (*Mf_sysex)(int len, char *msg); +extern void (*Mf_arbitrary)(int len, char *msg); +extern void (*Mf_metamisc)(int type, int len, char *msg); +extern void (*Mf_seqnum)(int num); +extern void (*Mf_eot)(void); +extern void (*Mf_smpte)(char m0, char m1, char m2, char m3, char m4); +extern void (*Mf_tempo)(long tempo); +extern void (*Mf_timesig)(char m0, char m1, char m2, char m3); +extern void (*Mf_keysig)(char m0, char m1); +extern void (*Mf_seqspecific)(int len, char *msg); +extern void (*Mf_text)(int type, int len, char *msg); extern unsigned long Mf_currtime; extern unsigned long Mf_realtime; extern unsigned long Mf_currtempo; @@ -33,20 +33,23 @@ extern int Mf_file_size; #endif /* definitions for MIDI file writing code */ -extern int (*Mf_putc)(); -extern int (*Mf_writetrack)(); -extern int (*Mf_writetempotrack)(); +extern int (*Mf_putc)(unsigned char c); +extern int (*Mf_writetrack)(int track); +extern int (*Mf_writetempotrack)(void); -extern void midifile(); -extern unsigned long mf_sec2ticks(); -extern void mfwrite(); -extern int mf_write_meta_event(); +extern void midifile(void); +extern unsigned long mf_sec2ticks(double secs, int division, + unsigned long tempo); +extern void mfwrite(int format, int ntracks, int division, FILE *fp); +extern int mf_write_meta_event(unsigned long delta_time, unsigned char type, + unsigned char *data, unsigned long size); extern int mf_write_midi_event(unsigned long delta_time, int type, int chan, char *data, unsigned long size); -extern double mf_ticks2sec(unsigned long ticks,int division,unsigned long tempo); -extern void mf_write_tempo(); -extern void mf_write_seqnum(); -extern void mfread(); +extern double mf_ticks2sec(unsigned long ticks, int division, + unsigned long tempo); +extern void mf_write_tempo(unsigned long delta_time, unsigned long tempo); +extern void mf_write_seqnum(unsigned long delta_time, unsigned int seqnum); +extern void mfread(void); extern void mferror(char *s); #ifndef NO_LC_DEFINES diff --git a/test/playmidi1.c b/test/playmidi1.c index 286aaa86..6ca0e397 100644 --- a/test/playmidi1.c +++ b/test/playmidi1.c @@ -243,14 +243,14 @@ static void alsa_stop_timer(void) } /* change the tempo */ -static void do_tempo(int us) +static void do_tempo(long us) { snd_seq_event_t ev; if (verbose >= VERB_MUCH) { double bpm; bpm = 60.0E6 / (double) us; - printf("Tempo %d us/beat, %.2f bpm\n", us, bpm); + printf("Tempo %ld us/beat, %.2f bpm\n", us, bpm); } /* store the new tempo and timestamp of the tempo change */ From d62b1d540781c61403681c1d903b7c74af6d1fa9 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 18 Sep 2025 11:00:47 +0200 Subject: [PATCH 05/34] conf: fix parse_array_def override code path The error may cause segmentation fault and incorrect behaviour. Closes: https://github.com/alsa-project/alsa-lib/issues/477 Signed-off-by: Jaroslav Kysela --- src/conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf.c b/src/conf.c index 905c8f4d..a48e0db0 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1268,13 +1268,13 @@ static int parse_array_def(snd_config_t *parent, input_t *input, int *idx, int s snd_config_t *n = NULL; if (!skip) { - snd_config_t *g; char static_id[12]; while (1) { snprintf(static_id, sizeof(static_id), "%i", *idx); - if (_snd_config_search(parent, static_id, -1, &g) == 0) { + if (_snd_config_search(parent, static_id, -1, &n) == 0) { if (override) { snd_config_delete(n); + n = NULL; } else { /* merge */ (*idx)++; From e6d0db9d0c9160d880861138d1a270cfef70dd26 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 28 Oct 2025 13:34:10 +0100 Subject: [PATCH 06/34] rawmidi: Fix the prefix of the inactive stream flag I copied SNDRV_RAWMIDI_INFO_STREAM_INACTIVE definition as is from the kernel uapi header, but for alsa-lib, it should have been changed to SND_ prefix instead. Put the correct definition while keeping the old SNDRV_ definition for compatibility (that might be already used by applications). Fixes: 137eca7720be ("rawmidi: Extensions for tied device and substream inactive flag") Signed-off-by: Takashi Iwai --- include/rawmidi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/rawmidi.h b/include/rawmidi.h index a144f659..f3676d29 100644 --- a/include/rawmidi.h +++ b/include/rawmidi.h @@ -101,7 +101,8 @@ typedef enum _snd_rawmidi_read_mode { /** rawmidi info bit flags */ #define SND_RAWMIDI_INFO_UMP 0x00000008 /**< rawmidi is UMP */ -#define SNDRV_RAWMIDI_INFO_STREAM_INACTIVE 0x00000010 /**< the selected substream is inactive */ +#define SND_RAWMIDI_INFO_STREAM_INACTIVE 0x00000010 /**< the selected substream is inactive */ +#define SNDRV_RAWMIDI_INFO_STREAM_INACTIVE SND_RAWMIDI_INFO_STREAM_INACTIVE /* only for compatibility */ int snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi, const char *name, int mode); From e5cb0b3346914e1326d84fe042f795e29826c2ba Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 18 Sep 2025 11:03:02 +0200 Subject: [PATCH 07/34] conf: Revert "conf: fix load_for_all_cards()" This reverts commit ddfc32abf5697de1618b9e7ffdf57a0f97013090. It was not a correct fix. The private values may differ (multiple instances for e.g. USB sound cards). This fix prevents to load private configurations for other instances. Signed-off-by: Jaroslav Kysela --- src/conf.c | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/src/conf.c b/src/conf.c index a48e0db0..4dfa9cc5 100644 --- a/src/conf.c +++ b/src/conf.c @@ -4413,23 +4413,18 @@ static int _snd_config_hook_table(snd_config_t *root, snd_config_t *config, snd_ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config, snd_config_t **dst, snd_config_t *private_data ATTRIBUTE_UNUSED) { int card = -1, err; - snd_config_t *loaded; // trace loaded cards - err = snd_config_top(&loaded); - if (err < 0) - return err; do { err = snd_card_next(&card); if (err < 0) - goto __fin_err; + return err; if (card >= 0) { - snd_config_t *n, *m, *private_data = NULL; + snd_config_t *n, *private_data = NULL; const char *driver; char *fdriver = NULL; - bool load; err = snd_determine_driver(card, &fdriver); if (err < 0) - goto __fin_err; + return err; if (snd_config_search(root, fdriver, &n) >= 0) { if (snd_config_get_string(n, &driver) < 0) { if (snd_config_get_type(n) == SND_CONFIG_TYPE_COMPOUND) { @@ -4450,19 +4445,6 @@ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config, driver = fdriver; } __std: - load = true; - err = snd_config_imake_integer(&m, driver, 1); - if (err < 0) - goto __err; - err = snd_config_add(loaded, m); - if (err < 0) { - if (err == -EEXIST) { - snd_config_delete(m); - load = false; - } else { - goto __err; - } - } private_data = _snd_config_hook_private_data(card, driver); if (!private_data) { err = -ENOMEM; @@ -4471,22 +4453,17 @@ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config, err = _snd_config_hook_table(root, config, private_data); if (err < 0) goto __err; - if (load) - err = snd_config_hook_load(root, config, &n, private_data); + err = snd_config_hook_load(root, config, &n, private_data); __err: if (private_data) snd_config_delete(private_data); free(fdriver); if (err < 0) - goto __fin_err; + return err; } } while (card >= 0); - snd_config_delete(loaded); *dst = NULL; return 0; -__fin_err: - snd_config_delete(loaded); - return err; } #ifndef DOC_HIDDEN SND_DLSYM_BUILD_VERSION(snd_config_hook_load_for_all_cards, SND_CONFIG_DLSYM_VERSION_HOOK); From eeca04741d44b0943ed4ea7c2f756d4d487ac46c Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 18 Sep 2025 15:34:09 +0200 Subject: [PATCH 08/34] conf: fix parse_array_def - merge arrays A tiny overlook caused wrong array merge. New compound member must be always created. Signed-off-by: Jaroslav Kysela --- src/conf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conf.c b/src/conf.c index 4dfa9cc5..b9417a8a 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1274,7 +1274,7 @@ static int parse_array_def(snd_config_t *parent, input_t *input, int *idx, int s if (_snd_config_search(parent, static_id, -1, &n) == 0) { if (override) { snd_config_delete(n); - n = NULL; + /* fallthrough to break */ } else { /* merge */ (*idx)++; @@ -1283,6 +1283,7 @@ static int parse_array_def(snd_config_t *parent, input_t *input, int *idx, int s } break; } + n = NULL; id = strdup(static_id); if (id == NULL) return -ENOMEM; From eda76146c5653ff1d5bc4b4c53f7a2d5ccc17da2 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 18 Sep 2025 11:49:37 +0200 Subject: [PATCH 09/34] conf: fix load_for_all_cards() - do not merge the card specific contents Signed-off-by: Jaroslav Kysela --- src/conf.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/conf.c b/src/conf.c index b9417a8a..91aa628b 100644 --- a/src/conf.c +++ b/src/conf.c @@ -4109,14 +4109,17 @@ static int config_filename_filter(const struct dirent64 *dirent) return 0; } -static int config_file_open(snd_config_t *root, const char *filename) +static int config_file_open(snd_config_t *root, const char *filename, int merge) { snd_input_t *in; int err; err = snd_input_stdio_open(&in, filename, "r"); if (err >= 0) { - err = snd_config_load(root, in); + if (merge) + err = snd_config_load(root, in); + else + err = snd_config_load_override(root, in); snd_input_close(in); if (err < 0) SNDERR("%s may be old or corrupted: consider to remove or fix it", filename); @@ -4126,7 +4129,7 @@ static int config_file_open(snd_config_t *root, const char *filename) return err; } -static int config_file_load(snd_config_t *root, const char *fn, int errors) +static int config_file_load(snd_config_t *root, const char *fn, int errors, int merge) { struct stat64 st; struct dirent64 **namelist; @@ -4139,7 +4142,7 @@ static int config_file_load(snd_config_t *root, const char *fn, int errors) return 1; } if (!S_ISDIR(st.st_mode)) - return config_file_open(root, fn); + return config_file_open(root, fn, merge); #ifndef DOC_HIDDEN #if defined(_GNU_SOURCE) && \ !defined(__NetBSD__) && \ @@ -4165,7 +4168,7 @@ static int config_file_load(snd_config_t *root, const char *fn, int errors) snprintf(filename, sl, "%s/%s", fn, namelist[j]->d_name); filename[sl-1] = '\0'; - err = config_file_open(root, filename); + err = config_file_open(root, filename, merge); free(filename); } free(namelist[j]); @@ -4177,20 +4180,20 @@ static int config_file_load(snd_config_t *root, const char *fn, int errors) return 0; } -static int config_file_load_user(snd_config_t *root, const char *fn, int errors) +static int config_file_load_user(snd_config_t *root, const char *fn, int errors, int merge) { char *fn2; int err; err = snd_user_file(fn, &fn2); if (err < 0) - return config_file_load(root, fn, errors); - err = config_file_load(root, fn2, errors); + return config_file_load(root, fn, errors, merge); + err = config_file_load(root, fn2, errors, merge); free(fn2); return err; } -static int config_file_load_user_all(snd_config_t *_root, snd_config_t *_file, int errors) +static int config_file_load_user_all(snd_config_t *_root, snd_config_t *_file, int errors, int merge) { snd_config_t *file = _file, *root = _root, *n; char *name, *name2, *remain, *rname = NULL; @@ -4221,7 +4224,7 @@ static int config_file_load_user_all(snd_config_t *_root, snd_config_t *_file, i *remain = '\0'; remain += 3; } - err = config_file_load_user(root, name2, errors); + err = config_file_load_user(root, name2, errors, merge); if (err < 0) goto _err; if (err == 0) /* first hit wins */ @@ -4270,7 +4273,7 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t { snd_config_t *n; snd_config_iterator_t i, next; - int err, idx = 0, errors = 1, hit; + int err, idx = 0, errors = 1, merge = 1, hit; assert(root && dst); if ((err = snd_config_search(config, "errors", &n)) >= 0) { @@ -4280,6 +4283,10 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t return errors; } } + /* special case, we know the card number (may be multiple times) */ + if (private_data && snd_config_search(private_data, "integer", &n) >= 0) { + merge = 0; + } if ((err = snd_config_search(config, "files", &n)) < 0) { SNDERR("Unable to find field files in the pre-load section"); return -EINVAL; @@ -4292,6 +4299,7 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t SNDERR("Invalid type for field filenames"); goto _err; } + do { hit = 0; snd_config_for_each(i, next, n) { @@ -4305,7 +4313,7 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t goto _err; } if (i == idx) { - err = config_file_load_user_all(root, n, errors); + err = config_file_load_user_all(root, n, errors, merge); if (err < 0) goto _err; idx++; From 11a716d1d09fd15c6a04a157601fa432131a6880 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 3 Nov 2025 16:01:34 +0100 Subject: [PATCH 10/34] rawmidi: Fix SNDRV_RAWMIDI_INFO_STREAM_INACTIVE duplicate definition The origin of this define is in include/alsa/sound/uapi/asound.h included from include/local.h. Skip redefinition in the internal build. Fixes: e6d0db9d ("rawmidi: Fix the prefix of the inactive stream flag") Signed-off-by: Jaroslav Kysela --- include/rawmidi.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/rawmidi.h b/include/rawmidi.h index f3676d29..554e706f 100644 --- a/include/rawmidi.h +++ b/include/rawmidi.h @@ -102,7 +102,9 @@ typedef enum _snd_rawmidi_read_mode { /** rawmidi info bit flags */ #define SND_RAWMIDI_INFO_UMP 0x00000008 /**< rawmidi is UMP */ #define SND_RAWMIDI_INFO_STREAM_INACTIVE 0x00000010 /**< the selected substream is inactive */ +#ifndef SNDRV_RAWMIDI_INFO_STREAM_INACTIVE #define SNDRV_RAWMIDI_INFO_STREAM_INACTIVE SND_RAWMIDI_INFO_STREAM_INACTIVE /* only for compatibility */ +#endif int snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi, const char *name, int mode); From fa6e83d78025cf14aa8a734b452709f54b160b20 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 3 Nov 2025 16:12:07 +0100 Subject: [PATCH 11/34] topology: fix nibble warning in tplg_save_quoted() Signed-off-by: Jaroslav Kysela --- src/topology/save.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/topology/save.c b/src/topology/save.c index 59f4759b..142fa536 100644 --- a/src/topology/save.c +++ b/src/topology/save.c @@ -226,9 +226,14 @@ static int tplg_check_quoted(const unsigned char *p) return 0; } +static unsigned char nibble(unsigned char b) +{ + b &= 0x0f; + return b < 10 ? b + '0' : b + 'a'; +} + static int tplg_save_quoted(struct tplg_buf *dst, const char *str) { - static const char nibble[16] = "0123456789abcdef"; unsigned char *p, *d, *t; int c; @@ -270,8 +275,8 @@ static int tplg_save_quoted(struct tplg_buf *dst, const char *str) } else { *t++ = '\\'; *t++ = 'x'; - *t++ = nibble[(c >> 4) & 0x0f]; - *t++ = nibble[(c >> 0) & 0x0f]; + *t++ = nibble(c >> 4); + *t++ = nibble(c >> 0); } break; } From 0a4e8854d53cf06a3c1cf4d60ce1e013f2ead487 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 3 Nov 2025 15:57:16 +0100 Subject: [PATCH 12/34] error: do not export internal snd_err_msg variable This variable was never intended to modify from outside (not in public headers). Signed-off-by: Jaroslav Kysela --- include/local.h | 6 +++--- src/error.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/local.h b/include/local.h index 2498cd26..fec332e5 100644 --- a/include/local.h +++ b/include/local.h @@ -274,9 +274,9 @@ size_t snd_strlcat(char *dst, const char *src, size_t size); */ #ifndef NDEBUG #define CHECK_SANITY(x) x -extern snd_lib_error_handler_t snd_err_msg; -#define SNDMSG(args...) snd_err_msg(__FILE__, __LINE__, __func__, 0, ##args) -#define SYSMSG(args...) snd_err_msg(__FILE__, __LINE__, __func__, errno, ##args) +extern snd_lib_error_handler_t _snd_err_msg; +#define SNDMSG(args...) _snd_err_msg(__FILE__, __LINE__, __func__, 0, ##args) +#define SYSMSG(args...) _snd_err_msg(__FILE__, __LINE__, __func__, errno, ##args) #else #define CHECK_SANITY(x) 0 /* not evaluated */ #define SNDMSG(args...) /* nop */ diff --git a/src/error.c b/src/error.c index 8db7556b..0eefce0e 100644 --- a/src/error.c +++ b/src/error.c @@ -131,7 +131,7 @@ int snd_lib_error_set_handler(snd_lib_error_handler_t handler) snd_lib_error = handler == NULL ? snd_lib_error_default : handler; #ifndef NDEBUG if (snd_lib_error != snd_lib_error_default) - snd_err_msg = snd_lib_error; + _snd_err_msg = snd_lib_error; #endif return 0; } @@ -174,7 +174,7 @@ static void snd_err_msg_default(const char *file, int line, const char *function /** * The ALSA error message handler */ -snd_lib_error_handler_t snd_err_msg = snd_err_msg_default; +snd_lib_error_handler_t _snd_err_msg = snd_err_msg_default; #endif From 7248b0c6609deedc0a9b9d62ab32f1f370b535fb Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 6 Nov 2025 14:29:54 +0100 Subject: [PATCH 13/34] redesign the message log functions Add priority level and interface classifiers. Define macros for all priority level types to keep the callers more readable. Ensure the compatibility with previous logging mechanism. Signed-off-by: Jaroslav Kysela --- include/error.h | 91 ++++++++++++++++---- include/local.h | 5 +- src/Versions.in.in | 13 +++ src/conf.c | 2 +- src/control/namehint.c | 14 ++-- src/error.c | 184 +++++++++++++++++++++++++++++------------ 6 files changed, 230 insertions(+), 79 deletions(-) diff --git a/include/error.h b/include/error.h index 13f59d55..8b9b8591 100644 --- a/include/error.h +++ b/include/error.h @@ -49,42 +49,103 @@ extern "C" { const char *snd_strerror(int errnum); +#define SND_LOG_ERROR 1 /**< error priority level */ +#define SND_LOG_WARN 2 /**< warning priority level */ +#define SND_LOG_INFO 3 /**< info priority level */ +#define SND_LOG_DEBUG 4 /**< debug priority level */ +#define SND_LOG_TRACE 5 /**< trace priority level */ + +#define SND_ILOG_CORE 1 /**< core library code */ +#define SND_ILOG_CONFIG 2 /**< configuration parsing and operations */ +#define SND_ILOG_CONTROL 3 /**< control API */ +#define SND_ILOG_HWDEP 4 /**< hwdep API */ +#define SND_ILOG_TIMER 5 /**< timer API */ +#define SND_ILOG_RAWMIDI 6 /**< RawMidi API */ +#define SND_ILOG_PCM 7 /**< PCM API */ +#define SND_ILOG_MIXER 8 /**< mixer API */ +#define SND_ILOG_SEQUENCER 9 /**< sequencer API */ +#define SND_ILOG_UCM 10 /**< UCM API */ +#define SND_ILOG_TOPOLOGY 11 /**< topology API */ +#define SND_ILOG_ASERVER 12 /**< aserver */ + /** - * \brief Error handler callback. + * \brief Log handler callback. + * \param prio Priority (SND_LOG_* defines). + * \param interface Interface (SND_ILOG_* defines). * \param file Source file name. * \param line Line number. * \param function Function name. - * \param err Value of \c errno, or 0 if not relevant. + * \param errcode Value of \c errno, or 0 if not relevant. * \param fmt \c printf(3) format. * \param ... \c printf(3) arguments. * * A function of this type is called by the ALSA library when an error occurs. * This function usually shows the message on the screen, and/or logs it. */ -typedef void (*snd_lib_error_handler_t)(const char *file, int line, const char *function, int err, const char *fmt, ...) /* __attribute__ ((format (printf, 5, 6))) */; -extern snd_lib_error_handler_t snd_lib_error; -extern int snd_lib_error_set_handler(snd_lib_error_handler_t handler); +typedef void (*snd_lib_log_handler_t)(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg); +extern snd_lib_log_handler_t snd_lib_vlog; +void snd_lib_log(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...) /* __attribute__ ((format (printf, 7, 8))) */; +void snd_lib_check(int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...); +snd_lib_log_handler_t snd_lib_log_set_handler(snd_lib_log_handler_t handler); +snd_lib_log_handler_t snd_lib_log_set_local(snd_lib_log_handler_t handler); #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95) -#define SNDERR(...) snd_lib_error(__FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows a sound error message. */ -#define SYSERR(...) snd_lib_error(__FILE__, __LINE__, __func__, errno, __VA_ARGS__) /**< Shows a system error message (related to \c errno). */ +#define snd_error(interface, ...) snd_lib_log(SND_LOG_ERROR, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows an error log message. */ +#define snd_errornum(interface, ...) snd_lib_log(SND_LOG_ERROR, SND_ILOG_##interface, __FILE__, __LINE__, __func__, errno, __VA_ARGS__) /**< Shows a system error log message (related to \c errno). */ +#define snd_warn(interface, ...) snd_lib_log(SND_LOG_WARN, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows an error log message. */ +#define snd_info(interface, ...) snd_lib_log(SND_LOG_INFO, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows an informational log message. */ +#define snd_debug(interface, ...) snd_lib_log(SND_LOG_DEBUG, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows an debug log message. */ +#define snd_trace(interface, ...) snd_lib_log(SND_LOG_TRACE, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows an trace log message. */ +#define snd_check(interface, ...) snd_lib_check(SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows an check log message. */ +#define snd_checknum(interface, ...) snd_lib_check(SND_ILOG_##interface, __FILE__, __LINE__, __func__, errno, __VA_ARGS__) /**< Shows an check log message (related to \c errno). */ #else -#define SNDERR(args...) snd_lib_error(__FILE__, __LINE__, __func__, 0, ##args) /**< Shows a sound error message. */ -#define SYSERR(args...) snd_lib_error(__FILE__, __LINE__, __func__, errno, ##args) /**< Shows a system error message (related to \c errno). */ +#define snd_error(interface, args...) snd_lib_log(SND_LOG_ERROR, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args) /**< Shows an error log message. */ +#define snd_errornum(interface, args...) snd_lib_log(SND_LOG_ERROR, SND_ILOG_##interface, __FILE__, __LINE__, __func__, errno, ##args) /**< Shows a system error log message (related to \c errno). */ +#define snd_warn(interface, args...) snd_lib_log(SND_LOG_WARN, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args) /**< Shows an error log message. */ +#define snd_info(interface, args...) snd_lib_log(SND_LOG_INFO, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args) /**< Shows an error log message. */ +#define snd_debug(interface, args...) snd_lib_log(SND_LOG_DEBUG, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args) /**< Shows an error log message. */ +#define snd_trace(interface, args...) snd_lib_log(SND_LOG_TRACE, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args) /**< Shows an trace log message. */ +#define snd_check(interface, args...) snd_lib_check(SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args) /**< Shows an check log message. */ +#define snd_check(interface, args...) snd_lib_check(SND_ILOG_##interface, __FILE__, __LINE__, __func__, errno, ##args) /**< Shows an check log message (related to \c errno). */ #endif +/** + * \brief Error handler callback. + * \param file Source file name. + * \param line Line number. + * \param function Function name. + * \param errcode Value of \c errno, or 0 if not relevant. + * \param fmt \c printf(3) format. + * \param ... \c printf(3) arguments. + * \deprecated Since 1.2.15 + * + * A function of this type is called by the ALSA library when an error occurs. + * This function usually shows the message on the screen, and/or logs it. + */ +typedef void (*snd_lib_error_handler_t)(const char *file, int line, const char *function, int errcode, const char *fmt, ...) /* __attribute__ ((format (printf, 5, 6))) */; +extern snd_lib_error_handler_t snd_lib_error; +int snd_lib_error_set_handler(snd_lib_error_handler_t handler); + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95) +#define SNDERR(...) snd_lib_log(SND_LOG_ERROR, 0, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows a sound error message. */ +#define SYSERR(...) snd_lib_log(SND_LOG_ERROR, 0, __FILE__, __LINE__, __func__, errno, __VA_ARGS__) /**< Shows a system error message (related to \c errno). */ +#else +#define SNDERR(args...) snd_lib_log(SND_LOG_ERROR, 0, __FILE__, __LINE__, __func__, 0, ##args) /**< Shows a sound error message. */ +#define SYSERR(args...) snd_lib_log(SND_LOG_ERROR, 0, __FILE__, __LINE__, __func__, errno, ##args) /**< Shows a system error message (related to \c errno). */ +#endif + +/** Local error handler function type */ +typedef void (*snd_local_error_handler_t)(const char *file, int line, + const char *func, int errcode, + const char *fmt, va_list arg); +snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func); + /** \} */ #ifdef __cplusplus } #endif -/** Local error handler function type */ -typedef void (*snd_local_error_handler_t)(const char *file, int line, - const char *func, int err, - const char *fmt, va_list arg); -snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func); #endif /* __ALSA_ERROR_H */ - diff --git a/include/local.h b/include/local.h index fec332e5..da70cf52 100644 --- a/include/local.h +++ b/include/local.h @@ -274,9 +274,8 @@ size_t snd_strlcat(char *dst, const char *src, size_t size); */ #ifndef NDEBUG #define CHECK_SANITY(x) x -extern snd_lib_error_handler_t _snd_err_msg; -#define SNDMSG(args...) _snd_err_msg(__FILE__, __LINE__, __func__, 0, ##args) -#define SYSMSG(args...) _snd_err_msg(__FILE__, __LINE__, __func__, errno, ##args) +#define SNDMSG(args...) snd_lib_check(0, __FILE__, __LINE__, __func__, 0, ##args) +#define SYSMSG(args...) snd_lib_check(0, __FILE__, __LINE__, __func__, errno, ##args) #else #define CHECK_SANITY(x) 0 /* not evaluated */ #define SNDMSG(args...) /* nop */ diff --git a/src/Versions.in.in b/src/Versions.in.in index 4aa2e13b..36b6ab5d 100644 --- a/src/Versions.in.in +++ b/src/Versions.in.in @@ -214,3 +214,16 @@ ALSA_1.2.13 { @SYMBOL_PREFIX@snd_ump_packet_length; #endif } ALSA_1.2.10; + + +ALSA_1.2.15 { + global: + + @SYMBOL_PREFIX@snd_lib_vlog; + @SYMBOL_PREFIX@snd_lib_log; + @SYMBOL_PREFIX@snd_lib_log_set_handler; + @SYMBOL_PREFIX@snd_lib_log_set_local; + @SYMBOL_PREFIX@snd_lib_log_priority; + @SYMBOL_PREFIX@snd_lib_log_interface; + @SYMBOL_PREFIX@snd_lib_check; +} ALSA_1.2.13; diff --git a/src/conf.c b/src/conf.c index 91aa628b..92446e61 100644 --- a/src/conf.c +++ b/src/conf.c @@ -811,7 +811,7 @@ static int get_char_skip_comments(input_t *input) dirp = opendir(str); if (!dirp) { - SNDERR("Invalid search dir %s", str); + snd_error(CONFIG, "Invalid search dir %s", str); free(str); return -EINVAL; } diff --git a/src/control/namehint.c b/src/control/namehint.c index 11783c0c..8d6c64d5 100644 --- a/src/control/namehint.c +++ b/src/control/namehint.c @@ -104,7 +104,9 @@ static int hint_list_add_custom(struct hint_list *list, return err; } -static void zero_handler(const char *file ATTRIBUTE_UNUSED, +static void zero_handler(int prio ATTRIBUTE_UNUSED, + int interface ATTRIBUTE_UNUSED, + const char *file ATTRIBUTE_UNUSED, int line ATTRIBUTE_UNUSED, const char *function ATTRIBUTE_UNUSED, int err ATTRIBUTE_UNUSED, @@ -239,7 +241,7 @@ static int try_config(snd_config_t *config, const char *base, const char *name) { - snd_local_error_handler_t eh; + snd_lib_log_handler_t eh; snd_config_t *res = NULL, *cfg, *cfg1, *n; snd_config_iterator_t i, next; char *buf, *buf1 = NULL, *buf2; @@ -266,9 +268,9 @@ static int try_config(snd_config_t *config, sprintf(buf, "%s:CARD=%s", name, snd_ctl_card_info_get_id(list->info)); else strcpy(buf, name); - eh = snd_lib_error_set_local(&zero_handler); + eh = snd_lib_log_set_local(&zero_handler); err = snd_config_search_definition(config, base, buf, &res); - snd_lib_error_set_local(eh); + snd_lib_log_set_local(eh); if (err < 0) goto __skip_add; cleanup_res = 1; @@ -369,9 +371,9 @@ static int try_config(snd_config_t *config, goto __ok; /* find, if all parameters have a default, */ /* otherwise filter this definition */ - eh = snd_lib_error_set_local(&zero_handler); + eh = snd_lib_log_set_local(&zero_handler); err = snd_config_search_alias_hooks(config, base, buf, &res); - snd_lib_error_set_local(eh); + snd_lib_log_set_local(eh); if (err < 0) goto __cleanup; if (snd_config_search(res, "@args", &cfg) >= 0) { diff --git a/src/error.c b/src/error.c index 0eefce0e..e077cb95 100644 --- a/src/error.c +++ b/src/error.c @@ -68,47 +68,100 @@ const char *snd_strerror(int errnum) #endif #endif +static TLS_PFX snd_lib_log_handler_t local_log = NULL; static TLS_PFX snd_local_error_handler_t local_error = NULL; /** - * \brief Install local error handler - * \param func The local error handler function - * \retval Previous local error handler function + * \brief Install local log handler + * \param func The local log handler function + * \retval Previous local log handler function */ -snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func) +snd_lib_log_handler_t snd_lib_log_set_local(snd_lib_log_handler_t func) { - snd_local_error_handler_t old = local_error; - local_error = func; + snd_lib_log_handler_t old = local_log; + local_log = func; return old; } /** - * \brief The default error handler function. + * \brief The default log handler function. + * \param prio Priority value (SND_LOG_*). + * \param interface Interface (SND_ILOG_*). * \param file The filename where the error was hit. * \param line The line number. * \param function The function name. - * \param err The error code. + * \param errcode The error code. * \param fmt The message (including the format characters). * \param ... Optional arguments. * * If a local error function has been installed for the current thread by - * \ref snd_lib_error_set_local, it is called. Otherwise, prints the error + * \ref snd_lib_log_set_local, it is called. Otherwise, prints the error * message including location to \c stderr. */ -static void snd_lib_error_default(const char *file, int line, const char *function, int err, const char *fmt, ...) +static void snd_lib_vlog_default(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg) { - va_list arg; - va_start(arg, fmt); - if (local_error) { - local_error(file, line, function, err, fmt, arg); - va_end(arg); + if (local_log) { + local_log(prio, interface, file, line, function, errcode, fmt, arg); + return; + } + if (local_error && prio == SND_LOG_ERROR) { + local_error(file, line, function, errcode, fmt, arg); return; } fprintf(stderr, "ALSA lib %s:%i:(%s) ", file, line, function); vfprintf(stderr, fmt, arg); - if (err) - fprintf(stderr, ": %s", snd_strerror(err)); + if (errcode) + fprintf(stderr, ": %s", snd_strerror(errcode)); putc('\n', stderr); +} + +/** + * \brief Root log handler function. + * \param prio Priority value (SND_LOG_*). + * \param interface Interface (SND_ILOG_*). + * \param file The filename where the error was hit. + * \param line The line number. + * \param function The function name. + * \param errcode The error code. + * \param fmt The message (including the format characters). + * \param ... Optional arguments. + */ +void snd_lib_log(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...) +{ + va_list arg; + va_start(arg, fmt); + snd_lib_vlog(prio, interface, file, line, function, errcode, fmt, arg); + va_end(arg); +} + +/** + * \brief The check point function. + * \param interface Interface (SND_ILOG_*). + * \param file The filename where the error was hit. + * \param line The line number. + * \param function The function name. + * \param errcode The error code. + * \param fmt The message (including the format characters). + * \param ... Optional arguments. + * + * The error message is passed with error priority level to snd_lib_vlog handler. + */ +void snd_lib_check(int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...) +{ + const char *verbose; + + va_list arg; + va_start(arg, fmt); + verbose = getenv("LIBASOUND_DEBUG"); + if (! verbose || ! *verbose) + goto finish; + snd_lib_vlog(SND_LOG_ERROR, interface, file, line, function, errcode, fmt, arg); +#ifdef ALSA_DEBUG_ASSERT + verbose = getenv("LIBASOUND_DEBUG_ASSERT"); + if (verbose && *verbose) + assert(0); +#endif +finish: va_end(arg); } @@ -117,11 +170,71 @@ static void snd_lib_error_default(const char *file, int line, const char *functi * Pointer to the error handler function. * For internal use only. */ +snd_lib_log_handler_t snd_lib_vlog = snd_lib_vlog_default; + +/** + * \brief Sets the log handler. + * \param handler The pointer to the new log handler function. + * \retval Previous log handler function + * + * This function sets a new log handler, or (if \c handler is \c NULL) + * the default one which prints the error messages to \c stderr. + */ +snd_lib_log_handler_t snd_lib_log_set_handler(snd_lib_log_handler_t handler) +{ + snd_lib_log_handler_t old = snd_lib_vlog; + snd_lib_vlog = handler == NULL ? snd_lib_vlog_default : handler; + return old; +} + + +/** + * \brief Install local error handler + * \param func The local error handler function + * \retval Previous local error handler function + * \deprecated Since 1.2.15 + */ +snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func) +{ + snd_local_error_handler_t old = local_error; + local_error = func; + return old; +} +link_warning(snd_lib_error_set_local, "Warning: snd_lib_error_set_local is deprecated, use snd_lib_log_set_local"); + +/** + * \brief The default error handler function. + * \param file The filename where the error was hit. + * \param line The line number. + * \param function The function name. + * \param errcode The error code. + * \param fmt The message (including the format characters). + * \param ... Optional arguments. + * \deprecated Since 1.2.15 + * + * Use snd_lib_vlog handler to print error message for anonymous interface. + */ +static void snd_lib_error_default(const char *file, int line, const char *function, int errcode, const char *fmt, ...) +{ + va_list arg; + va_start(arg, fmt); + snd_lib_vlog(SND_LOG_ERROR, 0, file, line, function, errcode, fmt, arg); + va_end(arg); +} + +/** + * \ingroup Error + * \deprecated Since 1.2.15 + * Pointer to the error handler function. + * For internal use only. + */ snd_lib_error_handler_t snd_lib_error = snd_lib_error_default; +link_warning(snd_lib_error, "Warning: snd_lib_error is deprecated, use snd_log interface"); /** * \brief Sets the error handler. * \param handler The pointer to the new error handler function. + * \deprecated Since 1.2.15 * * This function sets a new error handler, or (if \c handler is \c NULL) * the default one which prints the error messages to \c stderr. @@ -129,10 +242,6 @@ snd_lib_error_handler_t snd_lib_error = snd_lib_error_default; int snd_lib_error_set_handler(snd_lib_error_handler_t handler) { snd_lib_error = handler == NULL ? snd_lib_error_default : handler; -#ifndef NDEBUG - if (snd_lib_error != snd_lib_error_default) - _snd_err_msg = snd_lib_error; -#endif return 0; } @@ -145,39 +254,6 @@ const char *snd_asoundlib_version(void) return SND_LIB_VERSION_STR; } -#ifndef NDEBUG -/* - * internal error handling - */ -static void snd_err_msg_default(const char *file, int line, const char *function, int err, const char *fmt, ...) -{ - va_list arg; - const char *verbose; - - verbose = getenv("LIBASOUND_DEBUG"); - if (! verbose || ! *verbose) - return; - va_start(arg, fmt); - fprintf(stderr, "ALSA lib %s:%i:(%s) ", file, line, function); - vfprintf(stderr, fmt, arg); - if (err) - fprintf(stderr, ": %s", snd_strerror(err)); - putc('\n', stderr); - va_end(arg); -#ifdef ALSA_DEBUG_ASSERT - verbose = getenv("LIBASOUND_DEBUG_ASSERT"); - if (verbose && *verbose) - assert(0); -#endif -} - -/** - * The ALSA error message handler - */ -snd_lib_error_handler_t _snd_err_msg = snd_err_msg_default; - -#endif - /** * \brief Copy a C-string into a sized buffer * \param dst Where to copy the string to From 492df4bb94dfeaf1bd8feae5880098bf31234c1f Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 6 Nov 2025 14:45:33 +0100 Subject: [PATCH 14/34] error: add priority and interface strings to the log messages Signed-off-by: Jaroslav Kysela --- include/error.h | 2 ++ src/error.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/include/error.h b/include/error.h index 8b9b8591..7e4ab6a7 100644 --- a/include/error.h +++ b/include/error.h @@ -54,6 +54,7 @@ const char *snd_strerror(int errnum); #define SND_LOG_INFO 3 /**< info priority level */ #define SND_LOG_DEBUG 4 /**< debug priority level */ #define SND_LOG_TRACE 5 /**< trace priority level */ +#define SND_LOG_LAST SND_LOG_TRACE #define SND_ILOG_CORE 1 /**< core library code */ #define SND_ILOG_CONFIG 2 /**< configuration parsing and operations */ @@ -67,6 +68,7 @@ const char *snd_strerror(int errnum); #define SND_ILOG_UCM 10 /**< UCM API */ #define SND_ILOG_TOPOLOGY 11 /**< topology API */ #define SND_ILOG_ASERVER 12 /**< aserver */ +#define SND_ILOG_LAST SND_ILOG_ASERVER /** * \brief Log handler callback. diff --git a/src/error.c b/src/error.c index e077cb95..56ff27c7 100644 --- a/src/error.c +++ b/src/error.c @@ -83,6 +83,61 @@ snd_lib_log_handler_t snd_lib_log_set_local(snd_lib_log_handler_t func) return old; } +/** + * Array of log priority level names. + */ +static const char *snd_log_prio_names[SND_LOG_LAST + 1] = { + [0] = NULL, + [SND_LOG_ERROR] = "error", + [SND_LOG_WARN] = "warning", + [SND_LOG_INFO] = "info", + [SND_LOG_DEBUG] = "debug", + [SND_LOG_TRACE] = "trace", +}; + +/** + * Array of interface names. + */ +static const char *snd_ilog_interface_names[SND_ILOG_LAST + 1] = { + [0] = NULL, + [SND_ILOG_CORE] = "core", + [SND_ILOG_CONFIG] = "config", + [SND_ILOG_CONTROL] = "control", + [SND_ILOG_HWDEP] = "hwdep", + [SND_ILOG_TIMER] = "timer", + [SND_ILOG_RAWMIDI] = "rawmidi", + [SND_ILOG_PCM] = "pcm", + [SND_ILOG_MIXER] = "mixer", + [SND_ILOG_SEQUENCER] = "sequencer", + [SND_ILOG_UCM] = "ucm", + [SND_ILOG_TOPOLOGY] = "topology", + [SND_ILOG_ASERVER] = "aserver", +}; + +/** + * \brief Function to convert log priority level to text. + * \param prio Priority value (SND_LOG_*). + * \return The textual representation of the priority level, or NULL if invalid. + */ +const char *snd_lib_log_priority(int prio) +{ + if (prio >= 0 && prio <= SND_LOG_TRACE) + return snd_log_prio_names[prio]; + return NULL; +} + +/** + * \brief Function to convert interface code to text. + * \param interface Interface (SND_ILOG_*). + * \return The textual representation of the interface code, or NULL if invalid. + */ +const char *snd_lib_log_interface(int interface) +{ + if (interface >= 0 && interface <= SND_ILOG_TOPOLOGY) + return snd_ilog_interface_names[interface]; + return NULL; +} + /** * \brief The default log handler function. * \param prio Priority value (SND_LOG_*). @@ -100,6 +155,8 @@ snd_lib_log_handler_t snd_lib_log_set_local(snd_lib_log_handler_t func) */ static void snd_lib_vlog_default(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg) { + const char *text; + if (local_log) { local_log(prio, interface, file, line, function, errcode, fmt, arg); return; @@ -109,6 +166,15 @@ static void snd_lib_vlog_default(int prio, int interface, const char *file, int return; } fprintf(stderr, "ALSA lib %s:%i:(%s) ", file, line, function); + + text = snd_lib_log_priority(prio); + if (text) + fprintf(stderr, "[%s] ", text); + + text = snd_lib_log_interface(interface); + if (text) + fprintf(stderr, "[%s] ", text); + vfprintf(stderr, fmt, arg); if (errcode) fprintf(stderr, ": %s", snd_strerror(errcode)); From 62c8e635dcce3d750985505ad20f8711d6dabf0d Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 6 Nov 2025 15:57:13 +0100 Subject: [PATCH 15/34] replace SNDMSG,SYSMSG,SNDERR,SYSERR with new log macros ... with interface identifiers Signed-off-by: Jaroslav Kysela --- aserver/aserver.c | 2 +- modules/mixer/simple/python.c | 8 +- modules/mixer/simple/sbasedl.c | 10 +- src/async.c | 6 +- src/conf.c | 134 +++++++-------- src/confeval.c | 8 +- src/confmisc.c | 128 +++++++-------- src/control/control.c | 24 +-- src/control/control_empty.c | 4 +- src/control/control_ext.c | 4 +- src/control/control_hw.c | 23 +-- src/control/control_remap.c | 36 ++--- src/control/control_shm.c | 36 ++--- src/control/eld.c | 6 +- src/control/hcontrol.c | 4 +- src/control/namehint.c | 10 +- src/control/setup.c | 40 ++--- src/control/tlv.c | 8 +- src/dlmisc.c | 15 +- src/hwdep/hwdep.c | 24 +-- src/hwdep/hwdep_hw.c | 2 +- src/mixer/simple_abst.c | 18 +-- src/mixer/simple_none.c | 8 +- src/pcm/pcm.c | 286 ++++++++++++++++++--------------- src/pcm/pcm_adpcm.c | 6 +- src/pcm/pcm_alaw.c | 6 +- src/pcm/pcm_asym.c | 7 +- src/pcm/pcm_copy.c | 4 +- src/pcm/pcm_direct.c | 151 ++++++++--------- src/pcm/pcm_direct.h | 2 +- src/pcm/pcm_dmix.c | 24 +-- src/pcm/pcm_dshare.c | 22 +-- src/pcm/pcm_dsnoop.c | 20 +-- src/pcm/pcm_empty.c | 4 +- src/pcm/pcm_extplug.c | 23 +-- src/pcm/pcm_file.c | 44 ++--- src/pcm/pcm_hooks.c | 42 ++--- src/pcm/pcm_hw.c | 150 ++++++++--------- src/pcm/pcm_iec958.c | 18 +-- src/pcm/pcm_ioplug.c | 11 +- src/pcm/pcm_ladspa.c | 68 ++++---- src/pcm/pcm_lfloat.c | 10 +- src/pcm/pcm_linear.c | 6 +- src/pcm/pcm_meter.c | 28 ++-- src/pcm/pcm_misc.c | 22 +-- src/pcm/pcm_mmap.c | 36 ++--- src/pcm/pcm_mmap_emul.c | 4 +- src/pcm/pcm_mulaw.c | 6 +- src/pcm/pcm_multi.c | 32 ++-- src/pcm/pcm_null.c | 8 +- src/pcm/pcm_params.c | 2 +- src/pcm/pcm_plug.c | 29 ++-- src/pcm/pcm_plugin.c | 12 +- src/pcm/pcm_rate.c | 22 +-- src/pcm/pcm_rate_linear.c | 9 +- src/pcm/pcm_route.c | 30 ++-- src/pcm/pcm_share.c | 40 ++--- src/pcm/pcm_shm.c | 48 +++--- src/pcm/pcm_softvol.c | 60 +++---- src/pcm/scopes/level.c | 8 +- src/rawmidi/rawmidi.c | 20 +-- src/rawmidi/rawmidi_hw.c | 22 +-- src/seq/seq.c | 26 +-- src/seq/seq_hw.c | 14 +- src/seq/seqmid.c | 14 +- src/socket.c | 4 +- src/timer/timer.c | 26 +-- src/timer/timer_hw.c | 12 +- src/timer/timer_query.c | 24 +-- src/timer/timer_query_hw.c | 2 +- src/topology/builder.c | 38 +++-- src/topology/channel.c | 2 +- src/topology/ctl.c | 77 +++++---- src/topology/dapm.c | 92 ++++++----- src/topology/data.c | 93 ++++++----- src/topology/decoder.c | 16 +- src/topology/elem.c | 2 +- src/topology/ops.c | 2 +- src/topology/parser.c | 35 ++-- src/topology/pcm.c | 94 ++++++----- src/topology/save.c | 18 ++- src/topology/text.c | 2 +- 82 files changed, 1292 insertions(+), 1201 deletions(-) diff --git a/aserver/aserver.c b/aserver/aserver.c index 50ee3992..1924021c 100644 --- a/aserver/aserver.c +++ b/aserver/aserver.c @@ -1056,7 +1056,7 @@ int main(int argc, char **argv) return 1; } if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for server %s definition", srvname); + snd_error(ASERVER, "Invalid type for server %s definition", srvname); return -EINVAL; } snd_config_for_each(i, next, conf) { diff --git a/modules/mixer/simple/python.c b/modules/mixer/simple/python.c index 6b51e6bc..1df31049 100644 --- a/modules/mixer/simple/python.c +++ b/modules/mixer/simple/python.c @@ -931,7 +931,7 @@ static PyObject *new_helem(struct python_priv *priv, snd_hctl_elem_t *helem) } Py_XDECREF(obj1); } else { - SNDERR("Unable to create InternalMixer object"); + snd_error(MIXER, "Unable to create InternalMixer object"); return NULL; } if (obj2) { @@ -1073,7 +1073,7 @@ static int alsa_mixer_simple_pyinit(struct python_priv *priv, PyDict_SetItemString(mdict, "mixer", obj2); priv->py_mixer = obj2; } else { - SNDERR("Unable to create InternalMixer object"); + snd_error(MIXER, "Unable to create InternalMixer object"); return -EIO; } @@ -1083,7 +1083,7 @@ static int alsa_mixer_simple_pyinit(struct python_priv *priv, Py_XDECREF(obj); priv->py_event_func = PyDict_GetItemString(mdict, "event"); if (priv->py_event_func == NULL) { - SNDERR("Unable to find python function 'event'"); + snd_error(MIXER, "Unable to find python function 'event'"); return -EIO; } return 0; @@ -1128,7 +1128,7 @@ int alsa_mixer_simple_finit(snd_mixer_class_t *class, fp = fopen(file, "r"); if (fp == NULL) { - SNDERR("Unable to find python module '%s'", file); + snd_error(MIXER, "Unable to find python module '%s'", file); return -ENODEV; } diff --git a/modules/mixer/simple/sbasedl.c b/modules/mixer/simple/sbasedl.c index a1b33ccc..3ad7bdf4 100644 --- a/modules/mixer/simple/sbasedl.c +++ b/modules/mixer/simple/sbasedl.c @@ -65,27 +65,27 @@ int mixer_simple_basic_dlopen(snd_mixer_class_t *class, strcat(xlib, lib); h = snd_dlopen(xlib, RTLD_NOW, errbuf, sizeof(errbuf)); if (h == NULL) { - SNDERR("Unable to open library '%s': %s", xlib, errbuf); + snd_error(MIXER, "Unable to open library '%s': %s", xlib, errbuf); goto __error; } initpriv = dlsym(h, "alsa_mixer_sbasic_initpriv"); if (initpriv == NULL) { - SNDERR("Symbol 'alsa_mixer_sbasic_initpriv' was not found in '%s'", xlib); + snd_error(MIXER, "Symbol 'alsa_mixer_sbasic_initpriv' was not found in '%s'", xlib); goto __error; } priv->ops.event = dlsym(h, "alsa_mixer_sbasic_event"); if (priv->ops.event == NULL) { - SNDERR("Symbol 'alsa_mixer_sbasic_event' was not found in '%s'", xlib); + snd_error(MIXER, "Symbol 'alsa_mixer_sbasic_event' was not found in '%s'", xlib); goto __error; } priv->ops.selreg = dlsym(h, "alsa_mixer_sbasic_selreg"); if (priv->ops.selreg == NULL) { - SNDERR("Symbol 'alsa_mixer_sbasic_selreg' was not found in '%s'", xlib); + snd_error(MIXER, "Symbol 'alsa_mixer_sbasic_selreg' was not found in '%s'", xlib); goto __error; } priv->ops.sidreg = dlsym(h, "alsa_mixer_sbasic_sidreg"); if (priv->ops.sidreg == NULL) { - SNDERR("Symbol 'alsa_mixer_sbasic_sidreg' was not found in '%s'", xlib); + snd_error(MIXER, "Symbol 'alsa_mixer_sbasic_sidreg' was not found in '%s'", xlib); goto __error; } free(xlib); diff --git a/src/async.c b/src/async.c index 4117354a..4564c723 100644 --- a/src/async.c +++ b/src/async.c @@ -43,7 +43,7 @@ void snd_async_init(void) { snd_async_signo = __libc_allocate_rtsig(0); if (snd_async_signo < 0) { - SNDERR("Unable to find a RT signal to use for snd_async"); + snd_error(CORE, "Unable to find a RT signal to use for snd_async"); exit(1); } } @@ -135,7 +135,7 @@ int snd_async_add_handler(snd_async_handler_t **handler, int fd, assert(!previous_action.sa_sigaction); err = sigaction(snd_async_signo, &act, &previous_action); if (err < 0) { - SYSERR("sigaction"); + snd_errornum(CORE, "sigaction"); return -errno; } } @@ -189,7 +189,7 @@ int snd_async_del_handler(snd_async_handler_t *handler) if (!was_empty && list_empty(&snd_async_handlers)) { err = sigaction(snd_async_signo, &previous_action, NULL); if (err < 0) { - SYSERR("sigaction"); + snd_errornum(CORE, "sigaction"); return -errno; } memset(&previous_action, 0, sizeof(previous_action)); diff --git a/src/conf.c b/src/conf.c index 92446e61..d1fd2ccb 100644 --- a/src/conf.c +++ b/src/conf.c @@ -819,7 +819,7 @@ static int get_char_skip_comments(input_t *input) err = add_include_path(input->current, str); if (err < 0) { - SNDERR("Cannot add search dir %s", str); + snd_error(CORE, "Cannot add search dir %s", str); free(str); return err; } @@ -840,7 +840,7 @@ static int get_char_skip_comments(input_t *input) } if (err < 0) { - SNDERR("Cannot access file %s", str); + snd_error(CORE, "Cannot access file %s", str); free(str); return err; } @@ -1205,7 +1205,7 @@ static int parse_value(snd_config_t **_n, snd_config_t *parent, input_t *input, free(s); if (n) { if (n->type != SND_CONFIG_TYPE_REAL) { - SNDERR("%s is not a real", *id); + snd_error(CORE, "%s is not a real", *id); return -EINVAL; } } else { @@ -1221,7 +1221,7 @@ static int parse_value(snd_config_t **_n, snd_config_t *parent, input_t *input, free(s); if (n) { if (n->type != SND_CONFIG_TYPE_INTEGER && n->type != SND_CONFIG_TYPE_INTEGER64) { - SNDERR("%s is not an integer", *id); + snd_error(CORE, "%s is not an integer", *id); return -EINVAL; } } else { @@ -1242,7 +1242,7 @@ static int parse_value(snd_config_t **_n, snd_config_t *parent, input_t *input, } if (n) { if (n->type != SND_CONFIG_TYPE_STRING) { - SNDERR("%s is not a string", *id); + snd_error(CORE, "%s is not a string", *id); free(s); return -EINVAL; } @@ -1301,7 +1301,7 @@ static int parse_array_def(snd_config_t *parent, input_t *input, int *idx, int s if (!skip) { if (n) { if (n->type != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("%s is not a compound", id); + snd_error(CORE, "%s is not a compound", id); err = -EINVAL; goto __end; } @@ -1408,7 +1408,7 @@ static int parse_def(snd_config_t *parent, input_t *input, int skip, int overrid } if (mode != OVERRIDE) { if (n->type != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("%s is not a compound", id); + snd_error(CORE, "%s is not a compound", id); return -EINVAL; } n->u.compound.join = true; @@ -1419,7 +1419,7 @@ static int parse_def(snd_config_t *parent, input_t *input, int skip, int overrid snd_config_delete(n); } if (mode == MERGE) { - SNDERR("%s does not exists", id); + snd_error(CORE, "%s does not exists", id); err = -ENOENT; goto __end; } @@ -1446,7 +1446,7 @@ static int parse_def(snd_config_t *parent, input_t *input, int skip, int overrid } else { n = NULL; if (mode == MERGE) { - SNDERR("%s does not exists", id); + snd_error(CORE, "%s does not exists", id); err = -ENOENT; goto __end; } @@ -1460,7 +1460,7 @@ static int parse_def(snd_config_t *parent, input_t *input, int skip, int overrid if (!skip) { if (n) { if (n->type != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("%s is not a compound", id); + snd_error(CORE, "%s is not a compound", id); err = -EINVAL; goto __end; } @@ -1645,7 +1645,7 @@ int _snd_config_save_node_value(snd_config_t *n, snd_output_t *out, string_print(n->u.string, 0, out); break; case SND_CONFIG_TYPE_POINTER: - SNDERR("cannot save runtime pointer type"); + snd_error(CORE, "cannot save runtime pointer type"); return -EINVAL; case SND_CONFIG_TYPE_COMPOUND: array = snd_config_is_array(n); @@ -2012,13 +2012,13 @@ int _snd_config_load_with_include(snd_config_t *config, snd_input_t *in, str = strerror(-err); break; } - SNDERR("%s:%d:%d:%s", fd->name ? fd->name : "_toplevel_", fd->line, fd->column, str); + snd_error(CORE, "%s:%d:%d:%s", fd->name ? fd->name : "_toplevel_", fd->line, fd->column, str); goto _end; } err = get_char(&input); fd = input.current; if (err != LOCAL_UNEXPECTED_EOF) { - SNDERR("%s:%d:%d:Unexpected }", fd->name ? fd->name : "", fd->line, fd->column); + snd_error(CORE, "%s:%d:%d:Unexpected }", fd->name ? fd->name : "", fd->line, fd->column); err = -EINVAL; goto _end; } @@ -3565,9 +3565,9 @@ int snd_config_save(snd_config_t *config, snd_output_t *out) assert(key); \ if (!first && (strcmp(key, old_key) == 0 || maxloop <= 0)) { \ if (maxloop == 0) \ - SNDERR("maximum loop count reached (circular configuration?)"); \ + snd_error(CORE, "maximum loop count reached (circular configuration?)"); \ else \ - SNDERR("key %s refers to itself", key); \ + snd_error(CORE, "key %s refers to itself", key); \ err = -EINVAL; \ res = NULL; \ break; \ @@ -3971,12 +3971,12 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c err = snd_config_search(config, "func", &c); if (err < 0) { - SNDERR("Field func is missing"); + snd_error(CORE, "Field func is missing"); return err; } err = snd_config_get_string(c, &str); if (err < 0) { - SNDERR("Invalid type for field func"); + snd_error(CORE, "Invalid type for field func"); return err; } assert(str); @@ -3984,7 +3984,7 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c if (err >= 0) { snd_config_iterator_t i, next; if (snd_config_get_type(func_conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for func %s definition", str); + snd_error(CORE, "Invalid type for func %s definition", str); err = -EINVAL; goto _err; } @@ -3996,7 +3996,7 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c if (strcmp(id, "lib") == 0) { err = snd_config_get_string(n, &lib); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(CORE, "Invalid type for %s", id); goto _err; } continue; @@ -4004,12 +4004,12 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c if (strcmp(id, "func") == 0) { err = snd_config_get_string(n, &func_name); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(CORE, "Invalid type for %s", id); goto _err; } continue; } - SNDERR("Unknown field %s", id); + snd_error(CORE, "Unknown field %s", id); } } if (!func_name) { @@ -4027,10 +4027,10 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c func = h ? snd_dlsym(h, func_name, SND_DLSYM_VERSION(SND_CONFIG_DLSYM_VERSION_HOOK)) : NULL; err = 0; if (!h) { - SNDERR("Cannot open shared library %s (%s)", lib, errbuf); + snd_error(CORE, "Cannot open shared library %s (%s)", lib, errbuf); err = -ENOENT; } else if (!func) { - SNDERR("symbol %s is not defined inside %s", func_name, lib); + snd_error(CORE, "symbol %s is not defined inside %s", func_name, lib); snd_dlclose(h); err = -ENXIO; } @@ -4041,7 +4041,7 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c snd_config_t *nroot; err = func(root, config, &nroot, private_data); if (err < 0) - SNDERR("function %s returned error: %s", func_name, snd_strerror(err)); + snd_error(CORE, "function %s returned error: %s", func_name, snd_strerror(err)); snd_dlclose(h); if (err >= 0 && nroot) err = snd_config_substitute(root, nroot); @@ -4070,7 +4070,7 @@ static int snd_config_hooks(snd_config_t *config, snd_config_t *private_data) long i; err = safe_strtol(id, &i); if (err < 0) { - SNDERR("id of field %s is not and integer", id); + snd_error(CORE, "id of field %s is not and integer", id); err = -EINVAL; goto _err; } @@ -4122,9 +4122,9 @@ static int config_file_open(snd_config_t *root, const char *filename, int merge) err = snd_config_load_override(root, in); snd_input_close(in); if (err < 0) - SNDERR("%s may be old or corrupted: consider to remove or fix it", filename); + snd_error(CORE, "%s may be old or corrupted: consider to remove or fix it", filename); } else - SNDERR("cannot access file %s", filename); + snd_error(CORE, "cannot access file %s", filename); return err; } @@ -4138,7 +4138,7 @@ static int config_file_load(snd_config_t *root, const char *fn, int errors, int if (!errors && access(fn, R_OK) < 0) return 1; if (stat64(fn, &st) < 0) { - SNDERR("cannot stat file/directory %s", fn); + snd_error(CORE, "cannot stat file/directory %s", fn); return 1; } if (!S_ISDIR(st.st_mode)) @@ -4201,13 +4201,13 @@ static int config_file_load_user_all(snd_config_t *_root, snd_config_t *_file, i if (snd_config_get_type(_file) == SND_CONFIG_TYPE_COMPOUND) { if ((err = snd_config_search(_file, "file", &file)) < 0) { - SNDERR("Field file not found"); + snd_error(CORE, "Field file not found"); return err; } if ((err = snd_config_search(_file, "root", &root)) >= 0) { err = snd_config_get_ascii(root, &rname); if (err < 0) { - SNDERR("Field root is bad"); + snd_error(CORE, "Field root is bad"); return err; } err = snd_config_make_compound(&root, rname, 0); @@ -4279,7 +4279,7 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t if ((err = snd_config_search(config, "errors", &n)) >= 0) { errors = snd_config_get_bool(n); if (errors < 0) { - SNDERR("Invalid bool value in field errors"); + snd_error(CORE, "Invalid bool value in field errors"); return errors; } } @@ -4288,15 +4288,15 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t merge = 0; } if ((err = snd_config_search(config, "files", &n)) < 0) { - SNDERR("Unable to find field files in the pre-load section"); + snd_error(CORE, "Unable to find field files in the pre-load section"); return -EINVAL; } if ((err = snd_config_expand(n, root, NULL, private_data, &n)) < 0) { - SNDERR("Unable to expand filenames in the pre-load section"); + snd_error(CORE, "Unable to expand filenames in the pre-load section"); return err; } if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for field filenames"); + snd_error(CORE, "Invalid type for field filenames"); goto _err; } @@ -4308,7 +4308,7 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t long i; err = safe_strtol(id, &i); if (err < 0) { - SNDERR("id of field %s is not and integer", id); + snd_error(CORE, "id of field %s is not and integer", id); err = -EINVAL; goto _err; } @@ -4375,18 +4375,18 @@ static int _snd_config_hook_table(snd_config_t *root, snd_config_t *config, snd_ if (snd_config_search(config, "table", &n) < 0) return 0; if ((err = snd_config_expand(n, root, NULL, private_data, &n)) < 0) { - SNDERR("Unable to expand table compound"); + snd_error(CORE, "Unable to expand table compound"); return err; } if (snd_config_search(n, "id", &tn) < 0 || snd_config_get_string(tn, &id) < 0) { - SNDERR("Unable to find field table.id"); + snd_error(CORE, "Unable to find field table.id"); snd_config_delete(n); return -EINVAL; } if (snd_config_search(n, "value", &tn) < 0 || snd_config_get_type(tn) != SND_CONFIG_TYPE_STRING) { - SNDERR("Unable to find field table.value"); + snd_error(CORE, "Unable to find field table.value"); snd_config_delete(n); return -EINVAL; } @@ -4570,7 +4570,7 @@ int snd_config_update_r(snd_config_t **_top, snd_config_update_t **_update, cons lf->ino = st.st_ino; lf->mtime = st.st_mtime; } else { - SNDERR("Cannot access file %s", lf->name); + snd_error(CORE, "Cannot access file %s", lf->name); free(lf->name); memmove(&local->finfo[k], &local->finfo[k+1], sizeof(struct finfo) * (local->count - k - 1)); k--; @@ -4630,17 +4630,17 @@ int snd_config_update_r(snd_config_t **_top, snd_config_update_t **_update, cons err = snd_config_load(top, in); snd_input_close(in); if (err < 0) { - SNDERR("%s may be old or corrupted: consider to remove or fix it", local->finfo[k].name); + snd_error(CORE, "%s may be old or corrupted: consider to remove or fix it", local->finfo[k].name); goto _end; } } else { - SNDERR("cannot access file %s", local->finfo[k].name); + snd_error(CORE, "cannot access file %s", local->finfo[k].name); } } _skip: err = snd_config_hooks(top, NULL); if (err < 0) { - SNDERR("hooks failed, removing configuration"); + snd_error(CORE, "hooks failed, removing configuration"); goto _end; } *_top = top; @@ -5127,7 +5127,7 @@ static int _snd_config_evaluate(snd_config_t *src, return 1; err = snd_config_get_string(c, &str); if (err < 0) { - SNDERR("Invalid type for @func"); + snd_error(CORE, "Invalid type for @func"); return err; } assert(str); @@ -5135,7 +5135,7 @@ static int _snd_config_evaluate(snd_config_t *src, if (err >= 0) { snd_config_iterator_t i, next; if (snd_config_get_type(func_conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for func %s definition", str); + snd_error(CORE, "Invalid type for func %s definition", str); err = -EINVAL; goto _err; } @@ -5147,7 +5147,7 @@ static int _snd_config_evaluate(snd_config_t *src, if (strcmp(id, "lib") == 0) { err = snd_config_get_string(n, &lib); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(CORE, "Invalid type for %s", id); goto _err; } continue; @@ -5155,12 +5155,12 @@ static int _snd_config_evaluate(snd_config_t *src, if (strcmp(id, "func") == 0) { err = snd_config_get_string(n, &func_name); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(CORE, "Invalid type for %s", id); goto _err; } continue; } - SNDERR("Unknown field %s", id); + snd_error(CORE, "Unknown field %s", id); } } if (!func_name) { @@ -5179,11 +5179,11 @@ static int _snd_config_evaluate(snd_config_t *src, func = snd_dlsym(h, func_name, SND_DLSYM_VERSION(SND_CONFIG_DLSYM_VERSION_EVALUATE)); err = 0; if (!h) { - SNDERR("Cannot open shared library %s (%s)", lib, errbuf); + snd_error(CORE, "Cannot open shared library %s (%s)", lib, errbuf); err = -ENOENT; goto _errbuf; } else if (!func) { - SNDERR("symbol %s is not defined inside %s", func_name, lib); + snd_error(CORE, "symbol %s is not defined inside %s", func_name, lib); snd_dlclose(h); err = -ENXIO; goto _errbuf; @@ -5195,7 +5195,7 @@ static int _snd_config_evaluate(snd_config_t *src, snd_config_t *eval; err = func(&eval, root, src, private_data); if (err < 0) - SNDERR("function %s returned error: %s", func_name, snd_strerror(err)); + snd_error(CORE, "function %s returned error: %s", func_name, snd_strerror(err)); snd_dlclose(h); if (err >= 0 && eval) err = snd_config_substitute(src, eval); @@ -5259,7 +5259,7 @@ static int load_defaults(snd_config_t *subs, snd_config_t *defs) } continue; } - SNDERR("Unknown field %s", id); + snd_error(CORE, "Unknown field %s", id); return -EINVAL; } } @@ -5365,7 +5365,7 @@ static int parse_string(const char **ptr, char **val) int c = **ptr; switch (c) { case '\0': - SNDERR("Unterminated string"); + snd_error(CORE, "Unterminated string"); return -EINVAL; case '\\': c = parse_char(ptr); @@ -5502,7 +5502,7 @@ static int parse_args(snd_config_t *subs, const char *str, snd_config_t *defs) const char *id = n->id; err = snd_config_search(defs, id, &d); if (err < 0) { - SNDERR("Unknown parameter %s", id); + snd_error(CORE, "Unknown parameter %s", id); return err; } } @@ -5531,11 +5531,11 @@ static int parse_args(snd_config_t *subs, const char *str, snd_config_t *defs) } err = snd_config_search_alias(defs, NULL, var, &def); if (err < 0) { - SNDERR("Unknown parameter %s", var); + snd_error(CORE, "Unknown parameter %s", var); goto _err; } if (snd_config_get_type(def) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Parameter %s definition is not correct", var); + snd_error(CORE, "Parameter %s definition is not correct", var); err = -EINVAL; goto _err; } @@ -5547,7 +5547,7 @@ static int parse_args(snd_config_t *subs, const char *str, snd_config_t *defs) err = snd_config_search(def, "type", &typ); if (err < 0) { _invalid_type: - SNDERR("Parameter %s definition is missing a valid type info", var); + snd_error(CORE, "Parameter %s definition is missing a valid type info", var); goto _err; } err = snd_config_get_string(typ, &tmp); @@ -5560,7 +5560,7 @@ static int parse_args(snd_config_t *subs, const char *str, snd_config_t *defs) goto _err; err = safe_strtol(val, &v); if (err < 0) { - SNDERR("Parameter %s must be an integer", var); + snd_error(CORE, "Parameter %s must be an integer", var); goto _err; } err = snd_config_set_integer(sub, v); @@ -5573,7 +5573,7 @@ static int parse_args(snd_config_t *subs, const char *str, snd_config_t *defs) goto _err; err = safe_strtoll(val, &v); if (err < 0) { - SNDERR("Parameter %s must be an integer", var); + snd_error(CORE, "Parameter %s must be an integer", var); goto _err; } err = snd_config_set_integer64(sub, v); @@ -5586,7 +5586,7 @@ static int parse_args(snd_config_t *subs, const char *str, snd_config_t *defs) goto _err; err = safe_strtod(val, &v); if (err < 0) { - SNDERR("Parameter %s must be a real", var); + snd_error(CORE, "Parameter %s must be a real", var); goto _err; } err = snd_config_set_real(sub, v); @@ -5653,7 +5653,7 @@ int snd_config_expand_custom(snd_config_t *config, snd_config_t *root, err = snd_config_walk(config, root, &res, _snd_config_expand, fcn, private_data); if (err < 0) { - SNDERR("Expand error (walk): %s", snd_strerror(err)); + snd_error(CORE, "Expand error (walk): %s", snd_strerror(err)); return err; } *result = res; @@ -5685,7 +5685,7 @@ int snd_config_expand(snd_config_t *config, snd_config_t *root, const char *args err = snd_config_search(config, "@args", &defs); if (err < 0) { if (args != NULL) { - SNDERR("Unknown parameters %s", args); + snd_error(CORE, "Unknown parameters %s", args); return -EINVAL; } err = snd_config_copy(&res, config); @@ -5697,28 +5697,28 @@ int snd_config_expand(snd_config_t *config, snd_config_t *root, const char *args return err; err = load_defaults(subs, defs); if (err < 0) { - SNDERR("Load defaults error: %s", snd_strerror(err)); + snd_error(CORE, "Load defaults error: %s", snd_strerror(err)); goto _end; } err = parse_args(subs, args, defs); if (err < 0) { - SNDERR("Parse arguments error: %s", snd_strerror(err)); + snd_error(CORE, "Parse arguments error: %s", snd_strerror(err)); goto _end; } err = snd_config_evaluate(subs, root, private_data, NULL); if (err < 0) { - SNDERR("Args evaluate error: %s", snd_strerror(err)); + snd_error(CORE, "Args evaluate error: %s", snd_strerror(err)); goto _end; } err = snd_config_walk(config, root, &res, _snd_config_expand, _snd_config_expand_vars, subs); if (err < 0) { - SNDERR("Expand error (walk): %s", snd_strerror(err)); + snd_error(CORE, "Expand error (walk): %s", snd_strerror(err)); goto _end; } } err = snd_config_evaluate(res, root, private_data, NULL); if (err < 0) { - SNDERR("Evaluate error: %s", snd_strerror(err)); + snd_error(CORE, "Evaluate error: %s", snd_strerror(err)); snd_config_delete(res); goto _end; } @@ -5800,7 +5800,7 @@ int snd_config_check_hop(snd_config_t *conf) { if (conf) { if (conf->hop >= SND_CONF_MAX_HOPS) { - SYSERR("Too many definition levels (looped?)\n"); + snd_errornum(CORE, "Too many definition levels (looped?)\n"); return -EINVAL; } return conf->hop; diff --git a/src/confeval.c b/src/confeval.c index 56b6ebec..fd6b6334 100644 --- a/src/confeval.c +++ b/src/confeval.c @@ -147,7 +147,7 @@ int _snd_eval_string(snd_config_t **dst, const char *s, if (c == '\0') break; if (pos == END) { - SNDERR("unexpected expression tail '%s'", s); + snd_error(CORE, "unexpected expression tail '%s'", s); return -EINVAL; } if (pos == OP) { @@ -160,7 +160,7 @@ int _snd_eval_string(snd_config_t **dst, const char *s, case '|': case '&': op = c; break; default: - SNDERR("unknown operation '%c'", c); + snd_error(CORE, "unknown operation '%c'", c); return -EINVAL; } pos = RIGHT; @@ -225,7 +225,7 @@ int _snd_eval_string(snd_config_t **dst, const char *s, pos = op == LEFT ? OP : END; } if (pos != OP && pos != END) { - SNDERR("incomplete expression '%s'", save); + snd_error(CORE, "incomplete expression '%s'", save); return -EINVAL; } @@ -269,7 +269,7 @@ int snd_config_evaluate_string(snd_config_t **dst, const char *s, if (s[1] == '[') { err = _snd_eval_string(dst, s, fcn, private_data); if (err < 0) - SNDERR("wrong expression '%s'", s); + snd_error(CORE, "wrong expression '%s'", s); } else { err = fcn(dst, s + 1, private_data); } diff --git a/src/confmisc.c b/src/confmisc.c index 9b30d6c1..39aa1f04 100644 --- a/src/confmisc.c +++ b/src/confmisc.c @@ -127,14 +127,14 @@ int snd_config_get_bool(const snd_config_t *conf) if (err >= 0) { if (v < 0 || v > 1) { _invalid_value: - SNDERR("Invalid value for %s", id); + snd_error(CORE, "Invalid value for %s", id); return -EINVAL; } return v; } err = snd_config_get_string(conf, &str); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(CORE, "Invalid type for %s", id); return -EINVAL; } err = snd_config_get_bool_ascii(str); @@ -157,12 +157,12 @@ int snd_config_get_card(const snd_config_t *conf) if (snd_config_get_integer(conf, &v) < 0) { if (snd_config_get_string(conf, &str)) { if (snd_config_get_id(conf, &id) >= 0) - SNDERR("Invalid field %s", id); + snd_error(CORE, "Invalid field %s", id); return -EINVAL; } err = snd_card_get_index(str); if (err < 0) { - SNDERR("Cannot get card index for %s", str); + snd_error(CORE, "Cannot get card index for %s", str); return err; } v = err; @@ -213,14 +213,14 @@ int snd_config_get_ctl_iface(const snd_config_t *conf) if (err >= 0) { if (v < 0 || v > SND_CTL_ELEM_IFACE_LAST) { _invalid_value: - SNDERR("Invalid value for %s", id); + snd_error(CORE, "Invalid value for %s", id); return -EINVAL; } return v; } err = snd_config_get_string(conf, &str); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(CORE, "Invalid type for %s", id); return -EINVAL; } err = snd_config_get_ctl_iface_ascii(str); @@ -263,27 +263,27 @@ int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src, err = snd_config_search(src, "vars", &n); if (err < 0) { - SNDERR("field vars not found"); + snd_error(CORE, "field vars not found"); goto __error; } err = snd_config_evaluate(n, root, private_data, NULL); if (err < 0) { - SNDERR("error evaluating vars"); + snd_error(CORE, "error evaluating vars"); goto __error; } err = snd_config_search(src, "default", &d); if (err < 0) { - SNDERR("field default not found"); + snd_error(CORE, "field default not found"); goto __error; } err = snd_config_evaluate(d, root, private_data, NULL); if (err < 0) { - SNDERR("error evaluating default"); + snd_error(CORE, "error evaluating default"); goto __error; } err = snd_config_get_ascii(d, &def); if (err < 0) { - SNDERR("error getting field default"); + snd_error(CORE, "error getting field default"); goto __error; } do { @@ -295,13 +295,13 @@ int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src, if (snd_config_get_id(n, &id) < 0) continue; if (snd_config_get_type(n) != SND_CONFIG_TYPE_STRING) { - SNDERR("field %s is not a string", id); + snd_error(CORE, "field %s is not a string", id); err = -EINVAL; goto __error; } err = safe_strtol(id, &i); if (err < 0) { - SNDERR("id of field %s is not an integer", id); + snd_error(CORE, "id of field %s is not an integer", id); err = -EINVAL; goto __error; } @@ -309,7 +309,7 @@ int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src, idx++; err = snd_config_get_string(n, &ptr); if (err < 0) { - SNDERR("invalid string for id %s", id); + snd_error(CORE, "invalid string for id %s", id); err = -EINVAL; goto __error; } @@ -414,12 +414,12 @@ int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src, err = snd_config_search(src, "strings", &n); if (err < 0) { - SNDERR("field strings not found"); + snd_error(CORE, "field strings not found"); goto __error; } err = snd_config_evaluate(n, root, private_data, NULL); if (err < 0) { - SNDERR("error evaluating strings"); + snd_error(CORE, "error evaluating strings"); goto __error; } do { @@ -433,7 +433,7 @@ int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src, continue; err = safe_strtol(id, &i); if (err < 0) { - SNDERR("id of field %s is not an integer", id); + snd_error(CORE, "id of field %s is not an integer", id); err = -EINVAL; goto __error; } @@ -441,7 +441,7 @@ int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src, idx++; err = snd_config_get_ascii(n, &ptr); if (err < 0) { - SNDERR("invalid ascii string for id %s", id); + snd_error(CORE, "invalid ascii string for id %s", id); err = -EINVAL; goto __error; } @@ -462,7 +462,7 @@ int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src, } } while (hit); if (res == NULL) { - SNDERR("empty string is not accepted"); + snd_error(CORE, "empty string is not accepted"); err = -EINVAL; goto __error; } @@ -493,12 +493,12 @@ static int snd_func_iops(snd_config_t **dst, err = snd_config_search(src, "integers", &n); if (err < 0) { - SNDERR("field integers not found"); + snd_error(CORE, "field integers not found"); goto __error; } err = snd_config_evaluate(n, root, private_data, NULL); if (err < 0) { - SNDERR("error evaluating integers"); + snd_error(CORE, "error evaluating integers"); goto __error; } do { @@ -511,7 +511,7 @@ static int snd_func_iops(snd_config_t **dst, continue; err = safe_strtol(id, &i); if (err < 0) { - SNDERR("id of field %s is not an integer", id); + snd_error(CORE, "id of field %s is not an integer", id); err = -EINVAL; goto __error; } @@ -519,7 +519,7 @@ static int snd_func_iops(snd_config_t **dst, idx++; err = snd_config_get_integer(n, &val); if (err < 0) { - SNDERR("invalid integer for id %s", id); + snd_error(CORE, "invalid integer for id %s", id); err = -EINVAL; goto __error; } @@ -660,7 +660,7 @@ static int _snd_func_private_data(snd_config_t **dst, snd_config_t *src, err = snd_config_test_id(*private_data, id); if (err) { notfound: - SNDERR("field %s not found", id); + snd_error(CORE, "field %s not found", id); return -EINVAL; } return 0; @@ -695,7 +695,7 @@ int snd_func_private_string(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNU return err; err = snd_config_get_string(private_data, &str); if (err < 0) { - SNDERR("field string is not a string"); + snd_error(CORE, "field string is not a string"); return err; } err = snd_config_get_id(src, &id); @@ -736,7 +736,7 @@ int snd_func_private_integer(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UN return err; err = snd_config_get_integer(private_data, &val); if (err < 0) { - SNDERR("field integer is not a string"); + snd_error(CORE, "field integer is not a string"); return err; } err = snd_config_get_id(src, &id); @@ -759,12 +759,12 @@ int snd_determine_driver(int card, char **driver) assert(card >= 0 && card <= SND_MAX_CARDS); err = open_ctl(card, &ctl); if (err < 0) { - SNDERR("could not open control for card %i", card); + snd_error(CORE, "could not open control for card %i", card); goto __error; } err = snd_ctl_card_info(ctl, &info); if (err < 0) { - SNDERR("snd_ctl_card_info error: %s", snd_strerror(err)); + snd_error(CORE, "snd_ctl_card_info error: %s", snd_strerror(err)); goto __error; } res = strdup(snd_ctl_card_info_get_driver(&info)); @@ -808,12 +808,12 @@ int snd_func_private_card_driver(snd_config_t **dst, snd_config_t *root ATTRIBUT err = snd_config_test_id(private_data, "card"); if (err) { - SNDERR("field card not found"); + snd_error(CORE, "field card not found"); return -EINVAL; } err = snd_config_get_integer(private_data, &card); if (err < 0) { - SNDERR("field card is not an integer"); + snd_error(CORE, "field card is not an integer"); return err; } if ((err = snd_determine_driver(card, &driver)) < 0) @@ -837,22 +837,22 @@ static int parse_card(snd_config_t *root, snd_config_t *src, err = snd_config_search(src, "card", &n); if (err < 0) { - SNDERR("field card not found"); + snd_error(CORE, "field card not found"); return err; } err = snd_config_evaluate(n, root, private_data, NULL); if (err < 0) { - SNDERR("error evaluating card"); + snd_error(CORE, "error evaluating card"); return err; } err = snd_config_get_ascii(n, &str); if (err < 0) { - SNDERR("field card is not an integer or a string"); + snd_error(CORE, "field card is not an integer or a string"); return err; } card = snd_card_get_index(str); if (card < 0) - SNDERR("cannot find card '%s'", str); + snd_error(CORE, "cannot find card '%s'", str); free(str); return card; } @@ -959,12 +959,12 @@ int snd_func_card_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, return card; err = open_ctl(card, &ctl); if (err < 0) { - SNDERR("could not open control for card %i", card); + snd_error(CORE, "could not open control for card %i", card); goto __error; } err = snd_ctl_card_info(ctl, &info); if (err < 0) { - SNDERR("snd_ctl_card_info error: %s", snd_strerror(err)); + snd_error(CORE, "snd_ctl_card_info error: %s", snd_strerror(err)); goto __error; } err = snd_config_get_id(src, &id); @@ -1010,12 +1010,12 @@ int snd_func_card_name(snd_config_t **dst, snd_config_t *root, return card; err = open_ctl(card, &ctl); if (err < 0) { - SNDERR("could not open control for card %i", card); + snd_error(CORE, "could not open control for card %i", card); goto __error; } err = snd_ctl_card_info(ctl, &info); if (err < 0) { - SNDERR("snd_ctl_card_info error: %s", snd_strerror(err)); + snd_error(CORE, "snd_ctl_card_info error: %s", snd_strerror(err)); goto __error; } err = snd_config_get_id(src, &id); @@ -1075,41 +1075,41 @@ int snd_func_pcm_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, v return card; err = snd_config_search(src, "device", &n); if (err < 0) { - SNDERR("field device not found"); + snd_error(CORE, "field device not found"); goto __error; } err = snd_config_evaluate(n, root, private_data, NULL); if (err < 0) { - SNDERR("error evaluating device"); + snd_error(CORE, "error evaluating device"); goto __error; } err = snd_config_get_integer(n, &device); if (err < 0) { - SNDERR("field device is not an integer"); + snd_error(CORE, "field device is not an integer"); goto __error; } if (snd_config_search(src, "subdevice", &n) >= 0) { err = snd_config_evaluate(n, root, private_data, NULL); if (err < 0) { - SNDERR("error evaluating subdevice"); + snd_error(CORE, "error evaluating subdevice"); goto __error; } err = snd_config_get_integer(n, &subdevice); if (err < 0) { - SNDERR("field subdevice is not an integer"); + snd_error(CORE, "field subdevice is not an integer"); goto __error; } } err = open_ctl(card, &ctl); if (err < 0) { - SNDERR("could not open control for card %li", card); + snd_error(CORE, "could not open control for card %li", card); goto __error; } snd_pcm_info_set_device(&info, device); snd_pcm_info_set_subdevice(&info, subdevice); err = snd_ctl_pcm_info(ctl, &info); if (err < 0) { - SNDERR("snd_ctl_pcm_info error: %s", snd_strerror(err)); + snd_error(CORE, "snd_ctl_pcm_info error: %s", snd_strerror(err)); goto __error; } err = snd_config_get_id(src, &id); @@ -1158,53 +1158,53 @@ int snd_func_pcm_args_by_class(snd_config_t **dst, snd_config_t *root, snd_confi err = snd_config_search(src, "class", &n); if (err < 0) { - SNDERR("field class not found"); + snd_error(CORE, "field class not found"); goto __out; } err = snd_config_evaluate(n, root, private_data, NULL); if (err < 0) { - SNDERR("error evaluating class"); + snd_error(CORE, "error evaluating class"); goto __out; } err = snd_config_get_integer(n, &class); if (err < 0) { - SNDERR("field class is not an integer"); + snd_error(CORE, "field class is not an integer"); goto __out; } err = snd_config_search(src, "index", &n); if (err < 0) { - SNDERR("field index not found"); + snd_error(CORE, "field index not found"); goto __out; } err = snd_config_evaluate(n, root, private_data, NULL); if (err < 0) { - SNDERR("error evaluating index"); + snd_error(CORE, "error evaluating index"); goto __out; } err = snd_config_get_integer(n, &index); if (err < 0) { - SNDERR("field index is not an integer"); + snd_error(CORE, "field index is not an integer"); goto __out; } while(1) { err = snd_card_next(&card); if (err < 0) { - SNDERR("could not get next card"); + snd_error(CORE, "could not get next card"); goto __out; } if (card < 0) break; err = open_ctl(card, &ctl); if (err < 0) { - SNDERR("could not open control for card %i", card); + snd_error(CORE, "could not open control for card %i", card); goto __out; } dev = -1; while(1) { err = snd_ctl_pcm_next_device(ctl, &dev); if (err < 0) { - SNDERR("could not get next pcm for card %i", card); + snd_error(CORE, "could not get next pcm for card %i", card); goto __out; } if (dev < 0) @@ -1268,18 +1268,18 @@ int snd_func_private_pcm_subdevice(snd_config_t **dst, snd_config_t *root ATTRIB return snd_config_copy(dst, src); err = snd_config_test_id(private_data, "pcm_handle"); if (err) { - SNDERR("field pcm_handle not found"); + snd_error(CORE, "field pcm_handle not found"); return -EINVAL; } err = snd_config_get_pointer(private_data, &data); pcm = (snd_pcm_t *)data; if (err < 0) { - SNDERR("field pcm_handle is not a pointer"); + snd_error(CORE, "field pcm_handle is not a pointer"); return err; } err = snd_pcm_info(pcm, &info); if (err < 0) { - SNDERR("snd_ctl_pcm_info error: %s", snd_strerror(err)); + snd_error(CORE, "snd_ctl_pcm_info error: %s", snd_strerror(err)); return err; } err = snd_config_get_id(src, &id); @@ -1326,12 +1326,12 @@ int snd_func_refer(snd_config_t **dst, snd_config_t *root, snd_config_t *src, if (err >= 0) { err = snd_config_evaluate(n, root, private_data, NULL); if (err < 0) { - SNDERR("error evaluating file"); + snd_error(CORE, "error evaluating file"); goto _end; } err = snd_config_get_string(n, &file); if (err < 0) { - SNDERR("file is not a string"); + snd_error(CORE, "file is not a string"); goto _end; } } @@ -1339,25 +1339,25 @@ int snd_func_refer(snd_config_t **dst, snd_config_t *root, snd_config_t *src, if (err >= 0) { err = snd_config_evaluate(n, root, private_data, NULL); if (err < 0) { - SNDERR("error evaluating name"); + snd_error(CORE, "error evaluating name"); goto _end; } err = snd_config_get_string(n, &name); if (err < 0) { - SNDERR("name is not a string"); + snd_error(CORE, "name is not a string"); goto _end; } } if (!name) { err = -EINVAL; - SNDERR("name is not specified"); + snd_error(CORE, "name is not specified"); goto _end; } if (file) { snd_input_t *input; err = snd_input_stdio_open(&input, file, "r"); if (err < 0) { - SNDERR("Unable to open file %s: %s", file, snd_strerror(err)); + snd_error(CORE, "Unable to open file %s: %s", file, snd_strerror(err)); goto _end; } err = snd_config_load(root, input); @@ -1374,7 +1374,7 @@ int snd_func_refer(snd_config_t **dst, snd_config_t *root, snd_config_t *src, } else { err = snd_config_search(src, "default", &n); if (err < 0) - SNDERR("Unable to find definition '%s'", name); + snd_error(CORE, "Unable to find definition '%s'", name); else { const char *id; err = snd_config_evaluate(n, root, private_data, NULL); diff --git a/src/control/control.c b/src/control/control.c index e443d543..18841280 100644 --- a/src/control/control.c +++ b/src/control/control.c @@ -1367,7 +1367,7 @@ int snd_ctl_wait(snd_ctl_t *ctl, int timeout) npfds = snd_ctl_poll_descriptors_count(ctl); if (npfds <= 0 || npfds >= 16) { - SNDERR("Invalid poll_fds %d", npfds); + snd_error(CONTROL, "Invalid poll_fds %d", npfds); return -EIO; } pfd = alloca(sizeof(*pfd) * npfds); @@ -1375,7 +1375,7 @@ int snd_ctl_wait(snd_ctl_t *ctl, int timeout) if (err < 0) return err; if (err != npfds) { - SNDMSG("invalid poll descriptors %d", err); + snd_check(CONTROL, "invalid poll descriptors %d", err); return -EIO; } for (;;) { @@ -1458,30 +1458,30 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name, #endif if (snd_config_get_type(ctl_conf) != SND_CONFIG_TYPE_COMPOUND) { if (name) - SNDERR("Invalid type for CTL %s definition", name); + snd_error(CONTROL, "Invalid type for CTL %s definition", name); else - SNDERR("Invalid type for CTL definition"); + snd_error(CONTROL, "Invalid type for CTL definition"); return -EINVAL; } err = snd_config_search(ctl_conf, "type", &conf); if (err < 0) { - SNDERR("type is not defined"); + snd_error(CONTROL, "type is not defined"); return err; } err = snd_config_get_id(conf, &id); if (err < 0) { - SNDERR("unable to get id"); + snd_error(CONTROL, "unable to get id"); return err; } err = snd_config_get_string(conf, &str); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(CONTROL, "Invalid type for %s", id); return err; } err = snd_config_search_definition(ctl_root, "ctl_type", str, &type_conf); if (err >= 0) { if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for CTL type %s definition", str); + snd_error(CONTROL, "Invalid type for CTL type %s definition", str); err = -EINVAL; goto _err; } @@ -1495,7 +1495,7 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name, if (strcmp(id, "lib") == 0) { err = snd_config_get_string(n, &lib); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(CONTROL, "Invalid type for %s", id); goto _err; } continue; @@ -1503,12 +1503,12 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name, if (strcmp(id, "open") == 0) { err = snd_config_get_string(n, &open_name); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(CONTROL, "Invalid type for %s", id); goto _err; } continue; } - SNDERR("Unknown field %s", id); + snd_error(CONTROL, "Unknown field %s", id); err = -EINVAL; goto _err; } @@ -1572,7 +1572,7 @@ static int snd_ctl_open_noupdate(snd_ctl_t **ctlp, snd_config_t *root, err = snd_config_search_definition(root, "ctl", name, &ctl_conf); if (err < 0) { - SNDERR("Invalid CTL %s", name); + snd_error(CONTROL, "Invalid CTL %s", name); return err; } if (snd_config_get_string(ctl_conf, &str) >= 0) diff --git a/src/control/control_empty.c b/src/control/control_empty.c index c9b048c1..ac39ba1f 100644 --- a/src/control/control_empty.c +++ b/src/control/control_empty.c @@ -87,11 +87,11 @@ int _snd_ctl_empty_open(snd_ctl_t **handlep, const char *name ATTRIBUTE_UNUSED, child = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(CONTROL, "Unknown field %s", id); return -EINVAL; } if (!child) { - SNDERR("child is not defined"); + snd_error(CONTROL, "child is not defined"); return -EINVAL; } return _snd_ctl_open_named_child(handlep, name, root, child, mode, conf); diff --git a/src/control/control_ext.c b/src/control/control_ext.c index cf3da3d8..f4ddb2ae 100644 --- a/src/control/control_ext.c +++ b/src/control/control_ext.c @@ -560,7 +560,7 @@ SND_CTL_PLUGIN_DEFINE_FUNC(myctl) .... continue; } - SNDERR("Unknown field %s", id); + snd_error(CONTROL, "Unknown field %s", id); return -EINVAL; } @@ -712,7 +712,7 @@ int snd_ctl_ext_create(snd_ctl_ext_t *ext, const char *name, int mode) if (ext->version < SNDRV_PROTOCOL_VERSION(1, 0, 0) || ext->version > SND_CTL_EXT_VERSION) { - SNDERR("ctl_ext: Plugin version mismatch"); + snd_error(CONTROL, "ctl_ext: Plugin version mismatch"); return -ENXIO; } diff --git a/src/control/control_hw.c b/src/control/control_hw.c index a353767d..8db38f92 100644 --- a/src/control/control_hw.c +++ b/src/control/control_hw.c @@ -71,7 +71,7 @@ static int snd_ctl_hw_nonblock(snd_ctl_t *handle, int nonblock) long flags; int fd = hw->fd; if ((flags = fcntl(fd, F_GETFL)) < 0) { - SYSERR("F_GETFL failed"); + snd_errornum(CONTROL, "F_GETFL failed"); return -errno; } if (nonblock) @@ -79,7 +79,7 @@ static int snd_ctl_hw_nonblock(snd_ctl_t *handle, int nonblock) else flags &= ~O_NONBLOCK; if (fcntl(fd, F_SETFL, flags) < 0) { - SYSERR("F_SETFL for O_NONBLOCK failed"); + snd_errornum(CONTROL, "F_SETFL for O_NONBLOCK failed"); return -errno; } return 0; @@ -92,7 +92,7 @@ static int snd_ctl_hw_async(snd_ctl_t *ctl, int sig, pid_t pid) int fd = hw->fd; if ((flags = fcntl(fd, F_GETFL)) < 0) { - SYSERR("F_GETFL failed"); + snd_errornum(CONTROL, "F_GETFL failed"); return -errno; } if (sig >= 0) @@ -100,17 +100,17 @@ static int snd_ctl_hw_async(snd_ctl_t *ctl, int sig, pid_t pid) else flags &= ~O_ASYNC; if (fcntl(fd, F_SETFL, flags) < 0) { - SYSERR("F_SETFL for O_ASYNC failed"); + snd_errornum(CONTROL, "F_SETFL for O_ASYNC failed"); return -errno; } if (sig < 0) return 0; if (fcntl(fd, F_SETSIG, (long)sig) < 0) { - SYSERR("F_SETSIG failed"); + snd_errornum(CONTROL, "F_SETSIG failed"); return -errno; } if (fcntl(fd, F_SETOWN, (long)pid) < 0) { - SYSERR("F_SETOWN failed"); + snd_errornum(CONTROL, "F_SETOWN failed"); return -errno; } return 0; @@ -120,7 +120,7 @@ static int snd_ctl_hw_subscribe_events(snd_ctl_t *handle, int subscribe) { snd_ctl_hw_t *hw = handle->private_data; if (ioctl(hw->fd, SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS, &subscribe) < 0) { - SYSERR("SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS failed"); + snd_errornum(CONTROL, "SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS failed"); return -errno; } return 0; @@ -130,7 +130,7 @@ static int snd_ctl_hw_card_info(snd_ctl_t *handle, snd_ctl_card_info_t *info) { snd_ctl_hw_t *hw = handle->private_data; if (ioctl(hw->fd, SNDRV_CTL_IOCTL_CARD_INFO, info) < 0) { - SYSERR("SNDRV_CTL_IOCTL_CARD_INFO failed"); + snd_errornum(CONTROL, "SNDRV_CTL_IOCTL_CARD_INFO failed"); return -errno; } return 0; @@ -375,8 +375,9 @@ static int snd_ctl_hw_read(snd_ctl_t *handle, snd_ctl_event_t *event) if (res <= 0) return -errno; if (CHECK_SANITY(res != sizeof(*event))) { - SNDMSG("snd_ctl_hw_read: read size error (req:%d, got:%d)", - sizeof(*event), res); + snd_check(CONTROL, "snd_ctl_hw_read: read size error (req:%d, got:%d)", + sizeof(*event), res); + return -EINVAL; } return 1; @@ -437,7 +438,7 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode) *handle = NULL; if (CHECK_SANITY(card < 0 || card >= SND_MAX_CARDS)) { - SNDMSG("Invalid card index %d", card); + snd_check(CONTROL, "Invalid card index %d", card); return -EINVAL; } sprintf(filename, SNDRV_FILE_CONTROL, card); diff --git a/src/control/control_remap.c b/src/control/control_remap.c index 226b3c0b..2ed97d23 100644 --- a/src/control/control_remap.c +++ b/src/control/control_remap.c @@ -1242,27 +1242,27 @@ static int parse_remap(snd_ctl_remap_t *priv, snd_config_t *conf) if (snd_config_get_id(n, &id) < 0) continue; if (snd_config_get_string(n, &str) < 0) { - SNDERR("expected string with the target control id!"); + snd_error(CONTROL, "expected string with the target control id!"); return -EINVAL; } snd_ctl_elem_id_clear(&app); err = snd_ctl_ascii_elem_id_parse(&app, str); if (err < 0) { - SNDERR("unable to parse target id '%s'!", str); + snd_error(CONTROL, "unable to parse target id '%s'!", str); return -EINVAL; } if (remap_find_id_app(priv, &app)) { - SNDERR("duplicate target id '%s'!", id); + snd_error(CONTROL, "duplicate target id '%s'!", id); return -EINVAL; } snd_ctl_elem_id_clear(&child); err = snd_ctl_ascii_elem_id_parse(&child, id); if (err < 0) { - SNDERR("unable to parse source id '%s'!", id); + snd_error(CONTROL, "unable to parse source id '%s'!", id); return -EINVAL; } if (remap_find_id_child(priv, &app)) { - SNDERR("duplicate source id '%s'!", id); + snd_error(CONTROL, "duplicate source id '%s'!", id); return -EINVAL; } err = add_to_remap(priv, &child, &app); @@ -1321,7 +1321,7 @@ static int add_chn_to_map(struct snd_ctl_map_ctl *mctl, long idx, long src_idx, long *map; if (src_idx >= mctl->src_channels) { - SNDERR("Wrong channel mapping (extra source channel?)"); + snd_error(CONTROL, "Wrong channel mapping (extra source channel?)"); return -EINVAL; } if (mctl->channel_map_alloc <= (size_t)idx) { @@ -1350,7 +1350,7 @@ static int add_chn_to_map_array(struct snd_ctl_map_ctl *mctl, const char *dst_id snd_config_t *n = snd_config_iterator_entry(i); long idx = -1, chn = -1; if (safe_strtol(dst_id, &idx) || snd_config_get_integer(n, &chn)) { - SNDERR("Wrong channel mapping (%ld -> %ld)", idx, chn); + snd_error(CONTROL, "Wrong channel mapping (%ld -> %ld)", idx, chn); return -EINVAL; } err = add_chn_to_map(mctl, idx, src_idx, chn); @@ -1383,7 +1383,7 @@ static int parse_map_vindex(struct snd_ctl_map_ctl *mctl, snd_config_t *conf) err = add_chn_to_map_array(mctl, id, n); } else { if (safe_strtol(id, &idx) || snd_config_get_integer(n, &chn)) { - SNDERR("Wrong channel mapping (%ld -> %ld)", idx, chn); + snd_error(CONTROL, "Wrong channel mapping (%ld -> %ld)", idx, chn); return -EINVAL; } err = add_chn_to_map(mctl, idx, 0, chn); @@ -1430,7 +1430,7 @@ static int parse_map1(snd_ctl_map_t *map, snd_config_t *conf) snd_ctl_elem_id_clear(&cid); err = snd_ctl_ascii_elem_id_parse(&cid, id); if (err < 0) { - SNDERR("unable to parse control id '%s'!", id); + snd_error(CONTROL, "unable to parse control id '%s'!", id); return -EINVAL; } err = add_ctl_to_map(map, &mctl, &cid); @@ -1461,7 +1461,7 @@ static int parse_map(snd_ctl_remap_t *priv, snd_config_t *conf) snd_ctl_elem_id_clear(&eid); err = snd_ctl_ascii_elem_id_parse(&eid, id); if (err < 0) { - SNDERR("unable to parse id '%s'!", id); + snd_error(CONTROL, "unable to parse id '%s'!", id); return -EINVAL; } err = new_map(priv, &map, &eid); @@ -1508,14 +1508,14 @@ static int parse_sync1(snd_ctl_remap_t *priv, unsigned int count, snd_config_t * snd_config_for_each(i, next, conf) { snd_config_t *n = snd_config_iterator_entry(i); if (snd_config_get_string(n, &str) < 0) { - SNDERR("strings are expected in sync array"); + snd_error(CONTROL, "strings are expected in sync array"); return -EINVAL; } eid = &sync->control_ids[index]; snd_ctl_elem_id_clear(eid); err = snd_ctl_ascii_elem_id_parse(eid, str); if (err < 0) { - SNDERR("unable to parse control id '%s'!", str); + snd_error(CONTROL, "unable to parse control id '%s'!", str); return -EINVAL; } sync->control_items++; @@ -1542,12 +1542,12 @@ static int parse_sync_compound(snd_ctl_remap_t *priv, snd_config_t *conf) continue; if (strcmp(id, "switch") == 0) { if (snd_config_get_string(n, &str) < 0) { - SNDERR("String is expected for switch"); + snd_error(CONTROL, "String is expected for switch"); return -EINVAL; } err = snd_ctl_ascii_elem_id_parse(&eid, str); if (err < 0) { - SNDERR("unable to parse id '%s'!", str); + snd_error(CONTROL, "unable to parse id '%s'!", str); return -EINVAL; } eid_found = true; @@ -1555,7 +1555,7 @@ static int parse_sync_compound(snd_ctl_remap_t *priv, snd_config_t *conf) if (strcmp(id, "controls") == 0) { count = snd_config_is_array(n); if (count <= 0) { - SNDERR("Array is expected for sync!"); + snd_error(CONTROL, "Array is expected for sync!"); return -EINVAL; } err = parse_sync1(priv, count, n); @@ -1591,7 +1591,7 @@ static int parse_sync(snd_ctl_remap_t *priv, snd_config_t *conf) } else { count = snd_config_is_array(n); if (count <= 0) { - SNDERR("Array is expected for sync!"); + snd_error(CONTROL, "Array is expected for sync!"); return -EINVAL; } err = parse_sync1(priv, count, n); @@ -1817,11 +1817,11 @@ int _snd_ctl_remap_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd child = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(CONTROL, "Unknown field %s", id); return -EINVAL; } if (!child) { - SNDERR("child is not defined"); + snd_error(CONTROL, "child is not defined"); return -EINVAL; } err = _snd_ctl_open_child(&cctl, root, child, mode, conf); diff --git a/src/control/control_shm.c b/src/control/control_shm.c index 3d1555ee..44c0df45 100644 --- a/src/control/control_shm.c +++ b/src/control/control_shm.c @@ -60,7 +60,7 @@ static int snd_ctl_shm_action(snd_ctl_t *ctl) if (err != 1) return -EBADFD; if (ctrl->cmd) { - SNDERR("Server has not done the cmd"); + snd_error(CONTROL, "Server has not done the cmd"); return -EBADFD; } return ctrl->result; @@ -79,7 +79,7 @@ static int snd_ctl_shm_action_fd(snd_ctl_t *ctl, int *fd) if (err != 1) return -EBADFD; if (ctrl->cmd) { - SNDERR("Server has not done the cmd"); + snd_error(CONTROL, "Server has not done the cmd"); return -EBADFD; } return ctrl->result; @@ -448,7 +448,7 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname result = make_local_socket(sockname); if (result < 0) { - SNDERR("server for socket %s is not running", sockname); + snd_error(CONTROL, "server for socket %s is not running", sockname); goto _err; } sock = result; @@ -463,23 +463,23 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname req->namelen = snamelen; err = write(sock, req, reqlen); if (err < 0) { - SNDERR("write error"); + snd_error(CONTROL, "write error"); result = -errno; goto _err; } if ((size_t) err != reqlen) { - SNDERR("write size error"); + snd_error(CONTROL, "write size error"); result = -EINVAL; goto _err; } err = read(sock, &ans, sizeof(ans)); if (err < 0) { - SNDERR("read error"); + snd_error(CONTROL, "read error"); result = -errno; goto _err; } if (err != sizeof(ans)) { - SNDERR("read size error"); + snd_error(CONTROL, "read size error"); result = -EINVAL; goto _err; } @@ -546,7 +546,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_c if (strcmp(id, "server") == 0) { err = snd_config_get_string(n, &server); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(CONTROL, "Invalid type for %s", id); return -EINVAL; } continue; @@ -554,29 +554,29 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_c if (strcmp(id, "ctl") == 0) { err = snd_config_get_string(n, &ctl_name); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(CONTROL, "Invalid type for %s", id); return -EINVAL; } continue; } - SNDERR("Unknown field %s", id); + snd_error(CONTROL, "Unknown field %s", id); return -EINVAL; } if (!ctl_name) { - SNDERR("ctl is not defined"); + snd_error(CONTROL, "ctl is not defined"); return -EINVAL; } if (!server) { - SNDERR("server is not defined"); + snd_error(CONTROL, "server is not defined"); return -EINVAL; } err = snd_config_search_definition(root, "server", server, &sconfig); if (err < 0) { - SNDERR("Unknown server %s", server); + snd_error(CONTROL, "Unknown server %s", server); return -EINVAL; } if (snd_config_get_type(sconfig) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for server %s definition", server); + snd_error(CONTROL, "Invalid type for server %s definition", server); err = -EINVAL; goto _err; } @@ -592,7 +592,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_c if (strcmp(id, "socket") == 0) { err = snd_config_get_string(n, &sockname); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(CONTROL, "Invalid type for %s", id); goto _err; } continue; @@ -600,18 +600,18 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_c if (strcmp(id, "port") == 0) { err = snd_config_get_integer(n, &port); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(CONTROL, "Invalid type for %s", id); goto _err; } continue; } - SNDERR("Unknown field %s", id); + snd_error(CONTROL, "Unknown field %s", id); err = -EINVAL; goto _err; } if (!sockname) { - SNDERR("socket is not defined"); + snd_error(CONTROL, "socket is not defined"); goto _err; } err = snd_ctl_shm_open(handlep, name, sockname, ctl_name, mode); diff --git a/src/control/eld.c b/src/control/eld.c index 78dd4382..10b10c9b 100644 --- a/src/control/eld.c +++ b/src/control/eld.c @@ -53,7 +53,7 @@ int __snd_pcm_info_eld_fixup(snd_pcm_info_t * info) ret = snd_ctl_hw_open(&ctl, NULL, info->card, 0); if (ret < 0) { - SYSMSG("Cannot open the associated CTL"); + snd_checknum(CONTROL, "Cannot open the associated CTL"); return ret; } @@ -66,7 +66,7 @@ int __snd_pcm_info_eld_fixup(snd_pcm_info_t * info) if (ret == -ENOENT || cinfo.type != SND_CTL_ELEM_TYPE_BYTES || cinfo.count == 0) return 0; if (ret < 0) { - SYSMSG("Cannot read ELD"); + snd_checknum(CONTROL, "Cannot read ELD"); return ret; } /* decode connected HDMI device name */ @@ -78,7 +78,7 @@ int __snd_pcm_info_eld_fixup(snd_pcm_info_t * info) /* no monitor name detected */ goto __present; if (l > 16 || 20 + l > cinfo.count) { - SNDERR("ELD decode failed, using old HDMI output names"); + snd_error(CONTROL, "ELD decode failed, using old HDMI output names"); return 0; } s = alloca(l + 1); diff --git a/src/control/hcontrol.c b/src/control/hcontrol.c index 204d2e50..ec842926 100644 --- a/src/control/hcontrol.c +++ b/src/control/hcontrol.c @@ -680,7 +680,7 @@ int snd_hctl_wait(snd_hctl_t *hctl, int timeout) npfds = snd_hctl_poll_descriptors_count(hctl); if (npfds <= 0 || npfds >= 16) { - SNDERR("Invalid poll_fds %d", npfds); + snd_error(CONTROL, "Invalid poll_fds %d", npfds); return -EIO; } pfd = alloca(sizeof(*pfd) * npfds); @@ -689,7 +689,7 @@ int snd_hctl_wait(snd_hctl_t *hctl, int timeout) if (err < 0) return err; if (err != npfds) { - SNDMSG("invalid poll descriptors %d", err); + snd_check(CONTROL, "invalid poll descriptors %d", err); return -EIO; } do { diff --git a/src/control/namehint.c b/src/control/namehint.c index 8d6c64d5..e7e4e912 100644 --- a/src/control/namehint.c +++ b/src/control/namehint.c @@ -300,7 +300,7 @@ static int try_config(snd_config_t *config, strcmp(str, "hw") == 0) { if (snd_config_search(cfg1, "device", &cfg) >= 0) { if (snd_config_get_integer(cfg, &dev) < 0) { - SNDERR("(%s) device must be an integer", buf); + snd_error(CONTROL, "(%s) device must be an integer", buf); err = -EINVAL; goto __cleanup; } @@ -309,7 +309,7 @@ static int try_config(snd_config_t *config, if (snd_config_search(cfg1, "hint", &cfg) >= 0) { if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("hint (%s) must be a compound", buf); + snd_error(CONTROL, "hint (%s) must be a compound", buf); err = -EINVAL; goto __cleanup; } @@ -332,7 +332,7 @@ static int try_config(snd_config_t *config, } if (snd_config_search(cfg, "device", &n) >= 0) { if (snd_config_get_integer(n, &dev) < 0) { - SNDERR("(%s) device must be an integer", buf); + snd_error(CONTROL, "(%s) device must be an integer", buf); err = -EINVAL; goto __cleanup; } @@ -341,7 +341,7 @@ static int try_config(snd_config_t *config, } if (snd_config_search(cfg, "device_input", &n) >= 0) { if (snd_config_get_integer(n, &list->device_input) < 0) { - SNDERR("(%s) device_input must be an integer", buf); + snd_error(CONTROL, "(%s) device_input must be an integer", buf); err = -EINVAL; goto __cleanup; } @@ -351,7 +351,7 @@ static int try_config(snd_config_t *config, } if (snd_config_search(cfg, "device_output", &n) >= 0) { if (snd_config_get_integer(n, &list->device_output) < 0) { - SNDERR("(%s) device_output must be an integer", buf); + snd_error(CONTROL, "(%s) device_output must be an integer", buf); err = -EINVAL; goto __cleanup; } diff --git a/src/control/setup.c b/src/control/setup.c index fb096117..adcd00c2 100644 --- a/src/control/setup.c +++ b/src/control/setup.c @@ -93,13 +93,13 @@ int snd_sctl_install(snd_sctl_t *h) if (elem->lock) { err = snd_ctl_elem_lock(h->ctl, elem->id); if (err < 0) { - SNDERR("Cannot lock ctl elem"); + snd_error(CONTROL, "Cannot lock ctl elem"); return err; } } err = snd_ctl_elem_read(h->ctl, elem->old); if (err < 0) { - SNDERR("Cannot read ctl elem"); + snd_error(CONTROL, "Cannot read ctl elem"); return err; } count = snd_ctl_elem_info_get_count(elem->info); @@ -166,7 +166,7 @@ int snd_sctl_install(snd_sctl_t *h) } err = snd_ctl_elem_write(h->ctl, elem->val); if (err < 0) { - SNDERR("Cannot write ctl elem"); + snd_error(CONTROL, "Cannot write ctl elem"); return err; } } @@ -188,7 +188,7 @@ int snd_sctl_remove(snd_sctl_t *h) if (elem->lock) { err = snd_ctl_elem_unlock(h->ctl, elem->id); if (err < 0) { - SNDERR("Cannot unlock ctl elem"); + snd_error(CONTROL, "Cannot unlock ctl elem"); return err; } } @@ -205,7 +205,7 @@ int snd_sctl_remove(snd_sctl_t *h) if (elem->preserve && snd_ctl_elem_value_compare(elem->val, elem->old)) { err = snd_ctl_elem_write(h->ctl, elem->old); if (err < 0) { - SNDERR("Cannot restore ctl elem"); + snd_error(CONTROL, "Cannot restore ctl elem"); return err; } } @@ -235,7 +235,7 @@ static int snd_config_get_ctl_elem_enumerated(snd_config_t *n, snd_ctl_t *ctl, snd_ctl_elem_info_set_item(info, idx); err = snd_ctl_elem_info(ctl, info); if (err < 0) { - SNDERR("Cannot obtain info for CTL elem"); + snd_error(CONTROL, "Cannot obtain info for CTL elem"); return err; } if (strcmp(str, snd_ctl_elem_info_get_item_name(info)) == 0) @@ -293,7 +293,7 @@ static int snd_config_get_ctl_elem_value(snd_config_t *conf, case SND_CTL_ELEM_TYPE_IEC958: break; default: - SNDERR("Unknown control type: %d", type); + snd_error(CONTROL, "Unknown control type: %d", type); return -EINVAL; } } @@ -311,7 +311,7 @@ static int snd_config_get_ctl_elem_value(snd_config_t *conf, unsigned int idx = 0; if (len % 2 != 0 || len > count * 2) { _bad_content: - SNDERR("bad value content"); + snd_error(CONTROL, "bad value content"); return -EINVAL; } while (*buf) { @@ -340,7 +340,7 @@ static int snd_config_get_ctl_elem_value(snd_config_t *conf, break; } if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("bad value type"); + snd_error(CONTROL, "bad value type"); return -EINVAL; } @@ -351,7 +351,7 @@ static int snd_config_get_ctl_elem_value(snd_config_t *conf, continue; err = safe_strtol(id, &idx); if (err < 0 || idx < 0 || (unsigned int) idx >= count) { - SNDERR("bad value index"); + snd_error(CONTROL, "bad value index"); return -EINVAL; } switch (type) { @@ -424,11 +424,11 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da if (strcmp(id, "iface") == 0 || strcmp(id, "interface") == 0) { const char *ptr; if ((err = snd_config_get_string(n, &ptr)) < 0) { - SNDERR("field %s is not a string", id); + snd_error(CONTROL, "field %s is not a string", id); goto _err; } if ((err = snd_config_get_ctl_iface_ascii(ptr)) < 0) { - SNDERR("Invalid value for '%s'", id); + snd_error(CONTROL, "Invalid value for '%s'", id); goto _err; } iface = err; @@ -436,28 +436,28 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da } if (strcmp(id, "name") == 0) { if ((err = snd_config_get_string(n, &name)) < 0) { - SNDERR("field %s is not a string", id); + snd_error(CONTROL, "field %s is not a string", id); goto _err; } continue; } if (strcmp(id, "index") == 0) { if ((err = snd_config_get_integer(n, &index)) < 0) { - SNDERR("field %s is not an integer", id); + snd_error(CONTROL, "field %s is not an integer", id); goto _err; } continue; } if (strcmp(id, "device") == 0) { if ((err = snd_config_get_integer(n, &device)) < 0) { - SNDERR("field %s is not an integer", id); + snd_error(CONTROL, "field %s is not an integer", id); goto _err; } continue; } if (strcmp(id, "subdevice") == 0) { if ((err = snd_config_get_integer(n, &subdevice)) < 0) { - SNDERR("field %s is not an integer", id); + snd_error(CONTROL, "field %s is not an integer", id); goto _err; } continue; @@ -498,16 +498,16 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da skip_rest = err; continue; } - SNDERR("Unknown field %s", id); + snd_error(CONTROL, "Unknown field %s", id); return -EINVAL; } if (name == NULL) { - SNDERR("Missing control name"); + snd_error(CONTROL, "Missing control name"); err = -EINVAL; goto _err; } if (value == NULL) { - SNDERR("Missing control value"); + snd_error(CONTROL, "Missing control value"); err = -EINVAL; goto _err; } @@ -544,7 +544,7 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da err = snd_ctl_elem_info(h->ctl, elem->info); if (err < 0) { if (! optional) - SNDERR("Cannot obtain info for CTL elem (%s,'%s',%li,%li,%li): %s", snd_ctl_elem_iface_name(iface), name, index, device, subdevice, snd_strerror(err)); + snd_error(CONTROL, "Cannot obtain info for CTL elem (%s,'%s',%li,%li,%li): %s", snd_ctl_elem_iface_name(iface), name, index, device, subdevice, snd_strerror(err)); goto _err; } else { if (skip_rest) diff --git a/src/control/tlv.c b/src/control/tlv.c index fed46acd..cc60703d 100644 --- a/src/control/tlv.c +++ b/src/control/tlv.c @@ -69,7 +69,7 @@ int snd_tlv_parse_dB_info(unsigned int *tlv, /* Validate that it is possible to read the type and size * without reading past the end of the buffer. */ if (tlv_size < MIN_TLV_STREAM_LEN) { - SNDERR("TLV stream too short"); + snd_error(CONTROL, "TLV stream too short"); return -EINVAL; } @@ -78,7 +78,7 @@ int snd_tlv_parse_dB_info(unsigned int *tlv, size = tlv[SNDRV_CTL_TLVO_LEN]; tlv_size -= 2 * sizeof(int); if (size > tlv_size) { - SNDERR("TLV size error"); + snd_error(CONTROL, "TLV size error"); return -EINVAL; } switch (type) { @@ -110,11 +110,11 @@ int snd_tlv_parse_dB_info(unsigned int *tlv, else minsize = 2 * sizeof(int); if (size < minsize) { - SNDERR("Invalid dB_scale TLV size"); + snd_error(CONTROL, "Invalid dB_scale TLV size"); return -EINVAL; } if (size > MAX_TLV_RANGE_SIZE) { - SNDERR("Too big dB_scale TLV size: %d", size); + snd_error(CONTROL, "Too big dB_scale TLV size: %d", size); return -EINVAL; } *db_tlvp = tlv; diff --git a/src/dlmisc.c b/src/dlmisc.c index d7aff456..4686ed38 100644 --- a/src/dlmisc.c +++ b/src/dlmisc.c @@ -223,7 +223,7 @@ static int snd_dlsym_verify(void *handle, const char *name, const char *version) res = dlsym(handle, vname) == NULL ? -ENOENT : 0; // printf("dlsym verify: %i, vname = '%s'\n", res, vname); if (res < 0) - SNDERR("unable to verify version for symbol %s", name); + snd_error(CORE, "unable to verify version for symbol %s", name); return res; #else return 0; @@ -336,17 +336,20 @@ snd_dlobj_cache_get0(const char *lib, const char *name, verbose ? sizeof(errbuf) : 0); if (dlobj == NULL) { if (verbose) - SNDERR("Cannot open shared library %s (%s)", - lib ? lib : "[builtin]", - errbuf); + snd_error(CORE, "Cannot open shared library %s (%s)", + lib ? lib : "[builtin]", + + errbuf); + return NULL; } func = snd_dlsym(dlobj, name, version); if (func == NULL) { if (verbose) - SNDERR("symbol %s is not defined inside %s", - name, lib ? lib : "[builtin]"); + snd_error(CORE, "symbol %s is not defined inside %s", + name, lib ? lib : "[builtin]"); + goto __err; } c = malloc(sizeof(*c)); diff --git a/src/hwdep/hwdep.c b/src/hwdep/hwdep.c index 72f6f0d0..82f09434 100644 --- a/src/hwdep/hwdep.c +++ b/src/hwdep/hwdep.c @@ -54,30 +54,30 @@ static int snd_hwdep_open_conf(snd_hwdep_t **hwdep, void *h = NULL; if (snd_config_get_type(hwdep_conf) != SND_CONFIG_TYPE_COMPOUND) { if (name) - SNDERR("Invalid type for HWDEP %s definition", name); + snd_error(HWDEP, "Invalid type for HWDEP %s definition", name); else - SNDERR("Invalid type for HWDEP definition"); + snd_error(HWDEP, "Invalid type for HWDEP definition"); return -EINVAL; } err = snd_config_search(hwdep_conf, "type", &conf); if (err < 0) { - SNDERR("type is not defined"); + snd_error(HWDEP, "type is not defined"); return err; } err = snd_config_get_id(conf, &id); if (err < 0) { - SNDERR("unable to get id"); + snd_error(HWDEP, "unable to get id"); return err; } err = snd_config_get_string(conf, &str); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(HWDEP, "Invalid type for %s", id); return err; } err = snd_config_search_definition(hwdep_root, "hwdep_type", str, &type_conf); if (err >= 0) { if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for HWDEP type %s definition", str); + snd_error(HWDEP, "Invalid type for HWDEP type %s definition", str); err = -EINVAL; goto _err; } @@ -91,7 +91,7 @@ static int snd_hwdep_open_conf(snd_hwdep_t **hwdep, if (strcmp(id, "lib") == 0) { err = snd_config_get_string(n, &lib); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(HWDEP, "Invalid type for %s", id); goto _err; } continue; @@ -99,12 +99,12 @@ static int snd_hwdep_open_conf(snd_hwdep_t **hwdep, if (strcmp(id, "open") == 0) { err = snd_config_get_string(n, &open_name); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(HWDEP, "Invalid type for %s", id); goto _err; } continue; } - SNDERR("Unknown field %s", id); + snd_error(HWDEP, "Unknown field %s", id); err = -EINVAL; goto _err; } @@ -121,10 +121,10 @@ static int snd_hwdep_open_conf(snd_hwdep_t **hwdep, open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_HWDEP_DLSYM_VERSION)); err = 0; if (!h) { - SNDERR("Cannot open shared library %s (%s)", lib, errbuf); + snd_error(HWDEP, "Cannot open shared library %s (%s)", lib, errbuf); err = -ENOENT; } else if (!open_func) { - SNDERR("symbol %s is not defined inside %s", open_name, lib); + snd_error(HWDEP, "symbol %s is not defined inside %s", open_name, lib); snd_dlclose(h); err = -ENXIO; } @@ -148,7 +148,7 @@ static int snd_hwdep_open_noupdate(snd_hwdep_t **hwdep, snd_config_t *root, cons snd_config_t *hwdep_conf; err = snd_config_search_definition(root, "hwdep", name, &hwdep_conf); if (err < 0) { - SNDERR("Unknown HwDep %s", name); + snd_error(HWDEP, "Unknown HwDep %s", name); return err; } err = snd_hwdep_open_conf(hwdep, name, root, hwdep_conf, mode); diff --git a/src/hwdep/hwdep_hw.c b/src/hwdep/hwdep_hw.c index 0f28f23b..8e2ef1c5 100644 --- a/src/hwdep/hwdep_hw.c +++ b/src/hwdep/hwdep_hw.c @@ -172,7 +172,7 @@ int _snd_hwdep_hw_open(snd_hwdep_t **hwdep, char *name, return err; continue; } - SNDERR("Unexpected field %s", id); + snd_error(HWDEP, "Unexpected field %s", id); return -EINVAL; } if (card < 0) diff --git a/src/mixer/simple_abst.c b/src/mixer/simple_abst.c index ffc92e86..18a69f1d 100644 --- a/src/mixer/simple_abst.c +++ b/src/mixer/simple_abst.c @@ -82,20 +82,20 @@ static int try_open(snd_mixer_class_t *class, const char *lib) strcat(xlib, lib); h = INTERNAL(snd_dlopen)(xlib, RTLD_NOW, errbuf, sizeof(errbuf)); if (h == NULL) { - SNDERR("Unable to open library '%s' (%s)", xlib, errbuf); + snd_error(MIXER, "Unable to open library '%s' (%s)", xlib, errbuf); free(xlib); return -ENXIO; } priv->dlhandle = h; event_func = snd_dlsym(h, "alsa_mixer_simple_event", NULL); if (event_func == NULL) { - SNDERR("Symbol 'alsa_mixer_simple_event' was not found in '%s'", xlib); + snd_error(MIXER, "Symbol 'alsa_mixer_simple_event' was not found in '%s'", xlib); err = -ENXIO; } if (err == 0) { init_func = snd_dlsym(h, "alsa_mixer_simple_init", NULL); if (init_func == NULL) { - SNDERR("Symbol 'alsa_mixer_simple_init' was not found in '%s'", xlib); + snd_error(MIXER, "Symbol 'alsa_mixer_simple_init' was not found in '%s'", xlib); err = -ENXIO; } } @@ -129,20 +129,20 @@ static int try_open_full(snd_mixer_class_t *class, snd_mixer_t *mixer, /* note python modules requires RTLD_GLOBAL */ h = INTERNAL(snd_dlopen)(xlib, RTLD_NOW|RTLD_GLOBAL, errbuf, sizeof(errbuf)); if (h == NULL) { - SNDERR("Unable to open library '%s'", xlib); + snd_error(MIXER, "Unable to open library '%s'", xlib); free(xlib); return -ENXIO; } priv->dlhandle = h; event_func = snd_dlsym(h, "alsa_mixer_simple_event", NULL); if (event_func == NULL) { - SNDERR("Symbol 'alsa_mixer_simple_event' was not found in '%s'", xlib); + snd_error(MIXER, "Symbol 'alsa_mixer_simple_event' was not found in '%s'", xlib); err = -ENXIO; } if (err == 0) { init_func = snd_dlsym(h, "alsa_mixer_simple_finit", NULL); if (init_func == NULL) { - SNDERR("Symbol 'alsa_mixer_simple_finit' was not found in '%s'", xlib); + snd_error(MIXER, "Symbol 'alsa_mixer_simple_finit' was not found in '%s'", xlib); err = -ENXIO; } } @@ -308,13 +308,13 @@ int snd_mixer_simple_basic_register(snd_mixer_t *mixer, if (err >= 0) { err = snd_input_stdio_open(&input, file, "r"); if (err < 0) { - SNDERR("unable to open simple mixer configuration file '%s'", file); + snd_error(MIXER, "unable to open simple mixer configuration file '%s'", file); goto __error; } err = snd_config_load(top, input); snd_input_close(input); if (err < 0) { - SNDERR("%s may be old or corrupted: consider to remove or fix it", file); + snd_error(MIXER, "%s may be old or corrupted: consider to remove or fix it", file); goto __error; } err = find_full(class, mixer, top, priv->device); @@ -324,7 +324,7 @@ int snd_mixer_simple_basic_register(snd_mixer_t *mixer, if (err >= 0) { err = snd_ctl_open(&priv->ctl, priv->device, 0); if (err < 0) { - SNDERR("unable to open control device '%s': %s", priv->device, snd_strerror(err)); + snd_error(MIXER, "unable to open control device '%s': %s", priv->device, snd_strerror(err)); goto __error; } err = snd_hctl_open_ctl(&priv->hctl, priv->ctl); diff --git a/src/mixer/simple_none.c b/src/mixer/simple_none.c index dd03fcf1..1ff4277e 100644 --- a/src/mixer/simple_none.c +++ b/src/mixer/simple_none.c @@ -1552,9 +1552,11 @@ static int simple_add1(snd_mixer_class_t *class, const char *name, snd_mixer_selem_id_free(id); } if (simple->ctls[type].elem) { - SNDERR("helem (%s,'%s',%u,%u,%u) appears twice or more", - snd_ctl_elem_iface_name( - snd_hctl_elem_get_interface(helem)), + snd_error(MIXER, "helem (%s,'%s',%u,%u,%u) appears twice or more", + snd_ctl_elem_iface_name( + + snd_hctl_elem_get_interface(helem)), + snd_hctl_elem_get_name(helem), snd_hctl_elem_get_index(helem), snd_hctl_elem_get_device(helem), diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index c59ea3b6..ec751707 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -1003,11 +1003,11 @@ int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) int err; /* the hw_params must be set at first!!! */ if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } if (! params->avail_min) { - SNDMSG("params->avail_min is 0"); + snd_check(PCM, "params->avail_min is 0"); return -EINVAL; } #if 0 @@ -1016,7 +1016,7 @@ int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) */ if (params->start_threshold <= pcm->buffer_size && params->start_threshold > (pcm->buffer_size / params->avail_min) * params->avail_min) { - SNDMSG("params->avail_min problem for start_threshold"); + snd_check(PCM, "params->avail_min problem for start_threshold"); return -EINVAL; } #endif @@ -1110,7 +1110,7 @@ int snd_pcm_hwsync(snd_pcm_t *pcm) assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } snd_pcm_lock(pcm->fast_op_arg); @@ -1155,7 +1155,7 @@ int snd_pcm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp) assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } snd_pcm_lock(pcm->fast_op_arg); @@ -1184,7 +1184,7 @@ int snd_pcm_resume(snd_pcm_t *pcm) assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } /* lock handled in the callback */ @@ -1213,7 +1213,7 @@ int snd_pcm_htimestamp(snd_pcm_t *pcm, snd_pcm_uframes_t *avail, snd_htimestamp_ assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } snd_pcm_lock(pcm->fast_op_arg); @@ -1238,7 +1238,7 @@ int snd_pcm_prepare(snd_pcm_t *pcm) assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } err = bad_pcm_state(pcm, ~P_STATE(DISCONNECTED), 0); @@ -1268,7 +1268,7 @@ int snd_pcm_reset(snd_pcm_t *pcm) assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } snd_pcm_lock(pcm->fast_op_arg); @@ -1293,7 +1293,7 @@ int snd_pcm_start(snd_pcm_t *pcm) assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } err = bad_pcm_state(pcm, P_STATE(PREPARED), 0); @@ -1324,7 +1324,7 @@ int snd_pcm_drop(snd_pcm_t *pcm) assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } err = bad_pcm_state(pcm, P_STATE_RUNNABLE | P_STATE(SETUP) | @@ -1361,7 +1361,7 @@ int snd_pcm_drain(snd_pcm_t *pcm) assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } err = bad_pcm_state(pcm, P_STATE_RUNNABLE | P_STATE(SETUP), P_STATE(SETUP)); @@ -1395,7 +1395,7 @@ int snd_pcm_pause(snd_pcm_t *pcm, int enable) assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } err = bad_pcm_state(pcm, P_STATE_RUNNABLE, 0); @@ -1428,7 +1428,7 @@ snd_pcm_sframes_t snd_pcm_rewindable(snd_pcm_t *pcm) assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } err = bad_pcm_state(pcm, P_STATE_RUNNABLE, 0); @@ -1459,7 +1459,7 @@ snd_pcm_sframes_t snd_pcm_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames) assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } if (frames == 0) @@ -1494,7 +1494,7 @@ snd_pcm_sframes_t snd_pcm_forwardable(snd_pcm_t *pcm) assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } err = bad_pcm_state(pcm, P_STATE_RUNNABLE, 0); @@ -1529,7 +1529,7 @@ snd_pcm_sframes_t snd_pcm_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames) assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } if (frames == 0) @@ -1573,11 +1573,11 @@ snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_ufr assert(pcm); assert(size == 0 || buffer); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } if (pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED) { - SNDMSG("invalid access type %s", snd_pcm_access_name(pcm->access)); + snd_check(PCM, "invalid access type %s", snd_pcm_access_name(pcm->access)); return -EINVAL; } err = bad_pcm_state(pcm, P_STATE_RUNNABLE, 0); @@ -1612,11 +1612,11 @@ snd_pcm_sframes_t snd_pcm_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t assert(pcm); assert(size == 0 || bufs); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } if (pcm->access != SND_PCM_ACCESS_RW_NONINTERLEAVED) { - SNDMSG("invalid access type %s", snd_pcm_access_name(pcm->access)); + snd_check(PCM, "invalid access type %s", snd_pcm_access_name(pcm->access)); return -EINVAL; } err = bad_pcm_state(pcm, P_STATE_RUNNABLE, 0); @@ -1651,11 +1651,11 @@ snd_pcm_sframes_t snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t assert(pcm); assert(size == 0 || buffer); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } if (pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED) { - SNDMSG("invalid access type %s", snd_pcm_access_name(pcm->access)); + snd_check(PCM, "invalid access type %s", snd_pcm_access_name(pcm->access)); return -EINVAL; } err = bad_pcm_state(pcm, P_STATE_RUNNABLE, 0); @@ -1690,11 +1690,11 @@ snd_pcm_sframes_t snd_pcm_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t s assert(pcm); assert(size == 0 || bufs); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } if (pcm->access != SND_PCM_ACCESS_RW_NONINTERLEAVED) { - SNDMSG("invalid access type %s", snd_pcm_access_name(pcm->access)); + snd_check(PCM, "invalid access type %s", snd_pcm_access_name(pcm->access)); return -EINVAL; } err = bad_pcm_state(pcm, P_STATE_RUNNABLE, 0); @@ -1774,7 +1774,7 @@ static int __snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, if (pcm->fast_ops->poll_descriptors) return pcm->fast_ops->poll_descriptors(pcm->fast_op_arg, pfds, space); if (pcm->poll_fd < 0) { - SNDMSG("poll_fd < 0"); + snd_check(PCM, "poll_fd < 0"); return -EIO; } if (space >= 1 && pfds) { @@ -2340,7 +2340,7 @@ int snd_pcm_dump_hw_setup(snd_pcm_t *pcm, snd_output_t *out) assert(pcm); assert(out); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } snd_output_printf(out, " stream : %s\n", snd_pcm_stream_name(pcm->stream)); @@ -2370,7 +2370,7 @@ int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, snd_output_t *out) assert(pcm); assert(out); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } snd_output_printf(out, " tstamp_mode : %s\n", snd_pcm_tstamp_mode_name(pcm->tstamp_mode)); @@ -2449,7 +2449,7 @@ snd_pcm_sframes_t snd_pcm_bytes_to_frames(snd_pcm_t *pcm, ssize_t bytes) { assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } return bytes * 8 / pcm->frame_bits; @@ -2465,7 +2465,7 @@ ssize_t snd_pcm_frames_to_bytes(snd_pcm_t *pcm, snd_pcm_sframes_t frames) { assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } return frames * pcm->frame_bits / 8; @@ -2481,7 +2481,7 @@ long snd_pcm_bytes_to_samples(snd_pcm_t *pcm, ssize_t bytes) { assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } return bytes * 8 / pcm->sample_bits; @@ -2497,7 +2497,7 @@ ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, long samples) { assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } return samples * pcm->sample_bits / 8; @@ -2546,7 +2546,7 @@ int snd_async_add_pcm_handler(snd_async_handler_t **handler, snd_pcm_t *pcm, snd_pcm_t *snd_async_handler_get_pcm(snd_async_handler_t *handler) { if (handler->type != SND_ASYNC_HANDLER_PCM) { - SNDMSG("invalid handler type %d", handler->type); + snd_check(PCM, "invalid handler type %d", handler->type); return NULL; } return handler->u.pcm; @@ -2582,29 +2582,29 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name, snd_config_get_id(pcm_conf, &id); val = NULL; snd_config_get_ascii(pcm_conf, &val); - SNDERR("Invalid type for PCM %s%sdefinition (id: %s, value: %s)", name ? name : "", name ? " " : "", id, val); + snd_error(PCM, "Invalid type for PCM %s%sdefinition (id: %s, value: %s)", name ? name : "", name ? " " : "", id, val); free(val); return -EINVAL; } err = snd_config_search(pcm_conf, "type", &conf); if (err < 0) { - SNDERR("type is not defined"); + snd_error(PCM, "type is not defined"); return err; } err = snd_config_get_id(conf, &id); if (err < 0) { - SNDERR("unable to get id"); + snd_error(PCM, "unable to get id"); return err; } err = snd_config_get_string(conf, &str); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return err; } err = snd_config_search_definition(pcm_root, "pcm_type", str, &type_conf); if (err >= 0) { if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for PCM type %s definition", str); + snd_error(PCM, "Invalid type for PCM type %s definition", str); err = -EINVAL; goto _err; } @@ -2618,7 +2618,7 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "lib") == 0) { err = snd_config_get_string(n, &lib); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto _err; } continue; @@ -2626,12 +2626,12 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "open") == 0) { err = snd_config_get_string(n, &open_name); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto _err; } continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); err = -EINVAL; goto _err; } @@ -2719,7 +2719,7 @@ static int snd_pcm_open_noupdate(snd_pcm_t **pcmp, snd_config_t *root, err = snd_config_search_definition(root, "pcm", name, &pcm_conf); if (err < 0) { - SNDERR("Unknown PCM %s", name); + snd_error(PCM, "Unknown PCM %s", name); return err; } if (snd_config_get_string(pcm_conf, &str) >= 0) @@ -2972,7 +2972,7 @@ int snd_pcm_wait_nocheck(snd_pcm_t *pcm, int timeout) npfds = __snd_pcm_poll_descriptors_count(pcm); if (npfds <= 0 || npfds >= 16) { - SNDERR("Invalid poll_fds %d", npfds); + snd_error(PCM, "Invalid poll_fds %d", npfds); return -EIO; } pfd = alloca(sizeof(*pfd) * npfds); @@ -2980,7 +2980,7 @@ int snd_pcm_wait_nocheck(snd_pcm_t *pcm, int timeout) if (err < 0) return err; if (err != npfds) { - SNDMSG("invalid poll descriptors %d", err); + snd_check(PCM, "invalid poll descriptors %d", err); return -EIO; } if (timeout == SND_PCM_WAIT_IO) @@ -2988,7 +2988,7 @@ int snd_pcm_wait_nocheck(snd_pcm_t *pcm, int timeout) else if (timeout == SND_PCM_WAIT_DRAIN) timeout = __snd_pcm_wait_drain_timeout(pcm); else if (timeout < -1) - SNDMSG("invalid snd_pcm_wait timeout argument %d", timeout); + snd_check(PCM, "invalid snd_pcm_wait timeout argument %d", timeout); do { __snd_pcm_unlock(pcm->fast_op_arg); err_poll = poll(pfd, npfds, timeout); @@ -3078,7 +3078,7 @@ snd_pcm_sframes_t snd_pcm_avail(snd_pcm_t *pcm) assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } snd_pcm_lock(pcm->fast_op_arg); @@ -3111,7 +3111,7 @@ int snd_pcm_avail_delay(snd_pcm_t *pcm, assert(pcm && availp && delayp); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } snd_pcm_lock(pcm->fast_op_arg); @@ -3251,7 +3251,7 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes break; } default: - SNDMSG("invalid format width %d", width); + snd_check(PCM, "invalid format width %d", width); return -EINVAL; } return 0; @@ -3421,7 +3421,7 @@ int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t break; } default: - SNDMSG("invalid format width %d", width); + snd_check(PCM, "invalid format width %d", width); return -EINVAL; } return 0; @@ -3446,11 +3446,11 @@ int snd_pcm_areas_copy(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_ assert(dst_areas); assert(src_areas); if (! channels) { - SNDMSG("invalid channels %d", channels); + snd_check(PCM, "invalid channels %d", channels); return -EINVAL; } if (! frames) { - SNDMSG("invalid frames %ld", frames); + snd_check(PCM, "invalid frames %ld", frames); return -EINVAL; } while (channels > 0) { @@ -3589,7 +3589,7 @@ int snd_pcm_hw_params_can_mmap_sample_resolution(const snd_pcm_hw_params_t *para { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } return !!(params->info & SNDRV_PCM_INFO_MMAP_VALID); @@ -3609,7 +3609,7 @@ int snd_pcm_hw_params_is_double(const snd_pcm_hw_params_t *params) { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } return !!(params->info & SNDRV_PCM_INFO_DOUBLE); @@ -3629,7 +3629,7 @@ int snd_pcm_hw_params_is_batch(const snd_pcm_hw_params_t *params) { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } return !!(params->info & SNDRV_PCM_INFO_BATCH); @@ -3649,7 +3649,7 @@ int snd_pcm_hw_params_is_block_transfer(const snd_pcm_hw_params_t *params) { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } return !!(params->info & SNDRV_PCM_INFO_BLOCK_TRANSFER); @@ -3669,7 +3669,7 @@ int snd_pcm_hw_params_is_monotonic(const snd_pcm_hw_params_t *params) { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } return !!(params->info & SND_PCM_INFO_MONOTONIC); @@ -3689,7 +3689,7 @@ int snd_pcm_hw_params_can_overrange(const snd_pcm_hw_params_t *params) { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } return !!(params->info & SNDRV_PCM_INFO_OVERRANGE); @@ -3709,7 +3709,7 @@ int snd_pcm_hw_params_can_pause(const snd_pcm_hw_params_t *params) { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } return !!(params->info & SNDRV_PCM_INFO_PAUSE); @@ -3729,7 +3729,7 @@ int snd_pcm_hw_params_can_resume(const snd_pcm_hw_params_t *params) { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } return !!(params->info & SNDRV_PCM_INFO_RESUME); @@ -3749,7 +3749,7 @@ int snd_pcm_hw_params_is_half_duplex(const snd_pcm_hw_params_t *params) { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } return !!(params->info & SNDRV_PCM_INFO_HALF_DUPLEX); @@ -3769,7 +3769,7 @@ int snd_pcm_hw_params_is_joint_duplex(const snd_pcm_hw_params_t *params) { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } return !!(params->info & SNDRV_PCM_INFO_JOINT_DUPLEX); @@ -3789,7 +3789,7 @@ int snd_pcm_hw_params_can_sync_start(const snd_pcm_hw_params_t *params) { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } return !!(params->info & SNDRV_PCM_INFO_SYNC_START); @@ -3805,7 +3805,7 @@ int snd_pcm_hw_params_can_disable_period_wakeup(const snd_pcm_hw_params_t *param { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } return !!(params->info & SNDRV_PCM_INFO_NO_PERIOD_WAKEUP); @@ -3828,7 +3828,7 @@ int snd_pcm_hw_params_is_perfect_drain(const snd_pcm_hw_params_t *params) { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } return !!(params->info & SNDRV_PCM_INFO_PERFECT_DRAIN); @@ -3866,7 +3866,7 @@ int snd_pcm_hw_params_supports_audio_ts_type(const snd_pcm_hw_params_t *params, { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return 0; /* FIXME: should be a negative error? */ } switch (type) { @@ -3903,7 +3903,7 @@ int snd_pcm_hw_params_get_rate_numden(const snd_pcm_hw_params_t *params, { assert(params); if (CHECK_SANITY(params->rate_den == 0)) { - SNDMSG("invalid rate_den value"); + snd_check(PCM, "invalid rate_den value"); return -EINVAL; } *rate_num = params->rate_num; @@ -3933,7 +3933,7 @@ int snd_pcm_hw_params_get_sbits(const snd_pcm_hw_params_t *params) { assert(params); if (CHECK_SANITY(params->msbits == 0)) { - SNDMSG("invalid msbits value"); + snd_check(PCM, "invalid msbits value"); return -EINVAL; } return params->msbits; @@ -3952,7 +3952,7 @@ int snd_pcm_hw_params_get_fifo_size(const snd_pcm_hw_params_t *params) { assert(params); if (CHECK_SANITY(params->info == ~0U)) { - SNDMSG("invalid PCM info field"); + snd_check(PCM, "invalid PCM info field"); return -EINVAL; } return params->fifo_size; @@ -6395,7 +6395,7 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) { assert(pcm && params); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } __snd_pcm_lock(pcm); /* forced lock due to pcm field changes */ @@ -6498,7 +6498,7 @@ int snd_pcm_sw_params_set_start_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params params->start_threshold = pcm->boundary; break; default: - SNDMSG("invalid start mode value %d", val); + snd_check(PCM, "invalid start mode value %d", val); return -EINVAL; } return 0; @@ -6546,7 +6546,7 @@ int snd_pcm_sw_params_set_xrun_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, params->stop_threshold = pcm->boundary; break; default: - SNDMSG("invalid xrun mode value %d", val); + snd_check(PCM, "invalid xrun mode value %d", val); return -EINVAL; } return 0; @@ -6587,7 +6587,7 @@ int snd_pcm_sw_params_set_tstamp_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *param { assert(pcm && params); if (CHECK_SANITY(val > SND_PCM_TSTAMP_LAST)) { - SNDMSG("invalid tstamp_mode value %d", val); + snd_check(PCM, "invalid tstamp_mode value %d", val); return -EINVAL; } params->tstamp_mode = val; @@ -6622,7 +6622,7 @@ int snd_pcm_sw_params_set_tstamp_type(snd_pcm_t *pcm, snd_pcm_sw_params_t *param { assert(pcm && params); if (CHECK_SANITY(val > SND_PCM_TSTAMP_TYPE_LAST)) { - SNDMSG("invalid tstamp_type value %d", val); + snd_check(PCM, "invalid tstamp_type value %d", val); return -EINVAL; } params->tstamp_type = val; @@ -6893,8 +6893,9 @@ int snd_pcm_sw_params_set_silence_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t { assert(pcm && params); if (CHECK_SANITY(val >= pcm->buffer_size)) { - SNDMSG("invalid silent_threshold value %ld (buffer_size = %ld)", - val, pcm->buffer_size); + snd_check(PCM, "invalid silent_threshold value %ld (buffer_size = %ld)", + val, pcm->buffer_size); + return -EINVAL; } params->silence_threshold = val; @@ -6951,8 +6952,9 @@ int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm, snd_pcm_sw_params_t *para { assert(pcm && params); if (CHECK_SANITY(val < pcm->boundary && val > pcm->buffer_size)) { - SNDMSG("invalid silence_size %ld (boundary %ld, buffer_size %ld)", - val, pcm->boundary, pcm->buffer_size); + snd_check(PCM, "invalid silence_size %ld (boundary %ld, buffer_size %ld)", + val, pcm->boundary, pcm->buffer_size); + return -EINVAL; } params->silence_size = val; @@ -7566,13 +7568,15 @@ snd_pcm_sframes_t __snd_pcm_mmap_commit(snd_pcm_t *pcm, { assert(pcm); if (CHECK_SANITY(offset != *pcm->appl.ptr % pcm->buffer_size)) { - SNDMSG("commit offset (%ld) doesn't match with appl_ptr (%ld) %% buf_size (%ld)", - offset, *pcm->appl.ptr, pcm->buffer_size); + snd_check(PCM, "commit offset (%ld) doesn't match with appl_ptr (%ld) %% buf_size (%ld)", + offset, *pcm->appl.ptr, pcm->buffer_size); + return -EPIPE; } if (CHECK_SANITY(frames > snd_pcm_mmap_avail(pcm))) { - SNDMSG("commit frames (%ld) overflow (avail = %ld)", frames, - snd_pcm_mmap_avail(pcm)); + snd_check(PCM, "commit frames (%ld) overflow (avail = %ld)", frames, + snd_pcm_mmap_avail(pcm)); + return -EPIPE; } if (pcm->fast_ops->mmap_commit) @@ -7831,13 +7835,13 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf, if (snd_config_get_string(conf, &str) >= 0) { err = snd_config_search_definition(root, "pcm_slave", str, &conf); if (err < 0) { - SNDERR("Invalid slave definition"); + snd_error(PCM, "Invalid slave definition"); return -EINVAL; } to_free = 1; } if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid slave definition"); + snd_error(PCM, "Invalid slave definition"); err = -EINVAL; goto _err; } @@ -7877,7 +7881,7 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf, err = snd_config_get_string(n, &str); if (err < 0) { _invalid: - SNDERR("invalid type for %s", id); + snd_error(PCM, "invalid type for %s", id); goto _err; } if ((fields[k].flags & SCONF_UNCHANGED) && @@ -7887,7 +7891,7 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf, } f = snd_pcm_format_value(str); if (f == SND_PCM_FORMAT_UNKNOWN) { - SNDERR("unknown format %s", str); + snd_error(PCM, "unknown format %s", str); err = -EINVAL; goto _err; } @@ -7914,18 +7918,18 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf, } if (k < count) continue; - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); err = -EINVAL; goto _err; } if (!pcm_conf) { - SNDERR("missing field pcm"); + snd_error(PCM, "missing field pcm"); err = -EINVAL; goto _err; } for (k = 0; k < count; ++k) { if ((fields[k].flags & SCONF_MANDATORY) && !fields[k].present) { - SNDERR("missing field %s", names[fields[k].index]); + snd_error(PCM, "missing field %s", names[fields[k].index]); err = -EINVAL; goto _err; } @@ -8779,10 +8783,10 @@ int snd_pcm_recover(snd_pcm_t *pcm, int err, int silent) else s = "overrun"; if (!silent) - SNDERR("%s occurred", s); + snd_error(PCM, "%s occurred", s); err = snd_pcm_prepare(pcm); if (err < 0) { - SNDERR("cannot recovery from %s, prepare failed: %s", s, snd_strerror(err)); + snd_error(PCM, "cannot recovery from %s, prepare failed: %s", s, snd_strerror(err)); return err; } return 0; @@ -8794,7 +8798,7 @@ int snd_pcm_recover(snd_pcm_t *pcm, int err, int silent) if (err < 0) { err = snd_pcm_prepare(pcm); if (err < 0) { - SNDERR("cannot recovery from suspend, prepare failed: %s", snd_strerror(err)); + snd_error(PCM, "cannot recovery from suspend, prepare failed: %s", snd_strerror(err)); return err; } } @@ -8833,36 +8837,41 @@ int snd_pcm_set_params(snd_pcm_t *pcm, /* choose all parameters */ err = snd_pcm_hw_params_any(pcm, ¶ms); if (err < 0) { - SNDERR("Broken configuration for %s: no configurations available", - s); + snd_error(PCM, "Broken configuration for %s: no configurations available", + s); + return err; } /* set software resampling */ err = snd_pcm_hw_params_set_rate_resample(pcm, ¶ms, soft_resample); if (err < 0) { - SNDERR("Resampling setup failed for %s: %s", - s, snd_strerror(err)); + snd_error(PCM, "Resampling setup failed for %s: %s", + s, snd_strerror(err)); + return err; } /* set the selected read/write format */ err = snd_pcm_hw_params_set_access(pcm, ¶ms, access); if (err < 0) { - SNDERR("Access type not available for %s: %s", - s, snd_strerror(err)); + snd_error(PCM, "Access type not available for %s: %s", + s, snd_strerror(err)); + return err; } /* set the sample format */ err = snd_pcm_hw_params_set_format(pcm, ¶ms, format); if (err < 0) { - SNDERR("Sample format not available for %s: %s", - s, snd_strerror(err)); + snd_error(PCM, "Sample format not available for %s: %s", + s, snd_strerror(err)); + return err; } /* set the count of channels */ err = snd_pcm_hw_params_set_channels(pcm, ¶ms, channels); if (err < 0) { - SNDERR("Channels count (%i) not available for %s: %s", - channels, s, snd_strerror(err)); + snd_error(PCM, "Channels count (%i) not available for %s: %s", + channels, s, snd_strerror(err)); + return err; } /* set the stream rate */ @@ -8870,13 +8879,15 @@ int snd_pcm_set_params(snd_pcm_t *pcm, err = INTERNAL(snd_pcm_hw_params_set_rate_near)(pcm, ¶ms, &rrate, 0); if (err < 0) { - SNDERR("Rate %iHz not available for playback: %s", - rate, snd_strerror(err)); + snd_error(PCM, "Rate %iHz not available for playback: %s", + rate, snd_strerror(err)); + return err; } if (rrate != rate) { - SNDERR("Rate doesn't match (requested %iHz, get %iHz)", - rate, rrate); + snd_error(PCM, "Rate doesn't match (requested %iHz, get %iHz)", + rate, rrate); + return -EINVAL; } /* set the buffer time */ @@ -8891,30 +8902,34 @@ int snd_pcm_set_params(snd_pcm_t *pcm, err = INTERNAL(snd_pcm_hw_params_set_period_time_near)(pcm, ¶ms, &period_time, NULL); if (err < 0) { - SNDERR("Unable to set period time %i for %s: %s", - period_time, s, snd_strerror(err)); + snd_error(PCM, "Unable to set period time %i for %s: %s", + period_time, s, snd_strerror(err)); + return err; } err = INTERNAL(snd_pcm_hw_params_get_period_size)(¶ms, &period_size, NULL); if (err < 0) { - SNDERR("Unable to get period size for %s: %s", - s, snd_strerror(err)); + snd_error(PCM, "Unable to get period size for %s: %s", + s, snd_strerror(err)); + return err; } buffer_size = period_size * 4; err = INTERNAL(snd_pcm_hw_params_set_buffer_size_near)(pcm, ¶ms, &buffer_size); if (err < 0) { - SNDERR("Unable to set buffer size %lu %s: %s", - buffer_size, s, snd_strerror(err)); + snd_error(PCM, "Unable to set buffer size %lu %s: %s", + buffer_size, s, snd_strerror(err)); + return err; } err = INTERNAL(snd_pcm_hw_params_get_buffer_size)(¶ms, &buffer_size); if (err < 0) { - SNDERR("Unable to get buffer size for %s: %s", - s, snd_strerror(err)); + snd_error(PCM, "Unable to get buffer size for %s: %s", + s, snd_strerror(err)); + return err; } } else { @@ -8922,15 +8937,17 @@ int snd_pcm_set_params(snd_pcm_t *pcm, err = INTERNAL(snd_pcm_hw_params_get_buffer_size)(¶ms, &buffer_size); if (err < 0) { - SNDERR("Unable to get buffer size for %s: %s", - s, snd_strerror(err)); + snd_error(PCM, "Unable to get buffer size for %s: %s", + s, snd_strerror(err)); + return err; } err = INTERNAL(snd_pcm_hw_params_get_buffer_time)(¶ms, &latency, NULL); if (err < 0) { - SNDERR("Unable to get buffer time (latency) for %s: %s", - s, snd_strerror(err)); + snd_error(PCM, "Unable to get buffer time (latency) for %s: %s", + s, snd_strerror(err)); + return err; } /* set the period time */ @@ -8938,31 +8955,35 @@ int snd_pcm_set_params(snd_pcm_t *pcm, err = INTERNAL(snd_pcm_hw_params_set_period_time_near)(pcm, ¶ms, &period_time, NULL); if (err < 0) { - SNDERR("Unable to set period time %i for %s: %s", - period_time, s, snd_strerror(err)); + snd_error(PCM, "Unable to set period time %i for %s: %s", + period_time, s, snd_strerror(err)); + return err; } err = INTERNAL(snd_pcm_hw_params_get_period_size)(¶ms, &period_size, NULL); if (err < 0) { - SNDERR("Unable to get period size for %s: %s", - s, snd_strerror(err)); + snd_error(PCM, "Unable to get period size for %s: %s", + s, snd_strerror(err)); + return err; } } /* write the parameters to device */ err = snd_pcm_hw_params(pcm, ¶ms); if (err < 0) { - SNDERR("Unable to set hw params for %s: %s", - s, snd_strerror(err)); + snd_error(PCM, "Unable to set hw params for %s: %s", + s, snd_strerror(err)); + return err; } /* get the current swparams */ err = snd_pcm_sw_params_current(pcm, &swparams); if (err < 0) { - SNDERR("Unable to determine current swparams for %s: %s", - s, snd_strerror(err)); + snd_error(PCM, "Unable to determine current swparams for %s: %s", + s, snd_strerror(err)); + return err; } /* @@ -8972,8 +8993,9 @@ int snd_pcm_set_params(snd_pcm_t *pcm, err = snd_pcm_sw_params_set_start_threshold(pcm, &swparams, (buffer_size / period_size) * period_size); if (err < 0) { - SNDERR("Unable to set start threshold mode for %s: %s", - s, snd_strerror(err)); + snd_error(PCM, "Unable to set start threshold mode for %s: %s", + s, snd_strerror(err)); + return err; } /* @@ -8982,15 +9004,17 @@ int snd_pcm_set_params(snd_pcm_t *pcm, */ err = snd_pcm_sw_params_set_avail_min(pcm, &swparams, period_size); if (err < 0) { - SNDERR("Unable to set avail min for %s: %s", - s, snd_strerror(err)); + snd_error(PCM, "Unable to set avail min for %s: %s", + s, snd_strerror(err)); + return err; } /* write the parameters to the playback device */ err = snd_pcm_sw_params(pcm, &swparams); if (err < 0) { - SNDERR("Unable to set sw params for %s: %s", - s, snd_strerror(err)); + snd_error(PCM, "Unable to set sw params for %s: %s", + s, snd_strerror(err)); + return err; } return 0; diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c index efd41451..bd6f7da3 100644 --- a/src/pcm/pcm_adpcm.c +++ b/src/pcm/pcm_adpcm.c @@ -650,11 +650,11 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name, slave = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 1, @@ -664,7 +664,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name, if (snd_pcm_format_linear(sformat) != 1 && sformat != SND_PCM_FORMAT_IMA_ADPCM) { snd_config_delete(sconf); - SNDERR("invalid slave format"); + snd_error(PCM, "invalid slave format"); return -EINVAL; } err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode, conf); diff --git a/src/pcm/pcm_alaw.c b/src/pcm/pcm_alaw.c index 715b04c7..8fb0625f 100644 --- a/src/pcm/pcm_alaw.c +++ b/src/pcm/pcm_alaw.c @@ -525,11 +525,11 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, slave = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 1, @@ -539,7 +539,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, if (snd_pcm_format_linear(sformat) != 1 && sformat != SND_PCM_FORMAT_A_LAW) { snd_config_delete(sconf); - SNDERR("invalid slave format"); + snd_error(PCM, "invalid slave format"); return -EINVAL; } err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode, conf); diff --git a/src/pcm/pcm_asym.c b/src/pcm/pcm_asym.c index 9c32b1b9..e8004707 100644 --- a/src/pcm/pcm_asym.c +++ b/src/pcm/pcm_asym.c @@ -98,12 +98,13 @@ int _snd_pcm_asym_open(snd_pcm_t **pcmp, const char *name ATTRIBUTE_UNUSED, slave = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (! slave) { - SNDERR("%s slave is not defined", - stream == SND_PCM_STREAM_PLAYBACK ? "playback" : "capture"); + snd_error(PCM, "%s slave is not defined", + stream == SND_PCM_STREAM_PLAYBACK ? "playback" : "capture"); + return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 0); diff --git a/src/pcm/pcm_copy.c b/src/pcm/pcm_copy.c index 1bf745d2..c20a18bd 100644 --- a/src/pcm/pcm_copy.c +++ b/src/pcm/pcm_copy.c @@ -278,11 +278,11 @@ int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, slave = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 0); diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c index 5b8ec08f..74455985 100644 --- a/src/pcm/pcm_direct.c +++ b/src/pcm/pcm_direct.c @@ -212,7 +212,7 @@ static int make_local_socket(const char *filename, int server, mode_t ipc_perm, sock = socket(PF_LOCAL, SOCK_STREAM, 0); if (sock < 0) { int result = -errno; - SYSERR("socket failed"); + snd_errornum(PCM, "socket failed"); return result; } @@ -225,13 +225,13 @@ static int make_local_socket(const char *filename, int server, mode_t ipc_perm, if (server) { if (bind(sock, (struct sockaddr *) addr, size) < 0) { int result = -errno; - SYSERR("bind failed: %s", filename); + snd_errornum(PCM, "bind failed: %s", filename); close(sock); return result; } else { if (chmod(filename, ipc_perm) < 0) { int result = -errno; - SYSERR("chmod failed: %s", filename); + snd_errornum(PCM, "chmod failed: %s", filename); close(sock); unlink(filename); return result; @@ -239,7 +239,7 @@ static int make_local_socket(const char *filename, int server, mode_t ipc_perm, if (chown(filename, -1, ipc_gid) < 0) { #if 0 /* it's not fatal */ int result = -errno; - SYSERR("chown failed: %s", filename); + snd_errornum(PCM, "chown failed: %s", filename); close(sock); unlink(filename); return result; @@ -249,7 +249,7 @@ static int make_local_socket(const char *filename, int server, mode_t ipc_perm, } else { if (connect(sock, (struct sockaddr *) addr, size) < 0) { int result = -errno; - SYSERR("connect failed: %s", filename); + snd_errornum(PCM, "connect failed: %s", filename); close(sock); return result; } @@ -585,7 +585,7 @@ int snd_pcm_direct_slave_recover(snd_pcm_direct_t *direct) semerr = snd_pcm_direct_semaphore_down(direct, DIRECT_IPC_SEM_CLIENT); if (semerr < 0) { - SNDERR("SEMDOWN FAILED with err %d", semerr); + snd_error(PCM, "SEMDOWN FAILED with err %d", semerr); return semerr; } @@ -595,7 +595,7 @@ int snd_pcm_direct_slave_recover(snd_pcm_direct_t *direct) semerr = snd_pcm_direct_semaphore_up(direct, DIRECT_IPC_SEM_CLIENT); if (semerr < 0) { - SNDERR("SEMUP FAILED with err %d", semerr); + snd_error(PCM, "SEMUP FAILED with err %d", semerr); return semerr; } return 0; @@ -621,11 +621,11 @@ int snd_pcm_direct_slave_recover(snd_pcm_direct_t *direct) ret = snd_pcm_prepare(direct->spcm); if (ret < 0) { - SNDERR("recover: unable to prepare slave"); + snd_error(PCM, "recover: unable to prepare slave"); semerr = snd_pcm_direct_semaphore_up(direct, DIRECT_IPC_SEM_CLIENT); if (semerr < 0) { - SNDERR("SEMUP FAILED with err %d", semerr); + snd_error(PCM, "SEMUP FAILED with err %d", semerr); return semerr; } return ret; @@ -641,11 +641,11 @@ int snd_pcm_direct_slave_recover(snd_pcm_direct_t *direct) ret = snd_pcm_start(direct->spcm); if (ret < 0) { - SNDERR("recover: unable to start slave"); + snd_error(PCM, "recover: unable to start slave"); semerr = snd_pcm_direct_semaphore_up(direct, DIRECT_IPC_SEM_CLIENT); if (semerr < 0) { - SNDERR("SEMUP FAILED with err %d", semerr); + snd_error(PCM, "SEMUP FAILED with err %d", semerr); return semerr; } return ret; @@ -653,7 +653,7 @@ int snd_pcm_direct_slave_recover(snd_pcm_direct_t *direct) semerr = snd_pcm_direct_semaphore_up(direct, DIRECT_IPC_SEM_CLIENT); if (semerr < 0) { - SNDERR("SEMUP FAILED with err %d", semerr); + snd_error(PCM, "SEMUP FAILED with err %d", semerr); return semerr; } return 0; @@ -727,7 +727,7 @@ int snd_pcm_direct_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space) { if (pcm->poll_fd < 0) { - SNDMSG("poll_fd < 0"); + snd_check(PCM, "poll_fd < 0"); return -EIO; } if (space >= 1 && pfds) { @@ -845,7 +845,7 @@ static int hw_param_interval_refine_one(snd_pcm_hw_params_t *params, return 0; i = hw_param_interval(params, var); if (snd_interval_empty(i)) { - SNDERR("dshare interval %i empty?", (int)var); + snd_error(PCM, "dshare interval %i empty?", (int)var); return -EINVAL; } if (snd_interval_refine(i, src)) @@ -910,7 +910,7 @@ int snd_pcm_direct_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) #endif if (params->rmask & (1<rmask & (1<rmask & (1<channels); @@ -1203,12 +1203,12 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str __again: if (loops-- <= 0) { - SNDERR("unable to find a valid configuration for slave"); + snd_error(PCM, "unable to find a valid configuration for slave"); return -EINVAL; } ret = snd_pcm_hw_params_any(spcm, &hw_params); if (ret < 0) { - SNDERR("snd_pcm_hw_params_any failed"); + snd_error(PCM, "snd_pcm_hw_params_any failed"); return ret; } ret = snd_pcm_hw_params_set_access(spcm, &hw_params, @@ -1217,7 +1217,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str ret = snd_pcm_hw_params_set_access(spcm, &hw_params, SND_PCM_ACCESS_MMAP_NONINTERLEAVED); if (ret < 0) { - SNDERR("slave plugin does not support mmap interleaved or mmap noninterleaved access"); + snd_error(PCM, "slave plugin does not support mmap interleaved or mmap noninterleaved access"); return ret; } } @@ -1254,7 +1254,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str &hw_params, &format); } if (ret < 0) { - SNDERR("requested or auto-format is not available"); + snd_error(PCM, "requested or auto-format is not available"); return ret; } params->format = format; @@ -1262,13 +1262,13 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str ret = INTERNAL(snd_pcm_hw_params_set_channels_near)(spcm, &hw_params, (unsigned int *)¶ms->channels); if (ret < 0) { - SNDERR("requested count of channels is not available"); + snd_error(PCM, "requested count of channels is not available"); return ret; } ret = INTERNAL(snd_pcm_hw_params_set_rate_near)(spcm, &hw_params, (unsigned int *)¶ms->rate, 0); if (ret < 0) { - SNDERR("requested rate is not available"); + snd_error(PCM, "requested rate is not available"); return ret; } @@ -1277,14 +1277,14 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str ret = INTERNAL(snd_pcm_hw_params_set_buffer_time_near)(spcm, &hw_params, (unsigned int *)¶ms->buffer_time, 0); if (ret < 0) { - SNDERR("unable to set buffer time"); + snd_error(PCM, "unable to set buffer time"); return ret; } } else if (params->buffer_size > 0) { ret = INTERNAL(snd_pcm_hw_params_set_buffer_size_near)(spcm, &hw_params, (snd_pcm_uframes_t *)¶ms->buffer_size); if (ret < 0) { - SNDERR("unable to set buffer size"); + snd_error(PCM, "unable to set buffer size"); return ret; } } else { @@ -1295,7 +1295,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str ret = INTERNAL(snd_pcm_hw_params_set_period_time_near)(spcm, &hw_params, (unsigned int *)¶ms->period_time, 0); if (ret < 0) { - SNDERR("unable to set period_time"); + snd_error(PCM, "unable to set period_time"); return ret; } } else if (params->period_size > 0) { @@ -1303,7 +1303,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str &hw_params, (snd_pcm_uframes_t *)¶ms->period_size, 0); if (ret < 0) { - SNDERR("unable to set period_size"); + snd_error(PCM, "unable to set period_size"); return ret; } } @@ -1313,7 +1313,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str ret = INTERNAL(snd_pcm_hw_params_set_periods_near)(spcm, &hw_params, ¶ms->periods, 0); if (ret < 0) { - SNDERR("unable to set requested periods"); + snd_error(PCM, "unable to set requested periods"); return ret; } if (params->periods == 1) { @@ -1325,14 +1325,14 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str params->period_size /= 2; goto __again; } - SNDERR("unable to use stream with periods == 1"); + snd_error(PCM, "unable to use stream with periods == 1"); return ret; } } ret = snd_pcm_hw_params(spcm, &hw_params); if (ret < 0) { - SNDERR("unable to install hw params"); + snd_error(PCM, "unable to install hw params"); return ret; } @@ -1356,18 +1356,18 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str ret = snd_pcm_sw_params_current(spcm, &sw_params); if (ret < 0) { - SNDERR("unable to get current sw_params"); + snd_error(PCM, "unable to get current sw_params"); return ret; } ret = snd_pcm_sw_params_get_boundary(&sw_params, &boundary); if (ret < 0) { - SNDERR("unable to get boundary"); + snd_error(PCM, "unable to get boundary"); return ret; } ret = snd_pcm_sw_params_set_stop_threshold(spcm, &sw_params, boundary); if (ret < 0) { - SNDERR("unable to set stop threshold"); + snd_error(PCM, "unable to set stop threshold"); return ret; } @@ -1378,7 +1378,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str ret = snd_pcm_sw_params_set_tstamp_mode(spcm, &sw_params, SND_PCM_TSTAMP_ENABLE); if (ret < 0) { - SNDERR("unable to tstamp mode MMAP"); + snd_error(PCM, "unable to tstamp mode MMAP"); return ret; } @@ -1386,7 +1386,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str ret = snd_pcm_sw_params_set_tstamp_type(spcm, &sw_params, dmix->tstamp_type); if (ret < 0) { - SNDERR("unable to set tstamp type"); + snd_error(PCM, "unable to set tstamp type"); return ret; } } @@ -1397,12 +1397,12 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str ret = snd_pcm_sw_params_set_silence_threshold(spcm, &sw_params, 0); if (ret < 0) { - SNDERR("unable to set silence threshold"); + snd_error(PCM, "unable to set silence threshold"); return ret; } ret = snd_pcm_sw_params_set_silence_size(spcm, &sw_params, boundary); if (ret < 0) { - SNDERR("unable to set silence threshold (please upgrade to 0.9.0rc8+ driver)"); + snd_error(PCM, "unable to set silence threshold (please upgrade to 0.9.0rc8+ driver)"); return ret; } @@ -1410,7 +1410,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str ret = snd_pcm_sw_params(spcm, &sw_params); if (ret < 0) { - SNDERR("unable to install sw params (please upgrade to 0.9.0rc8+ driver)"); + snd_error(PCM, "unable to install sw params (please upgrade to 0.9.0rc8+ driver)"); return ret; } @@ -1423,12 +1423,12 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str ret = snd_pcm_start(spcm); if (ret < 0) { - SNDERR("unable to start PCM stream"); + snd_error(PCM, "unable to start PCM stream"); return ret; } if (snd_pcm_poll_descriptors_count(spcm) != 1) { - SNDERR("unable to use hardware pcm with fd more than one!!!"); + snd_error(PCM, "unable to use hardware pcm with fd more than one!!!"); return ret; } snd_pcm_poll_descriptors(spcm, &fd, 1); @@ -1476,7 +1476,7 @@ int snd_pcm_direct_initialize_poll_fd(snd_pcm_direct_t *dmix) dmix->timer_ticks = 1; ret = snd_pcm_info(dmix->spcm, &info); if (ret < 0) { - SNDERR("unable to info for slave pcm"); + snd_error(PCM, "unable to info for slave pcm"); return ret; } sprintf(name, "hw:CLASS=%i,SCLASS=0,CARD=%i,DEV=%i,SUBDEV=%i", @@ -1491,13 +1491,13 @@ int snd_pcm_direct_initialize_poll_fd(snd_pcm_direct_t *dmix) ret = snd_timer_open(&dmix->timer, name, SND_TIMER_OPEN_NONBLOCK); if (ret < 0) { - SNDERR("unable to open timer '%s'", name); + snd_error(PCM, "unable to open timer '%s'", name); return ret; } } if (snd_timer_poll_descriptors_count(dmix->timer) != 1) { - SNDERR("unable to use timer '%s' with more than one fd!", name); + snd_error(PCM, "unable to use timer '%s' with more than one fd!", name); return ret; } snd_timer_poll_descriptors(dmix->timer, &dmix->timer_fd, 1); @@ -1598,7 +1598,7 @@ int snd_pcm_direct_open_secondary_client(snd_pcm_t **spcmp, snd_pcm_direct_t *dm ret = snd_pcm_hw_open_fd(spcmp, client_name, dmix->hw_fd, 0); if (ret < 0) { - SNDERR("unable to open hardware"); + snd_error(PCM, "unable to open hardware"); return ret; } @@ -1616,7 +1616,7 @@ int snd_pcm_direct_open_secondary_client(snd_pcm_t **spcmp, snd_pcm_direct_t *dm ret = snd_pcm_mmap(spcm); if (ret < 0) { - SNDERR("unable to mmap channels"); + snd_error(PCM, "unable to mmap channels"); return ret; } return 0; @@ -1643,7 +1643,7 @@ int snd_pcm_direct_initialize_secondary_slave(snd_pcm_direct_t *dmix, ret = snd_pcm_mmap(spcm); if (ret < 0) { - SNDERR("unable to mmap channels"); + snd_error(PCM, "unable to mmap channels"); return ret; } return 0; @@ -1666,7 +1666,7 @@ int snd_pcm_direct_set_timer_params(snd_pcm_direct_t *dmix) } ret = snd_timer_params(dmix->timer, ¶ms); if (ret < 0) { - SNDERR("unable to set timer parameters"); + snd_error(PCM, "unable to set timer parameters"); return ret; } return 0; @@ -1729,7 +1729,7 @@ int snd_pcm_direct_parse_bindings(snd_pcm_direct_t *dmix, if (cfg == NULL) return 0; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("invalid type for bindings"); + snd_error(PCM, "invalid type for bindings"); return -EINVAL; } snd_config_for_each(i, next, cfg) { @@ -1740,7 +1740,7 @@ int snd_pcm_direct_parse_bindings(snd_pcm_direct_t *dmix, continue; err = safe_strtol(id, &cchannel); if (err < 0 || cchannel < 0) { - SNDERR("invalid client channel in binding: %s", id); + snd_error(PCM, "invalid client channel in binding: %s", id); return -EINVAL; } if ((unsigned)cchannel >= count) @@ -1749,7 +1749,7 @@ int snd_pcm_direct_parse_bindings(snd_pcm_direct_t *dmix, if (count == 0) return 0; if (count > 1024) { - SNDERR("client channel out of range"); + snd_error(PCM, "client channel out of range"); return -EINVAL; } bindings = malloc(count * sizeof(unsigned int)); @@ -1765,13 +1765,14 @@ int snd_pcm_direct_parse_bindings(snd_pcm_direct_t *dmix, continue; safe_strtol(id, &cchannel); if (snd_config_get_integer(n, &schannel) < 0) { - SNDERR("unable to get slave channel (should be integer type) in binding: %s", id); + snd_error(PCM, "unable to get slave channel (should be integer type) in binding: %s", id); free(bindings); return -EINVAL; } if (schannel < 0 || schannel >= params->channels) { - SNDERR("invalid slave channel number %ld in binding to %ld", - schannel, cchannel); + snd_error(PCM, "invalid slave channel number %ld in binding to %ld", + schannel, cchannel); + free(bindings); return -EINVAL; } @@ -1785,7 +1786,7 @@ int snd_pcm_direct_parse_bindings(snd_pcm_direct_t *dmix, if (chn == chn1) continue; if (bindings[chn] == dmix->bindings[chn1]) { - SNDERR("unable to route channels %d,%d to same destination %d", chn, chn1, bindings[chn]); + snd_error(PCM, "unable to route channels %d,%d to same destination %d", chn, chn1, bindings[chn]); free(bindings); return -EINVAL; } @@ -1814,12 +1815,12 @@ static int _snd_pcm_direct_get_slave_ipc_offset(snd_config_t *root, if (snd_config_get_string(sconf, &str) >= 0) { if (hop > SND_CONF_MAX_HOPS) { - SNDERR("Too many definition levels (looped?)"); + snd_error(PCM, "Too many definition levels (looped?)"); return -EINVAL; } err = snd_config_search_definition(root, "pcm", str, &pcm_conf); if (err < 0) { - SNDERR("Unknown slave PCM %s", str); + snd_error(PCM, "Unknown slave PCM %s", str); return err; } err = _snd_pcm_direct_get_slave_ipc_offset(root, pcm_conf, @@ -1869,11 +1870,11 @@ static int _snd_pcm_direct_get_slave_ipc_offset(snd_config_t *root, if (strcmp(id, "type") == 0) { err = snd_config_get_string(n, &str); if (err < 0) { - SNDERR("Invalid value for PCM type definition"); + snd_error(PCM, "Invalid value for PCM type definition"); return -EINVAL; } if (strcmp(str, "hw")) { - SNDERR("Invalid type '%s' for slave PCM", str); + snd_error(PCM, "Invalid type '%s' for slave PCM", str); return -EINVAL; } continue; @@ -1888,7 +1889,7 @@ static int _snd_pcm_direct_get_slave_ipc_offset(snd_config_t *root, if (strcmp(id, "device") == 0) { err = snd_config_get_integer(n, &device); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return err; } continue; @@ -1896,7 +1897,7 @@ static int _snd_pcm_direct_get_slave_ipc_offset(snd_config_t *root, if (strcmp(id, "subdevice") == 0) { err = snd_config_get_integer(n, &subdevice); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return err; } continue; @@ -1959,7 +1960,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf, long key; err = snd_config_get_integer(n, &key); if (err < 0) { - SNDERR("The field ipc_key must be an integer type"); + snd_error(PCM, "The field ipc_key must be an integer type"); return err; } @@ -1970,11 +1971,11 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf, long perm; err = snd_config_get_integer(n, &perm); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return err; } if ((perm & ~0777) != 0) { - SNDERR("The field ipc_perm must be a valid file permission"); + snd_error(PCM, "The field ipc_perm must be a valid file permission"); return -EINVAL; } rec->ipc_perm = perm; @@ -1984,7 +1985,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf, const char *str; err = snd_config_get_string(n, &str); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } if (strcmp(str, "no") == 0 || strcmp(str, "off") == 0) @@ -1996,7 +1997,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf, else if (strcmp(str, "auto") == 0) rec->hw_ptr_alignment = SND_PCM_HW_PTR_ALIGNMENT_AUTO; else { - SNDERR("The field hw_ptr_alignment is invalid : %s", str); + snd_error(PCM, "The field hw_ptr_alignment is invalid : %s", str); return -EINVAL; } @@ -2006,7 +2007,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf, const char *str; err = snd_config_get_string(n, &str); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } if (strcmp(str, "default") == 0) @@ -2018,7 +2019,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf, else if (strcmp(str, "monotonic_raw") == 0) rec->tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW; else { - SNDERR("The field tstamp_type is invalid : %s", str); + snd_error(PCM, "The field tstamp_type is invalid : %s", str); return -EINVAL; } continue; @@ -2028,7 +2029,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf, char *endp; err = snd_config_get_ascii(n, &group); if (err < 0) { - SNDERR("The field ipc_gid must be a valid group"); + snd_error(PCM, "The field ipc_gid must be a valid group"); return err; } if (! *group) { @@ -2045,7 +2046,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf, return -ENOMEM; int st = getgrnam_r(group, &grp, buffer, len, &pgrp); if (st != 0 || !pgrp) { - SNDERR("The field ipc_gid must be a valid group (create group %s)", group); + snd_error(PCM, "The field ipc_gid must be a valid group (create group %s)", group); free(buffer); return -EINVAL; } @@ -2059,7 +2060,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf, } if (strcmp(id, "ipc_key_add_uid") == 0) { if ((err = snd_config_get_bool(n)) < 0) { - SNDERR("The field ipc_key_add_uid must be a boolean type"); + snd_error(PCM, "The field ipc_key_add_uid must be a boolean type"); return err; } ipc_key_add_uid = err; @@ -2102,15 +2103,15 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf, rec->direct_memory_access = err; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!rec->slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } if (!rec->ipc_key) { - SNDERR("Unique IPC key is not defined"); + snd_error(PCM, "Unique IPC key is not defined"); return -EINVAL; } if (ipc_key_add_uid) @@ -2175,7 +2176,7 @@ int _snd_pcm_direct_new(snd_pcm_t **pcmp, snd_pcm_direct_t **_dmix, int type, while (1) { ret = snd_pcm_direct_semaphore_create_or_connect(dmix); if (ret < 0) { - SNDERR("unable to create IPC semaphore"); + snd_error(PCM, "unable to create IPC semaphore"); goto _err_nosem_free; } ret = snd_pcm_direct_semaphore_down(dmix, DIRECT_IPC_SEM_CLIENT); @@ -2190,7 +2191,7 @@ int _snd_pcm_direct_new(snd_pcm_t **pcmp, snd_pcm_direct_t **_dmix, int type, ret = snd_pcm_direct_shm_create_or_connect(dmix); if (ret < 0) { - SNDERR("unable to create IPC shm instance"); + snd_error(PCM, "unable to create IPC shm instance"); snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT); goto _err_nosem_free; } else { diff --git a/src/pcm/pcm_direct.h b/src/pcm/pcm_direct.h index e7d89e5f..2a398045 100644 --- a/src/pcm/pcm_direct.h +++ b/src/pcm/pcm_direct.h @@ -308,7 +308,7 @@ static inline int snd_pcm_direct_semaphore_up(snd_pcm_direct_t *dmix, int sem_nu static inline int snd_pcm_direct_semaphore_final(snd_pcm_direct_t *dmix, int sem_num) { if (dmix->locked[sem_num] != 1) { - SNDMSG("invalid semaphore count to finalize %d: %d", sem_num, dmix->locked[sem_num]); + snd_check(PCM, "invalid semaphore count to finalize %d: %d", sem_num, dmix->locked[sem_num]); return -EBUSY; } return snd_pcm_direct_semaphore_up(dmix, sem_num); diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c index 55cae3e7..e1e94c0e 100644 --- a/src/pcm/pcm_dmix.c +++ b/src/pcm/pcm_dmix.c @@ -970,7 +970,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, assert(pcmp); if (stream != SND_PCM_STREAM_PLAYBACK) { - SNDERR("The dmix plugin supports only playback stream"); + snd_error(PCM, "The dmix plugin supports only playback stream"); return -EINVAL; } @@ -997,19 +997,19 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, ret = snd_pcm_open_slave(&spcm, root, sconf, stream, mode | SND_PCM_NONBLOCK, NULL); if (ret < 0) { - SNDERR("unable to open slave"); + snd_error(PCM, "unable to open slave"); goto _err; } if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) { - SNDERR("dmix plugin can be only connected to hw plugin"); + snd_error(PCM, "dmix plugin can be only connected to hw plugin"); ret = -EINVAL; goto _err; } ret = snd_pcm_direct_initialize_slave(dmix, spcm, params); if (ret < 0) { - SNDERR("unable to initialize slave"); + snd_error(PCM, "unable to initialize slave"); goto _err; } @@ -1020,7 +1020,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, ret = snd_pcm_direct_server_create(dmix); if (ret < 0) { - SNDERR("unable to create server"); + snd_error(PCM, "unable to create server"); goto _err; } } @@ -1032,7 +1032,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT); ret = snd_pcm_direct_client_connect(dmix); if (ret < 0) { - SNDERR("unable to connect client"); + snd_error(PCM, "unable to connect client"); goto _err_nosem; } @@ -1054,18 +1054,18 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, first_instance = 1; goto retry; } - SNDERR("unable to open slave"); + snd_error(PCM, "unable to open slave"); goto _err; } if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) { - SNDERR("dmix plugin can be only connected to hw plugin"); + snd_error(PCM, "dmix plugin can be only connected to hw plugin"); ret = -EINVAL; goto _err; } ret = snd_pcm_direct_initialize_secondary_slave(dmix, spcm, params); if (ret < 0) { - SNDERR("unable to initialize slave"); + snd_error(PCM, "unable to initialize slave"); goto _err; } } @@ -1075,13 +1075,13 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, ret = shm_sum_create_or_connect(dmix); if (ret < 0) { - SNDERR("unable to initialize sum ring buffer"); + snd_error(PCM, "unable to initialize sum ring buffer"); goto _err; } ret = snd_pcm_direct_initialize_poll_fd(dmix); if (ret < 0) { - SNDERR("unable to initialize poll_fd"); + snd_error(PCM, "unable to initialize poll_fd"); goto _err; } @@ -1325,7 +1325,7 @@ int _snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, params.format = SND_PCM_FORMAT_UNKNOWN; else if (!(dmix_supported_format & (1ULL << params.format))) { /* sorry, limited features */ - SNDERR("Unsupported format"); + snd_error(PCM, "Unsupported format"); snd_config_delete(sconf); return -EINVAL; } diff --git a/src/pcm/pcm_dshare.c b/src/pcm/pcm_dshare.c index c0329098..3cb66de8 100644 --- a/src/pcm/pcm_dshare.c +++ b/src/pcm/pcm_dshare.c @@ -667,7 +667,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, assert(pcmp); if (stream != SND_PCM_STREAM_PLAYBACK) { - SNDERR("The dshare plugin supports only playback stream"); + snd_error(PCM, "The dshare plugin supports only playback stream"); return -EINVAL; } @@ -698,18 +698,18 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, ret = snd_pcm_open_slave(&spcm, root, sconf, stream, mode | SND_PCM_NONBLOCK, NULL); if (ret < 0) { - SNDERR("unable to open slave"); + snd_error(PCM, "unable to open slave"); goto _err; } if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) { - SNDERR("dshare plugin can be only connected to hw plugin"); + snd_error(PCM, "dshare plugin can be only connected to hw plugin"); goto _err; } ret = snd_pcm_direct_initialize_slave(dshare, spcm, params); if (ret < 0) { - SNDERR("unable to initialize slave"); + snd_error(PCM, "unable to initialize slave"); goto _err; } @@ -718,7 +718,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, if (dshare->shmptr->use_server) { ret = snd_pcm_direct_server_create(dshare); if (ret < 0) { - SNDERR("unable to create server"); + snd_error(PCM, "unable to create server"); goto _err; } } @@ -730,7 +730,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, snd_pcm_direct_semaphore_up(dshare, DIRECT_IPC_SEM_CLIENT); ret = snd_pcm_direct_client_connect(dshare); if (ret < 0) { - SNDERR("unable to connect client"); + snd_error(PCM, "unable to connect client"); goto _err_nosem; } @@ -753,18 +753,18 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, first_instance = 1; goto retry; } - SNDERR("unable to open slave"); + snd_error(PCM, "unable to open slave"); goto _err; } if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) { - SNDERR("dshare plugin can be only connected to hw plugin"); + snd_error(PCM, "dshare plugin can be only connected to hw plugin"); ret = -EINVAL; goto _err; } ret = snd_pcm_direct_initialize_secondary_slave(dshare, spcm, params); if (ret < 0) { - SNDERR("unable to initialize slave"); + snd_error(PCM, "unable to initialize slave"); goto _err; } } @@ -778,7 +778,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, dshare->u.dshare.chn_mask |= (1ULL << dchn); } if (dshare->shmptr->u.dshare.chn_mask & dshare->u.dshare.chn_mask) { - SNDERR("destination channel specified in bindings is already used"); + snd_error(PCM, "destination channel specified in bindings is already used"); dshare->u.dshare.chn_mask = 0; ret = -EINVAL; goto _err; @@ -787,7 +787,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, ret = snd_pcm_direct_initialize_poll_fd(dshare); if (ret < 0) { - SNDERR("unable to initialize poll_fd"); + snd_error(PCM, "unable to initialize poll_fd"); goto _err; } diff --git a/src/pcm/pcm_dsnoop.c b/src/pcm/pcm_dsnoop.c index bf67c68a..684ed63f 100644 --- a/src/pcm/pcm_dsnoop.c +++ b/src/pcm/pcm_dsnoop.c @@ -538,7 +538,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, assert(pcmp); if (stream != SND_PCM_STREAM_CAPTURE) { - SNDERR("The dsnoop plugin supports only capture stream"); + snd_error(PCM, "The dsnoop plugin supports only capture stream"); return -EINVAL; } @@ -564,18 +564,18 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, ret = snd_pcm_open_slave(&spcm, root, sconf, stream, mode | SND_PCM_NONBLOCK, NULL); if (ret < 0) { - SNDERR("unable to open slave"); + snd_error(PCM, "unable to open slave"); goto _err; } if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) { - SNDERR("dsnoop plugin can be only connected to hw plugin"); + snd_error(PCM, "dsnoop plugin can be only connected to hw plugin"); goto _err; } ret = snd_pcm_direct_initialize_slave(dsnoop, spcm, params); if (ret < 0) { - SNDERR("unable to initialize slave"); + snd_error(PCM, "unable to initialize slave"); goto _err; } @@ -584,7 +584,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, if (dsnoop->shmptr->use_server) { ret = snd_pcm_direct_server_create(dsnoop); if (ret < 0) { - SNDERR("unable to create server"); + snd_error(PCM, "unable to create server"); goto _err; } } @@ -596,7 +596,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, snd_pcm_direct_semaphore_up(dsnoop, DIRECT_IPC_SEM_CLIENT); ret = snd_pcm_direct_client_connect(dsnoop); if (ret < 0) { - SNDERR("unable to connect client"); + snd_error(PCM, "unable to connect client"); goto _err_nosem; } @@ -619,18 +619,18 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, first_instance = 1; goto retry; } - SNDERR("unable to open slave"); + snd_error(PCM, "unable to open slave"); goto _err; } if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) { - SNDERR("dsnoop plugin can be only connected to hw plugin"); + snd_error(PCM, "dsnoop plugin can be only connected to hw plugin"); ret = -EINVAL; goto _err; } ret = snd_pcm_direct_initialize_secondary_slave(dsnoop, spcm, params); if (ret < 0) { - SNDERR("unable to initialize slave"); + snd_error(PCM, "unable to initialize slave"); goto _err; } } @@ -640,7 +640,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, ret = snd_pcm_direct_initialize_poll_fd(dsnoop); if (ret < 0) { - SNDERR("unable to initialize poll_fd"); + snd_error(PCM, "unable to initialize poll_fd"); goto _err; } diff --git a/src/pcm/pcm_empty.c b/src/pcm/pcm_empty.c index 7cbd349f..72065b94 100644 --- a/src/pcm/pcm_empty.c +++ b/src/pcm/pcm_empty.c @@ -95,11 +95,11 @@ int _snd_pcm_empty_open(snd_pcm_t **pcmp, const char *name ATTRIBUTE_UNUSED, slave = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 0); diff --git a/src/pcm/pcm_extplug.c b/src/pcm/pcm_extplug.c index feb32b99..bb7933c8 100644 --- a/src/pcm/pcm_extplug.c +++ b/src/pcm/pcm_extplug.c @@ -547,12 +547,12 @@ SND_PCM_PLUGIN_DEFINE_FUNC(myplug) .... continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (! slave) { - SNDERR("No slave defined for myplug"); + snd_error(PCM, "No slave defined for myplug"); return -EINVAL; } @@ -690,8 +690,9 @@ int snd_pcm_extplug_create(snd_pcm_extplug_t *extplug, const char *name, /* We support 1.0.0 to current */ if (extplug->version < 0x010000 || extplug->version > SND_PCM_EXTPLUG_VERSION) { - SNDERR("extplug: Plugin version mismatch: 0x%x", - extplug->version); + snd_error(PCM, "extplug: Plugin version mismatch: 0x%x", + extplug->version); + return -ENXIO; } @@ -781,7 +782,7 @@ int snd_pcm_extplug_set_slave_param_list(snd_pcm_extplug_t *extplug, int type, u { extplug_priv_t *ext = extplug->pcm->private_data; if (type < 0 || type >= SND_PCM_EXTPLUG_HW_PARAMS) { - SNDERR("EXTPLUG: invalid parameter type %d", type); + snd_error(PCM, "EXTPLUG: invalid parameter type %d", type); return -EINVAL; } return snd_ext_parm_set_list(&ext->sparams[type], num_list, list); @@ -803,11 +804,11 @@ int snd_pcm_extplug_set_slave_param_minmax(snd_pcm_extplug_t *extplug, int type, { extplug_priv_t *ext = extplug->pcm->private_data; if (type < 0 || type >= SND_PCM_EXTPLUG_HW_PARAMS) { - SNDERR("EXTPLUG: invalid parameter type %d", type); + snd_error(PCM, "EXTPLUG: invalid parameter type %d", type); return -EINVAL; } if (is_mask_type(type)) { - SNDERR("EXTPLUG: invalid parameter type %d", type); + snd_error(PCM, "EXTPLUG: invalid parameter type %d", type); return -EINVAL; } return snd_ext_parm_set_minmax(&ext->sparams[type], min, max); @@ -829,7 +830,7 @@ int snd_pcm_extplug_set_param_list(snd_pcm_extplug_t *extplug, int type, unsigne { extplug_priv_t *ext = extplug->pcm->private_data; if (type < 0 || type >= SND_PCM_EXTPLUG_HW_PARAMS) { - SNDERR("EXTPLUG: invalid parameter type %d", type); + snd_error(PCM, "EXTPLUG: invalid parameter type %d", type); return -EINVAL; } return snd_ext_parm_set_list(&ext->params[type], num_list, list); @@ -851,11 +852,11 @@ int snd_pcm_extplug_set_param_minmax(snd_pcm_extplug_t *extplug, int type, unsig { extplug_priv_t *ext = extplug->pcm->private_data; if (type < 0 || type >= SND_PCM_EXTPLUG_HW_PARAMS) { - SNDERR("EXTPLUG: invalid parameter type %d", type); + snd_error(PCM, "EXTPLUG: invalid parameter type %d", type); return -EINVAL; } if (is_mask_type(type)) { - SNDERR("EXTPLUG: invalid parameter type %d", type); + snd_error(PCM, "EXTPLUG: invalid parameter type %d", type); return -EINVAL; } return snd_ext_parm_set_minmax(&ext->params[type], min, max); @@ -877,7 +878,7 @@ int snd_pcm_extplug_set_param_link(snd_pcm_extplug_t *extplug, int type, extplug_priv_t *ext = extplug->pcm->private_data; if (type < 0 || type >= SND_PCM_EXTPLUG_HW_PARAMS) { - SNDERR("EXTPLUG: invalid parameter type %d", type); + snd_error(PCM, "EXTPLUG: invalid parameter type %d", type); return -EINVAL; } ext->params[type].keep_link = keep_link ? 1 : 0; diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c index 90b3f3f5..a5208067 100644 --- a/src/pcm/pcm_file.c +++ b/src/pcm/pcm_file.c @@ -239,8 +239,9 @@ static int snd_pcm_file_open_output_file(snd_pcm_file_t *file) /* clearing */ pipe = popen(file->final_fname + 1, "w"); if (!pipe) { - SYSERR("running %s for writing failed", - file->final_fname); + snd_errornum(PCM, "running %s for writing failed", + file->final_fname); + return -errno; } fd = fileno(pipe); @@ -274,8 +275,9 @@ static int snd_pcm_file_open_output_file(snd_pcm_file_t *file) } } if (fd < 0) { - SYSERR("open %s for writing failed", - file->final_fname); + snd_errornum(PCM, "open %s for writing failed", + file->final_fname); + free(tmpfname); return -errno; } @@ -303,7 +305,7 @@ static int snd_pcm_file_areas_read_infile(snd_pcm_t *pcm, return -ENOMEM; if (file->rbuf_size < frames) { - SYSERR("requested more frames than pcm buffer"); + snd_errornum(PCM, "requested more frames than pcm buffer"); return -ENOMEM; } @@ -312,7 +314,7 @@ static int snd_pcm_file_areas_read_infile(snd_pcm_t *pcm, return bytes; bytes = read(file->ifd, file->rbuf, bytes); if (bytes < 0) { - SYSERR("read from file failed, error: %d", bytes); + snd_errornum(PCM, "read from file failed, error: %d", bytes); return bytes; } @@ -376,9 +378,9 @@ write_error: * be used to signal XRUN on playback device */ if (res < 0) - SYSERR("%s write header failed, file data may be corrupt", file->fname); + snd_errornum(PCM, "%s write header failed, file data may be corrupt", file->fname); else - SNDERR("%s write header incomplete, file data may be corrupt", file->fname); + snd_error(PCM, "%s write header incomplete, file data may be corrupt", file->fname); memset(&file->wav_header, 0, sizeof(struct wav_fmt)); @@ -440,7 +442,7 @@ static int snd_pcm_file_write_bytes(snd_pcm_t *pcm, size_t bytes) if (err < 0) { file->wbuf_used_bytes = 0; file->file_ptr_bytes = 0; - SYSERR("%s write failed, file data may be corrupt", file->fname); + snd_errornum(PCM, "%s write failed, file data may be corrupt", file->fname); return err; } bytes -= err; @@ -791,7 +793,7 @@ static int snd_pcm_file_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) if (file->fd < 0) { err = snd_pcm_file_open_output_file(file); if (err < 0) { - SYSERR("failed opening output file %s", file->fname); + snd_errornum(PCM, "failed opening output file %s", file->fname); return err; } } @@ -914,7 +916,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, else if (!strcmp(fmt, "wav")) format = SND_PCM_FILE_FORMAT_WAV; else { - SNDERR("file format %s is unknown", fmt); + snd_error(PCM, "file format %s is unknown", fmt); return -EINVAL; } file = calloc(1, sizeof(snd_pcm_file_t)); @@ -932,7 +934,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, if (ifname && (stream == SND_PCM_STREAM_CAPTURE)) { ifd = open(ifname, O_RDONLY); /* TODO: mind blocking mode */ if (ifd < 0) { - SYSERR("open %s for reading failed", ifname); + snd_errornum(PCM, "open %s for reading failed", ifname); free(file->fname); free(file); return -errno; @@ -1057,7 +1059,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "format") == 0) { err = snd_config_get_string(n, &format); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } continue; @@ -1067,7 +1069,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, if (err < 0) { err = snd_config_get_integer(n, &fd); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } } @@ -1078,7 +1080,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, if (err < 0) { err = snd_config_get_integer(n, &ifd); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } } @@ -1087,11 +1089,11 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "perm") == 0) { err = snd_config_get_integer(n, &perm); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return err; } if ((perm & ~0777) != 0) { - SNDERR("The field perm must be a valid file permission"); + snd_error(PCM, "The field perm must be a valid file permission"); return -EINVAL; } continue; @@ -1103,7 +1105,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, trunc = err; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!format) { @@ -1112,13 +1114,13 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, if (snd_config_search(root, "defaults.pcm.file_format", &n) >= 0) { err = snd_config_get_string(n, &format); if (err < 0) { - SNDERR("Invalid file format"); + snd_error(PCM, "Invalid file format"); return -EINVAL; } } } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 0); @@ -1126,7 +1128,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, return err; if ((!fname || strlen(fname) == 0) && fd < 0) { snd_config_delete(sconf); - SNDERR("file is not defined"); + snd_error(PCM, "file is not defined"); return -EINVAL; } err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode, conf); diff --git a/src/pcm/pcm_hooks.c b/src/pcm/pcm_hooks.c index 4416d363..c4afbccb 100644 --- a/src/pcm/pcm_hooks.c +++ b/src/pcm/pcm_hooks.c @@ -350,7 +350,7 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_ void *h = NULL; if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid hook definition"); + snd_error(PCM, "Invalid hook definition"); return -EINVAL; } snd_config_for_each(i, next, conf) { @@ -368,27 +368,27 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_ args = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!type) { - SNDERR("type is not defined"); + snd_error(PCM, "type is not defined"); return -EINVAL; } err = snd_config_get_id(type, &id); if (err < 0) { - SNDERR("unable to get id"); + snd_error(PCM, "unable to get id"); return err; } err = snd_config_get_string(type, &str); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return err; } err = snd_config_search_definition(root, "pcm_hook_type", str, &type); if (err >= 0) { if (snd_config_get_type(type) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for PCM type %s definition", str); + snd_error(PCM, "Invalid type for PCM type %s definition", str); err = -EINVAL; goto _err; } @@ -402,7 +402,7 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_ if (strcmp(id, "lib") == 0) { err = snd_config_get_string(n, &lib); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto _err; } continue; @@ -410,12 +410,12 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_ if (strcmp(id, "install") == 0) { err = snd_config_get_string(n, &install); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto _err; } continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); err = -EINVAL; goto _err; } @@ -428,12 +428,14 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_ install_func = h ? snd_dlsym(h, install, SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION)) : NULL; err = 0; if (!h) { - SNDERR("Cannot open shared library %s (%s)", - lib ? lib : "[builtin]", errbuf); + snd_error(PCM, "Cannot open shared library %s (%s)", + lib ? lib : "[builtin]", errbuf); + err = -ENOENT; } else if (!install_func) { - SNDERR("symbol %s is not defined inside %s", install, - lib ? lib : "[builtin]"); + snd_error(PCM, "symbol %s is not defined inside %s", install, + lib ? lib : "[builtin]"); + snd_dlclose(h); err = -ENXIO; } @@ -446,7 +448,7 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_ if (args && snd_config_get_string(args, &str) >= 0) { err = snd_config_search_definition(root, "hook_args", str, &args); if (err < 0) - SNDERR("unknown hook_args %s", str); + snd_error(PCM, "unknown hook_args %s", str); else err = install_func(pcm, args); snd_config_delete(args); @@ -499,17 +501,17 @@ int _snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name, } if (strcmp(id, "hooks") == 0) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } hooks = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 0); @@ -532,7 +534,7 @@ int _snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name, if (snd_config_get_string(n, &str) >= 0) { err = snd_config_search_definition(root, "pcm_hook", str, &n); if (err < 0) { - SNDERR("unknown pcm_hook %s", str); + snd_error(PCM, "unknown pcm_hook %s", str); } else { err = snd_pcm_hook_add_conf(rpcm, root, n); snd_config_delete(n); @@ -681,13 +683,13 @@ int _snd_pcm_hook_ctl_elems_install(snd_pcm_t *pcm, snd_config_t *conf) return err; card = snd_pcm_info_get_card(&info); if (card < 0) { - SNDERR("No card for this PCM"); + snd_error(PCM, "No card for this PCM"); return -EINVAL; } sprintf(ctl_name, "hw:%d", card); err = snd_ctl_open(&ctl, ctl_name, 0); if (err < 0) { - SNDERR("Cannot open CTL %s", ctl_name); + snd_error(PCM, "Cannot open CTL %s", ctl_name); return err; } err = snd_config_imake_pointer(&pcm_conf, "pcm_handle", pcm); diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index 833cad02..207738ef 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -145,7 +145,7 @@ static int sync_ptr1(snd_pcm_hw_t *hw, unsigned int flags) hw->sync_ptr->flags = flags; if (ioctl(hw->fd, SNDRV_PCM_IOCTL_SYNC_PTR, hw->sync_ptr) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_SYNC_PTR failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_SYNC_PTR failed (%i)", err); return err; } return 0; @@ -268,7 +268,7 @@ static int snd_pcm_hw_nonblock(snd_pcm_t *pcm, int nonblock) if ((flags = fcntl(fd, F_GETFL)) < 0) { err = -errno; - SYSMSG("F_GETFL failed (%i)", err); + snd_checknum(PCM, "F_GETFL failed (%i)", err); return err; } if (nonblock) @@ -277,7 +277,7 @@ static int snd_pcm_hw_nonblock(snd_pcm_t *pcm, int nonblock) flags &= ~O_NONBLOCK; if (fcntl(fd, F_SETFL, flags) < 0) { err = -errno; - SYSMSG("F_SETFL for O_NONBLOCK failed (%i)", err); + snd_checknum(PCM, "F_SETFL for O_NONBLOCK failed (%i)", err); return err; } return 0; @@ -291,7 +291,7 @@ static int snd_pcm_hw_async(snd_pcm_t *pcm, int sig, pid_t pid) if ((flags = fcntl(fd, F_GETFL)) < 0) { err = -errno; - SYSMSG("F_GETFL failed (%i)", err); + snd_checknum(PCM, "F_GETFL failed (%i)", err); return err; } if (sig >= 0) @@ -300,19 +300,19 @@ static int snd_pcm_hw_async(snd_pcm_t *pcm, int sig, pid_t pid) flags &= ~O_ASYNC; if (fcntl(fd, F_SETFL, flags) < 0) { err = -errno; - SYSMSG("F_SETFL for O_ASYNC failed (%i)", err); + snd_checknum(PCM, "F_SETFL for O_ASYNC failed (%i)", err); return err; } if (sig < 0) return 0; if (fcntl(fd, F_SETSIG, (long)sig) < 0) { err = -errno; - SYSMSG("F_SETSIG failed (%i)", err); + snd_checknum(PCM, "F_SETSIG failed (%i)", err); return err; } if (fcntl(fd, F_SETOWN, (long)pid) < 0) { err = -errno; - SYSMSG("F_SETOWN failed (%i)", err); + snd_checknum(PCM, "F_SETOWN failed (%i)", err); return err; } return 0; @@ -324,7 +324,7 @@ static int snd_pcm_hw_info(snd_pcm_t *pcm, snd_pcm_info_t * info) int fd = hw->fd, err; if (ioctl(fd, SNDRV_PCM_IOCTL_INFO, info) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_INFO failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_INFO failed (%i)", err); return err; } /* may be configurable (optional) */ @@ -409,7 +409,7 @@ static int snd_pcm_hw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) int err; if (hw_params_call(hw, params) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_HW_PARAMS failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_HW_PARAMS failed (%i)", err); return err; } params->info &= ~0xf0000000; @@ -515,7 +515,7 @@ static int snd_pcm_hw_hw_free(snd_pcm_t *pcm) snd_pcm_hw_change_timer(pcm, 0); if (ioctl(fd, SNDRV_PCM_IOCTL_HW_FREE) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_HW_FREE failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_HW_FREE failed (%i)", err); return err; } return 0; @@ -541,19 +541,19 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params) } if (params->tstamp_type == SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW && hw->version < SNDRV_PROTOCOL_VERSION(2, 0, 12)) { - SYSMSG("Kernel doesn't support SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW"); + snd_checknum(PCM, "Kernel doesn't support SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW"); err = -EINVAL; goto out; } if (params->tstamp_type == SND_PCM_TSTAMP_TYPE_MONOTONIC && hw->version < SNDRV_PROTOCOL_VERSION(2, 0, 5)) { - SYSMSG("Kernel doesn't support SND_PCM_TSTAMP_TYPE_MONOTONIC"); + snd_checknum(PCM, "Kernel doesn't support SND_PCM_TSTAMP_TYPE_MONOTONIC"); err = -EINVAL; goto out; } if (ioctl(fd, SNDRV_PCM_IOCTL_SW_PARAMS, params) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err); goto out; } hw->prepare_reset_sw_params = false; @@ -563,7 +563,7 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params) SND_PCM_TSTAMP_TYPE_MONOTONIC; if (ioctl(fd, SNDRV_PCM_IOCTL_TSTAMP, &on) < 0) { err = -errno; - SNDMSG("TSTAMP failed"); + snd_check(PCM, "TSTAMP failed"); goto out; } } @@ -589,7 +589,7 @@ static int snd_pcm_hw_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t * info i.channel = info->channel; if (ioctl(fd, SNDRV_PCM_IOCTL_CHANNEL_INFO, &i) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_CHANNEL_INFO failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_CHANNEL_INFO failed (%i)", err); return err; } info->channel = i.channel; @@ -609,13 +609,13 @@ static int snd_pcm_hw_status(snd_pcm_t *pcm, snd_pcm_status_t * status) if (SNDRV_PROTOCOL_VERSION(2, 0, 13) > hw->version) { if (ioctl(fd, SNDRV_PCM_IOCTL_STATUS, status) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_STATUS failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_STATUS failed (%i)", err); return err; } } else { if (ioctl(fd, SNDRV_PCM_IOCTL_STATUS_EXT, status) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_STATUS_EXT failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_STATUS_EXT failed (%i)", err); return err; } } @@ -642,7 +642,7 @@ static int snd_pcm_hw_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp) int fd = hw->fd, err; if (ioctl(fd, SNDRV_PCM_IOCTL_DELAY, delayp) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_DELAY failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_DELAY failed (%i)", err); return err; } return 0; @@ -660,7 +660,7 @@ static int snd_pcm_hw_hwsync(snd_pcm_t *pcm) } else { if (ioctl(fd, SNDRV_PCM_IOCTL_HWSYNC) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_HWSYNC failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_HWSYNC failed (%i)", err); return err; } } @@ -690,14 +690,14 @@ static int snd_pcm_hw_prepare(snd_pcm_t *pcm) snd_pcm_sw_params_current_no_lock(pcm, &sw_params); if (ioctl(hw->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sw_params) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err); return err; } hw->prepare_reset_sw_params = false; } if (ioctl(fd, SNDRV_PCM_IOCTL_PREPARE) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_PREPARE failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_PREPARE failed (%i)", err); return err; } return query_status_and_control_data(hw); @@ -709,7 +709,7 @@ static int snd_pcm_hw_reset(snd_pcm_t *pcm) int fd = hw->fd, err; if (ioctl(fd, SNDRV_PCM_IOCTL_RESET) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_RESET failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_RESET failed (%i)", err); return err; } return query_status_and_control_data(hw); @@ -726,10 +726,10 @@ static int snd_pcm_hw_start(snd_pcm_t *pcm) issue_applptr(hw); if (ioctl(hw->fd, SNDRV_PCM_IOCTL_START) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_START failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_START failed (%i)", err); #if 0 if (err == -EBADFD) - SNDERR("PCM state = %s", snd_pcm_state_name(snd_pcm_hw_state(pcm))); + snd_error(PCM, "PCM state = %s", snd_pcm_state_name(snd_pcm_hw_state(pcm))); #endif return err; } @@ -742,7 +742,7 @@ static int snd_pcm_hw_drop(snd_pcm_t *pcm) int err; if (ioctl(hw->fd, SNDRV_PCM_IOCTL_DROP) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_DROP failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_DROP failed (%i)", err); return err; } else { } @@ -792,7 +792,7 @@ __manual_silence: sw_params.silence_size = silence_size; if (ioctl(hw->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sw_params) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err); return err; } hw->prepare_reset_sw_params = true; @@ -800,7 +800,7 @@ __manual_silence: __skip_silence: if (ioctl(hw->fd, SNDRV_PCM_IOCTL_DRAIN) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_DRAIN failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_DRAIN failed (%i)", err); return err; } return 0; @@ -812,7 +812,7 @@ static int snd_pcm_hw_pause(snd_pcm_t *pcm, int enable) int err; if (ioctl(hw->fd, SNDRV_PCM_IOCTL_PAUSE, enable) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_PAUSE failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_PAUSE failed (%i)", err); return err; } return 0; @@ -829,7 +829,7 @@ static snd_pcm_sframes_t snd_pcm_hw_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t fra int err; if (ioctl(hw->fd, SNDRV_PCM_IOCTL_REWIND, &frames) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_REWIND failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_REWIND failed (%i)", err); return err; } err = query_status_and_control_data(hw); @@ -850,7 +850,7 @@ static snd_pcm_sframes_t snd_pcm_hw_forward(snd_pcm_t *pcm, snd_pcm_uframes_t fr if (SNDRV_PROTOCOL_VERSION(2, 0, 4) <= hw->version) { if (ioctl(hw->fd, SNDRV_PCM_IOCTL_FORWARD, &frames) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_FORWARD failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_FORWARD failed (%i)", err); return err; } err = query_status_and_control_data(hw); @@ -887,7 +887,7 @@ static int snd_pcm_hw_resume(snd_pcm_t *pcm) int fd = hw->fd, err; if (ioctl(fd, SNDRV_PCM_IOCTL_RESUME) < 0) { err = -errno; - SYSMSG("SNDRV_PCM_IOCTL_RESUME failed (%i)", err); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_RESUME failed (%i)", err); return err; } return 0; @@ -898,7 +898,7 @@ static int hw_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2) snd_pcm_hw_t *hw1 = pcm1->private_data; snd_pcm_hw_t *hw2 = pcm2->private_data; if (ioctl(hw1->fd, SNDRV_PCM_IOCTL_LINK, hw2->fd) < 0) { - SYSMSG("SNDRV_PCM_IOCTL_LINK failed (%i)", -errno); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_LINK failed (%i)", -errno); return -errno; } return 0; @@ -907,7 +907,7 @@ static int hw_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2) static int snd_pcm_hw_link_slaves(snd_pcm_t *pcm, snd_pcm_t *master) { if (master->type != SND_PCM_TYPE_HW) { - SYSMSG("Invalid type for SNDRV_PCM_IOCTL_LINK (%i)", master->type); + snd_checknum(PCM, "Invalid type for SNDRV_PCM_IOCTL_LINK (%i)", master->type); return -EINVAL; } return hw_link(master, pcm); @@ -928,7 +928,7 @@ static int snd_pcm_hw_unlink(snd_pcm_t *pcm) snd_pcm_hw_t *hw = pcm->private_data; if (ioctl(hw->fd, SNDRV_PCM_IOCTL_UNLINK) < 0) { - SYSMSG("SNDRV_PCM_IOCTL_UNLINK failed (%i)", -errno); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_UNLINK failed (%i)", -errno); return -errno; } return 0; @@ -1128,7 +1128,7 @@ static void unmap_status_data(snd_pcm_hw_t *hw) if (!hw->mmap_status_fallbacked) { if (munmap((void *)hw->mmap_status, page_align(sizeof(*hw->mmap_status))) < 0) - SYSMSG("status munmap failed (%u)", errno); + snd_checknum(PCM, "status munmap failed (%u)", errno); } } @@ -1137,7 +1137,7 @@ static void unmap_control_data(snd_pcm_hw_t *hw) if (!hw->mmap_control_fallbacked) { if (munmap((void *)hw->mmap_control, page_align(sizeof(*hw->mmap_control))) < 0) - SYSMSG("control munmap failed (%u)", errno); + snd_checknum(PCM, "control munmap failed (%u)", errno); } } @@ -1172,7 +1172,7 @@ static int snd_pcm_hw_close(snd_pcm_t *pcm) int err = 0; if (close(hw->fd)) { err = -errno; - SYSMSG("close failed (%i)", err); + snd_checknum(PCM, "close failed (%i)", err); } unmap_status_and_control_data(hw); @@ -1295,7 +1295,7 @@ snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev, ret = snd_ctl_hw_open(&ctl, NULL, card, 0); if (ret < 0) { - SYSMSG("Cannot open the associated CTL"); + snd_checknum(PCM, "Cannot open the associated CTL"); return NULL; } @@ -1303,7 +1303,7 @@ snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev, ret = snd_ctl_elem_tlv_read(ctl, &id, tlv, sizeof(tlv)); snd_ctl_close(ctl); if (ret < 0) { - SYSMSG("Cannot read Channel Map TLV"); + snd_checknum(PCM, "Cannot read Channel Map TLV"); return NULL; } @@ -1317,7 +1317,7 @@ snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev, type = tlv[SNDRV_CTL_TLVO_TYPE]; if (type != SND_CTL_TLVT_CONTAINER) { if (!is_chmap_type(type)) { - SYSMSG("Invalid TLV type %d", type); + snd_checknum(PCM, "Invalid TLV type %d", type); return NULL; } start = tlv; @@ -1330,7 +1330,7 @@ snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev, nums = 0; for (p = start; size > 0; ) { if (!is_chmap_type(p[0])) { - SYSMSG("Invalid TLV type %d", p[0]); + snd_checknum(PCM, "Invalid TLV type %d", p[0]); return NULL; } nums++; @@ -1421,8 +1421,9 @@ static snd_pcm_chmap_t *snd_pcm_hw_get_chmap(snd_pcm_t *pcm) case SNDRV_PCM_STATE_SUSPENDED: break; default: - SYSMSG("Invalid PCM state for chmap_get: %s", - snd_pcm_state_name(FAST_PCM_STATE(hw))); + snd_checknum(PCM, "Invalid PCM state for chmap_get: %s", + snd_pcm_state_name(FAST_PCM_STATE(hw))); + return NULL; } map = malloc(pcm->channels * sizeof(map->pos[0]) + sizeof(*map)); @@ -1432,7 +1433,7 @@ static snd_pcm_chmap_t *snd_pcm_hw_get_chmap(snd_pcm_t *pcm) ret = snd_ctl_hw_open(&ctl, NULL, hw->card, 0); if (ret < 0) { free(map); - SYSMSG("Cannot open the associated CTL"); + snd_checknum(PCM, "Cannot open the associated CTL"); chmap_caps_set_error(hw, CHMAP_CTL_GET); return NULL; } @@ -1442,7 +1443,7 @@ static snd_pcm_chmap_t *snd_pcm_hw_get_chmap(snd_pcm_t *pcm) snd_ctl_close(ctl); if (ret < 0) { free(map); - SYSMSG("Cannot read Channel Map ctl"); + snd_checknum(PCM, "Cannot read Channel Map ctl"); chmap_caps_set_error(hw, CHMAP_CTL_GET); return NULL; } @@ -1468,17 +1469,18 @@ static int snd_pcm_hw_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map) return -ENXIO; if (map->channels > 128) { - SYSMSG("Invalid number of channels %d", map->channels); + snd_checknum(PCM, "Invalid number of channels %d", map->channels); return -EINVAL; } if (FAST_PCM_STATE(hw) != SNDRV_PCM_STATE_PREPARED) { - SYSMSG("Invalid PCM state for chmap_set: %s", - snd_pcm_state_name(FAST_PCM_STATE(hw))); + snd_checknum(PCM, "Invalid PCM state for chmap_set: %s", + snd_pcm_state_name(FAST_PCM_STATE(hw))); + return -EBADFD; } ret = snd_ctl_hw_open(&ctl, NULL, hw->card, 0); if (ret < 0) { - SYSMSG("Cannot open the associated CTL"); + snd_checknum(PCM, "Cannot open the associated CTL"); chmap_caps_set_error(hw, CHMAP_CTL_SET); return ret; } @@ -1496,7 +1498,7 @@ static int snd_pcm_hw_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map) ret = -ENXIO; } if (ret < 0) - SYSMSG("Cannot write Channel Map ctl"); + snd_checknum(PCM, "Cannot write Channel Map ctl"); return ret; } @@ -1506,7 +1508,7 @@ static void snd_pcm_hw_dump(snd_pcm_t *pcm, snd_output_t *out) char *name; int err = snd_card_get_name(hw->card, &name); if (err < 0) { - SNDERR("cannot get card name"); + snd_error(PCM, "cannot get card name"); return; } snd_output_printf(out, "Hardware PCM card %d '%s' device %d subdevice %d\n", @@ -1627,7 +1629,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd, memset(&info, 0, sizeof(info)); if (ioctl(fd, SNDRV_PCM_IOCTL_INFO, &info) < 0) { ret = -errno; - SYSMSG("SNDRV_PCM_IOCTL_INFO failed (%i)", ret); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_INFO failed (%i)", ret); close(fd); return ret; @@ -1648,7 +1650,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd, if (ioctl(fd, SNDRV_PCM_IOCTL_PVERSION, &ver) < 0) { ret = -errno; - SYSMSG("SNDRV_PCM_IOCTL_PVERSION failed (%i)", ret); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_PVERSION failed (%i)", ret); close(fd); return ret; } @@ -1660,7 +1662,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd, unsigned int user_ver = SNDRV_PCM_VERSION; if (ioctl(fd, SNDRV_PCM_IOCTL_USER_PVERSION, &user_ver) < 0) { ret = -errno; - SNDMSG("USER_PVERSION failed"); + snd_check(PCM, "USER_PVERSION failed"); return ret; } } @@ -1673,7 +1675,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd, int on = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC; if (ioctl(fd, SNDRV_PCM_IOCTL_TTSTAMP, &on) < 0) { ret = -errno; - SNDMSG("TTSTAMP failed"); + snd_check(PCM, "TTSTAMP failed"); return ret; } } @@ -1685,7 +1687,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd, int on = 1; if (ioctl(fd, SNDRV_PCM_IOCTL_TSTAMP, &on) < 0) { ret = -errno; - SNDMSG("TSTAMP failed"); + snd_check(PCM, "TSTAMP failed"); return ret; } } @@ -1777,7 +1779,7 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, filefmt = SNDRV_FILE_PCM_STREAM_CAPTURE; break; default: - SNDERR("invalid stream %d", stream); + snd_error(PCM, "invalid stream %d", stream); return -EINVAL; } sprintf(filename, filefmt, card, device); @@ -1800,14 +1802,14 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, fd = snd_open_device(filename, fmode); if (fd < 0) { ret = -errno; - SYSMSG("open '%s' failed (%i)", filename, ret); + snd_checknum(PCM, "open '%s' failed (%i)", filename, ret); goto _err; } if (subdevice >= 0) { memset(&info, 0, sizeof(info)); if (ioctl(fd, SNDRV_PCM_IOCTL_INFO, &info) < 0) { ret = -errno; - SYSMSG("SNDRV_PCM_IOCTL_INFO failed (%i)", ret); + snd_checknum(PCM, "SNDRV_PCM_IOCTL_INFO failed (%i)", ret); goto _err; } if (info.subdevice != (unsigned int) subdevice) { @@ -1915,7 +1917,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "device") == 0) { err = snd_config_get_integer(n, &device); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto fail; } continue; @@ -1923,7 +1925,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "subdevice") == 0) { err = snd_config_get_integer(n, &subdevice); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto fail; } continue; @@ -1949,12 +1951,12 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, snd_config_t *m; err = snd_config_search(n, "0", &m); if (err < 0) { - SNDERR("array expected for rate compound"); + snd_error(PCM, "array expected for rate compound"); goto fail; } err = snd_config_get_integer(m, &val); if (err < 0) { - SNDERR("Invalid type for rate.0"); + snd_error(PCM, "Invalid type for rate.0"); goto fail; } min_rate = max_rate = val; @@ -1962,7 +1964,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, if (err >= 0) { err = snd_config_get_integer(m, &val); if (err < 0) { - SNDERR("Invalid type for rate.0"); + snd_error(PCM, "Invalid type for rate.0"); goto fail; } max_rate = val; @@ -1970,7 +1972,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, } else { err = snd_config_get_integer(n, &val); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto fail; } min_rate = max_rate = val; @@ -1981,7 +1983,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, long val; err = snd_config_get_integer(n, &val); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto fail; } min_rate = val; @@ -1991,7 +1993,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, long val; err = snd_config_get_integer(n, &val); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto fail; } max_rate = val; @@ -2000,7 +2002,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "format") == 0) { err = snd_config_get_string(n, &str); if (err < 0) { - SNDERR("invalid type for %s", id); + snd_error(PCM, "invalid type for %s", id); goto fail; } format = snd_pcm_format_value(str); @@ -2010,7 +2012,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, long val; err = snd_config_get_integer(n, &val); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto fail; } channels = val; @@ -2020,7 +2022,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_free_chmaps(chmap); chmap = _snd_pcm_parse_config_chmaps(n); if (!chmap) { - SNDERR("Invalid channel map for %s", id); + snd_error(PCM, "Invalid channel map for %s", id); err = -EINVAL; goto fail; } @@ -2030,23 +2032,23 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, long val; err = snd_config_get_integer(n, &val); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto fail; } drain_silence = val; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); err = -EINVAL; goto fail; } if (card < 0) { - SNDERR("card is not defined"); + snd_error(PCM, "card is not defined"); err = -EINVAL; goto fail; } if ((min_rate < 0) || (max_rate < min_rate)) { - SNDERR("min_rate - max_rate configuration invalid"); + snd_error(PCM, "min_rate - max_rate configuration invalid"); err = -EINVAL; goto fail; } diff --git a/src/pcm/pcm_iec958.c b/src/pcm/pcm_iec958.c index 7b8459fb..90d4bbe6 100644 --- a/src/pcm/pcm_iec958.c +++ b/src/pcm/pcm_iec958.c @@ -712,7 +712,7 @@ int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name, } if (strcmp(id, "status") == 0) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } status = n; @@ -720,7 +720,7 @@ int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name, } if (strcmp(id, "preamble") == 0) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } preamble = n; @@ -733,7 +733,7 @@ int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name, hdmi_mode = err; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } memset(status_bits, 0, sizeof(status_bits)); @@ -744,12 +744,12 @@ int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name, long val; snd_config_t *n = snd_config_iterator_entry(i); if (snd_config_get_type(n) != SND_CONFIG_TYPE_INTEGER) { - SNDERR("invalid IEC958 status bits"); + snd_error(PCM, "invalid IEC958 status bits"); return -EINVAL; } err = snd_config_get_integer(n, &val); if (err < 0) { - SNDERR("invalid IEC958 status bits"); + snd_error(PCM, "invalid IEC958 status bits"); return err; } status_bits[bytes] = val; @@ -775,19 +775,19 @@ int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name, else if (strcmp(id, "w") == 0 || strcmp(id, "y") == 0) idx = PREAMBLE_Y; else { - SNDERR("invalid IEC958 preamble type %s", id); + snd_error(PCM, "invalid IEC958 preamble type %s", id); return -EINVAL; } err = snd_config_get_integer(n, &val); if (err < 0) { - SNDERR("invalid IEC958 preamble value"); + snd_error(PCM, "invalid IEC958 preamble value"); return err; } preamble_vals[idx] = val; } } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 1, @@ -798,7 +798,7 @@ int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name, sformat != SND_PCM_FORMAT_IEC958_SUBFRAME_LE && sformat != SND_PCM_FORMAT_IEC958_SUBFRAME_BE) { snd_config_delete(sconf); - SNDERR("invalid slave format"); + snd_error(PCM, "invalid slave format"); return -EINVAL; } err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode, conf); diff --git a/src/pcm/pcm_ioplug.c b/src/pcm/pcm_ioplug.c index df2c7f81..fbc59e90 100644 --- a/src/pcm/pcm_ioplug.c +++ b/src/pcm/pcm_ioplug.c @@ -1086,8 +1086,9 @@ int snd_pcm_ioplug_create(snd_pcm_ioplug_t *ioplug, const char *name, /* We support 1.0.0 to current */ if (ioplug->version < 0x010000 || ioplug->version > SND_PCM_IOPLUG_VERSION) { - SNDERR("ioplug: Plugin version mismatch: 0x%x", - ioplug->version); + snd_error(PCM, "ioplug: Plugin version mismatch: 0x%x", + ioplug->version); + return -ENXIO; } @@ -1156,7 +1157,7 @@ int snd_pcm_ioplug_set_param_list(snd_pcm_ioplug_t *ioplug, int type, unsigned i { ioplug_priv_t *io = ioplug->pcm->private_data; if (type < 0 || type >= SND_PCM_IOPLUG_HW_PARAMS) { - SNDERR("IOPLUG: invalid parameter type %d", type); + snd_error(PCM, "IOPLUG: invalid parameter type %d", type); return -EINVAL; } if (type == SND_PCM_IOPLUG_HW_PERIODS) @@ -1180,11 +1181,11 @@ int snd_pcm_ioplug_set_param_minmax(snd_pcm_ioplug_t *ioplug, int type, unsigned { ioplug_priv_t *io = ioplug->pcm->private_data; if (type < 0 || type >= SND_PCM_IOPLUG_HW_PARAMS) { - SNDERR("IOPLUG: invalid parameter type %d", type); + snd_error(PCM, "IOPLUG: invalid parameter type %d", type); return -EINVAL; } if (type == SND_PCM_IOPLUG_HW_ACCESS || type == SND_PCM_IOPLUG_HW_FORMAT) { - SNDERR("IOPLUG: invalid parameter type %d", type); + snd_error(PCM, "IOPLUG: invalid parameter type %d", type); return -EINVAL; } if (type == SND_PCM_IOPLUG_HW_PERIODS) diff --git a/src/pcm/pcm_ladspa.c b/src/pcm/pcm_ladspa.c index 25eac76f..79b728d8 100644 --- a/src/pcm/pcm_ladspa.c +++ b/src/pcm/pcm_ladspa.c @@ -420,7 +420,7 @@ static int snd_pcm_ladspa_connect_plugin1(snd_pcm_ladspa_plugin_t *plugin, else { err = snd_pcm_ladspa_find_port(&port, plugin, io->pdesc | LADSPA_PORT_AUDIO, idx); if (err < 0) { - SNDERR("unable to find audio %s port %u plugin '%s'", io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", idx, plugin->desc->Name); + snd_error(PCM, "unable to find audio %s port %u plugin '%s'", io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", idx, plugin->desc->Name); return err; } } @@ -428,12 +428,12 @@ static int snd_pcm_ladspa_connect_plugin1(snd_pcm_ladspa_plugin_t *plugin, continue; err = snd_pcm_ladspa_add_to_carray(&eps->channels, idx1, idx); if (err < 0) { - SNDERR("unable to add channel %u for audio %s plugin '%s'", idx, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name); + snd_error(PCM, "unable to add channel %u for audio %s plugin '%s'", idx, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name); return err; } err = snd_pcm_ladspa_add_to_array(&eps->ports, idx1, port); if (err < 0) { - SNDERR("unable to add port %u for audio %s plugin '%s'", port, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name); + snd_error(PCM, "unable to add port %u for audio %s plugin '%s'", port, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name); return err; } idx1++; @@ -469,18 +469,18 @@ static int snd_pcm_ladspa_connect_plugin_duplicate1(snd_pcm_ladspa_plugin_t *plu } else { err = snd_pcm_ladspa_find_port(&port, plugin, io->pdesc | LADSPA_PORT_AUDIO, 0); if (err < 0) { - SNDERR("unable to find audio %s port %u plugin '%s'", io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", (unsigned int)0, plugin->desc->Name); + snd_error(PCM, "unable to find audio %s port %u plugin '%s'", io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", (unsigned int)0, plugin->desc->Name); return err; } } err = snd_pcm_ladspa_add_to_carray(&eps->channels, 0, idx); if (err < 0) { - SNDERR("unable to add channel %u for audio %s plugin '%s'", idx, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name); + snd_error(PCM, "unable to add channel %u for audio %s plugin '%s'", idx, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name); return err; } err = snd_pcm_ladspa_add_to_array(&eps->ports, 0, port); if (err < 0) { - SNDERR("unable to add port %u for audio %s plugin '%s'", port, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name); + snd_error(PCM, "unable to add port %u for audio %s plugin '%s'", port, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name); return err; } return 0; @@ -596,13 +596,13 @@ static int snd_pcm_ladspa_check_connect(snd_pcm_ladspa_plugin_t *plugin, for (idx = midx = 0; idx < plugin->desc->PortCount; idx++) if ((plugin->desc->PortDescriptors[idx] & (io->pdesc | LADSPA_PORT_AUDIO)) == (io->pdesc | LADSPA_PORT_AUDIO)) { if (eps->channels.array[midx] == NO_ASSIGN) { - SNDERR("%s port for plugin %s depth %u is not connected", io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name, depth); + snd_error(PCM, "%s port for plugin %s depth %u is not connected", io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name, depth); err++; } midx++; } if (err > 0) { - SNDERR("%i connection errors total", err); + snd_error(PCM, "%i connection errors total", err); return -EINVAL; } return 0; @@ -640,7 +640,7 @@ static int snd_pcm_ladspa_allocate_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *l instance->handle = plugin->desc->instantiate(plugin->desc, pcm->rate); instance->depth = depth; if (instance->handle == NULL) { - SNDERR("Unable to create instance of LADSPA plugin '%s'", plugin->desc->Name); + snd_error(PCM, "Unable to create instance of LADSPA plugin '%s'", plugin->desc->Name); free(instance); return -EINVAL; } @@ -648,13 +648,13 @@ static int snd_pcm_ladspa_allocate_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *l if (plugin->policy == SND_PCM_LADSPA_POLICY_DUPLICATE) { err = snd_pcm_ladspa_connect_plugin_duplicate(plugin, &plugin->input, &plugin->output, instance, idx); if (err < 0) { - SNDERR("Unable to connect duplicate port of plugin '%s' channel %u depth %u", plugin->desc->Name, idx, instance->depth); + snd_error(PCM, "Unable to connect duplicate port of plugin '%s' channel %u depth %u", plugin->desc->Name, idx, instance->depth); return err; } } else { err = snd_pcm_ladspa_connect_plugin(plugin, instance); if (err < 0) { - SNDERR("Unable to connect plugin '%s' depth %u", plugin->desc->Name, depth); + snd_error(PCM, "Unable to connect plugin '%s' depth %u", plugin->desc->Name, depth); return err; } } @@ -1256,7 +1256,7 @@ static int snd_pcm_ladspa_parse_controls(snd_pcm_ladspa_plugin_t *lplug, int err; if (snd_config_get_type(controls) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("controls definition must be a compound"); + snd_error(PCM, "controls definition must be a compound"); return -EINVAL; } @@ -1275,16 +1275,16 @@ static int snd_pcm_ladspa_parse_controls(snd_pcm_ladspa_plugin_t *lplug, err = snd_pcm_ladspa_find_sport(&port, lplug, io->pdesc | LADSPA_PORT_CONTROL, id); } if (err < 0) { - SNDERR("Unable to find an control port (%s)", id); + snd_error(PCM, "Unable to find an control port (%s)", id); return err; } if (snd_config_get_ireal(n, &dval) < 0) { - SNDERR("Control port %s has not an float or integer value", id); + snd_error(PCM, "Control port %s has not an float or integer value", id); return err; } err = snd_pcm_ladspa_find_port_idx(&uval, lplug, io->pdesc | LADSPA_PORT_CONTROL, port); if (err < 0) { - SNDERR("internal error"); + snd_error(PCM, "internal error"); return err; } io->controls_initialized[uval] = 1; @@ -1304,7 +1304,7 @@ static int snd_pcm_ladspa_parse_bindings(snd_pcm_ladspa_plugin_t *lplug, int err; if (snd_config_get_type(bindings) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("bindings definition must be a compound"); + snd_error(PCM, "bindings definition must be a compound"); return -EINVAL; } snd_config_for_each(i, next, bindings) { @@ -1315,11 +1315,11 @@ static int snd_pcm_ladspa_parse_bindings(snd_pcm_ladspa_plugin_t *lplug, continue; err = safe_strtol(id, &channel); if (err < 0 || channel < 0) { - SNDERR("Invalid channel number: %s", id); + snd_error(PCM, "Invalid channel number: %s", id); return -EINVAL; } if (lplug->policy == SND_PCM_LADSPA_POLICY_DUPLICATE && channel > 0) { - SNDERR("Wrong channel specification for duplicate policy"); + snd_error(PCM, "Wrong channel specification for duplicate policy"); return -EINVAL; } if (count < (unsigned int)(channel + 1)) @@ -1347,19 +1347,19 @@ static int snd_pcm_ladspa_parse_bindings(snd_pcm_ladspa_plugin_t *lplug, if (err >= 0) { err = snd_pcm_ladspa_find_port(&array[channel], lplug, io->pdesc | LADSPA_PORT_AUDIO, port); if (err < 0) { - SNDERR("Unable to find an audio port (%li) for channel %s", port, id); + snd_error(PCM, "Unable to find an audio port (%li) for channel %s", port, id); return err; } continue; } err = snd_config_get_string(n, &sport); if (err < 0) { - SNDERR("Invalid LADSPA port field type for %s", id); + snd_error(PCM, "Invalid LADSPA port field type for %s", id); return -EINVAL; } err = snd_pcm_ladspa_find_sport(&array[channel], lplug, io->pdesc | LADSPA_PORT_AUDIO, sport); if (err < 0) { - SNDERR("Unable to find an audio port (%s) for channel %s", sport, id); + snd_error(PCM, "Unable to find an audio port (%s) for channel %s", sport, id); return err; } } @@ -1379,7 +1379,7 @@ static int snd_pcm_ladspa_parse_ioconfig(snd_pcm_ladspa_plugin_t *lplug, /* always add default controls for both input and output */ err = snd_pcm_ladspa_add_default_controls(lplug, io); if (err < 0) { - SNDERR("error adding default controls"); + snd_error(PCM, "error adding default controls"); return err; } @@ -1388,7 +1388,7 @@ static int snd_pcm_ladspa_parse_ioconfig(snd_pcm_ladspa_plugin_t *lplug, } if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("input or output definition must be a compound"); + snd_error(PCM, "input or output definition must be a compound"); return -EINVAL; } snd_config_for_each(i, next, conf) { @@ -1471,7 +1471,7 @@ static int snd_pcm_ladspa_add_plugin(struct list_head *list, const char *str; err = snd_config_get_string(n, &str); if (err < 0) { - SNDERR("policy field must be a string"); + snd_error(PCM, "policy field must be a string"); return err; } if (strcmp(str, "none") == 0) @@ -1479,14 +1479,14 @@ static int snd_pcm_ladspa_add_plugin(struct list_head *list, else if (strcmp(str, "duplicate") == 0) policy = SND_PCM_LADSPA_POLICY_DUPLICATE; else { - SNDERR("unknown policy definition"); + snd_error(PCM, "unknown policy definition"); return -EINVAL; } continue; } } if (label == NULL && ladspa_id <= 0) { - SNDERR("no plugin label or id"); + snd_error(PCM, "no plugin label or id"); return -EINVAL; } lplug = (snd_pcm_ladspa_plugin_t *)calloc(1, sizeof(snd_pcm_ladspa_plugin_t)); @@ -1499,14 +1499,14 @@ static int snd_pcm_ladspa_add_plugin(struct list_head *list, if (filename) { err = snd_pcm_ladspa_check_file(lplug, filename, label, ladspa_id); if (err < 0) { - SNDERR("Unable to load plugin '%s' ID %li, filename '%s'", label, ladspa_id, filename); + snd_error(PCM, "Unable to load plugin '%s' ID %li, filename '%s'", label, ladspa_id, filename); free(lplug); return err; } } else { err = snd_pcm_ladspa_look_for_plugin(lplug, path, label, ladspa_id); if (err < 0) { - SNDERR("Unable to find or load plugin '%s' ID %li, path '%s'", label, ladspa_id, path); + snd_error(PCM, "Unable to find or load plugin '%s' ID %li, path '%s'", label, ladspa_id, path); free(lplug); return err; } @@ -1536,7 +1536,7 @@ static int snd_pcm_ladspa_build_plugins(struct list_head *list, if (plugins == NULL) /* nothing TODO */ return 0; if (snd_config_get_type(plugins) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("plugins must be defined inside a compound"); + snd_error(PCM, "plugins must be defined inside a compound"); return -EINVAL; } do { @@ -1549,7 +1549,7 @@ static int snd_pcm_ladspa_build_plugins(struct list_head *list, continue; err = safe_strtol(id, &i); if (err < 0) { - SNDERR("id of field %s is not an integer", id); + snd_error(PCM, "id of field %s is not an integer", id); return err; } if (i == idx) { @@ -1562,7 +1562,7 @@ static int snd_pcm_ladspa_build_plugins(struct list_head *list, } } while (hit); if (list_empty(list)) { - SNDERR("empty plugin list is not accepted"); + snd_error(PCM, "empty plugin list is not accepted"); return -EINVAL; } return 0; @@ -1776,16 +1776,16 @@ int _snd_pcm_ladspa_open(snd_pcm_t **pcmp, const char *name, cplugins = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } if (plugins) { if (pplugins || cplugins) { - SNDERR("'plugins' definition cannot be combined with 'playback_plugins' or 'capture_plugins'"); + snd_error(PCM, "'plugins' definition cannot be combined with 'playback_plugins' or 'capture_plugins'"); return -EINVAL; } pplugins = plugins; diff --git a/src/pcm/pcm_lfloat.c b/src/pcm/pcm_lfloat.c index d9aa136d..8df993d4 100644 --- a/src/pcm/pcm_lfloat.c +++ b/src/pcm/pcm_lfloat.c @@ -483,11 +483,11 @@ int _snd_pcm_lfloat_open(snd_pcm_t **pcmp, const char *name, slave = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 1, @@ -497,7 +497,7 @@ int _snd_pcm_lfloat_open(snd_pcm_t **pcmp, const char *name, if (snd_pcm_format_linear(sformat) != 1 && snd_pcm_format_float(sformat) != 1) { snd_config_delete(sconf); - SNDERR("slave format is not linear integer or linear float"); + snd_error(PCM, "slave format is not linear integer or linear float"); return -EINVAL; } err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode, conf); @@ -521,7 +521,7 @@ int snd_pcm_lfloat_open(snd_pcm_t **pcmp ATTRIBUTE_UNUSED, snd_pcm_t *slave ATTRIBUTE_UNUSED, int close_slave ATTRIBUTE_UNUSED) { - SNDERR("please, upgrade your GCC to use lfloat plugin"); + snd_error(PCM, "please, upgrade your GCC to use lfloat plugin"); return -EINVAL; } @@ -532,7 +532,7 @@ int _snd_pcm_lfloat_open(snd_pcm_t **pcmp ATTRIBUTE_UNUSED, snd_pcm_stream_t stream ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - SNDERR("please, upgrade your GCC to use lfloat plugin"); + snd_error(PCM, "please, upgrade your GCC to use lfloat plugin"); return -EINVAL; } diff --git a/src/pcm/pcm_linear.c b/src/pcm/pcm_linear.c index 81edccaa..9084eef6 100644 --- a/src/pcm/pcm_linear.c +++ b/src/pcm/pcm_linear.c @@ -526,11 +526,11 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name, slave = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 1, @@ -539,7 +539,7 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name, return err; if (snd_pcm_format_linear(sformat) != 1) { snd_config_delete(sconf); - SNDERR("slave format is not linear"); + snd_error(PCM, "slave format is not linear"); return -EINVAL; } err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode, conf); diff --git a/src/pcm/pcm_meter.c b/src/pcm/pcm_meter.c index 68c369de..05649a92 100644 --- a/src/pcm/pcm_meter.c +++ b/src/pcm/pcm_meter.c @@ -621,23 +621,23 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name, int err; if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for scope %s", str); + snd_error(PCM, "Invalid type for scope %s", str); err = -EINVAL; goto _err; } err = snd_config_search(conf, "type", &c); if (err < 0) { - SNDERR("type is not defined"); + snd_error(PCM, "type is not defined"); goto _err; } err = snd_config_get_id(c, &id); if (err < 0) { - SNDERR("unable to get id"); + snd_error(PCM, "unable to get id"); goto _err; } err = snd_config_get_string(c, &str); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto _err; } err = snd_config_search_definition(root, "pcm_scope_type", str, &type_conf); @@ -652,7 +652,7 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name, if (strcmp(id, "lib") == 0) { err = snd_config_get_string(n, &lib); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto _err; } continue; @@ -660,12 +660,12 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name, if (strcmp(id, "open") == 0) { err = snd_config_get_string(n, &open_name); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto _err; } continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); err = -EINVAL; goto _err; } @@ -678,10 +678,10 @@ static int snd_pcm_meter_add_scope_conf(snd_pcm_t *pcm, const char *name, open_func = h ? dlsym(h, open_name) : NULL; err = 0; if (!h) { - SNDERR("Cannot open shared library %s (%s)", lib, errbuf); + snd_error(PCM, "Cannot open shared library %s (%s)", lib, errbuf); err = -ENOENT; } else if (!open_func) { - SNDERR("symbol %s is not defined inside %s", open_name, lib); + snd_error(PCM, "symbol %s is not defined inside %s", open_name, lib); snd_dlclose(h); err = -ENXIO; } @@ -779,24 +779,24 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "frequency") == 0) { err = snd_config_get_integer(n, &frequency); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } continue; } if (strcmp(id, "scopes") == 0) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } scopes = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 0); @@ -821,7 +821,7 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name, if (snd_config_get_string(n, &str) >= 0) { err = snd_config_search_definition(root, "pcm_scope", str, &n); if (err < 0) { - SNDERR("unknown pcm_scope %s", str); + snd_error(PCM, "unknown pcm_scope %s", str); } else { err = snd_pcm_meter_add_scope_conf(*pcmp, id, root, n); snd_config_delete(n); diff --git a/src/pcm/pcm_misc.c b/src/pcm/pcm_misc.c index 3cff4326..8a00d1c4 100644 --- a/src/pcm/pcm_misc.c +++ b/src/pcm/pcm_misc.c @@ -803,11 +803,11 @@ int snd_pcm_parse_control_id(snd_config_t *conf, snd_ctl_elem_id_t *ctl_id, int if (strcmp(id, "iface") == 0 || strcmp(id, "interface") == 0) { const char *ptr; if ((err = snd_config_get_string(n, &ptr)) < 0) { - SNDERR("field %s is not a string", id); + snd_error(PCM, "field %s is not a string", id); goto _err; } if ((err = snd_config_get_ctl_iface_ascii(ptr)) < 0) { - SNDERR("Invalid value for '%s'", id); + snd_error(PCM, "Invalid value for '%s'", id); goto _err; } iface = err; @@ -815,28 +815,28 @@ int snd_pcm_parse_control_id(snd_config_t *conf, snd_ctl_elem_id_t *ctl_id, int } if (strcmp(id, "name") == 0) { if ((err = snd_config_get_string(n, &name)) < 0) { - SNDERR("field %s is not a string", id); + snd_error(PCM, "field %s is not a string", id); goto _err; } continue; } if (strcmp(id, "index") == 0) { if ((err = snd_config_get_integer(n, &index)) < 0) { - SNDERR("field %s is not an integer", id); + snd_error(PCM, "field %s is not an integer", id); goto _err; } continue; } if (strcmp(id, "device") == 0) { if ((err = snd_config_get_integer(n, &device)) < 0) { - SNDERR("field %s is not an integer", id); + snd_error(PCM, "field %s is not an integer", id); goto _err; } continue; } if (strcmp(id, "subdevice") == 0) { if ((err = snd_config_get_integer(n, &subdevice)) < 0) { - SNDERR("field %s is not an integer", id); + snd_error(PCM, "field %s is not an integer", id); goto _err; } continue; @@ -844,11 +844,11 @@ int snd_pcm_parse_control_id(snd_config_t *conf, snd_ctl_elem_id_t *ctl_id, int if (cchannelsp && strcmp(id, "count") == 0) { long v; if ((err = snd_config_get_integer(n, &v)) < 0) { - SNDERR("field %s is not an integer", id); + snd_error(PCM, "field %s is not an integer", id); goto _err; } if (v < 1 || v > 2) { - SNDERR("Invalid count %ld", v); + snd_error(PCM, "Invalid count %ld", v); goto _err; } *cchannelsp = v; @@ -856,17 +856,17 @@ int snd_pcm_parse_control_id(snd_config_t *conf, snd_ctl_elem_id_t *ctl_id, int } if (hwctlp && strcmp(id, "hwctl") == 0) { if ((err = snd_config_get_bool(n)) < 0) { - SNDERR("The field %s must be a boolean type", id); + snd_error(PCM, "The field %s must be a boolean type", id); return err; } *hwctlp = err; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (name == NULL) { - SNDERR("Missing control name"); + snd_error(PCM, "Missing control name"); err = -EINVAL; goto _err; } diff --git a/src/pcm/pcm_mmap.c b/src/pcm/pcm_mmap.c index 0b62978e..88b1f45f 100644 --- a/src/pcm/pcm_mmap.c +++ b/src/pcm/pcm_mmap.c @@ -74,7 +74,7 @@ static snd_pcm_sframes_t snd_pcm_mmap_write_areas(snd_pcm_t *pcm, snd_pcm_uframes_t xfer = 0; if (snd_pcm_mmap_playback_avail(pcm) < size) { - SNDMSG("too short avail %ld to size %ld", snd_pcm_mmap_playback_avail(pcm), size); + snd_check(PCM, "too short avail %ld to size %ld", snd_pcm_mmap_playback_avail(pcm), size); return -EPIPE; } while (size > 0) { @@ -106,7 +106,7 @@ static snd_pcm_sframes_t snd_pcm_mmap_read_areas(snd_pcm_t *pcm, snd_pcm_uframes_t xfer = 0; if (snd_pcm_mmap_capture_avail(pcm) < size) { - SNDMSG("too short avail %ld to size %ld", snd_pcm_mmap_capture_avail(pcm), size); + snd_check(PCM, "too short avail %ld to size %ld", snd_pcm_mmap_capture_avail(pcm), size); return -EPIPE; } while (size > 0) { @@ -244,7 +244,7 @@ int snd_pcm_channel_info_shm(snd_pcm_t *pcm, snd_pcm_channel_info_t *info, int s info->step = pcm->sample_bits; break; default: - SNDMSG("invalid access type %d", pcm->access); + snd_check(PCM, "invalid access type %d", pcm->access); return -EINVAL; } info->addr = 0; @@ -263,11 +263,11 @@ int snd_pcm_mmap(snd_pcm_t *pcm) unsigned int c; assert(pcm); if (CHECK_SANITY(! pcm->setup)) { - SNDMSG("PCM not set up"); + snd_check(PCM, "PCM not set up"); return -EIO; } if (CHECK_SANITY(pcm->mmap_channels || pcm->running_areas)) { - SNDMSG("Already mmapped"); + snd_check(PCM, "Already mmapped"); return -EBUSY; } if (pcm->ops->mmap) @@ -342,7 +342,7 @@ int snd_pcm_mmap(snd_pcm_t *pcm) case SND_PCM_AREA_MMAP: ptr = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, i->u.mmap.fd, i->u.mmap.offset); if (ptr == MAP_FAILED) { - SYSERR("mmap failed"); + snd_errornum(PCM, "mmap failed"); return -errno; } i->addr = ptr; @@ -354,23 +354,23 @@ int snd_pcm_mmap(snd_pcm_t *pcm) /* FIXME: safer permission? */ id = shmget(IPC_PRIVATE, size, 0666); if (id < 0) { - SYSERR("shmget failed"); + snd_errornum(PCM, "shmget failed"); return -errno; } i->u.shm.shmid = id; ptr = shmat(i->u.shm.shmid, 0, 0); if (ptr == (void *) -1) { - SYSERR("shmat failed"); + snd_errornum(PCM, "shmat failed"); return -errno; } /* automatically remove segment if not used */ if (shmctl(id, IPC_RMID, NULL) < 0){ - SYSERR("shmctl mark remove failed"); + snd_errornum(PCM, "shmctl mark remove failed"); return -errno; } i->u.shm.area = snd_shm_area_create(id, ptr); if (i->u.shm.area == NULL) { - SYSERR("snd_shm_area_create failed"); + snd_errornum(PCM, "snd_shm_area_create failed"); return -ENOMEM; } if (pcm->access == SND_PCM_ACCESS_MMAP_INTERLEAVED || @@ -387,20 +387,20 @@ int snd_pcm_mmap(snd_pcm_t *pcm) } else { ptr = shmat(i->u.shm.shmid, 0, 0); if (ptr == (void*) -1) { - SYSERR("shmat failed"); + snd_errornum(PCM, "shmat failed"); return -errno; } } i->addr = ptr; break; #else - SYSERR("shm support not available"); + snd_errornum(PCM, "shm support not available"); return -ENOSYS; #endif case SND_PCM_AREA_LOCAL: ptr = malloc(size); if (ptr == NULL) { - SYSERR("malloc failed"); + snd_errornum(PCM, "malloc failed"); return -errno; } i->addr = ptr; @@ -445,7 +445,7 @@ int snd_pcm_munmap(snd_pcm_t *pcm) unsigned int c; assert(pcm); if (CHECK_SANITY(! pcm->mmap_channels)) { - SNDMSG("Not mmapped"); + snd_check(PCM, "Not mmapped"); return -ENXIO; } if (pcm->mmap_shadow) { @@ -476,7 +476,7 @@ int snd_pcm_munmap(snd_pcm_t *pcm) case SND_PCM_AREA_MMAP: err = munmap(i->addr, size); if (err < 0) { - SYSERR("mmap failed"); + snd_errornum(PCM, "mmap failed"); return -errno; } errno = 0; @@ -500,7 +500,7 @@ int snd_pcm_munmap(snd_pcm_t *pcm) } break; #else - SYSERR("shm support not available"); + snd_errornum(PCM, "shm support not available"); return -ENOSYS; #endif case SND_PCM_AREA_LOCAL: @@ -567,7 +567,7 @@ snd_pcm_sframes_t snd_pcm_write_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t offset, break; } default: - SNDMSG("invalid access type %d", pcm->access); + snd_check(PCM, "invalid access type %d", pcm->access); return -EINVAL; } if (err < 0) @@ -623,7 +623,7 @@ snd_pcm_sframes_t snd_pcm_read_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t offset, break; } default: - SNDMSG("invalid access type %d", pcm->access); + snd_check(PCM, "invalid access type %d", pcm->access); return -EINVAL; } if (err < 0) diff --git a/src/pcm/pcm_mmap_emul.c b/src/pcm/pcm_mmap_emul.c index 009cebb3..b0bf61e0 100644 --- a/src/pcm/pcm_mmap_emul.c +++ b/src/pcm/pcm_mmap_emul.c @@ -489,11 +489,11 @@ int _snd_pcm_mmap_emul_open(snd_pcm_t **pcmp, const char *name, slave = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 0); diff --git a/src/pcm/pcm_mulaw.c b/src/pcm/pcm_mulaw.c index 177a61bb..1dd8b613 100644 --- a/src/pcm/pcm_mulaw.c +++ b/src/pcm/pcm_mulaw.c @@ -538,11 +538,11 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name, slave = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 1, @@ -552,7 +552,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name, if (snd_pcm_format_linear(sformat) != 1 && sformat != SND_PCM_FORMAT_MU_LAW) { snd_config_delete(sconf); - SNDERR("invalid slave format"); + snd_error(PCM, "invalid slave format"); return -EINVAL; } err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode, conf); diff --git a/src/pcm/pcm_multi.c b/src/pcm/pcm_multi.c index 74e1e3f1..1bdc0657 100644 --- a/src/pcm/pcm_multi.c +++ b/src/pcm/pcm_multi.c @@ -266,7 +266,7 @@ static int snd_pcm_multi_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) for (k = 0; k < multi->slaves_count; ++k) { err = snd_pcm_multi_hw_refine_sprepare(pcm, k, &sparams[k]); if (err < 0) { - SNDERR("Slave PCM #%d not usable", k); + snd_error(PCM, "Slave PCM #%d not usable", k); return err; } } @@ -1267,7 +1267,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, continue; if (strcmp(id, "slaves") == 0) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } slaves = n; @@ -1275,7 +1275,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, } if (strcmp(id, "bindings") == 0) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } bindings = n; @@ -1283,27 +1283,27 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, } if (strcmp(id, "master") == 0) { if (snd_config_get_integer(n, &master_slave) < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slaves) { - SNDERR("slaves is not defined"); + snd_error(PCM, "slaves is not defined"); return -EINVAL; } if (!bindings) { - SNDERR("bindings is not defined"); + snd_error(PCM, "bindings is not defined"); return -EINVAL; } snd_config_for_each(i, inext, slaves) { ++slaves_count; } if (master_slave < 0 || master_slave >= (long)slaves_count) { - SNDERR("Master slave is out of range (0-%u)", slaves_count-1); + snd_error(PCM, "Master slave is out of range (0-%u)", slaves_count-1); return -EINVAL; } snd_config_for_each(i, inext, bindings) { @@ -1314,14 +1314,14 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, continue; err = safe_strtol(id, &cchannel); if (err < 0 || cchannel < 0) { - SNDERR("Invalid channel number: %s", id); + snd_error(PCM, "Invalid channel number: %s", id); return -EINVAL; } if ((unsigned long)cchannel >= channels_count) channels_count = cchannel + 1; } if (channels_count == 0) { - SNDERR("No channels defined"); + snd_error(PCM, "No channels defined"); return -EINVAL; } slaves_id = calloc(slaves_count, sizeof(*slaves_id)); @@ -1365,7 +1365,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, continue; err = safe_strtol(id, &cchannel); if (err < 0 || cchannel < 0) { - SNDERR("Invalid channel number: %s", id); + snd_error(PCM, "Invalid channel number: %s", id); err = -EINVAL; goto _free; } @@ -1383,7 +1383,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, if (err < 0) { err = snd_config_get_integer(n, &val); if (err < 0) { - SNDERR("Invalid value for %s", id); + snd_error(PCM, "Invalid value for %s", id); goto _free; } sprintf(buf, "%ld", val); @@ -1398,23 +1398,23 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "channel") == 0) { err = snd_config_get_integer(n, &schannel); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto _free; } continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); err = -EINVAL; goto _free; } if (slave < 0 || (unsigned int)slave >= slaves_count) { - SNDERR("Invalid or missing sidx for channel %s", id); + snd_error(PCM, "Invalid or missing sidx for channel %s", id); err = -EINVAL; goto _free; } if (schannel < 0 || (unsigned int) schannel >= slaves_channels[slave]) { - SNDERR("Invalid or missing schannel for channel %s", id); + snd_error(PCM, "Invalid or missing schannel for channel %s", id); err = -EINVAL; goto _free; } diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c index f7b096bc..47f423a8 100644 --- a/src/pcm/pcm_null.c +++ b/src/pcm/pcm_null.c @@ -386,13 +386,13 @@ int snd_pcm_null_open(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t strea if (stream == SND_PCM_STREAM_PLAYBACK) { fd = open("/dev/null", O_WRONLY); if (fd < 0) { - SYSERR("Cannot open /dev/null"); + snd_errornum(PCM, "Cannot open /dev/null"); return -errno; } } else { fd = open("/dev/full", O_RDONLY); if (fd < 0) { - SYSERR("Cannot open /dev/full"); + snd_errornum(PCM, "Cannot open /dev/full"); return -errno; } } @@ -481,12 +481,12 @@ int _snd_pcm_null_open(snd_pcm_t **pcmp, const char *name, snd_pcm_free_chmaps(chmap); chmap = _snd_pcm_parse_config_chmaps(n); if (!chmap) { - SNDERR("Invalid channel map for %s", id); + snd_error(PCM, "Invalid channel map for %s", id); return -EINVAL; } continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); snd_pcm_free_chmaps(chmap); return -EINVAL; } diff --git a/src/pcm/pcm_params.c b/src/pcm/pcm_params.c index 05bfe3b2..deca344f 100644 --- a/src/pcm/pcm_params.c +++ b/src/pcm/pcm_params.c @@ -2232,7 +2232,7 @@ int snd_pcm_hw_refine_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, return err; err = sprepare(pcm, &sparams); if (err < 0) { - SNDERR("Slave PCM not usable"); + snd_error(PCM, "Slave PCM not usable"); return err; } #ifdef RULES_DEBUG diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c index bd681a9f..1bae89d0 100644 --- a/src/pcm/pcm_plug.c +++ b/src/pcm/pcm_plug.c @@ -480,7 +480,7 @@ static int snd_pcm_plug_change_channels(snd_pcm_t *pcm, snd_pcm_t **new, snd_pcm ttable[c * tt_ssize + c] = SND_PCM_PLUGIN_ROUTE_FULL; break; default: - SNDERR("Invalid route policy"); + snd_error(PCM, "Invalid route policy"); break; } } @@ -861,16 +861,16 @@ static int snd_pcm_plug_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p } if (snd_pcm_format_mask_empty(&sfmt_mask)) { - SNDERR("Unable to find an usable slave format for '%s'", pcm->name); + snd_error(PCM, "Unable to find an usable slave format for '%s'", pcm->name); for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) { if (!snd_pcm_format_mask_test(format_mask, format)) continue; - SNDERR("Format: %s", snd_pcm_format_name(format)); + snd_error(PCM, "Format: %s", snd_pcm_format_name(format)); } for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) { if (!snd_pcm_format_mask_test(sformat_mask, format)) continue; - SNDERR("Slave format: %s", snd_pcm_format_name(format)); + snd_error(PCM, "Slave format: %s", snd_pcm_format_name(format)); } return -EINVAL; } @@ -883,8 +883,9 @@ static int snd_pcm_plug_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p if (snd_pcm_hw_param_never_eq(params, SND_PCM_HW_PARAM_ACCESS, sparams)) { err = check_access_change(params, sparams); if (err < 0) { - SNDERR("Unable to find an usable access for '%s'", - pcm->name); + snd_error(PCM, "Unable to find an usable access for '%s'", + pcm->name); + return err; } } @@ -950,16 +951,16 @@ static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, } if (snd_pcm_format_mask_empty(&fmt_mask)) { - SNDERR("Unable to find an usable client format"); + snd_error(PCM, "Unable to find an usable client format"); for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) { if (!snd_pcm_format_mask_test(format_mask, format)) continue; - SNDERR("Format: %s", snd_pcm_format_name(format)); + snd_error(PCM, "Format: %s", snd_pcm_format_name(format)); } for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) { if (!snd_pcm_format_mask_test(sformat_mask, format)) continue; - SNDERR("Slave format: %s", snd_pcm_format_name(format)); + snd_error(PCM, "Slave format: %s", snd_pcm_format_name(format)); } return -EINVAL; } @@ -1293,7 +1294,7 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "ttable") == 0) { route_policy = PLUG_ROUTE_POLICY_NONE; if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } tt = n; @@ -1302,11 +1303,11 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "route_policy") == 0) { const char *str; if ((err = snd_config_get_string(n, &str)) < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } if (tt != NULL) - SNDERR("Table is defined, route policy is ignored"); + snd_error(PCM, "Table is defined, route policy is ignored"); if (!strcmp(str, "default")) route_policy = PLUG_ROUTE_POLICY_DEFAULT; else if (!strcmp(str, "average")) @@ -1324,11 +1325,11 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name, continue; } #endif - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 3, diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c index 9d7e233e..100e12a7 100644 --- a/src/pcm/pcm_plugin.c +++ b/src/pcm/pcm_plugin.c @@ -257,8 +257,9 @@ static snd_pcm_sframes_t snd_pcm_plugin_write_areas(snd_pcm_t *pcm, frames = plugin->write(pcm, areas, offset, frames, slave_areas, slave_offset, &slave_frames); if (CHECK_SANITY(slave_frames > snd_pcm_mmap_playback_avail(slave))) { - SNDMSG("write overflow %ld > %ld", slave_frames, - snd_pcm_mmap_playback_avail(slave)); + snd_check(PCM, "write overflow %ld > %ld", slave_frames, + snd_pcm_mmap_playback_avail(slave)); + err = -EPIPE; goto error; } @@ -314,8 +315,9 @@ static snd_pcm_sframes_t snd_pcm_plugin_read_areas(snd_pcm_t *pcm, frames = (plugin->read)(pcm, areas, offset, frames, slave_areas, slave_offset, &slave_frames); if (CHECK_SANITY(slave_frames > snd_pcm_mmap_capture_avail(slave))) { - SNDMSG("read overflow %ld > %ld", slave_frames, - snd_pcm_mmap_playback_avail(slave)); + snd_check(PCM, "read overflow %ld > %ld", slave_frames, + snd_pcm_mmap_playback_avail(slave)); + err = -EPIPE; goto error; } @@ -447,7 +449,7 @@ snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm, xfer += frames; } if (CHECK_SANITY(size)) { - SNDMSG("short commit: %ld", size); + snd_check(PCM, "short commit: %ld", size); return -EPIPE; } return xfer; diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index ef6b8006..3e2a2dcb 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -396,7 +396,7 @@ static int snd_pcm_rate_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) sinfo->period_size = slave->period_size; if (CHECK_SANITY(rate->pareas)) { - SNDMSG("rate plugin already in use"); + snd_check(PCM, "rate plugin already in use"); return -EBUSY; } @@ -412,7 +412,7 @@ static int snd_pcm_rate_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) rate->orig_in_format = rate->info.in.format; rate->orig_out_format = rate->info.out.format; if (choose_preferred_format(rate) < 0) { - SNDERR("No matching format in rate plugin"); + snd_error(PCM, "No matching format in rate plugin"); err = -EINVAL; goto error_pareas; } @@ -854,7 +854,7 @@ static int snd_pcm_rate_commit_area(snd_pcm_t *pcm, snd_pcm_rate_t *rate, return result; #if 0 if (slave_offset) { - SNDERR("non-zero slave_offset %ld", slave_offset); + snd_error(PCM, "non-zero slave_offset %ld", slave_offset); return -EIO; } #endif @@ -953,7 +953,7 @@ static int snd_pcm_rate_grab_next_period(snd_pcm_t *pcm, snd_pcm_uframes_t hw_of return result; #if 0 if (slave_offset) { - SNDERR("non-zero slave_offset %ld", slave_offset); + snd_error(PCM, "non-zero slave_offset %ld", slave_offset); return -EIO; } #endif @@ -1565,20 +1565,20 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, break; } if (!type) { - SNDERR("No name given for rate converter"); + snd_error(PCM, "No name given for rate converter"); snd_pcm_free(pcm); free(rate); return -EINVAL; } err = rate_open_func(rate, type, converter, 1); } else { - SNDERR("Invalid type for rate converter"); + snd_error(PCM, "Invalid type for rate converter"); snd_pcm_free(pcm); free(rate); return -EINVAL; } if (err < 0) { - SNDERR("Cannot find rate converter"); + snd_error(PCM, "Cannot find rate converter"); snd_pcm_free(pcm); free(rate); return -ENOENT; @@ -1596,7 +1596,7 @@ int snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, if (! rate->ops.init || ! (rate->ops.convert || rate->ops.convert_s16) || ! rate->ops.input_frames || ! rate->ops.output_frames) { - SNDERR("Inproper rate plugin %s initialization", type); + snd_error(PCM, "Inproper rate plugin %s initialization", type); snd_pcm_free(pcm); free(rate); return err; @@ -1698,11 +1698,11 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, converter = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } @@ -1714,7 +1714,7 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, if (sformat != SND_PCM_FORMAT_UNKNOWN && snd_pcm_format_linear(sformat) != 1) { snd_config_delete(sconf); - SNDERR("slave format is not linear"); + snd_error(PCM, "slave format is not linear"); return -EINVAL; } err = snd_pcm_open_slave(&spcm, root, sconf, stream, mode, conf); diff --git a/src/pcm/pcm_rate_linear.c b/src/pcm/pcm_rate_linear.c index 35a4d8ea..f4fc0afc 100644 --- a/src/pcm/pcm_rate_linear.c +++ b/src/pcm/pcm_rate_linear.c @@ -246,7 +246,7 @@ static void linear_shrink(struct rate_linear *rate, dst += dst_step; dst_frames1++; if (CHECK_SANITY(dst_frames1 > dst_frames)) { - SNDERR("dst_frames overflow"); + snd_error(PCM, "dst_frames overflow"); break; } } @@ -298,7 +298,7 @@ static void linear_shrink_s16(struct rate_linear *rate, dst += dst_step; dst_frames1++; if (CHECK_SANITY(dst_frames1 > dst_frames)) { - SNDERR("dst_frames overflow"); + snd_error(PCM, "dst_frames overflow"); break; } } @@ -375,8 +375,9 @@ static int linear_adjust_pitch(void *obj, snd_pcm_rate_info_t *info) cframes_new = input_frames(rate, info->out.period_size); if ((cframes > info->in.period_size && cframes_new < info->in.period_size) || (cframes < info->in.period_size && cframes_new > info->in.period_size)) { - SNDERR("invalid pcm period_size %ld -> %ld", - info->in.period_size, info->out.period_size); + snd_error(PCM, "invalid pcm period_size %ld -> %ld", + info->in.period_size, info->out.period_size); + return -EIO; } cframes = cframes_new; diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index affb929f..15a28bb3 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -810,7 +810,7 @@ static int determine_chmap(snd_config_t *tt, snd_pcm_chmap_t **tt_chmap) continue; if (chmap->channels >= MAX_CHMAP_CHANNELS) { - SNDERR("Too many channels in ttable chmap"); + snd_error(PCM, "Too many channels in ttable chmap"); goto err; } chmap->pos[chmap->channels++] = ch; @@ -875,7 +875,7 @@ static int find_matching_chmap(snd_pcm_chmap_query_t **chmaps, } if (*found_chmap == NULL) { - SNDERR("Found no matching channel map"); + snd_error(PCM, "Found no matching channel map"); return -EINVAL; } return 0; @@ -1085,7 +1085,7 @@ static int _snd_pcm_route_determine_ttable(snd_config_t *tt, continue; err = safe_strtol(id, &cchannel); if (err < 0) { - SNDERR("Invalid client channel: %s", id); + snd_error(PCM, "Invalid client channel: %s", id); return -EINVAL; } if (cchannel + 1 > csize) @@ -1100,7 +1100,7 @@ static int _snd_pcm_route_determine_ttable(snd_config_t *tt, continue; err = strtochannel(id, chmap, &schannel, 1); if (err < 0) { - SNDERR("Invalid slave channel: %s", id); + snd_error(PCM, "Invalid slave channel: %s", id); return -EINVAL; } if (schannel + 1 > ssize) @@ -1108,7 +1108,7 @@ static int _snd_pcm_route_determine_ttable(snd_config_t *tt, } } if (csize == 0 || ssize == 0) { - SNDERR("Invalid null ttable configuration"); + snd_error(PCM, "Invalid null ttable configuration"); return -EINVAL; } *tt_csize = csize; @@ -1168,7 +1168,7 @@ static int _snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_ent err = safe_strtol(id, &cchannel); if (err < 0 || cchannel < 0 || (unsigned int) cchannel > tt_csize) { - SNDERR("Invalid client channel: %s", id); + snd_error(PCM, "Invalid client channel: %s", id); return -EINVAL; } if (snd_config_get_type(in) != SND_CONFIG_TYPE_COMPOUND) @@ -1183,13 +1183,13 @@ static int _snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_ent ss = strtochannel(id, chmap, scha, tt_ssize); if (ss < 0) { - SNDERR("Invalid slave channel: %s", id); + snd_error(PCM, "Invalid slave channel: %s", id); return -EINVAL; } err = snd_config_get_ireal(jnode, &value); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } @@ -1197,7 +1197,7 @@ static int _snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_ent long schannel = scha[k]; if (schannel < 0 || (unsigned int) schannel > tt_ssize || (schannels > 0 && schannel >= schannels)) { - SNDERR("Invalid slave channel: %s", id); + snd_error(PCM, "Invalid slave channel: %s", id); return -EINVAL; } ttable[cchannel * tt_ssize + schannel] = value; @@ -1315,7 +1315,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name, } if (strcmp(id, "ttable") == 0) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); snd_pcm_free_chmaps(chmaps); return -EINVAL; } @@ -1325,21 +1325,21 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "chmap") == 0) { chmaps = _snd_pcm_parse_config_chmaps(n); if (!chmaps) { - SNDERR("Invalid channel map for %s", id); + snd_error(PCM, "Invalid channel map for %s", id); return -EINVAL; } continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); snd_pcm_free_chmaps(chmaps); return -EINVAL; } if (!tt) { - SNDERR("ttable is not defined"); + snd_error(PCM, "ttable is not defined"); snd_pcm_free_chmaps(chmaps); return -EINVAL; } @@ -1353,7 +1353,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name, if (sformat != SND_PCM_FORMAT_UNKNOWN && snd_pcm_format_linear(sformat) != 1) { snd_config_delete(sconf); - SNDERR("slave format is not linear"); + snd_error(PCM, "slave format is not linear"); snd_pcm_free_chmaps(chmaps); return -EINVAL; } diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c index 0699fc87..0b22c58d 100644 --- a/src/pcm/pcm_share.c +++ b/src/pcm/pcm_share.c @@ -238,11 +238,11 @@ static snd_pcm_uframes_t _snd_pcm_share_missing(snd_pcm_t *pcm) } err = snd_pcm_mmap_commit(spcm, snd_pcm_mmap_offset(spcm), frames); if (err < 0) { - SYSMSG("snd_pcm_mmap_commit error"); + snd_checknum(PCM, "snd_pcm_mmap_commit error"); return INT_MAX; } if (err != frames) - SYSMSG("commit returns %ld for size %ld", err, frames); + snd_checknum(PCM, "commit returns %ld for size %ld", err, frames); slave_avail -= err; } else { if (safety_missing == 0) @@ -282,7 +282,7 @@ static snd_pcm_uframes_t _snd_pcm_share_missing(snd_pcm_t *pcm) running = 1; break; default: - SNDERR("invalid shared PCM state %d", share->state); + snd_error(PCM, "invalid shared PCM state %d", share->state); return INT_MAX; } @@ -370,13 +370,13 @@ static void *snd_pcm_share_thread(void *data) pfd[0].events = POLLIN; err = snd_pcm_poll_descriptors(spcm, &pfd[1], 1); if (err != 1) { - SNDERR("invalid poll descriptors %d", err); + snd_error(PCM, "invalid poll descriptors %d", err); return NULL; } Pthread_mutex_lock(&slave->mutex); err = pipe(slave->poll); if (err < 0) { - SYSERR("can't create a pipe"); + snd_errornum(PCM, "can't create a pipe"); Pthread_mutex_unlock(&slave->mutex); return NULL; } @@ -403,7 +403,7 @@ static void *snd_pcm_share_thread(void *data) snd_pcm_sw_params_set_avail_min(spcm, &slave->sw_params, avail_min); err = snd_pcm_sw_params(spcm, &slave->sw_params); if (err < 0) { - SYSERR("snd_pcm_sw_params error"); + snd_errornum(PCM, "snd_pcm_sw_params error"); Pthread_mutex_unlock(&slave->mutex); return NULL; } @@ -457,7 +457,7 @@ static void _snd_pcm_share_update(snd_pcm_t *pcm) snd_pcm_sw_params_set_avail_min(spcm, &slave->sw_params, avail_min); err = snd_pcm_sw_params(spcm, &slave->sw_params); if (err < 0) { - SYSERR("snd_pcm_sw_params error"); + snd_errornum(PCM, "snd_pcm_sw_params error"); return; } } @@ -648,7 +648,7 @@ static int snd_pcm_share_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) spcm->buffer_size, 0); _err: if (err < 0) { - SNDERR("slave is already running with incompatible setup"); + snd_error(PCM, "slave is already running with incompatible setup"); err = -EBUSY; goto _end; } @@ -852,11 +852,11 @@ static snd_pcm_sframes_t _snd_pcm_share_mmap_commit(snd_pcm_t *pcm, snd_pcm_sframes_t err; err = snd_pcm_mmap_commit(spcm, snd_pcm_mmap_offset(spcm), frames); if (err < 0) { - SYSMSG("snd_pcm_mmap_commit error"); + snd_checknum(PCM, "snd_pcm_mmap_commit error"); return err; } if (err != frames) { - SYSMSG("commit returns %ld for size %ld", err, frames); + snd_checknum(PCM, "commit returns %ld for size %ld", err, frames); return err; } } @@ -1399,11 +1399,11 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, const char *sname, for (k = 0; k < channels; ++k) { if (channels_map[k] >= sizeof(slave_map) / sizeof(slave_map[0])) { - SNDERR("Invalid slave channel (%d) in binding", channels_map[k]); + snd_error(PCM, "Invalid slave channel (%d) in binding", channels_map[k]); return -EINVAL; } if (slave_map[channels_map[k]]) { - SNDERR("Repeated slave channel (%d) in binding", channels_map[k]); + snd_error(PCM, "Repeated slave channel (%d) in binding", channels_map[k]); return -EINVAL; } slave_map[channels_map[k]] = 1; @@ -1516,7 +1516,7 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, const char *sname, snd_pcm_share_t *sh = list_entry(i, snd_pcm_share_t, list); for (k = 0; k < sh->channels; ++k) { if (slave_map[sh->slave_channels[k]]) { - SNDERR("Slave channel %d is already in use", sh->slave_channels[k]); + snd_error(PCM, "Slave channel %d is already in use", sh->slave_channels[k]); Pthread_mutex_unlock(&slave->mutex); close(sd[0]); close(sd[1]); @@ -1638,17 +1638,17 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, } if (strcmp(id, "bindings") == 0) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } bindings = n; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } err = snd_pcm_slave_conf(root, slave, &sconf, 5, @@ -1665,12 +1665,12 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, sname = err >= 0 && sname ? strdup(sname) : NULL; snd_config_delete(sconf); if (sname == NULL) { - SNDERR("slave.pcm is not a string"); + snd_error(PCM, "slave.pcm is not a string"); return err; } if (!bindings) { - SNDERR("bindings is not defined"); + snd_error(PCM, "bindings is not defined"); err = -EINVAL; goto _free; } @@ -1682,7 +1682,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, continue; err = safe_strtol(id, &cchannel); if (err < 0 || cchannel < 0) { - SNDERR("Invalid client channel in binding: %s", id); + snd_error(PCM, "Invalid client channel in binding: %s", id); err = -EINVAL; goto _free; } @@ -1690,7 +1690,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, channels = cchannel + 1; } if (channels == 0) { - SNDERR("No bindings defined"); + snd_error(PCM, "No bindings defined"); err = -EINVAL; goto _free; } diff --git a/src/pcm/pcm_shm.c b/src/pcm/pcm_shm.c index d9596547..a523f237 100644 --- a/src/pcm/pcm_shm.c +++ b/src/pcm/pcm_shm.c @@ -72,7 +72,7 @@ static long snd_pcm_shm_action_fd0(snd_pcm_t *pcm, int *fd) if (err != 1) return -EBADFD; if (ctrl->cmd) { - SNDERR("Server has not done the cmd"); + snd_error(PCM, "Server has not done the cmd"); return -EBADFD; } return ctrl->result; @@ -99,7 +99,7 @@ static int snd_pcm_shm_new_rbptr(snd_pcm_t *pcm, snd_pcm_shm_t *shm, mmap_size = page_ptr(shm_rbptr->offset, sizeof(snd_pcm_uframes_t), &offset, &mmap_offset); ptr = mmap(NULL, mmap_size, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, mmap_offset); if (ptr == MAP_FAILED || ptr == NULL) { - SYSERR("shm rbptr mmap failed"); + snd_errornum(PCM, "shm rbptr mmap failed"); return -errno; } if (&pcm->hw == rbptr) @@ -126,7 +126,7 @@ static long snd_pcm_shm_action(snd_pcm_t *pcm) if (err != 1) return -EBADFD; if (ctrl->cmd) { - SNDERR("Server has not done the cmd"); + snd_error(PCM, "Server has not done the cmd"); return -EBADFD; } result = ctrl->result; @@ -161,7 +161,7 @@ static long snd_pcm_shm_action_fd(snd_pcm_t *pcm, int *fd) if (err != 1) return -EBADFD; if (ctrl->cmd) { - SNDERR("Server has not done the cmd"); + snd_error(PCM, "Server has not done the cmd"); return -EBADFD; } if (ctrl->hw.changed) { @@ -354,7 +354,7 @@ static int snd_pcm_shm_munmap(snd_pcm_t *pcm) } err = close(i->u.mmap.fd); if (err < 0) { - SYSERR("close failed"); + snd_errornum(PCM, "close failed"); return -errno; } } @@ -641,7 +641,7 @@ static int make_local_socket(const char *filename) sock = socket(PF_LOCAL, SOCK_STREAM, 0); if (sock < 0) { - SYSERR("socket failed"); + snd_errornum(PCM, "socket failed"); return -errno; } @@ -649,7 +649,7 @@ static int make_local_socket(const char *filename) memcpy(addr->sun_path, filename, l); if (connect(sock, (struct sockaddr *) addr, size) < 0) { - SYSERR("connect failed"); + snd_errornum(PCM, "connect failed"); return -errno; } return sock; @@ -687,7 +687,7 @@ int snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, result = make_local_socket(sockname); if (result < 0) { - SNDERR("server for socket %s is not running", sockname); + snd_error(PCM, "server for socket %s is not running", sockname); goto _err; } sock = result; @@ -702,23 +702,23 @@ int snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, req->namelen = snamelen; err = write(sock, req, reqlen); if (err < 0) { - SYSERR("write error"); + snd_errornum(PCM, "write error"); result = -errno; goto _err; } if ((size_t) err != reqlen) { - SNDERR("write size error"); + snd_error(PCM, "write size error"); result = -EINVAL; goto _err; } err = read(sock, &ans, sizeof(ans)); if (err < 0) { - SYSERR("read error"); + snd_errornum(PCM, "read error"); result = -errno; goto _err; } if (err != sizeof(ans)) { - SNDERR("read size error"); + snd_error(PCM, "read size error"); result = -EINVAL; goto _err; } @@ -728,7 +728,7 @@ int snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, ctrl = shmat(ans.cookie, 0, 0); if (!ctrl) { - SYSERR("shmat error"); + snd_errornum(PCM, "shmat error"); result = -errno; goto _err; } @@ -830,7 +830,7 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "server") == 0) { err = snd_config_get_string(n, &server); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } continue; @@ -838,29 +838,29 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "pcm") == 0) { err = snd_config_get_string(n, &pcm_name); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!pcm_name) { - SNDERR("pcm is not defined"); + snd_error(PCM, "pcm is not defined"); return -EINVAL; } if (!server) { - SNDERR("server is not defined"); + snd_error(PCM, "server is not defined"); return -EINVAL; } err = snd_config_search_definition(root, "server", server, &sconfig); if (err < 0) { - SNDERR("Unknown server %s", server); + snd_error(PCM, "Unknown server %s", server); return -EINVAL; } if (snd_config_get_type(sconfig) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for server %s definition", server); + snd_error(PCM, "Invalid type for server %s definition", server); goto _err; } snd_config_for_each(i, next, sconfig) { @@ -875,7 +875,7 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "socket") == 0) { err = snd_config_get_string(n, &sockname); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto _err; } continue; @@ -883,19 +883,19 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "port") == 0) { err = snd_config_get_integer(n, &port); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); goto _err; } continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); _err: err = -EINVAL; goto __error; } if (!sockname) { - SNDERR("socket is not defined"); + snd_error(PCM, "socket is not defined"); goto _err; } err = snd_pcm_shm_open(pcmp, name, sockname, pcm_name, stream, mode); diff --git a/src/pcm/pcm_softvol.c b/src/pcm/pcm_softvol.c index 38c63679..71ed8a46 100644 --- a/src/pcm/pcm_softvol.c +++ b/src/pcm/pcm_softvol.c @@ -632,8 +632,9 @@ static int snd_pcm_softvol_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * param slave->format != SND_PCM_FORMAT_S24_LE && slave->format != SND_PCM_FORMAT_S32_LE && slave->format != SND_PCM_FORMAT_S32_BE) { - SNDERR("softvol supports only S16_LE, S16_BE, S24_LE, S24_3LE, " - "S32_LE or S32_BE"); + snd_error(PCM, "softvol supports only S16_LE, S16_BE, S24_LE, S24_3LE, " + "S32_LE or S32_BE"); + return -EINVAL; } svol->sformat = slave->format; @@ -772,14 +773,14 @@ static int softvol_load_control(snd_pcm_t *pcm, snd_pcm_softvol_t *svol, return err; ctl_card = snd_pcm_info_get_card(&info); if (ctl_card < 0) { - SNDERR("No card defined for softvol control"); + snd_error(PCM, "No card defined for softvol control"); return -EINVAL; } } sprintf(tmp_name, "hw:%d", ctl_card); err = snd_ctl_open(&svol->ctl, tmp_name, 0); if (err < 0) { - SNDERR("Cannot open CTL %s", tmp_name); + snd_error(PCM, "Cannot open CTL %s", tmp_name); return err; } @@ -798,12 +799,12 @@ static int softvol_load_control(snd_pcm_t *pcm, snd_pcm_softvol_t *svol, snd_ctl_elem_info_set_id(&cinfo, ctl_id); if ((err = snd_ctl_elem_info(svol->ctl, &cinfo)) < 0) { if (err != -ENOENT) { - SNDERR("Cannot get info for CTL %s", tmp_name); + snd_error(PCM, "Cannot get info for CTL %s", tmp_name); return err; } err = add_user_ctl(svol, &cinfo, cchannels); if (err < 0) { - SNDERR("Cannot add a control"); + snd_error(PCM, "Cannot add a control"); return err; } } else { @@ -822,14 +823,14 @@ static int softvol_load_control(snd_pcm_t *pcm, snd_pcm_softvol_t *svol, (cinfo.access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) != 0)) { err = snd_ctl_elem_remove(svol->ctl, &cinfo.id); if (err < 0) { - SNDERR("Control %s mismatch", tmp_name); + snd_error(PCM, "Control %s mismatch", tmp_name); return err; } /* clear cinfo including numid */ snd_ctl_elem_info_clear(&cinfo); snd_ctl_elem_info_set_id(&cinfo, ctl_id); if ((err = add_user_ctl(svol, &cinfo, cchannels)) < 0) { - SNDERR("Cannot add a control"); + snd_error(PCM, "Cannot add a control"); return err; } } else if (svol->max_val > 1) { @@ -852,7 +853,7 @@ static int softvol_load_control(snd_pcm_t *pcm, snd_pcm_softvol_t *svol, #ifndef HAVE_SOFT_FLOAT svol->dB_value = calloc(resolution, sizeof(unsigned int)); if (! svol->dB_value) { - SNDERR("cannot allocate dB table"); + snd_error(PCM, "cannot allocate dB table"); return -ENOMEM; } svol->min_dB = min_dB; @@ -868,7 +869,7 @@ static int softvol_load_control(snd_pcm_t *pcm, snd_pcm_softvol_t *svol, if (svol->zero_dB_val) svol->dB_value[svol->zero_dB_val] = 65535; #else - SNDERR("Cannot handle the given dB range and resolution"); + snd_error(PCM, "Cannot handle the given dB range and resolution"); return -EINVAL; #endif } @@ -1020,28 +1021,28 @@ static int _snd_pcm_parse_control_id(snd_config_t *conf, snd_ctl_elem_id_t *ctl_ } if (strcmp(id, "name") == 0) { if ((err = snd_config_get_string(n, &name)) < 0) { - SNDERR("field %s is not a string", id); + snd_error(PCM, "field %s is not a string", id); goto _err; } continue; } if (strcmp(id, "index") == 0) { if ((err = snd_config_get_integer(n, &index)) < 0) { - SNDERR("field %s is not an integer", id); + snd_error(PCM, "field %s is not an integer", id); goto _err; } continue; } if (strcmp(id, "device") == 0) { if ((err = snd_config_get_integer(n, &device)) < 0) { - SNDERR("field %s is not an integer", id); + snd_error(PCM, "field %s is not an integer", id); goto _err; } continue; } if (strcmp(id, "subdevice") == 0) { if ((err = snd_config_get_integer(n, &subdevice)) < 0) { - SNDERR("field %s is not an integer", id); + snd_error(PCM, "field %s is not an integer", id); goto _err; } continue; @@ -1049,21 +1050,21 @@ static int _snd_pcm_parse_control_id(snd_config_t *conf, snd_ctl_elem_id_t *ctl_ if (strcmp(id, "count") == 0) { long v; if ((err = snd_config_get_integer(n, &v)) < 0) { - SNDERR("field %s is not an integer", id); + snd_error(PCM, "field %s is not an integer", id); goto _err; } if (v < 1 || v > 2) { - SNDERR("Invalid count %ld", v); + snd_error(PCM, "Invalid count %ld", v); goto _err; } *cchannels = v; continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (name == NULL) { - SNDERR("Missing control name"); + snd_error(PCM, "Missing control name"); err = -EINVAL; goto _err; } @@ -1182,7 +1183,7 @@ int _snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name, long v; err = snd_config_get_integer(n, &v); if (err < 0) { - SNDERR("Invalid resolution value"); + snd_error(PCM, "Invalid resolution value"); return err; } resolution = v; @@ -1191,7 +1192,7 @@ int _snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "min_dB") == 0) { err = snd_config_get_ireal(n, &min_dB); if (err < 0) { - SNDERR("Invalid min_dB value"); + snd_error(PCM, "Invalid min_dB value"); return err; } continue; @@ -1199,33 +1200,34 @@ int _snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "max_dB") == 0) { err = snd_config_get_ireal(n, &max_dB); if (err < 0) { - SNDERR("Invalid max_dB value"); + snd_error(PCM, "Invalid max_dB value"); return err; } continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (!slave) { - SNDERR("slave is not defined"); + snd_error(PCM, "slave is not defined"); return -EINVAL; } if (!control) { - SNDERR("control is not defined"); + snd_error(PCM, "control is not defined"); return -EINVAL; } if (min_dB >= 0) { - SNDERR("min_dB must be a negative value"); + snd_error(PCM, "min_dB must be a negative value"); return -EINVAL; } if (max_dB <= min_dB || max_dB > MAX_DB_UPPER_LIMIT) { - SNDERR("max_dB must be larger than min_dB and less than %d dB", - MAX_DB_UPPER_LIMIT); + snd_error(PCM, "max_dB must be larger than min_dB and less than %d dB", + MAX_DB_UPPER_LIMIT); + return -EINVAL; } if (resolution <= 1 || resolution > 1024) { - SNDERR("Invalid resolution value %d", resolution); + snd_error(PCM, "Invalid resolution value %d", resolution); return -EINVAL; } if (mode & SND_PCM_NO_SOFTVOL) { @@ -1247,7 +1249,7 @@ int _snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name, sformat != SND_PCM_FORMAT_S24_LE && sformat != SND_PCM_FORMAT_S32_LE && sformat != SND_PCM_FORMAT_S32_BE) { - SNDERR("only S16_LE, S16_BE, S24_LE, S24_3LE, S32_LE or S32_BE format is supported"); + snd_error(PCM, "only S16_LE, S16_BE, S24_LE, S24_3LE, S32_LE or S32_BE format is supported"); snd_config_delete(sconf); return -EINVAL; } diff --git a/src/pcm/scopes/level.c b/src/pcm/scopes/level.c index ca7c0f60..d5589969 100644 --- a/src/pcm/scopes/level.c +++ b/src/pcm/scopes/level.c @@ -236,7 +236,7 @@ int _snd_pcm_scope_level_open(snd_pcm_t *pcm, const char *name, if (strcmp(id, "bar_width") == 0) { err = snd_config_get_integer(n, &bar_width); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } continue; @@ -244,7 +244,7 @@ int _snd_pcm_scope_level_open(snd_pcm_t *pcm, const char *name, if (strcmp(id, "decay_ms") == 0) { err = snd_config_get_integer(n, &decay_ms); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } continue; @@ -252,12 +252,12 @@ int _snd_pcm_scope_level_open(snd_pcm_t *pcm, const char *name, if (strcmp(id, "peak_ms") == 0) { err = snd_config_get_integer(n, &peak_ms); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(PCM, "Invalid type for %s", id); return -EINVAL; } continue; } - SNDERR("Unknown field %s", id); + snd_error(PCM, "Unknown field %s", id); return -EINVAL; } if (bar_width < 0) diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c index 9bb6d744..1021f1c4 100644 --- a/src/rawmidi/rawmidi.c +++ b/src/rawmidi/rawmidi.c @@ -188,30 +188,30 @@ static int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp #endif if (snd_config_get_type(rawmidi_conf) != SND_CONFIG_TYPE_COMPOUND) { if (name) - SNDERR("Invalid type for RAWMIDI %s definition", name); + snd_error(RAWMIDI, "Invalid type for RAWMIDI %s definition", name); else - SNDERR("Invalid type for RAWMIDI definition"); + snd_error(RAWMIDI, "Invalid type for RAWMIDI definition"); return -EINVAL; } err = snd_config_search(rawmidi_conf, "type", &conf); if (err < 0) { - SNDERR("type is not defined"); + snd_error(RAWMIDI, "type is not defined"); return err; } err = snd_config_get_id(conf, &id); if (err < 0) { - SNDERR("unable to get id"); + snd_error(RAWMIDI, "unable to get id"); return err; } err = snd_config_get_string(conf, &str); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(RAWMIDI, "Invalid type for %s", id); return err; } err = snd_config_search_definition(rawmidi_root, "rawmidi_type", str, &type_conf); if (err >= 0) { if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for RAWMIDI type %s definition", str); + snd_error(RAWMIDI, "Invalid type for RAWMIDI type %s definition", str); err = -EINVAL; goto _err; } @@ -225,7 +225,7 @@ static int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp if (strcmp(id, "lib") == 0) { err = snd_config_get_string(n, &lib); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(RAWMIDI, "Invalid type for %s", id); goto _err; } continue; @@ -233,12 +233,12 @@ static int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp if (strcmp(id, "open") == 0) { err = snd_config_get_string(n, &open_name); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(RAWMIDI, "Invalid type for %s", id); goto _err; } continue; } - SNDERR("Unknown field %s", id); + snd_error(RAWMIDI, "Unknown field %s", id); err = -EINVAL; goto _err; } @@ -290,7 +290,7 @@ static int snd_rawmidi_open_noupdate(snd_rawmidi_t **inputp, snd_rawmidi_t **out snd_config_t *rawmidi_conf; err = snd_config_search_definition(root, "rawmidi", name, &rawmidi_conf); if (err < 0) { - SNDERR("Unknown RawMidi %s", name); + snd_error(RAWMIDI, "Unknown RawMidi %s", name); return err; } err = snd_rawmidi_open_conf(inputp, outputp, name, root, rawmidi_conf, mode); diff --git a/src/rawmidi/rawmidi_hw.c b/src/rawmidi/rawmidi_hw.c index 3b1d941e..c4908a19 100644 --- a/src/rawmidi/rawmidi_hw.c +++ b/src/rawmidi/rawmidi_hw.c @@ -69,7 +69,7 @@ static int snd_rawmidi_hw_close(snd_rawmidi_t *rmidi) return 0; if (close(hw->fd)) { err = -errno; - SYSMSG("close failed"); + snd_checknum(RAWMIDI, "close failed"); } free(hw->buf); free(hw); @@ -82,7 +82,7 @@ static int snd_rawmidi_hw_nonblock(snd_rawmidi_t *rmidi, int nonblock) long flags; if ((flags = fcntl(hw->fd, F_GETFL)) < 0) { - SYSMSG("F_GETFL failed"); + snd_checknum(RAWMIDI, "F_GETFL failed"); return -errno; } if (nonblock) @@ -90,7 +90,7 @@ static int snd_rawmidi_hw_nonblock(snd_rawmidi_t *rmidi, int nonblock) else flags &= ~O_NONBLOCK; if (fcntl(hw->fd, F_SETFL, flags) < 0) { - SYSMSG("F_SETFL for O_NONBLOCK failed"); + snd_checknum(RAWMIDI, "F_SETFL for O_NONBLOCK failed"); return -errno; } return 0; @@ -101,7 +101,7 @@ static int snd_rawmidi_hw_info(snd_rawmidi_t *rmidi, snd_rawmidi_info_t * info) snd_rawmidi_hw_t *hw = rmidi->private_data; info->stream = rmidi->stream; if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_INFO, info) < 0) { - SYSMSG("SNDRV_RAWMIDI_IOCTL_INFO failed"); + snd_checknum(RAWMIDI, "SNDRV_RAWMIDI_IOCTL_INFO failed"); return -errno; } return 0; @@ -113,7 +113,7 @@ static int snd_rawmidi_hw_params(snd_rawmidi_t *rmidi, snd_rawmidi_params_t * pa int tstamp; params->stream = rmidi->stream; if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_PARAMS, params) < 0) { - SYSMSG("SNDRV_RAWMIDI_IOCTL_PARAMS failed"); + snd_checknum(RAWMIDI, "SNDRV_RAWMIDI_IOCTL_PARAMS failed"); return -errno; } buf_reset(hw); @@ -145,7 +145,7 @@ static int snd_rawmidi_hw_status(snd_rawmidi_t *rmidi, snd_rawmidi_status_t * st snd_rawmidi_hw_t *hw = rmidi->private_data; status->stream = rmidi->stream; if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_STATUS, status) < 0) { - SYSMSG("SNDRV_RAWMIDI_IOCTL_STATUS failed"); + snd_checknum(RAWMIDI, "SNDRV_RAWMIDI_IOCTL_STATUS failed"); return -errno; } return 0; @@ -156,7 +156,7 @@ static int snd_rawmidi_hw_drop(snd_rawmidi_t *rmidi) snd_rawmidi_hw_t *hw = rmidi->private_data; int str = rmidi->stream; if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_DROP, &str) < 0) { - SYSMSG("SNDRV_RAWMIDI_IOCTL_DROP failed"); + snd_checknum(RAWMIDI, "SNDRV_RAWMIDI_IOCTL_DROP failed"); return -errno; } buf_reset(hw); @@ -168,7 +168,7 @@ static int snd_rawmidi_hw_drain(snd_rawmidi_t *rmidi) snd_rawmidi_hw_t *hw = rmidi->private_data; int str = rmidi->stream; if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_DRAIN, &str) < 0) { - SYSMSG("SNDRV_RAWMIDI_IOCTL_DRAIN failed"); + snd_checknum(RAWMIDI, "SNDRV_RAWMIDI_IOCTL_DRAIN failed"); return -errno; } return 0; @@ -382,13 +382,13 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, fd = snd_open_device(filename, fmode); if (fd < 0) { snd_ctl_close(ctl); - SYSMSG("open %s failed", filename); + snd_checknum(RAWMIDI, "open %s failed", filename); return -errno; } } if (ioctl(fd, SNDRV_RAWMIDI_IOCTL_PVERSION, &ver) < 0) { ret = -errno; - SYSMSG("SNDRV_RAWMIDI_IOCTL_PVERSION failed"); + snd_checknum(RAWMIDI, "SNDRV_RAWMIDI_IOCTL_PVERSION failed"); close(fd); snd_ctl_close(ctl); return ret; @@ -407,7 +407,7 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, memset(&info, 0, sizeof(info)); info.stream = outputp ? SNDRV_RAWMIDI_STREAM_OUTPUT : SNDRV_RAWMIDI_STREAM_INPUT; if (ioctl(fd, SNDRV_RAWMIDI_IOCTL_INFO, &info) < 0) { - SYSMSG("SNDRV_RAWMIDI_IOCTL_INFO failed"); + snd_checknum(RAWMIDI, "SNDRV_RAWMIDI_IOCTL_INFO failed"); ret = -errno; close(fd); snd_ctl_close(ctl); diff --git a/src/seq/seq.c b/src/seq/seq.c index 38cb1afd..7a5fe27d 100644 --- a/src/seq/seq.c +++ b/src/seq/seq.c @@ -914,30 +914,30 @@ static int snd_seq_open_conf(snd_seq_t **seqp, const char *name, void *h = NULL; if (snd_config_get_type(seq_conf) != SND_CONFIG_TYPE_COMPOUND) { if (name) - SNDERR("Invalid type for SEQ %s definition", name); + snd_error(SEQUENCER, "Invalid type for SEQ %s definition", name); else - SNDERR("Invalid type for SEQ definition"); + snd_error(SEQUENCER, "Invalid type for SEQ definition"); return -EINVAL; } err = snd_config_search(seq_conf, "type", &conf); if (err < 0) { - SNDERR("type is not defined"); + snd_error(SEQUENCER, "type is not defined"); return err; } err = snd_config_get_id(conf, &id); if (err < 0) { - SNDERR("unable to get id"); + snd_error(SEQUENCER, "unable to get id"); return err; } err = snd_config_get_string(conf, &str); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(SEQUENCER, "Invalid type for %s", id); return err; } err = snd_config_search_definition(seq_root, "seq_type", str, &type_conf); if (err >= 0) { if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for SEQ type %s definition", str); + snd_error(SEQUENCER, "Invalid type for SEQ type %s definition", str); goto _err; } snd_config_for_each(i, next, type_conf) { @@ -950,7 +950,7 @@ static int snd_seq_open_conf(snd_seq_t **seqp, const char *name, if (strcmp(id, "lib") == 0) { err = snd_config_get_string(n, &lib); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(SEQUENCER, "Invalid type for %s", id); goto _err; } continue; @@ -958,12 +958,12 @@ static int snd_seq_open_conf(snd_seq_t **seqp, const char *name, if (strcmp(id, "open") == 0) { err = snd_config_get_string(n, &open_name); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(SEQUENCER, "Invalid type for %s", id); goto _err; } continue; } - SNDERR("Unknown field %s", id); + snd_error(SEQUENCER, "Unknown field %s", id); err = -EINVAL; goto _err; } @@ -980,10 +980,10 @@ static int snd_seq_open_conf(snd_seq_t **seqp, const char *name, open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_SEQ_DLSYM_VERSION)); err = 0; if (!h) { - SNDERR("Cannot open shared library %s (%s)", lib, errbuf); + snd_error(SEQUENCER, "Cannot open shared library %s (%s)", lib, errbuf); err = -ENOENT; } else if (!open_func) { - SNDERR("symbol %s is not defined inside %s", open_name, lib); + snd_error(SEQUENCER, "symbol %s is not defined inside %s", open_name, lib); snd_dlclose(h); err = -ENXIO; } @@ -1008,7 +1008,7 @@ static int snd_seq_open_noupdate(snd_seq_t **seqp, snd_config_t *root, snd_config_t *seq_conf; err = snd_config_search_definition(root, "seq", name, &seq_conf); if (err < 0) { - SNDERR("Unknown SEQ %s", name); + snd_error(SEQUENCER, "Unknown SEQ %s", name); return err; } snd_config_set_hop(seq_conf, hop); @@ -4594,7 +4594,7 @@ static int snd_seq_event_input_feed(snd_seq_t *seq, int timeout) pfd.events = POLLIN; err = poll(&pfd, 1, timeout); if (err < 0) { - SYSERR("poll"); + snd_errornum(SEQUENCER, "poll"); return -errno; } if (pfd.revents & POLLIN) diff --git a/src/seq/seq_hw.c b/src/seq/seq_hw.c index fe9d9bc7..5ee41953 100644 --- a/src/seq/seq_hw.c +++ b/src/seq/seq_hw.c @@ -46,7 +46,7 @@ static int snd_seq_hw_close(snd_seq_t *seq) if (close(hw->fd)) { err = -errno; - SYSERR("close failed\n"); + snd_errornum(SEQUENCER, "close failed\n"); } free(hw); return err; @@ -58,7 +58,7 @@ static int snd_seq_hw_nonblock(snd_seq_t *seq, int nonblock) long flags; if ((flags = fcntl(hw->fd, F_GETFL)) < 0) { - SYSERR("F_GETFL failed"); + snd_errornum(SEQUENCER, "F_GETFL failed"); return -errno; } if (nonblock) @@ -66,7 +66,7 @@ static int snd_seq_hw_nonblock(snd_seq_t *seq, int nonblock) else flags &= ~O_NONBLOCK; if (fcntl(hw->fd, F_SETFL, flags) < 0) { - SYSERR("F_SETFL for O_NONBLOCK failed"); + snd_errornum(SEQUENCER, "F_SETFL for O_NONBLOCK failed"); return -errno; } return 0; @@ -77,7 +77,7 @@ static int snd_seq_hw_client_id(snd_seq_t *seq) snd_seq_hw_t *hw = seq->private_data; int client; if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_CLIENT_ID, &client) < 0) { - SYSERR("SNDRV_SEQ_IOCTL_CLIENT_ID failed"); + snd_errornum(SEQUENCER, "SNDRV_SEQ_IOCTL_CLIENT_ID failed"); return -errno; } return client; @@ -87,7 +87,7 @@ static int snd_seq_hw_system_info(snd_seq_t *seq, snd_seq_system_info_t * info) { snd_seq_hw_t *hw = seq->private_data; if (ioctl(hw->fd, SNDRV_SEQ_IOCTL_SYSTEM_INFO, info) < 0) { - SYSERR("SNDRV_SEQ_IOCTL_SYSTEM_INFO failed"); + snd_errornum(SEQUENCER, "SNDRV_SEQ_IOCTL_SYSTEM_INFO failed"); return -errno; } return 0; @@ -537,11 +537,11 @@ int snd_seq_hw_open(snd_seq_t **handle, const char *name, int streams, int mode) } #endif if (fd < 0) { - SYSERR("open %s failed", filename); + snd_errornum(SEQUENCER, "open %s failed", filename); return -errno; } if (ioctl(fd, SNDRV_SEQ_IOCTL_PVERSION, &ver) < 0) { - SYSERR("SNDRV_SEQ_IOCTL_PVERSION failed"); + snd_errornum(SEQUENCER, "SNDRV_SEQ_IOCTL_PVERSION failed"); ret = -errno; close(fd); return ret; diff --git a/src/seq/seqmid.c b/src/seq/seqmid.c index edffa675..ca9686e4 100644 --- a/src/seq/seqmid.c +++ b/src/seq/seqmid.c @@ -525,7 +525,7 @@ int snd_seq_create_ump_endpoint(snd_seq_t *seq, return -EINVAL; if (!(info->protocol_caps & info->protocol)) { - SNDERR("Inconsistent UMP protocol_caps and protocol\n"); + snd_error(SEQUENCER, "Inconsistent UMP protocol_caps and protocol\n"); return -EINVAL; } @@ -534,13 +534,13 @@ int snd_seq_create_ump_endpoint(snd_seq_t *seq, } else if (info->protocol & SND_UMP_EP_INFO_PROTO_MIDI1) { version = SND_SEQ_CLIENT_UMP_MIDI_1_0; } else { - SNDERR("Invalid UMP protocol set 0x%x\n", info->protocol); + snd_error(SEQUENCER, "Invalid UMP protocol set 0x%x\n", info->protocol); return -EINVAL; } err = snd_seq_set_client_midi_version(seq, version); if (err < 0) { - SNDERR("Failed to set to MIDI protocol 0x%x\n", version); + snd_error(SEQUENCER, "Failed to set to MIDI protocol 0x%x\n", version); return err; } @@ -560,7 +560,7 @@ int snd_seq_create_ump_endpoint(snd_seq_t *seq, err = snd_seq_set_ump_endpoint_info(seq, seq->ump_ep); if (err < 0) { - SNDERR("Failed to set UMP EP info\n"); + snd_error(SEQUENCER, "Failed to set UMP EP info\n"); goto error_free; } @@ -586,7 +586,7 @@ int snd_seq_create_ump_endpoint(snd_seq_t *seq, snd_seq_port_info_set_ump_group(pinfo, 0); err = snd_seq_create_port(seq, pinfo); if (err < 0) { - SNDERR("Failed to create MIDI 2.0 port\n"); + snd_error(SEQUENCER, "Failed to create MIDI 2.0 port\n"); goto error_free; } @@ -601,7 +601,7 @@ int snd_seq_create_ump_endpoint(snd_seq_t *seq, snd_seq_port_info_set_ump_group(pinfo, i + 1); err = snd_seq_create_port(seq, pinfo); if (err < 0) { - SNDERR("Failed to create Group port %d\n", i + 1); + snd_error(SEQUENCER, "Failed to create Group port %d\n", i + 1); goto error; } } @@ -725,7 +725,7 @@ int snd_seq_create_ump_block(snd_seq_t *seq, int blkid, err = snd_seq_set_ump_block_info(seq, blkid, bp); if (err < 0) { - SNDERR("Failed to set UMP EP info\n"); + snd_error(SEQUENCER, "Failed to set UMP EP info\n"); free(bp); seq->ump_blks[blkid] = NULL; return err; diff --git a/src/socket.c b/src/socket.c index c68fa300..971c434e 100644 --- a/src/socket.c +++ b/src/socket.c @@ -67,7 +67,7 @@ int snd_send_fd(int sock, void *data, size_t len, int fd) ret = sendmsg(sock, &msghdr, 0 ); if (ret < 0) { - SYSERR("sendmsg failed"); + snd_errornum(CORE, "sendmsg failed"); return -errno; } return ret; @@ -100,7 +100,7 @@ int snd_receive_fd(int sock, void *data, size_t len, int *fd) ret = recvmsg(sock, &msghdr, 0); if (ret < 0) { - SYSERR("recvmsg failed"); + snd_errornum(CORE, "recvmsg failed"); return -errno; } *fd = *fds; diff --git a/src/timer/timer.c b/src/timer/timer.c index 0f8491b8..c4daa2a0 100644 --- a/src/timer/timer.c +++ b/src/timer/timer.c @@ -89,30 +89,30 @@ static int snd_timer_open_conf(snd_timer_t **timer, void *h = NULL; if (snd_config_get_type(timer_conf) != SND_CONFIG_TYPE_COMPOUND) { if (name) - SNDERR("Invalid type for TIMER %s definition", name); + snd_error(TIMER, "Invalid type for TIMER %s definition", name); else - SNDERR("Invalid type for TIMER definition"); + snd_error(TIMER, "Invalid type for TIMER definition"); return -EINVAL; } err = snd_config_search(timer_conf, "type", &conf); if (err < 0) { - SNDERR("type is not defined"); + snd_error(TIMER, "type is not defined"); return err; } err = snd_config_get_id(conf, &id); if (err < 0) { - SNDERR("unable to get id"); + snd_error(TIMER, "unable to get id"); return err; } err = snd_config_get_string(conf, &str); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(TIMER, "Invalid type for %s", id); return err; } err = snd_config_search_definition(timer_root, "timer_type", str, &type_conf); if (err >= 0) { if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for TIMER type %s definition", str); + snd_error(TIMER, "Invalid type for TIMER type %s definition", str); goto _err; } snd_config_for_each(i, next, type_conf) { @@ -125,7 +125,7 @@ static int snd_timer_open_conf(snd_timer_t **timer, if (strcmp(id, "lib") == 0) { err = snd_config_get_string(n, &lib); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(TIMER, "Invalid type for %s", id); goto _err; } continue; @@ -133,12 +133,12 @@ static int snd_timer_open_conf(snd_timer_t **timer, if (strcmp(id, "open") == 0) { err = snd_config_get_string(n, &open_name); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(TIMER, "Invalid type for %s", id); goto _err; } continue; } - SNDERR("Unknown field %s", id); + snd_error(TIMER, "Unknown field %s", id); err = -EINVAL; goto _err; } @@ -155,10 +155,10 @@ static int snd_timer_open_conf(snd_timer_t **timer, open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_TIMER_DLSYM_VERSION)); err = 0; if (!h) { - SNDERR("Cannot open shared library %s (%s)", lib, errbuf); + snd_error(TIMER, "Cannot open shared library %s (%s)", lib, errbuf); err = -ENOENT; } else if (!open_func) { - SNDERR("symbol %s is not defined inside %s", open_name, lib); + snd_error(TIMER, "symbol %s is not defined inside %s", open_name, lib); snd_dlclose(h); err = -ENXIO; } @@ -181,7 +181,7 @@ static int snd_timer_open_noupdate(snd_timer_t **timer, snd_config_t *root, cons snd_config_t *timer_conf; err = snd_config_search_definition(root, "timer", name, &timer_conf); if (err < 0) { - SNDERR("Unknown timer %s", name); + snd_error(TIMER, "Unknown timer %s", name); return err; } err = snd_timer_open_conf(timer, name, root, timer_conf, mode); @@ -331,7 +331,7 @@ int snd_async_add_timer_handler(snd_async_handler_t **handler, snd_timer_t *time snd_timer_t *snd_async_handler_get_timer(snd_async_handler_t *handler) { if (handler->type != SND_ASYNC_HANDLER_TIMER) { - SNDMSG("invalid handler type %d", handler->type); + snd_check(TIMER, "invalid handler type %d", handler->type); return NULL; } return handler->u.timer; diff --git a/src/timer/timer_hw.c b/src/timer/timer_hw.c index fe4e40bb..3783491f 100644 --- a/src/timer/timer_hw.c +++ b/src/timer/timer_hw.c @@ -72,7 +72,7 @@ static int snd_timer_hw_async(snd_timer_t *timer, int sig, pid_t pid) assert(timer); fd = timer->poll_fd; if ((flags = fcntl(fd, F_GETFL)) < 0) { - SYSERR("F_GETFL failed"); + snd_errornum(TIMER, "F_GETFL failed"); return -errno; } if (sig >= 0) @@ -80,19 +80,19 @@ static int snd_timer_hw_async(snd_timer_t *timer, int sig, pid_t pid) else flags &= ~O_ASYNC; if (fcntl(fd, F_SETFL, flags) < 0) { - SYSERR("F_SETFL for O_ASYNC failed"); + snd_errornum(TIMER, "F_SETFL for O_ASYNC failed"); return -errno; } if (sig < 0) return 0; #ifdef F_SETSIG if (fcntl(fd, F_SETSIG, (long)sig) < 0) { - SYSERR("F_SETSIG failed"); + snd_errornum(TIMER, "F_SETSIG failed"); return -errno; } #endif if (fcntl(fd, F_SETOWN, (long)pid) < 0) { - SYSERR("F_SETOWN failed"); + snd_errornum(TIMER, "F_SETOWN failed"); return -errno; } return 0; @@ -250,7 +250,7 @@ int snd_timer_hw_open(snd_timer_t **handle, const char *name, int dev_class, int ret = -errno; __no_tread: close(fd); - SNDMSG("extended read is not supported (SNDRV_TIMER_IOCTL_TREAD)"); + snd_check(TIMER, "extended read is not supported (SNDRV_TIMER_IOCTL_TREAD)"); return ret; } } @@ -327,7 +327,7 @@ int _snd_timer_hw_open(snd_timer_t **timer, char *name, return err; continue; } - SNDERR("Unexpected field %s", id); + snd_error(TIMER, "Unexpected field %s", id); return -EINVAL; } return snd_timer_hw_open(timer, name, dev_class, dev_sclass, card, device, subdevice, mode); diff --git a/src/timer/timer_query.c b/src/timer/timer_query.c index 084ff61a..9fa14069 100644 --- a/src/timer/timer_query.c +++ b/src/timer/timer_query.c @@ -46,30 +46,30 @@ static int snd_timer_query_open_conf(snd_timer_query_t **timer, void *h = NULL; if (snd_config_get_type(timer_conf) != SND_CONFIG_TYPE_COMPOUND) { if (name) - SNDERR("Invalid type for TIMER %s definition", name); + snd_error(TIMER, "Invalid type for TIMER %s definition", name); else - SNDERR("Invalid type for TIMER definition"); + snd_error(TIMER, "Invalid type for TIMER definition"); return -EINVAL; } err = snd_config_search(timer_conf, "type", &conf); if (err < 0) { - SNDERR("type is not defined"); + snd_error(TIMER, "type is not defined"); return err; } err = snd_config_get_id(conf, &id); if (err < 0) { - SNDERR("unable to get id"); + snd_error(TIMER, "unable to get id"); return err; } err = snd_config_get_string(conf, &str); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(TIMER, "Invalid type for %s", id); return err; } err = snd_config_search_definition(timer_root, "timer_query_type", str, &type_conf); if (err >= 0) { if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("Invalid type for TIMER type %s definition", str); + snd_error(TIMER, "Invalid type for TIMER type %s definition", str); err = -EINVAL; goto _err; } @@ -83,7 +83,7 @@ static int snd_timer_query_open_conf(snd_timer_query_t **timer, if (strcmp(id, "lib") == 0) { err = snd_config_get_string(n, &lib); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(TIMER, "Invalid type for %s", id); goto _err; } continue; @@ -91,12 +91,12 @@ static int snd_timer_query_open_conf(snd_timer_query_t **timer, if (strcmp(id, "open") == 0) { err = snd_config_get_string(n, &open_name); if (err < 0) { - SNDERR("Invalid type for %s", id); + snd_error(TIMER, "Invalid type for %s", id); goto _err; } continue; } - SNDERR("Unknown field %s", id); + snd_error(TIMER, "Unknown field %s", id); err = -EINVAL; goto _err; } @@ -113,10 +113,10 @@ static int snd_timer_query_open_conf(snd_timer_query_t **timer, open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_TIMER_QUERY_DLSYM_VERSION)); err = 0; if (!h) { - SNDERR("Cannot open shared library %s (%s)", lib, errbuf); + snd_error(TIMER, "Cannot open shared library %s (%s)", lib, errbuf); err = -ENOENT; } else if (!open_func) { - SNDERR("symbol %s is not defined inside %s", open_name, lib); + snd_error(TIMER, "symbol %s is not defined inside %s", open_name, lib); snd_dlclose(h); err = -ENXIO; } @@ -139,7 +139,7 @@ static int snd_timer_query_open_noupdate(snd_timer_query_t **timer, snd_config_t snd_config_t *timer_conf; err = snd_config_search_definition(root, "timer_query", name, &timer_conf); if (err < 0) { - SNDERR("Unknown timer %s", name); + snd_error(TIMER, "Unknown timer %s", name); return err; } err = snd_timer_query_open_conf(timer, name, root, timer_conf, mode); diff --git a/src/timer/timer_query_hw.c b/src/timer/timer_query_hw.c index d8bac6e7..0e217e53 100644 --- a/src/timer/timer_query_hw.c +++ b/src/timer/timer_query_hw.c @@ -130,7 +130,7 @@ int _snd_timer_query_hw_open(snd_timer_query_t **timer, char *name, continue; if (_snd_conf_generic_id(id)) continue; - SNDERR("Unexpected field %s", id); + snd_error(TIMER, "Unexpected field %s", id); return -EINVAL; } return snd_timer_query_hw_open(timer, name, mode); diff --git a/src/topology/builder.c b/src/topology/builder.c index 9c52c9cc..f7cf8534 100644 --- a/src/topology/builder.c +++ b/src/topology/builder.c @@ -50,11 +50,15 @@ static ssize_t write_block_header(snd_tplg_t *tplg, unsigned int type, /* make sure file offset is aligned with the calculated HDR offset */ if (tplg->bin_pos != tplg->next_hdr_pos) { - SNDERR("New header is at offset 0x%zx but file" - " offset 0x%zx is %s by %ld bytes", - tplg->next_hdr_pos, tplg->bin_pos, - tplg->bin_pos > tplg->next_hdr_pos ? "ahead" : "behind", - tplg->bin_pos - tplg->next_hdr_pos); + snd_error(TOPOLOGY, "New header is at offset 0x%zx but file" + " offset 0x%zx is %s by %ld bytes", + + tplg->next_hdr_pos, tplg->bin_pos, + + tplg->bin_pos > tplg->next_hdr_pos ? "ahead" : "behind", + + tplg->bin_pos - tplg->next_hdr_pos); + return -EINVAL; } @@ -95,8 +99,9 @@ static int write_elem_block(snd_tplg_t *tplg, ret = write_block_header(tplg, tplg_type, elem->vendor_type, tplg->version, elem->index, block_size, count); if (ret < 0) { - SNDERR("failed to write %s block %d", - obj_name, ret); + snd_error(TOPOLOGY, "failed to write %s block %d", + obj_name, ret); + return ret; } @@ -137,8 +142,9 @@ static int write_elem_block(snd_tplg_t *tplg, /* make sure we have written the correct size */ if (total_size != size) { - SNDERR("size mismatch. Expected %zu wrote %zu", - size, total_size); + snd_error(TOPOLOGY, "size mismatch. Expected %zu wrote %zu", + size, total_size); + return -EIO; } @@ -210,7 +216,7 @@ static ssize_t write_manifest_data(snd_tplg_t *tplg) tplg->version, 0, sizeof(tplg->manifest) + tplg->manifest.priv.size, 1); if (ret < 0) { - SNDERR("failed to write manifest block"); + snd_error(TOPOLOGY, "failed to write manifest block"); return ret; } @@ -258,7 +264,7 @@ int tplg_write_data(snd_tplg_t *tplg) /* write manifest */ ret = write_manifest_data(tplg); if (ret < 0) { - SNDERR("failed to write manifest %d", ret); + snd_error(TOPOLOGY, "failed to write manifest %d", ret); return ret; } @@ -279,8 +285,9 @@ int tplg_write_data(snd_tplg_t *tplg) ret = write_elem_block(tplg, list, size, tptr->tsoc, tptr->name); if (ret < 0) { - SNDERR("failed to write %s elements: %s", - tptr->name, snd_strerror(-ret)); + snd_error(TOPOLOGY, "failed to write %s elements: %s", + tptr->name, snd_strerror(-ret)); + return ret; } } @@ -289,8 +296,9 @@ int tplg_write_data(snd_tplg_t *tplg) tplg->bin_pos, tplg->bin_pos); if (total_size != tplg->bin_pos) { - SNDERR("total size mismatch (%zd != %zd)", - total_size, tplg->bin_pos); + snd_error(TOPOLOGY, "total size mismatch (%zd != %zd)", + total_size, tplg->bin_pos); + return -EINVAL; } diff --git a/src/topology/channel.c b/src/topology/channel.c index 9239c3b2..66c59707 100644 --- a/src/topology/channel.c +++ b/src/topology/channel.c @@ -103,7 +103,7 @@ int tplg_parse_channel(snd_tplg_t *tplg, snd_config_t *cfg, channel_id = lookup_channel(id); if (channel_id < 0) { - SNDERR("invalid channel %s", id); + snd_error(TOPOLOGY, "invalid channel %s", id); return -EINVAL; } diff --git a/src/topology/ctl.c b/src/topology/ctl.c index 67622957..6c9c0718 100644 --- a/src/topology/ctl.c +++ b/src/topology/ctl.c @@ -94,7 +94,7 @@ int parse_access(snd_config_t *cfg, if (strcmp(id, "access") == 0) { err = parse_access_values(n, hdr); if (err < 0) { - SNDERR("failed to parse access"); + snd_error(TOPOLOGY, "failed to parse access"); return err; } continue; @@ -187,8 +187,9 @@ static int tplg_build_mixer_control(snd_tplg_t *tplg, } if (!ref->elem) { - SNDERR("cannot find '%s' referenced by" - " control '%s'", ref->id, elem->id); + snd_error(TOPOLOGY, "cannot find '%s' referenced by" + " control '%s'", ref->id, elem->id); + return -EINVAL; } else if (err < 0) return err; @@ -236,8 +237,9 @@ static int tplg_build_enum_control(snd_tplg_t *tplg, return err; } if (!ref->elem) { - SNDERR("cannot find '%s' referenced by" - " control '%s'", ref->id, elem->id); + snd_error(TOPOLOGY, "cannot find '%s' referenced by" + " control '%s'", ref->id, elem->id); + return -EINVAL; } } @@ -358,7 +360,7 @@ static int tplg_parse_tlv_dbscale(snd_config_t *cfg, struct tplg_elem *elem) else if (strcmp(id, "mute") == 0) scale->mute = val; else - SNDERR("unknown id '%s'", id); + snd_error(TOPOLOGY, "unknown id '%s'", id); } return 0; @@ -387,7 +389,7 @@ int tplg_parse_tlv(snd_tplg_t *tplg, snd_config_t *cfg, if (strcmp(id, "scale") == 0) { err = tplg_parse_tlv_dbscale(n, elem); if (err < 0) { - SNDERR("failed to DBScale"); + snd_error(TOPOLOGY, "failed to DBScale"); return err; } continue; @@ -407,7 +409,7 @@ int tplg_save_tlv(snd_tplg_t *tplg ATTRIBUTE_UNUSED, int err; if (tlv->type != SNDRV_CTL_TLVT_DB_SCALE) { - SNDERR("unknown TLV type"); + snd_error(TOPOLOGY, "unknown TLV type"); return -EINVAL; } @@ -650,7 +652,7 @@ int tplg_parse_control_enum(snd_tplg_t *tplg, snd_config_t *cfg, if (strcmp(id, "channel") == 0) { if (ec->num_channels >= SND_SOC_TPLG_MAX_CHAN) { - SNDERR("too many channels %s", elem->id); + snd_error(TOPOLOGY, "too many channels %s", elem->id); return -EINVAL; } @@ -778,7 +780,7 @@ int tplg_parse_control_mixer(snd_tplg_t *tplg, if (strcmp(id, "channel") == 0) { if (mc->num_channels >= SND_SOC_TPLG_MAX_CHAN) { - SNDERR("too many channels %s", elem->id); + snd_error(TOPOLOGY, "too many channels %s", elem->id); return -EINVAL; } @@ -936,7 +938,7 @@ static int init_ctl_hdr(snd_tplg_t *tplg, struct snd_soc_tplg_tlv_dbscale *scale; if (!tlvt) { - SNDERR("missing TLV data"); + snd_error(TOPOLOGY, "missing TLV data"); return -EINVAL; } @@ -966,7 +968,7 @@ static int init_ctl_hdr(snd_tplg_t *tplg, /* TODO: add support for other TLV types */ default: - SNDERR("unsupported TLV type %d", tlv->type); + snd_error(TOPOLOGY, "unsupported TLV type %d", tlv->type); break; } } @@ -985,7 +987,7 @@ int tplg_add_mixer(snd_tplg_t *tplg, struct snd_tplg_mixer_template *mixer, tplg_dbg(" Control Mixer: %s", mixer->hdr.name); if (mixer->hdr.type != SND_SOC_TPLG_TYPE_MIXER) { - SNDERR("invalid mixer type %d", mixer->hdr.type); + snd_error(TOPOLOGY, "invalid mixer type %d", mixer->hdr.type); return -EINVAL; } @@ -1049,7 +1051,7 @@ int tplg_add_enum(snd_tplg_t *tplg, struct snd_tplg_enum_template *enum_ctl, tplg_dbg(" Control Enum: %s", enum_ctl->hdr.name); if (enum_ctl->hdr.type != SND_SOC_TPLG_TYPE_ENUM) { - SNDERR("invalid enum type %d", enum_ctl->hdr.type); + snd_error(TOPOLOGY, "invalid enum type %d", enum_ctl->hdr.type); return -EINVAL; } @@ -1140,7 +1142,7 @@ int tplg_add_bytes(snd_tplg_t *tplg, struct snd_tplg_bytes_template *bytes_ctl, tplg_dbg(" Control Bytes: %s", bytes_ctl->hdr.name); if (bytes_ctl->hdr.type != SND_SOC_TPLG_TYPE_BYTES) { - SNDERR("invalid bytes type %d", bytes_ctl->hdr.type); + snd_error(TOPOLOGY, "invalid bytes type %d", bytes_ctl->hdr.type); return -EINVAL; } @@ -1177,8 +1179,9 @@ int tplg_add_bytes(snd_tplg_t *tplg, struct snd_tplg_bytes_template *bytes_ctl, if (be->hdr.access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { if ((be->hdr.access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE) != SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE) { - SNDERR("Invalid TLV bytes control access 0x%x", - be->hdr.access); + snd_error(TOPOLOGY, "Invalid TLV bytes control access 0x%x", + be->hdr.access); + tplg_elem_free(elem); return -EINVAL; } @@ -1221,14 +1224,14 @@ int tplg_decode_control_mixer1(snd_tplg_t *tplg, int i; if (size < sizeof(*mc)) { - SNDERR("mixer: small size %d", size); + snd_error(TOPOLOGY, "mixer: small size %d", size); return -EINVAL; } tplg_log(tplg, 'D', pos, "mixer: size %d TLV size %d private size %d", mc->size, mc->hdr.tlv.size, mc->priv.size); if (size != mc->size + mc->priv.size) { - SNDERR("mixer: unexpected element size %d", size); + snd_error(TOPOLOGY, "mixer: unexpected element size %d", size); return -EINVAL; } @@ -1258,8 +1261,9 @@ int tplg_decode_control_mixer1(snd_tplg_t *tplg, /* nothing */ } else if (mc->hdr.tlv.size == sizeof(struct snd_soc_tplg_ctl_tlv)) { if (mc->hdr.tlv.type != SNDRV_CTL_TLVT_DB_SCALE) { - SNDERR("mixer: unknown TLV type %d", - mc->hdr.tlv.type); + snd_error(TOPOLOGY, "mixer: unknown TLV type %d", + mc->hdr.tlv.type); + return -EINVAL; } db = tplg_calloc(heap, sizeof(*db)); @@ -1273,7 +1277,7 @@ int tplg_decode_control_mixer1(snd_tplg_t *tplg, tplg_log(tplg, 'D', pos, "mixer: dB scale TLV: min %d step %d mute %d", db->min, db->step, db->mute); } else { - SNDERR("mixer: wrong TLV size %d", mc->hdr.tlv.size); + snd_error(TOPOLOGY, "mixer: wrong TLV size %d", mc->hdr.tlv.size); return -EINVAL; } @@ -1301,15 +1305,16 @@ int tplg_decode_control_mixer(snd_tplg_t *tplg, next: if (size < sizeof(*mc)) { - SNDERR("mixer: small size %d", size); + snd_error(TOPOLOGY, "mixer: small size %d", size); return -EINVAL; } INIT_LIST_HEAD(&heap); mc = bin; size2 = mc->size + mc->priv.size; if (size2 > size) { - SNDERR("mixer: wrong element size (%d, priv %d)", - mc->size, mc->priv.size); + snd_error(TOPOLOGY, "mixer: wrong element size (%d, priv %d)", + mc->size, mc->priv.size); + return -EINVAL; } @@ -1342,11 +1347,11 @@ int tplg_decode_control_enum1(snd_tplg_t *tplg, if (ec->num_channels > SND_TPLG_MAX_CHAN || ec->num_channels > SND_SOC_TPLG_MAX_CHAN) { - SNDERR("enum: unexpected channel count %d", ec->num_channels); + snd_error(TOPOLOGY, "enum: unexpected channel count %d", ec->num_channels); return -EINVAL; } if (ec->items > SND_SOC_TPLG_NUM_TEXTS) { - SNDERR("enum: unexpected texts count %d", ec->items); + snd_error(TOPOLOGY, "enum: unexpected texts count %d", ec->items); return -EINVAL; } @@ -1404,15 +1409,16 @@ int tplg_decode_control_enum(snd_tplg_t *tplg, next: if (size < sizeof(*ec)) { - SNDERR("enum: small size %d", size); + snd_error(TOPOLOGY, "enum: small size %d", size); return -EINVAL; } INIT_LIST_HEAD(&heap); ec = bin; size2 = ec->size + ec->priv.size; if (size2 > size) { - SNDERR("enum: wrong element size (%d, priv %d)", - ec->size, ec->priv.size); + snd_error(TOPOLOGY, "enum: wrong element size (%d, priv %d)", + ec->size, ec->priv.size); + return -EINVAL; } @@ -1446,14 +1452,14 @@ int tplg_decode_control_bytes1(snd_tplg_t *tplg, struct snd_soc_tplg_bytes_control *bc = bin; if (size < sizeof(*bc)) { - SNDERR("bytes: small size %d", size); + snd_error(TOPOLOGY, "bytes: small size %d", size); return -EINVAL; } tplg_log(tplg, 'D', pos, "control bytes: size %d private size %d", bc->size, bc->priv.size); if (size != bc->size + bc->priv.size) { - SNDERR("bytes: unexpected element size %d", size); + snd_error(TOPOLOGY, "bytes: unexpected element size %d", size); return -EINVAL; } @@ -1495,14 +1501,15 @@ int tplg_decode_control_bytes(snd_tplg_t *tplg, next: if (size < sizeof(*bc)) { - SNDERR("bytes: small size %d", size); + snd_error(TOPOLOGY, "bytes: small size %d", size); return -EINVAL; } bc = bin; size2 = bc->size + bc->priv.size; if (size2 > size) { - SNDERR("bytes: wrong element size (%d, priv %d)", - bc->size, bc->priv.size); + snd_error(TOPOLOGY, "bytes: wrong element size (%d, priv %d)", + bc->size, bc->priv.size); + return -EINVAL; } diff --git a/src/topology/dapm.c b/src/topology/dapm.c index 55bb2fab..a02d724c 100644 --- a/src/topology/dapm.c +++ b/src/topology/dapm.c @@ -154,8 +154,9 @@ static int tplg_build_widget(snd_tplg_t *tplg, struct tplg_elem *elem) } if (!ref->elem) { - SNDERR("cannot find '%s' referenced by widget '%s'", - ref->id, elem->id); + snd_error(TOPOLOGY, "cannot find '%s' referenced by widget '%s'", + ref->id, elem->id); + return -EINVAL; } @@ -178,7 +179,7 @@ int tplg_build_widgets(snd_tplg_t *tplg) elem = list_entry(pos, struct tplg_elem, list); if (!elem->widget || elem->type != SND_TPLG_TYPE_DAPM_WIDGET) { - SNDERR("invalid widget '%s'", elem->id); + snd_error(TOPOLOGY, "invalid widget '%s'", elem->id); return -EINVAL; } @@ -205,7 +206,7 @@ int tplg_build_routes(snd_tplg_t *tplg) elem = list_entry(pos, struct tplg_elem, list); if (!elem->route || elem->type != SND_TPLG_TYPE_DAPM_GRAPH) { - SNDERR("invalid route '%s'", elem->id); + snd_error(TOPOLOGY, "invalid route '%s'", elem->id); return -EINVAL; } @@ -215,13 +216,13 @@ int tplg_build_routes(snd_tplg_t *tplg) /* validate sink */ if (strlen(route->sink) <= 0) { - SNDERR("no sink"); + snd_error(TOPOLOGY, "no sink"); return -EINVAL; } if (!tplg_elem_lookup(&tplg->widget_list, route->sink, SND_TPLG_TYPE_DAPM_WIDGET, SND_TPLG_INDEX_ALL)) { - SNDERR("undefined sink widget/stream '%s'", route->sink); + snd_error(TOPOLOGY, "undefined sink widget/stream '%s'", route->sink); } /* validate control name */ @@ -230,21 +231,23 @@ int tplg_build_routes(snd_tplg_t *tplg) SND_TPLG_TYPE_MIXER, elem->index) && !tplg_elem_lookup(&tplg->enum_list, route->control, SND_TPLG_TYPE_ENUM, elem->index)) { - SNDERR("undefined mixer/enum control '%s'", - route->control); + snd_error(TOPOLOGY, "undefined mixer/enum control '%s'", + route->control); + } } /* validate source */ if (strlen(route->source) <= 0) { - SNDERR("no source"); + snd_error(TOPOLOGY, "no source"); return -EINVAL; } if (!tplg_elem_lookup(&tplg->widget_list, route->source, SND_TPLG_TYPE_DAPM_WIDGET, SND_TPLG_INDEX_ALL)) { - SNDERR("undefined source widget/stream '%s'", - route->source); + snd_error(TOPOLOGY, "undefined source widget/stream '%s'", + route->source); + } /* add graph to manifest */ @@ -296,7 +299,7 @@ static int tplg_parse_line(const char *text, len = strlen(buf); if (len <= 2) { - SNDERR("invalid route \"%s\"", buf); + snd_error(TOPOLOGY, "invalid route \"%s\"", buf); return -EINVAL; } @@ -305,7 +308,7 @@ static int tplg_parse_line(const char *text, if (buf[i] == ',') goto second; } - SNDERR("invalid route \"%s\"", buf); + snd_error(TOPOLOGY, "invalid route \"%s\"", buf); return -EINVAL; second: @@ -319,7 +322,7 @@ second: goto done; } - SNDERR("invalid route \"%s\"", buf); + snd_error(TOPOLOGY, "invalid route \"%s\"", buf); return -EINVAL; done: @@ -374,7 +377,7 @@ int tplg_parse_dapm_graph(snd_tplg_t *tplg, snd_config_t *cfg, int index = -1; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("compound is expected for dapm graph definition"); + snd_error(TOPOLOGY, "compound is expected for dapm graph definition"); return -EINVAL; } @@ -397,14 +400,16 @@ int tplg_parse_dapm_graph(snd_tplg_t *tplg, snd_config_t *cfg, if (strcmp(id, "lines") == 0) { if (index < 0) { - SNDERR("failed to parse dapm graph %s, missing index", - graph_id); + snd_error(TOPOLOGY, "failed to parse dapm graph %s, missing index", + graph_id); + return -EINVAL; } err = tplg_parse_routes(tplg, n, index); if (err < 0) { - SNDERR("failed to parse dapm graph %s", - graph_id); + snd_error(TOPOLOGY, "failed to parse dapm graph %s", + graph_id); + return err; } continue; @@ -545,8 +550,9 @@ int tplg_parse_dapm_widget(snd_tplg_t *tplg, widget_type = lookup_widget(val); if (widget_type < 0){ - SNDERR("widget '%s': Unsupported widget type %s", - elem->id, val); + snd_error(TOPOLOGY, "widget '%s': Unsupported widget type %s", + elem->id, val); + return -EINVAL; } @@ -847,8 +853,9 @@ int tplg_add_widget_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t) break; default: - SNDERR("widget %s: invalid type %d for ctl %d", - wt->name, ct->type, i); + snd_error(TOPOLOGY, "widget %s: invalid type %d for ctl %d", + wt->name, ct->type, i); + ret = -EINVAL; break; } @@ -898,17 +905,19 @@ next: w = bin; if (size < sizeof(*w)) { - SNDERR("dapm widget: small size %d", size); + snd_error(TOPOLOGY, "dapm widget: small size %d", size); return -EINVAL; } if (sizeof(*w) != w->size) { - SNDERR("dapm widget: unknown element size %d (expected %zd)", - w->size, sizeof(*w)); + snd_error(TOPOLOGY, "dapm widget: unknown element size %d (expected %zd)", + w->size, sizeof(*w)); + return -EINVAL; } if (w->num_kcontrols > 16) { - SNDERR("dapm widget: too many kcontrols %d", - w->num_kcontrols); + snd_error(TOPOLOGY, "dapm widget: too many kcontrols %d", + w->num_kcontrols); + return -EINVAL; } @@ -934,8 +943,9 @@ next: wt->name, wt->sname); if (sizeof(*w) + w->priv.size > size) { - SNDERR("dapm widget: wrong private data size %d", - w->priv.size); + snd_error(TOPOLOGY, "dapm widget: wrong private data size %d", + w->priv.size); + return -EINVAL; } @@ -962,8 +972,9 @@ next: size2 = mc->size + mc->priv.size; tplg_log(tplg, 'D', pos, "kcontrol mixer size %zd", size2); if (size2 > size) { - SNDERR("dapm widget: small mixer size %d", - size2); + snd_error(TOPOLOGY, "dapm widget: small mixer size %d", + size2); + err = -EINVAL; goto retval; } @@ -982,8 +993,9 @@ next: size2 = ec->size + ec->priv.size; tplg_log(tplg, 'D', pos, "kcontrol enum size %zd", size2); if (size2 > size) { - SNDERR("dapm widget: small enum size %d", - size2); + snd_error(TOPOLOGY, "dapm widget: small enum size %d", + size2); + err = -EINVAL; goto retval; } @@ -1001,8 +1013,9 @@ next: size2 = bc->size + bc->priv.size; tplg_log(tplg, 'D', pos, "kcontrol bytes size %zd", size2); if (size2 > size) { - SNDERR("dapm widget: small bytes size %d", - size2); + snd_error(TOPOLOGY, "dapm widget: small bytes size %d", + size2); + err = -EINVAL; goto retval; } @@ -1010,8 +1023,9 @@ next: bin, size2); break; default: - SNDERR("dapm widget: wrong control type %d", - chdr->type); + snd_error(TOPOLOGY, "dapm widget: wrong control type %d", + chdr->type); + err = -EINVAL; goto retval; } @@ -1059,7 +1073,7 @@ int tplg_decode_dapm_graph(snd_tplg_t *tplg, for (ge = gt->elem; size > 0; ge++) { g = bin; if (size < sizeof(*g)) { - SNDERR("dapm graph: small size %d", size); + snd_error(TOPOLOGY, "dapm graph: small size %d", size); return -EINVAL; } ge->src = g->source; diff --git a/src/topology/data.c b/src/topology/data.c index e1611aea..93fa6f0d 100644 --- a/src/topology/data.c +++ b/src/topology/data.c @@ -60,8 +60,9 @@ struct snd_soc_tplg_private *get_priv_data(struct tplg_elem *elem) priv = &elem->pcm->priv; break; default: - SNDERR("'%s': no support for private data for type %d", - elem->id, elem->type); + snd_error(TOPOLOGY, "'%s': no support for private data for type %d", + elem->id, elem->type); + } return priv; @@ -94,7 +95,7 @@ int tplg_parse_refs(snd_config_t *cfg, struct tplg_elem *elem, } if (cfg_type != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("compound type expected for %s", elem->id); + snd_error(TOPOLOGY, "compound type expected for %s", elem->id); return -EINVAL; } @@ -183,7 +184,7 @@ static int tplg_parse_data_file(snd_config_t *cfg, struct tplg_elem *elem) fp = fopen(filename, "r"); if (fp == NULL) { - SNDERR("invalid data file path '%s'", filename); + snd_error(TOPOLOGY, "invalid data file path '%s'", filename); return -errno; } @@ -191,12 +192,12 @@ static int tplg_parse_data_file(snd_config_t *cfg, struct tplg_elem *elem) size = ftell(fp); fseek(fp, 0L, SEEK_SET); if (size <= 0) { - SNDERR("invalid data file size %zu", size); + snd_error(TOPOLOGY, "invalid data file size %zu", size); ret = -EINVAL; goto err; } if (size > TPLG_MAX_PRIV_SIZE) { - SNDERR("data file too big %zu", size); + snd_error(TOPOLOGY, "data file too big %zu", size); ret = -EINVAL; goto err; } @@ -218,7 +219,7 @@ static int tplg_parse_data_file(snd_config_t *cfg, struct tplg_elem *elem) elem->size = sizeof(*priv) + size; if (fclose(fp) == EOF) { - SNDERR("Cannot close data file."); + snd_error(TOPOLOGY, "Cannot close data file."); return -errno; } return 0; @@ -359,7 +360,7 @@ static int get_uuid(const char *str, unsigned char *uuid_le) if ((errno == ERANGE && val == ULONG_MAX) || (errno != 0 && val == 0) || (val > UCHAR_MAX)) { - SNDERR("invalid value for uuid"); + snd_error(TOPOLOGY, "invalid value for uuid"); ret = -EINVAL; goto out; } @@ -383,7 +384,7 @@ data2: if ((errno == ERANGE && val == ULONG_MAX) || (errno != 0 && val == 0) || (val > UCHAR_MAX)) { - SNDERR("invalid value for uuid"); + snd_error(TOPOLOGY, "invalid value for uuid"); ret = -EINVAL; goto out; } @@ -398,7 +399,7 @@ data2: } if (values < 16) { - SNDERR("less than 16 integers for uuid"); + snd_error(TOPOLOGY, "less than 16 integers for uuid"); ret = -EINVAL; } @@ -475,7 +476,7 @@ static int tplg_parse_data_hex(snd_config_t *cfg, struct tplg_elem *elem, num = get_hex_num(value); if (num <= 0) { - SNDERR("malformed hex variable list %s", value); + snd_error(TOPOLOGY, "malformed hex variable list %s", value); return -EINVAL; } @@ -483,7 +484,7 @@ static int tplg_parse_data_hex(snd_config_t *cfg, struct tplg_elem *elem, priv = elem->data; if (size > TPLG_MAX_PRIV_SIZE) { - SNDERR("data too big %d", size); + snd_error(TOPOLOGY, "data too big %d", size); return -EINVAL; } @@ -521,7 +522,7 @@ static int get_token_value(const char *token_id, return tokens->token[i].value; } - SNDERR("cannot find token id '%s'", token_id); + snd_error(TOPOLOGY, "cannot find token id '%s'", token_id); return -1; } @@ -609,7 +610,7 @@ static int copy_tuples(struct tplg_elem *elem, * tuple_set->num_tuples; size += set_size; if (size > TPLG_MAX_PRIV_SIZE) { - SNDERR("data too big %d", size); + snd_error(TOPOLOGY, "data too big %d", size); return -EINVAL; } @@ -693,13 +694,13 @@ static int build_tuples(snd_tplg_t *tplg, struct tplg_elem *elem) ref->id, SND_TPLG_TYPE_TUPLE, elem->index); tuples = ref->elem; if (!tuples) { - SNDERR("cannot find tuples %s", ref->id); + snd_error(TOPOLOGY, "cannot find tuples %s", ref->id); return -EINVAL; } tokens = get_tokens(tplg, tuples); if (!tokens) { - SNDERR("cannot find token for %s", ref->id); + snd_error(TOPOLOGY, "cannot find token for %s", ref->id); return -EINVAL; } @@ -795,7 +796,7 @@ static int parse_tuple_set(snd_config_t *cfg, type = get_tuple_type(id); if (type < 0) { - SNDERR("invalid tuple type '%s'", id); + snd_error(TOPOLOGY, "invalid tuple type '%s'", id); return type; } @@ -852,7 +853,7 @@ static int parse_tuple_set(snd_config_t *cfg, case SND_SOC_TPLG_TUPLE_TYPE_WORD: ival = tplg_get_unsigned(n, &tuple_val, 0); if (ival < 0) { - SNDERR("tuple %s: %s", id, snd_strerror(ival)); + snd_error(TOPOLOGY, "tuple %s: %s", id, snd_strerror(ival)); goto err; } @@ -862,7 +863,7 @@ static int parse_tuple_set(snd_config_t *cfg, && tuple_val > USHRT_MAX) || (type == SND_SOC_TPLG_TUPLE_TYPE_BYTE && tuple_val > UCHAR_MAX)) { - SNDERR("tuple %s: invalid value", id); + snd_error(TOPOLOGY, "tuple %s: invalid value", id); goto err; } @@ -976,7 +977,7 @@ static int parse_tuple_sets(snd_config_t *cfg, if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { if (snd_config_get_id(cfg, &id) >= 0) - SNDERR("compound type expected for %s", id); + snd_error(TOPOLOGY, "compound type expected for %s", id); return -EINVAL; } @@ -994,8 +995,9 @@ static int parse_tuple_sets(snd_config_t *cfg, snd_config_for_each(i, next, cfg) { n = snd_config_iterator_entry(i); if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("compound type expected for %s, is %d", - id, snd_config_get_type(n)); + snd_error(TOPOLOGY, "compound type expected for %s, is %d", + id, snd_config_get_type(n)); + return -EINVAL; } @@ -1204,7 +1206,7 @@ int tplg_parse_manifest_data(snd_tplg_t *tplg, snd_config_t *cfg, int err; if (!list_empty(&tplg->manifest_list)) { - SNDERR("already has manifest data"); + snd_error(TOPOLOGY, "already has manifest data"); return -EINVAL; } @@ -1364,7 +1366,7 @@ int tplg_parse_data(snd_tplg_t *tplg, snd_config_t *cfg, if (strcmp(id, "file") == 0) { err = tplg_parse_data_file(n, elem); if (err < 0) { - SNDERR("failed to parse data file"); + snd_error(TOPOLOGY, "failed to parse data file"); return err; } continue; @@ -1373,7 +1375,7 @@ int tplg_parse_data(snd_tplg_t *tplg, snd_config_t *cfg, if (strcmp(id, "bytes") == 0) { err = tplg_parse_data_hex(n, elem, 1); if (err < 0) { - SNDERR("failed to parse data bytes"); + snd_error(TOPOLOGY, "failed to parse data bytes"); return err; } continue; @@ -1382,7 +1384,7 @@ int tplg_parse_data(snd_tplg_t *tplg, snd_config_t *cfg, if (strcmp(id, "shorts") == 0) { err = tplg_parse_data_hex(n, elem, 2); if (err < 0) { - SNDERR("failed to parse data shorts"); + snd_error(TOPOLOGY, "failed to parse data shorts"); return err; } continue; @@ -1391,7 +1393,7 @@ int tplg_parse_data(snd_tplg_t *tplg, snd_config_t *cfg, if (strcmp(id, "words") == 0) { err = tplg_parse_data_hex(n, elem, 4); if (err < 0) { - SNDERR("failed to parse data words"); + snd_error(TOPOLOGY, "failed to parse data words"); return err; } continue; @@ -1508,8 +1510,9 @@ int tplg_copy_data(snd_tplg_t *tplg, struct tplg_elem *elem, ref_elem = tplg_elem_lookup(&tplg->pdata_list, ref->id, SND_TPLG_TYPE_DATA, elem->index); if (!ref_elem) { - SNDERR("cannot find data '%s' referenced by" - " element '%s'", ref->id, elem->id); + snd_error(TOPOLOGY, "cannot find data '%s' referenced by" + " element '%s'", ref->id, elem->id); + return -EINVAL; } @@ -1579,24 +1582,25 @@ int tplg_decode_manifest_data(snd_tplg_t *tplg, size_t off; if (hdr->index != 0) { - SNDERR("manifest - wrong index %d", hdr->index); + snd_error(TOPOLOGY, "manifest - wrong index %d", hdr->index); return -EINVAL; } if (sizeof(*m) > size) { - SNDERR("manifest - wrong size %zd (minimal %zd)", - size, sizeof(*m)); + snd_error(TOPOLOGY, "manifest - wrong size %zd (minimal %zd)", + size, sizeof(*m)); + return -EINVAL; } if (m->size != sizeof(*m)) { - SNDERR("manifest - wrong sructure size %d", m->size); + snd_error(TOPOLOGY, "manifest - wrong sructure size %d", m->size); return -EINVAL; } off = offsetof(struct snd_soc_tplg_manifest, priv); if (off + m->priv.size > size) { - SNDERR("manifest - wrong private size %d", m->priv.size); + snd_error(TOPOLOGY, "manifest - wrong private size %d", m->priv.size); return -EINVAL; } @@ -1718,7 +1722,7 @@ static int tplg_decode_tuple_set(snd_tplg_t *tplg, va = bin; if (size < sizeof(*va) || size < va->size) { - SNDERR("tuples: wrong size %zd", size); + snd_error(TOPOLOGY, "tuples: wrong size %zd", size); return -EINVAL; } @@ -1731,20 +1735,21 @@ static int tplg_decode_tuple_set(snd_tplg_t *tplg, case SND_SOC_TPLG_TUPLE_TYPE_SHORT: break; default: - SNDERR("tuples: unknown array type %d", va->type); + snd_error(TOPOLOGY, "tuples: unknown array type %d", va->type); return -EINVAL; } j = tplg_get_tuple_size(va->type) * va->num_elems; if (j + sizeof(*va) != va->size) { - SNDERR("tuples: wrong vendor array size %d " - "(expected %d for %d count %d)", + snd_error(TOPOLOGY, "tuples: wrong vendor array size %d " + "(expected %d for %d count %d)", + va->size, j + sizeof(*va), va->type, va->num_elems); return -EINVAL; } if (va->num_elems > 4096) { - SNDERR("tuples: tuples overflow %d", va->num_elems); + snd_error(TOPOLOGY, "tuples: tuples overflow %d", va->num_elems); return -EINVAL; } @@ -1841,19 +1846,19 @@ static int tplg_decode_tuples(snd_tplg_t *tplg, int err; if (size < sizeof(*va)) { - SNDERR("tuples: small size %zd", size); + snd_error(TOPOLOGY, "tuples: small size %zd", size); return -EINVAL; } next: va = bin; if (size < sizeof(*va)) { - SNDERR("tuples: unexpected vendor arry size %zd", size); + snd_error(TOPOLOGY, "tuples: unexpected vendor arry size %zd", size); return -EINVAL; } if (tuples->num_sets >= tuples->alloc_sets) { - SNDERR("tuples: index overflow (%d)", tuples->num_sets); + snd_error(TOPOLOGY, "tuples: index overflow (%d)", tuples->num_sets); return -EINVAL; } @@ -1893,7 +1898,7 @@ int tplg_add_data(snd_tplg_t *tplg, next: tp = bin; if (off + size < tp->size) { - SNDERR("data: unexpected element size %zd", size); + snd_error(TOPOLOGY, "data: unexpected element size %zd", size); return -EINVAL; } @@ -1997,6 +2002,6 @@ int tplg_decode_data(snd_tplg_t *tplg ATTRIBUTE_UNUSED, void *bin ATTRIBUTE_UNUSED, size_t size ATTRIBUTE_UNUSED) { - SNDERR("data type not expected"); + snd_error(TOPOLOGY, "data type not expected"); return -EINVAL; } diff --git a/src/topology/decoder.c b/src/topology/decoder.c index c8df7e35..bf46d406 100644 --- a/src/topology/decoder.c +++ b/src/topology/decoder.c @@ -61,40 +61,40 @@ int snd_tplg_decode(snd_tplg_t *tplg, void *bin, size_t size, int dflags) } if (size - pos < sizeof(*hdr)) { tplg_log(tplg, 'D', pos, "block: small size"); - SNDERR("incomplete header data to decode"); + snd_error(TOPOLOGY, "incomplete header data to decode"); return -EINVAL; } hdr = b; if (hdr->magic != SND_SOC_TPLG_MAGIC) { - SNDERR("bad block magic %08x", hdr->magic); + snd_error(TOPOLOGY, "bad block magic %08x", hdr->magic); return -EINVAL; } tplg_log(tplg, 'D', pos, "block: abi %d size %d payload size %d", hdr->abi, hdr->size, hdr->payload_size); if (hdr->abi != SND_SOC_TPLG_ABI_VERSION) { - SNDERR("unsupported ABI version %d", hdr->abi); + snd_error(TOPOLOGY, "unsupported ABI version %d", hdr->abi); return -EINVAL; } if (hdr->size != sizeof(*hdr)) { - SNDERR("header size mismatch"); + snd_error(TOPOLOGY, "header size mismatch"); return -EINVAL; } if (size - pos < hdr->size + hdr->payload_size) { - SNDERR("incomplete payload data to decode"); + snd_error(TOPOLOGY, "incomplete payload data to decode"); return -EINVAL; } if (hdr->payload_size < 8) { - SNDERR("wrong payload size %d", hdr->payload_size); + snd_error(TOPOLOGY, "wrong payload size %d", hdr->payload_size); return -EINVAL; } /* first block must be manifest */ if (b == bin) { if (hdr->type != SND_SOC_TPLG_TYPE_MANIFEST) { - SNDERR("first block must be manifest (value %d)", hdr->type); + snd_error(TOPOLOGY, "first block must be manifest (value %d)", hdr->type); return -EINVAL; } err = snd_tplg_set_version(tplg, hdr->version); @@ -109,7 +109,7 @@ int snd_tplg_decode(snd_tplg_t *tplg, void *bin, size_t size, int dflags) break; } if (index >= tplg_table_items || tptr->decod == NULL) { - SNDERR("unknown block type %d", hdr->type); + snd_error(TOPOLOGY, "unknown block type %d", hdr->type); return -EINVAL; } tplg_log(tplg, 'D', pos, "block: type %d - %s", hdr->type, tptr->name); diff --git a/src/topology/elem.c b/src/topology/elem.c index 2e31da5d..0ce11b04 100644 --- a/src/topology/elem.c +++ b/src/topology/elem.c @@ -237,7 +237,7 @@ int tplg_get_type(int asoc_type) for (index = 0; index < tplg_table_items; index++) if (tplg_table[index].tsoc == asoc_type) return tplg_table[index].type; - SNDERR("uknown asoc type %d", asoc_type); + snd_error(TOPOLOGY, "uknown asoc type %d", asoc_type); return -EINVAL; } diff --git a/src/topology/ops.c b/src/topology/ops.c index 74f7cbab..232073a3 100644 --- a/src/topology/ops.c +++ b/src/topology/ops.c @@ -44,7 +44,7 @@ static int lookup_ops(const char *c) /* cant find string name in our table so we use its ID number */ i = safe_strtol(c, &ret); if (i < 0) { - SNDERR("wrong kcontrol ops value string '%s'", c); + snd_error(TOPOLOGY, "wrong kcontrol ops value string '%s'", c); return i; } diff --git a/src/topology/parser.c b/src/topology/parser.c index 874ec524..5ecf98f5 100644 --- a/src/topology/parser.c +++ b/src/topology/parser.c @@ -120,7 +120,7 @@ int tplg_parse_compound(snd_tplg_t *tplg, snd_config_t *cfg, return -EINVAL; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("compound type expected for %s", id); + snd_error(TOPOLOGY, "compound type expected for %s", id); return -EINVAL; } @@ -129,8 +129,9 @@ int tplg_parse_compound(snd_tplg_t *tplg, snd_config_t *cfg, n = snd_config_iterator_entry(i); if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("compound type expected for %s, is %d", - id, snd_config_get_type(cfg)); + snd_error(TOPOLOGY, "compound type expected for %s, is %d", + id, snd_config_get_type(cfg)); + return -EINVAL; } @@ -153,7 +154,7 @@ static int tplg_parse_config(snd_tplg_t *tplg, snd_config_t *cfg) int err; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - SNDERR("compound type expected at top level"); + snd_error(TOPOLOGY, "compound type expected at top level"); return -EINVAL; } @@ -178,7 +179,7 @@ static int tplg_parse_config(snd_tplg_t *tplg, snd_config_t *cfg) } if (parser == NULL) { - SNDERR("unknown section %s", id); + snd_error(TOPOLOGY, "unknown section %s", id); continue; } @@ -200,7 +201,7 @@ static int tplg_load_config(snd_tplg_t *tplg, snd_input_t *in) ret = snd_config_load(top, in); if (ret < 0) { - SNDERR("could not load configuration"); + snd_error(TOPOLOGY, "could not load configuration"); snd_config_delete(top); return ret; } @@ -208,7 +209,7 @@ static int tplg_load_config(snd_tplg_t *tplg, snd_input_t *in) ret = tplg_parse_config(tplg, top); snd_config_delete(top); if (ret < 0) { - SNDERR("failed to parse topology"); + snd_error(TOPOLOGY, "failed to parse topology"); return ret; } @@ -265,7 +266,7 @@ int snd_tplg_load(snd_tplg_t *tplg, const char *buf, size_t size) err = snd_input_buffer_open(&in, buf, size); if (err < 0) { - SNDERR("could not create input buffer"); + snd_error(TOPOLOGY, "could not create input buffer"); return err; } @@ -280,13 +281,13 @@ static int tplg_build(snd_tplg_t *tplg) err = tplg_build_integ(tplg); if (err < 0) { - SNDERR("failed to check topology integrity"); + snd_error(TOPOLOGY, "failed to check topology integrity"); return err; } err = tplg_write_data(tplg); if (err < 0) { - SNDERR("failed to write data %d", err); + snd_error(TOPOLOGY, "failed to write data %d", err); return err; } return 0; @@ -302,14 +303,14 @@ int snd_tplg_build_file(snd_tplg_t *tplg, fp = fopen(infile, "r"); if (fp == NULL) { - SNDERR("could not open configuration file %s", infile); + snd_error(TOPOLOGY, "could not open configuration file %s", infile); return -errno; } err = snd_input_stdio_attach(&in, fp, 1); if (err < 0) { fclose(fp); - SNDERR("could not attach stdio %s", infile); + snd_error(TOPOLOGY, "could not attach stdio %s", infile); return err; } @@ -343,7 +344,7 @@ int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t) case SND_TPLG_TYPE_CC: return tplg_add_link_object(tplg, t); default: - SNDERR("invalid object type %d", t->type); + snd_error(TOPOLOGY, "invalid object type %d", t->type); return -EINVAL; }; } @@ -359,18 +360,18 @@ int snd_tplg_build(snd_tplg_t *tplg, const char *outfile) fd = open(outfile, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); if (fd < 0) { - SNDERR("failed to open %s err %d", outfile, -errno); + snd_error(TOPOLOGY, "failed to open %s err %d", outfile, -errno); return -errno; } r = write(fd, tplg->bin, tplg->bin_size); close(fd); if (r < 0) { err = -errno; - SNDERR("write error: %s", strerror(errno)); + snd_error(TOPOLOGY, "write error: %s", strerror(errno)); return err; } if ((size_t)r != tplg->bin_size) { - SNDERR("partial write (%zd != %zd)", r, tplg->bin_size); + snd_error(TOPOLOGY, "partial write (%zd != %zd)", r, tplg->bin_size); return -EIO; } return 0; @@ -436,7 +437,7 @@ snd_tplg_t *snd_tplg_create(int flags) snd_tplg_t *tplg; if (!is_little_endian()) { - SNDERR("cannot support big-endian machines"); + snd_error(TOPOLOGY, "cannot support big-endian machines"); return NULL; } diff --git a/src/topology/pcm.c b/src/topology/pcm.c index acec27f9..cef5127c 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -115,8 +115,9 @@ static int build_pcm(snd_tplg_t *tplg, struct tplg_elem *elem) return err; } if (!ref->elem) { - SNDERR("cannot find '%s' referenced by" - " PCM '%s'", ref->id, elem->id); + snd_error(TOPOLOGY, "cannot find '%s' referenced by" + " PCM '%s'", ref->id, elem->id); + return -EINVAL; } } @@ -136,7 +137,7 @@ int tplg_build_pcms(snd_tplg_t *tplg, unsigned int type) elem = list_entry(pos, struct tplg_elem, list); if (elem->type != type) { - SNDERR("invalid elem '%s'", elem->id); + snd_error(TOPOLOGY, "invalid elem '%s'", elem->id); return -EINVAL; } @@ -195,7 +196,7 @@ int tplg_build_dais(snd_tplg_t *tplg, unsigned int type) elem = list_entry(pos, struct tplg_elem, list); if (elem->type != type) { - SNDERR("invalid elem '%s'", elem->id); + snd_error(TOPOLOGY, "invalid elem '%s'", elem->id); return -EINVAL; } @@ -250,9 +251,10 @@ static int build_link(snd_tplg_t *tplg, struct tplg_elem *elem) ref->elem = tplg_elem_lookup(&tplg->hw_cfg_list, ref->id, SND_TPLG_TYPE_HW_CONFIG, elem->index); if (!ref->elem) { - SNDERR("cannot find HW config '%s'" - " referenced by link '%s'", - ref->id, elem->id); + snd_error(TOPOLOGY, "cannot find HW config '%s'" + " referenced by link '%s'", + ref->id, elem->id); + return -EINVAL; } @@ -320,7 +322,7 @@ static int split_format(struct snd_soc_tplg_stream_caps *caps, char *str) while ((s != NULL) && (i < SND_SOC_TPLG_MAX_FORMATS)) { format = snd_pcm_format_value(s); if (format == SND_PCM_FORMAT_UNKNOWN) { - SNDERR("unsupported stream format %s", s); + snd_error(TOPOLOGY, "unsupported stream format %s", s); return -EINVAL; } @@ -363,7 +365,7 @@ static int split_rate(struct snd_soc_tplg_stream_caps *caps, char *str) rate = get_rate_value(s); if (rate == SND_PCM_RATE_UNKNOWN) { - SNDERR("unsupported stream rate %s", s); + snd_error(TOPOLOGY, "unsupported stream rate %s", s); return -EINVAL; } @@ -762,7 +764,7 @@ static int tplg_parse_fe_dai(snd_tplg_t *tplg ATTRIBUTE_UNUSED, if (strcmp(id, "id") == 0) { if (tplg_get_unsigned(n, &dai_id, 0)) { - SNDERR("invalid fe dai ID"); + snd_error(TOPOLOGY, "invalid fe dai ID"); return -EINVAL; } @@ -1413,7 +1415,7 @@ static int get_audio_hw_format(const char *val) if (strcasecmp(audio_hw_formats[i].name, val) == 0) return audio_hw_formats[i].type; - SNDERR("invalid audio HW format %s", val); + snd_error(TOPOLOGY, "invalid audio HW format %s", val); return -EINVAL; } @@ -1480,7 +1482,7 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, provider_legacy = false; if (strcmp(id, "bclk_master") == 0) { - SNDERR("deprecated option %s, please use 'bclk'", id); + snd_error(TOPOLOGY, "deprecated option %s, please use 'bclk'", id); provider_legacy = true; } @@ -1494,17 +1496,17 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, /* For backwards capability, * "master" == "codec is slave" */ - SNDERR("deprecated bclk value '%s'", val); + snd_error(TOPOLOGY, "deprecated bclk value '%s'", val); hw_cfg->bclk_provider = SND_SOC_TPLG_BCLK_CC; } else if (!strcmp(val, "codec_slave")) { - SNDERR("deprecated bclk value '%s', use 'codec_consumer'", val); + snd_error(TOPOLOGY, "deprecated bclk value '%s', use 'codec_consumer'", val); hw_cfg->bclk_provider = SND_SOC_TPLG_BCLK_CC; } else if (!strcmp(val, "codec_consumer")) { hw_cfg->bclk_provider = SND_SOC_TPLG_BCLK_CC; } else if (!strcmp(val, "codec_master")) { - SNDERR("deprecated bclk value '%s', use 'codec_provider", val); + snd_error(TOPOLOGY, "deprecated bclk value '%s', use 'codec_provider", val); hw_cfg->bclk_provider = SND_SOC_TPLG_BCLK_CP; } else if (!strcmp(val, "codec_provider")) { @@ -1532,7 +1534,7 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, provider_legacy = false; if (strcmp(id, "fsync_master") == 0) { - SNDERR("deprecated option %s, please use 'fsync'", id); + snd_error(TOPOLOGY, "deprecated option %s, please use 'fsync'", id); provider_legacy = true; } @@ -1546,17 +1548,17 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, /* For backwards capability, * "master" == "codec is slave" */ - SNDERR("deprecated fsync value '%s'", val); + snd_error(TOPOLOGY, "deprecated fsync value '%s'", val); hw_cfg->fsync_provider = SND_SOC_TPLG_FSYNC_CC; } else if (!strcmp(val, "codec_slave")) { - SNDERR("deprecated fsync value '%s', use 'codec_consumer'", val); + snd_error(TOPOLOGY, "deprecated fsync value '%s', use 'codec_consumer'", val); hw_cfg->fsync_provider = SND_SOC_TPLG_FSYNC_CC; } else if (!strcmp(val, "codec_consumer")) { hw_cfg->fsync_provider = SND_SOC_TPLG_FSYNC_CC; } else if (!strcmp(val, "codec_master")) { - SNDERR("deprecated fsync value '%s', use 'codec_provider'", val); + snd_error(TOPOLOGY, "deprecated fsync value '%s', use 'codec_provider'", val); hw_cfg->fsync_provider = SND_SOC_TPLG_FSYNC_CP; } else if (!strcmp(val, "codec_provider")) { @@ -1598,7 +1600,7 @@ int tplg_parse_hw_config(snd_tplg_t *tplg, snd_config_t *cfg, /* For backwards capability, * "master" == "for codec, mclk is input" */ - SNDERR("deprecated mclk value '%s'", val); + snd_error(TOPOLOGY, "deprecated mclk value '%s'", val); hw_cfg->mclk_direction = SND_SOC_TPLG_MCLK_CI; } else if (!strcmp(val, "codec_mclk_in")) { @@ -2016,20 +2018,21 @@ next: pcm = bin; if (size < sizeof(*pcm)) { - SNDERR("pcm: small size %d", size); + snd_error(TOPOLOGY, "pcm: small size %d", size); return -EINVAL; } if (sizeof(*pcm) != pcm->size) { - SNDERR("pcm: unknown element size %d (expected %zd)", - pcm->size, sizeof(*pcm)); + snd_error(TOPOLOGY, "pcm: unknown element size %d (expected %zd)", + pcm->size, sizeof(*pcm)); + return -EINVAL; } if (pcm->num_streams > SND_SOC_TPLG_STREAM_CONFIG_MAX) { - SNDERR("pcm: wrong number of streams %d", pcm->num_streams); + snd_error(TOPOLOGY, "pcm: wrong number of streams %d", pcm->num_streams); return -EINVAL; } if (sizeof(*pcm) + pcm->priv.size > size) { - SNDERR("pcm: wrong private data size %d", pcm->priv.size); + snd_error(TOPOLOGY, "pcm: wrong private data size %d", pcm->priv.size); return -EINVAL; } @@ -2054,8 +2057,9 @@ next: for (i = 0; i < pcm->num_streams; i++) { stream = &pt->stream[i]; if (pcm->stream[i].size != sizeof(pcm->stream[0])) { - SNDERR("pcm: unknown stream structure size %d", - pcm->stream[i].size); + snd_error(TOPOLOGY, "pcm: unknown stream structure size %d", + pcm->stream[i].size); + return -EINVAL; } stream->name = pcm->stream[i].name; @@ -2075,8 +2079,9 @@ next: cap = &caps[i]; pt->caps[i] = cap; if (pcm->caps[i].size != sizeof(pcm->caps[0])) { - SNDERR("pcm: unknown caps structure size %d", - pcm->caps[i].size); + snd_error(TOPOLOGY, "pcm: unknown caps structure size %d", + pcm->caps[i].size); + return -EINVAL; } cap->name = pcm->caps[i].name; @@ -2123,7 +2128,7 @@ int tplg_decode_dai(snd_tplg_t *tplg ATTRIBUTE_UNUSED, void *bin ATTRIBUTE_UNUSED, size_t size ATTRIBUTE_UNUSED) { - SNDERR("not implemented"); + snd_error(TOPOLOGY, "not implemented"); return -ENXIO; } @@ -2134,7 +2139,7 @@ int tplg_decode_cc(snd_tplg_t *tplg ATTRIBUTE_UNUSED, void *bin ATTRIBUTE_UNUSED, size_t size ATTRIBUTE_UNUSED) { - SNDERR("not implemented"); + snd_error(TOPOLOGY, "not implemented"); return -ENXIO; } @@ -2165,24 +2170,25 @@ next: link = bin; if (size < sizeof(*link)) { - SNDERR("link: small size %d", size); + snd_error(TOPOLOGY, "link: small size %d", size); return -EINVAL; } if (sizeof(*link) != link->size) { - SNDERR("link: unknown element size %d (expected %zd)", - link->size, sizeof(*link)); + snd_error(TOPOLOGY, "link: unknown element size %d (expected %zd)", + link->size, sizeof(*link)); + return -EINVAL; } if (link->num_streams > SND_SOC_TPLG_STREAM_CONFIG_MAX) { - SNDERR("link: wrong number of streams %d", link->num_streams); + snd_error(TOPOLOGY, "link: wrong number of streams %d", link->num_streams); return -EINVAL; } if (link->num_hw_configs > SND_SOC_TPLG_HW_CONFIG_MAX) { - SNDERR("link: wrong number of streams %d", link->num_streams); + snd_error(TOPOLOGY, "link: wrong number of streams %d", link->num_streams); return -EINVAL; } if (sizeof(*link) + link->priv.size > size) { - SNDERR("link: wrong private data size %d", link->priv.size); + snd_error(TOPOLOGY, "link: wrong private data size %d", link->priv.size); return -EINVAL; } @@ -2204,8 +2210,9 @@ next: for (i = 0; i < link->num_streams; i++) { stream = &streams[i]; if (link->stream[i].size != sizeof(link->stream[0])) { - SNDERR("link: unknown stream structure size %d", - link->stream[i].size); + snd_error(TOPOLOGY, "link: unknown stream structure size %d", + link->stream[i].size); + return -EINVAL; } stream->name = link->stream[i].name; @@ -2222,8 +2229,9 @@ next: for (i = 0; i < link->num_hw_configs; i++) { hw = &hws[i]; if (link->hw_config[i].size != sizeof(link->hw_config[0])) { - SNDERR("link: unknown hw_config structure size %d", - link->hw_config[i].size); + snd_error(TOPOLOGY, "link: unknown hw_config structure size %d", + link->hw_config[i].size); + return -EINVAL; } hw->id = link->hw_config[i].id; @@ -2243,14 +2251,14 @@ next: hw->rx_slots = link->hw_config[i].rx_slots; hw->tx_channels = link->hw_config[i].tx_channels; if (hw->tx_channels > SND_SOC_TPLG_MAX_CHAN) { - SNDERR("link: wrong tx channels %d", hw->tx_channels); + snd_error(TOPOLOGY, "link: wrong tx channels %d", hw->tx_channels); return -EINVAL; } for (j = 0; j < hw->tx_channels; j++) hw->tx_chanmap[j] = link->hw_config[i].tx_chanmap[j]; hw->rx_channels = link->hw_config[i].rx_channels; if (hw->rx_channels > SND_SOC_TPLG_MAX_CHAN) { - SNDERR("link: wrong rx channels %d", hw->tx_channels); + snd_error(TOPOLOGY, "link: wrong rx channels %d", hw->tx_channels); return -EINVAL; } for (j = 0; j < hw->rx_channels; j++) diff --git a/src/topology/save.c b/src/topology/save.c index 142fa536..8874b062 100644 --- a/src/topology/save.c +++ b/src/topology/save.c @@ -446,8 +446,9 @@ static int tplg_save(snd_tplg_t *tplg, struct tplg_buf *dst, if (gindex >= 0 && elem->index != gindex) continue; if (tptr->save == NULL && tptr->gsave == NULL) { - SNDERR("unable to create %s block (no callback)", - tptr->id); + snd_error(TOPOLOGY, "unable to create %s block (no callback)", + tptr->id); + err = -ENXIO; goto _err; } @@ -482,8 +483,9 @@ static int tplg_save(snd_tplg_t *tplg, struct tplg_buf *dst, } err = tptr->save(tplg, elem, dst, count > 1 ? pfx2 : prefix); if (err < 0) { - SNDERR("failed to save %s elements: %s", - tptr->id, snd_strerror(-err)); + snd_error(TOPOLOGY, "failed to save %s elements: %s", + tptr->id, snd_strerror(-err)); + goto _err; } } @@ -607,7 +609,7 @@ int snd_tplg_save(snd_tplg_t *tplg, char **dst, int flags) /* always load configuration - check */ err = snd_input_buffer_open(&in, buf.dst, strlen(buf.dst)); if (err < 0) { - SNDERR("could not create input buffer"); + snd_error(TOPOLOGY, "could not create input buffer"); goto _err; } @@ -620,7 +622,7 @@ int snd_tplg_save(snd_tplg_t *tplg, char **dst, int flags) err = snd_config_load(top, in); snd_input_close(in); if (err < 0) { - SNDERR("could not load configuration"); + snd_error(TOPOLOGY, "could not load configuration"); snd_config_delete(top); goto _err; } @@ -628,7 +630,7 @@ int snd_tplg_save(snd_tplg_t *tplg, char **dst, int flags) if (flags & SND_TPLG_SAVE_SORT) { top2 = sort_config(NULL, top); if (top2 == NULL) { - SNDERR("could not sort configuration"); + snd_error(TOPOLOGY, "could not sort configuration"); snd_config_delete(top); err = -EINVAL; goto _err; @@ -641,7 +643,7 @@ int snd_tplg_save(snd_tplg_t *tplg, char **dst, int flags) err = save_config(&buf2, 0, NULL, top); snd_config_delete(top); if (err < 0) { - SNDERR("could not save configuration"); + snd_error(TOPOLOGY, "could not save configuration"); goto _err; } diff --git a/src/topology/text.c b/src/topology/text.c index 47abb8d8..c5022c19 100644 --- a/src/topology/text.c +++ b/src/topology/text.c @@ -79,7 +79,7 @@ int tplg_parse_text(snd_tplg_t *tplg, snd_config_t *cfg, if (strcmp(id, "values") == 0) { err = parse_text_values(n, elem); if (err < 0) { - SNDERR("error: failed to parse text values"); + snd_error(TOPOLOGY, "error: failed to parse text values"); return err; } continue; From 524081b4d6905b865e46861099a56f9ad4e91758 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 6 Nov 2025 16:03:36 +0100 Subject: [PATCH 16/34] config: do not print errno in snd_config_check_hop() Signed-off-by: Jaroslav Kysela --- src/conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf.c b/src/conf.c index d1fd2ccb..ac63a1c0 100644 --- a/src/conf.c +++ b/src/conf.c @@ -5800,7 +5800,7 @@ int snd_config_check_hop(snd_config_t *conf) { if (conf) { if (conf->hop >= SND_CONF_MAX_HOPS) { - snd_errornum(CORE, "Too many definition levels (looped?)\n"); + snd_error(CORE, "Too many definition levels (looped?)\n"); return -EINVAL; } return conf->hop; From b37ac0982bb943187dc5c4e10e032232b7111530 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 12:18:00 +0100 Subject: [PATCH 17/34] log: implement filter based on string configuration (env LIBASOUND_DEBUG). Examples: "debug" - Set global level to debug "3" - Set global level to 3 (info) "info,pcm:debug" - Set global to info, pcm to debug "error,mixer:5,pcm:4" - Set global to error, mixer to 5 (trace), pcm to 4 (debug) Signed-off-by: Jaroslav Kysela --- include/error.h | 1 + src/Versions.in.in | 1 + src/error.c | 156 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+) diff --git a/include/error.h b/include/error.h index 7e4ab6a7..13a9d2bc 100644 --- a/include/error.h +++ b/include/error.h @@ -86,6 +86,7 @@ const char *snd_strerror(int errnum); */ typedef void (*snd_lib_log_handler_t)(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg); extern snd_lib_log_handler_t snd_lib_vlog; +int snd_lib_log_filter(int prio, int interface, const char *configstr); void snd_lib_log(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...) /* __attribute__ ((format (printf, 7, 8))) */; void snd_lib_check(int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...); snd_lib_log_handler_t snd_lib_log_set_handler(snd_lib_log_handler_t handler); diff --git a/src/Versions.in.in b/src/Versions.in.in index 36b6ab5d..18f31f9d 100644 --- a/src/Versions.in.in +++ b/src/Versions.in.in @@ -225,5 +225,6 @@ ALSA_1.2.15 { @SYMBOL_PREFIX@snd_lib_log_set_local; @SYMBOL_PREFIX@snd_lib_log_priority; @SYMBOL_PREFIX@snd_lib_log_interface; + @SYMBOL_PREFIX@snd_lib_log_filter; @SYMBOL_PREFIX@snd_lib_check; } ALSA_1.2.13; diff --git a/src/error.c b/src/error.c index 56ff27c7..d8b5bb6a 100644 --- a/src/error.c +++ b/src/error.c @@ -138,6 +138,158 @@ const char *snd_lib_log_interface(int interface) return NULL; } +/** + * \brief Structure to hold parsed debug configuration. + */ +static struct { + const char *configstr; + int global_level; + int interface_levels[SND_ILOG_LAST + 1]; + int parsed; +} debug_config; + +/** + * \brief Parse the LIBASOUND_DEBUG environment variable. + * + * Format: [][,:][,:,...] + * + * Examples: + * "debug" - Set global level to debug + * "3" - Set global level to 3 (info) + * "info,pcm:debug" - Set global to info, pcm to debug + * "error,mixer:5,pcm:4" - Set global to error, mixer to 5 (trace), pcm to 4 (debug) + */ +static void parse_libasound_debug(const char *configstr) +{ + const char *env; + char *str, *token, *saveptr; + int i; + + if (debug_config.parsed && debug_config.configstr == configstr) + return; + + debug_config.parsed = 1; + debug_config.global_level = 0; + debug_config.configstr = configstr; + for (i = 0; i <= SND_ILOG_LAST; i++) + debug_config.interface_levels[i] = 0; + + if (configstr == NULL) { + env = getenv("LIBASOUND_DEBUG"); + if (!env || !*env) + return; + } else { + env = configstr; + } + + str = strdup(env); + if (!str) + return; + + token = strtok_r(str, ",", &saveptr); + while (token) { + char *colon = strchr(token, ':'); + if (colon) { + /* interface:level format */ + *colon = '\0'; + const char *interface_name = token; + const char *level_str = colon + 1; + int interface_num = -1; + int level = -1; + + /* Try to find interface by name */ + for (i = 1; i <= SND_ILOG_LAST; i++) { + if (snd_ilog_interface_names[i] && + strcmp(snd_ilog_interface_names[i], interface_name) == 0) { + interface_num = i; + break; + } + } + + /* If not found by name, try direct number */ + if (interface_num < 0) { + char *endptr; + long val = strtol(interface_name, &endptr, 10); + if (*endptr == '\0' && val >= 0 && val <= SND_ILOG_LAST) + interface_num = val; + } + + /* Parse level */ + for (i = 1; i <= SND_LOG_LAST; i++) { + if (snd_log_prio_names[i] && + strcmp(snd_log_prio_names[i], level_str) == 0) { + level = i; + break; + } + } + + /* If not found by name, try direct number */ + if (level < 0) { + char *endptr; + long val = strtol(level_str, &endptr, 10); + if (*endptr == '\0' && val >= 0 && val <= SND_LOG_LAST) + level = val; + } + + /* Store the interface-specific level */ + if (interface_num > 0 && level > 0) + debug_config.interface_levels[interface_num] = level; + } else { + /* Global level only */ + int level = -1; + + /* Try to find level by name */ + for (i = 1; i <= SND_LOG_LAST; i++) { + if (snd_log_prio_names[i] && + strcmp(snd_log_prio_names[i], token) == 0) { + level = i; + break; + } + } + + /* If not found by name, try direct number */ + if (level < 0) { + char *endptr; + long val = strtol(token, &endptr, 10); + if (*endptr == '\0' && val >= 0 && val <= SND_LOG_LAST) + level = val; + } + + if (level > 0) + debug_config.global_level = level; + } + + token = strtok_r(NULL, ",", &saveptr); + } + + free(str); +} + +/** + * \brief Check if a log message should be shown based on LIBASOUND_DEBUG. + * \param prio Priority value (SND_LOG_*). + * \param interface Interface (SND_ILOG_*). + * \param configstr Configuration string (usually LIBASOUND_DEBUG environment variable) + * \return 1 if the message should be shown, 0 otherwise. + */ +int snd_lib_log_filter(int prio, int interface, const char *configstr) +{ + unsigned int level; + + parse_libasound_debug(configstr); + + if (interface > 0 && interface <= SND_ILOG_LAST && debug_config.interface_levels[interface] > 0) { + level = debug_config.interface_levels[interface]; + } else { + level = debug_config.global_level; } + + if (level == 0) + level = SND_LOG_ERROR; + + /* Show message if its priority is less than or equal to the configured level */ + return prio <= (int)level; +} + /** * \brief The default log handler function. * \param prio Priority value (SND_LOG_*). @@ -165,6 +317,10 @@ static void snd_lib_vlog_default(int prio, int interface, const char *file, int local_error(file, line, function, errcode, fmt, arg); return; } + + if (!snd_lib_log_filter(prio, interface, NULL)) + return; + fprintf(stderr, "ALSA lib %s:%i:(%s) ", file, line, function); text = snd_lib_log_priority(prio); From 66a3d542ace67f52b3bf70e6679e9e69e83df69a Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 14:27:38 +0100 Subject: [PATCH 18/34] huge correction of tabulators and whitespaces Signed-off-by: Jaroslav Kysela --- aserver/aserver.c | 12 +- include/alsa-symbols.h | 4 +- include/aserver.h | 4 +- include/conf.h | 16 +- include/control.h | 6 +- include/global.h | 2 +- include/local.h | 2 +- include/mixer.h | 16 +- include/mixer_abst.h | 12 +- include/pcm.h | 28 +- include/pcm_extplug.h | 2 +- include/pcm_ioplug.h | 4 +- include/pcm_plugin.h | 12 +- include/seq.h | 2 +- include/seq_event.h | 6 +- include/seqmid.h | 4 +- include/sound/uapi/asequencer.h | 10 +- include/sound/uapi/asound.h | 2 +- include/sound/uapi/emu10k1.h | 2 +- include/sound/uapi/hdsp.h | 4 +- include/sound/uapi/sb16_csp.h | 2 +- include/timer.h | 4 +- include/use-case.h | 20 +- modules/mixer/simple/ac97.c | 2 +- modules/mixer/simple/hda.c | 2 +- modules/mixer/simple/python.c | 224 ++++---- modules/mixer/simple/sbase.c | 32 +- modules/mixer/simple/sbasedl.c | 4 +- src/async.c | 2 +- src/conf.c | 78 +-- src/confmisc.c | 84 +-- src/control/cards.c | 6 +- src/control/control.c | 16 +- src/control/control_ext.c | 10 +- src/control/control_hw.c | 8 +- src/control/control_local.h | 2 +- src/control/control_shm.c | 6 +- src/control/control_symbols.c | 2 +- src/control/ctlparse.c | 8 +- src/control/hcontrol.c | 10 +- src/control/namehint.c | 60 +-- src/control/setup.c | 4 +- src/dlmisc.c | 6 +- src/hwdep/hwdep.c | 18 +- src/hwdep/hwdep_hw.c | 2 +- src/hwdep/hwdep_symbols.c | 2 +- src/input.c | 10 +- src/mixer/mixer.c | 4 +- src/mixer/mixer_local.h | 2 +- src/mixer/simple.c | 6 +- src/mixer/simple_abst.c | 4 +- src/mixer/simple_none.c | 28 +- src/names.c | 2 +- src/output.c | 8 +- src/pcm/interval.c | 6 +- src/pcm/interval.h | 6 +- src/pcm/interval_inline.h | 8 +- src/pcm/ladspa.h | 68 +-- src/pcm/mask.c | 2 +- src/pcm/mask.h | 2 +- src/pcm/mask_inline.h | 52 +- src/pcm/pcm.c | 256 ++++----- src/pcm/pcm_adpcm.c | 32 +- src/pcm/pcm_alaw.c | 38 +- src/pcm/pcm_asym.c | 30 +- src/pcm/pcm_copy.c | 10 +- src/pcm/pcm_direct.c | 46 +- src/pcm/pcm_direct.h | 6 +- src/pcm/pcm_dmix.c | 54 +- src/pcm/pcm_dmix_generic.c | 24 +- src/pcm/pcm_dmix_i386.c | 8 +- src/pcm/pcm_dmix_i386.h | 2 +- src/pcm/pcm_dmix_x86_64.c | 6 +- src/pcm/pcm_dmix_x86_64.h | 6 +- src/pcm/pcm_dshare.c | 36 +- src/pcm/pcm_dsnoop.c | 40 +- src/pcm/pcm_empty.c | 6 +- src/pcm/pcm_extplug.c | 12 +- src/pcm/pcm_file.c | 30 +- src/pcm/pcm_generic.c | 6 +- src/pcm/pcm_generic.h | 4 +- src/pcm/pcm_hooks.c | 8 +- src/pcm/pcm_hw.c | 20 +- src/pcm/pcm_iec958.c | 34 +- src/pcm/pcm_ioplug.c | 10 +- src/pcm/pcm_ladspa.c | 908 ++++++++++++++++---------------- src/pcm/pcm_lfloat.c | 34 +- src/pcm/pcm_linear.c | 38 +- src/pcm/pcm_local.h | 10 +- src/pcm/pcm_meter.c | 28 +- src/pcm/pcm_misc.c | 6 +- src/pcm/pcm_mmap.c | 26 +- src/pcm/pcm_mmap_emul.c | 2 +- src/pcm/pcm_mulaw.c | 30 +- src/pcm/pcm_multi.c | 22 +- src/pcm/pcm_null.c | 18 +- src/pcm/pcm_params.c | 92 ++-- src/pcm/pcm_plug.c | 40 +- src/pcm/pcm_plugin.c | 26 +- src/pcm/pcm_plugin.h | 10 +- src/pcm/pcm_rate.c | 54 +- src/pcm/pcm_rate_linear.c | 18 +- src/pcm/pcm_route.c | 68 +-- src/pcm/pcm_share.c | 42 +- src/pcm/pcm_shm.c | 14 +- src/pcm/pcm_simple.c | 14 +- src/pcm/pcm_softvol.c | 48 +- src/pcm/pcm_symbols.c | 2 +- src/pcm/plugin_ops.h | 26 +- src/pcm/scopes/level.c | 2 +- src/rawmidi/rawmidi.c | 18 +- src/rawmidi/rawmidi_hw.c | 14 +- src/rawmidi/rawmidi_symbols.c | 2 +- src/rawmidi/rawmidi_virt.c | 2 +- src/seq/seq.c | 234 ++++---- src/seq/seq_hw.c | 2 +- src/seq/seq_symbols.c | 2 +- src/seq/seqmid.c | 10 +- src/socket.c | 4 +- src/timer/timer.c | 20 +- src/timer/timer_hw.c | 2 +- src/timer/timer_query.c | 22 +- src/timer/timer_query_hw.c | 2 +- src/timer/timer_symbols.c | 4 +- src/topology/builder.c | 6 +- src/topology/channel.c | 4 +- src/topology/ctl.c | 4 +- src/topology/dapm.c | 4 +- src/topology/data.c | 6 +- src/topology/elem.c | 4 +- src/topology/ops.c | 4 +- src/topology/parser.c | 4 +- src/topology/pcm.c | 4 +- src/topology/text.c | 4 +- src/ucm/main.c | 12 +- src/ucm/parser.c | 10 +- src/ucm/ucm_local.h | 8 +- src/ucm/utils.c | 14 +- src/userfile.c | 2 +- test/audio_time.c | 2 +- test/control.c | 2 +- test/latency.c | 46 +- test/midifile.c | 14 +- test/midifile.h | 4 +- test/midiloop.c | 16 +- test/mixtest.c | 44 +- test/omixer.c | 2 +- test/pcm.c | 38 +- test/pcm_min.c | 2 +- test/playmidi1.c | 34 +- test/queue_timer.c | 2 +- test/rawmidi.c | 46 +- test/seq-decoder.c | 20 +- test/seq-sender.c | 10 +- test/seq.c | 24 +- test/timer.c | 6 +- test/user-ctl-element-set.c | 2 +- 157 files changed, 2008 insertions(+), 2008 deletions(-) diff --git a/aserver/aserver.c b/aserver/aserver.c index 1924021c..823b345c 100644 --- a/aserver/aserver.c +++ b/aserver/aserver.c @@ -50,7 +50,7 @@ char *command; fprintf(stderr, ##args); \ putc('\n', stderr); \ } while (0) -#endif +#endif #define SYSERROR(string) ERROR(string ": %s", strerror(errno)) @@ -67,7 +67,7 @@ static int make_local_socket(const char *filename) SYSERROR("socket failed"); return result; } - + unlink(filename); addr->sun_family = AF_LOCAL; @@ -94,7 +94,7 @@ static int make_inet_socket(int port) SYSERROR("socket failed"); return result; } - + memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port); @@ -329,7 +329,7 @@ static int pcm_shm_close(client_t *client) } err = snd_pcm_close(client->device.pcm.handle); ctrl->result = err; - if (err < 0) + if (err < 0) ERROR("snd_pcm_close"); if (client->transport.shm.ctrl) { err = shmdt((void *)client->transport.shm.ctrl); @@ -592,7 +592,7 @@ static int ctl_shm_close(client_t *client) } err = snd_ctl_close(client->device.ctl.handle); ctrl->result = err; - if (err < 0) + if (err < 0) ERROR("snd_ctl_close"); if (client->transport.shm.ctrl) { err = shmdt((void *)client->transport.shm.ctrl); @@ -1005,7 +1005,7 @@ static int server(const char *sockname, int port) free(waiters); return result; } - + static void usage(void) { diff --git a/include/alsa-symbols.h b/include/alsa-symbols.h index 2298cb50..6d5b5895 100644 --- a/include/alsa-symbols.h +++ b/include/alsa-symbols.h @@ -56,8 +56,8 @@ #define use_symbol_version(real, name, version) /* nothing */ #if defined(__alpha__) || defined(__mips__) #define use_default_symbol_version(real, name, version) \ - __asm__ (".weak " ASM_NAME(#name)); \ - __asm__ (ASM_NAME(#name) " = " ASM_NAME(#real)) + __asm__ (".weak " ASM_NAME(#name)); \ + __asm__ (ASM_NAME(#name) " = " ASM_NAME(#real)) #else #define use_default_symbol_version(real, name, version) \ __asm__ (".weak " ASM_NAME(#name)); \ diff --git a/include/aserver.h b/include/aserver.h index ffddf2b4..dc31706c 100644 --- a/include/aserver.h +++ b/include/aserver.h @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "../src/pcm/pcm_local.h" #include "../src/control/control_local.h" #include @@ -106,7 +106,7 @@ typedef struct { } snd_pcm_shm_ctrl_t; #define PCM_SHM_SIZE sizeof(snd_pcm_shm_ctrl_t) - + #define SND_CTL_IOCTL_READ _IOR('U', 0xf1, snd_ctl_event_t) #define SND_CTL_IOCTL_CLOSE _IO ('U', 0xf2) #define SND_CTL_IOCTL_POLL_DESCRIPTOR _IO ('U', 0xf3) diff --git a/include/conf.h b/include/conf.h index 327659c9..2a6d8296 100644 --- a/include/conf.h +++ b/include/conf.h @@ -52,15 +52,15 @@ extern "C" { /** \brief Configuration node type. */ typedef enum _snd_config_type { /** Integer number. */ - SND_CONFIG_TYPE_INTEGER, + SND_CONFIG_TYPE_INTEGER, /** 64-bit integer number. */ - SND_CONFIG_TYPE_INTEGER64, + SND_CONFIG_TYPE_INTEGER64, /** Real number. */ - SND_CONFIG_TYPE_REAL, + SND_CONFIG_TYPE_REAL, /** Character string. */ - SND_CONFIG_TYPE_STRING, - /** Pointer (runtime only, cannot be saved). */ - SND_CONFIG_TYPE_POINTER, + SND_CONFIG_TYPE_STRING, + /** Pointer (runtime only, cannot be saved). */ + SND_CONFIG_TYPE_POINTER, /** Compound node. */ SND_CONFIG_TYPE_COMPOUND = 1024 } snd_config_type_t; @@ -108,7 +108,7 @@ void snd_config_unref(snd_config_t *top); int snd_config_search(snd_config_t *config, const char *key, snd_config_t **result); -int snd_config_searchv(snd_config_t *config, +int snd_config_searchv(snd_config_t *config, snd_config_t **result, ...); int snd_config_search_definition(snd_config_t *config, const char *base, const char *key, @@ -122,7 +122,7 @@ int snd_config_search_definition(snd_config_t *config, * \param[in] private_data Handle to the \c private_data node. * \return A non-negative value if successful, otherwise a negative error code. * - * Use a function of this type to define a custom expansion + * Use a function of this type to define a custom expansion */ typedef int (*snd_config_expand_fcn_t)(snd_config_t **dst, const char *s, void *private_data); diff --git a/include/control.h b/include/control.h index b206fbb0..e670e6c1 100644 --- a/include/control.h +++ b/include/control.h @@ -386,7 +386,7 @@ int snd_ctl_open_fallback(snd_ctl_t **ctl, snd_config_t *root, const char *name, int snd_ctl_close(snd_ctl_t *ctl); int snd_ctl_nonblock(snd_ctl_t *ctl, int nonblock); static __inline__ int snd_ctl_abort(snd_ctl_t *ctl) { return snd_ctl_nonblock(ctl, 2); } -int snd_async_add_ctl_handler(snd_async_handler_t **handler, snd_ctl_t *ctl, +int snd_async_add_ctl_handler(snd_async_handler_t **handler, snd_ctl_t *ctl, snd_async_callback_t callback, void *private_data); snd_ctl_t *snd_async_handler_get_ctl(snd_async_handler_t *handler); int snd_ctl_poll_descriptors_count(snd_ctl_t *ctl); @@ -718,7 +718,7 @@ typedef int (*snd_hctl_compare_t)(const snd_hctl_elem_t *e1, const snd_hctl_elem_t *e2); int snd_hctl_compare_fast(const snd_hctl_elem_t *c1, const snd_hctl_elem_t *c2); -/** +/** * \brief HCTL callback function * \param hctl HCTL handle * \param mask event mask @@ -728,7 +728,7 @@ int snd_hctl_compare_fast(const snd_hctl_elem_t *c1, typedef int (*snd_hctl_callback_t)(snd_hctl_t *hctl, unsigned int mask, snd_hctl_elem_t *elem); -/** +/** * \brief HCTL element callback function * \param elem HCTL element * \param mask event mask diff --git a/include/global.h b/include/global.h index 84a40557..ae706133 100644 --- a/include/global.h +++ b/include/global.h @@ -124,7 +124,7 @@ typedef struct _snd_async_handler snd_async_handler_t; */ typedef void (*snd_async_callback_t)(snd_async_handler_t *handler); -int snd_async_add_handler(snd_async_handler_t **handler, int fd, +int snd_async_add_handler(snd_async_handler_t **handler, int fd, snd_async_callback_t callback, void *private_data); int snd_async_del_handler(snd_async_handler_t *handler); int snd_async_handler_get_fd(snd_async_handler_t *handler); diff --git a/include/local.h b/include/local.h index da70cf52..a9f8c126 100644 --- a/include/local.h +++ b/include/local.h @@ -385,7 +385,7 @@ int snd_config_check_hop(snd_config_t *conf); #define SND_CONF_MAX_HOPS 64 int snd_config_search_alias_hooks(snd_config_t *config, - const char *base, const char *key, + const char *base, const char *key, snd_config_t **result); int _snd_conf_generic_id(const char *id); diff --git a/include/mixer.h b/include/mixer.h index 93dd70cd..f9c6026c 100644 --- a/include/mixer.h +++ b/include/mixer.h @@ -51,7 +51,7 @@ typedef struct _snd_mixer_class snd_mixer_class_t; /** Mixer element handle */ typedef struct _snd_mixer_elem snd_mixer_elem_t; -/** +/** * \brief Mixer callback function * \param ctl Mixer handle * \param mask event mask @@ -62,7 +62,7 @@ typedef int (*snd_mixer_callback_t)(snd_mixer_t *ctl, unsigned int mask, snd_mixer_elem_t *elem); -/** +/** * \brief Mixer element callback function * \param elem Mixer element * \param mask event mask @@ -276,17 +276,17 @@ int snd_mixer_selem_set_playback_switch(snd_mixer_elem_t *elem, snd_mixer_selem_ int snd_mixer_selem_set_capture_switch(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, int value); int snd_mixer_selem_set_playback_switch_all(snd_mixer_elem_t *elem, int value); int snd_mixer_selem_set_capture_switch_all(snd_mixer_elem_t *elem, int value); -int snd_mixer_selem_get_playback_volume_range(snd_mixer_elem_t *elem, +int snd_mixer_selem_get_playback_volume_range(snd_mixer_elem_t *elem, long *min, long *max); -int snd_mixer_selem_get_playback_dB_range(snd_mixer_elem_t *elem, +int snd_mixer_selem_get_playback_dB_range(snd_mixer_elem_t *elem, long *min, long *max); -int snd_mixer_selem_set_playback_volume_range(snd_mixer_elem_t *elem, +int snd_mixer_selem_set_playback_volume_range(snd_mixer_elem_t *elem, long min, long max); -int snd_mixer_selem_get_capture_volume_range(snd_mixer_elem_t *elem, +int snd_mixer_selem_get_capture_volume_range(snd_mixer_elem_t *elem, long *min, long *max); -int snd_mixer_selem_get_capture_dB_range(snd_mixer_elem_t *elem, +int snd_mixer_selem_get_capture_dB_range(snd_mixer_elem_t *elem, long *min, long *max); -int snd_mixer_selem_set_capture_volume_range(snd_mixer_elem_t *elem, +int snd_mixer_selem_set_capture_volume_range(snd_mixer_elem_t *elem, long min, long max); int snd_mixer_selem_is_enumerated(snd_mixer_elem_t *elem); diff --git a/include/mixer_abst.h b/include/mixer_abst.h index ec23e0dd..8807eae3 100644 --- a/include/mixer_abst.h +++ b/include/mixer_abst.h @@ -43,11 +43,11 @@ extern "C" { #define SM_CAP_GSWITCH (1<<2) #define SM_CAP_PVOLUME (1<<3) #define SM_CAP_PVOLUME_JOIN (1<<4) -#define SM_CAP_PSWITCH (1<<5) -#define SM_CAP_PSWITCH_JOIN (1<<6) -#define SM_CAP_CVOLUME (1<<7) -#define SM_CAP_CVOLUME_JOIN (1<<8) -#define SM_CAP_CSWITCH (1<<9) +#define SM_CAP_PSWITCH (1<<5) +#define SM_CAP_PSWITCH_JOIN (1<<6) +#define SM_CAP_CVOLUME (1<<7) +#define SM_CAP_CVOLUME_JOIN (1<<8) +#define SM_CAP_CSWITCH (1<<9) #define SM_CAP_CSWITCH_JOIN (1<<10) #define SM_CAP_CSWITCH_EXCL (1<<11) #define SM_CAP_PENUM (1<<12) @@ -77,7 +77,7 @@ typedef struct _sm_class_basic { snd_ctl_card_info_t *info; } sm_class_basic_t; -struct sm_elem_ops { +struct sm_elem_ops { int (*is)(snd_mixer_elem_t *elem, int dir, int cmd, int val); int (*get_range)(snd_mixer_elem_t *elem, int dir, long *min, long *max); int (*set_range)(snd_mixer_elem_t *elem, int dir, long min, long max); diff --git a/include/pcm.h b/include/pcm.h index 3fa9203e..74020511 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -303,7 +303,7 @@ typedef enum _snd_pcm_subformat { typedef enum _snd_pcm_state { /** Open */ SND_PCM_STATE_OPEN = 0, - /** Setup installed */ + /** Setup installed */ SND_PCM_STATE_SETUP, /** Ready to start */ SND_PCM_STATE_PREPARED, @@ -525,9 +525,9 @@ typedef union _snd_pcm_sync_id { /** #SND_PCM_TYPE_METER scope handle */ typedef struct _snd_pcm_scope snd_pcm_scope_t; -int snd_pcm_open(snd_pcm_t **pcm, const char *name, +int snd_pcm_open(snd_pcm_t **pcm, const char *name, snd_pcm_stream_t stream, int mode); -int snd_pcm_open_lconf(snd_pcm_t **pcm, const char *name, +int snd_pcm_open_lconf(snd_pcm_t **pcm, const char *name, snd_pcm_stream_t stream, int mode, snd_config_t *lconf); int snd_pcm_open_fallback(snd_pcm_t **pcm, snd_config_t *root, @@ -543,7 +543,7 @@ int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int s int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents); int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock); static __inline__ int snd_pcm_abort(snd_pcm_t *pcm) { return snd_pcm_nonblock(pcm, 2); } -int snd_async_add_pcm_handler(snd_async_handler_t **handler, snd_pcm_t *pcm, +int snd_async_add_pcm_handler(snd_async_handler_t **handler, snd_pcm_t *pcm, snd_async_callback_t callback, void *private_data); snd_pcm_t *snd_async_handler_get_pcm(snd_async_handler_t *handler); int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info); @@ -679,15 +679,15 @@ snd_pcm_chmap_t *snd_pcm_chmap_parse_string(const char *str); int snd_pcm_recover(snd_pcm_t *pcm, int err, int silent); int snd_pcm_set_params(snd_pcm_t *pcm, - snd_pcm_format_t format, - snd_pcm_access_t access, - unsigned int channels, - unsigned int rate, - int soft_resample, - unsigned int latency); + snd_pcm_format_t format, + snd_pcm_access_t access, + unsigned int channels, + unsigned int rate, + int soft_resample, + unsigned int latency); int snd_pcm_get_params(snd_pcm_t *pcm, - snd_pcm_uframes_t *buffer_size, - snd_pcm_uframes_t *period_size); + snd_pcm_uframes_t *buffer_size, + snd_pcm_uframes_t *period_size); /** \} */ @@ -1149,7 +1149,7 @@ snd_pcm_sframes_t snd_pcm_mmap_commit(snd_pcm_t *pcm, snd_pcm_sframes_t snd_pcm_mmap_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size); snd_pcm_sframes_t snd_pcm_mmap_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size); snd_pcm_sframes_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size); -snd_pcm_sframes_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size); +snd_pcm_sframes_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size); /** \} */ @@ -1326,7 +1326,7 @@ int16_t *snd_pcm_scope_s16_get_channel_buffer(snd_pcm_scope_t *scope, /** Simple PCM latency type */ typedef enum _snd_spcm_latency { /** standard latency - for standard playback or capture - (estimated latency in one direction 350ms) */ + (estimated latency in one direction 350ms) */ SND_SPCM_LATENCY_STANDARD = 0, /** medium latency - software phones etc. (estimated latency in one direction maximally 25ms */ diff --git a/include/pcm_extplug.h b/include/pcm_extplug.h index 1294a59e..9049783c 100644 --- a/include/pcm_extplug.h +++ b/include/pcm_extplug.h @@ -49,7 +49,7 @@ enum { SND_PCM_EXTPLUG_HW_CHANNELS, /**< channels */ SND_PCM_EXTPLUG_HW_PARAMS /**< max number of hw constraints */ }; - + /** Handle of external filter plugin */ typedef struct snd_pcm_extplug snd_pcm_extplug_t; /** Callback table of extplug */ diff --git a/include/pcm_ioplug.h b/include/pcm_ioplug.h index 722dc9d7..c41c5c1f 100644 --- a/include/pcm_ioplug.h +++ b/include/pcm_ioplug.h @@ -54,7 +54,7 @@ enum { SND_PCM_IOPLUG_HW_PERIODS, /**< number of periods */ SND_PCM_IOPLUG_HW_PARAMS /**< max number of hw constraints */ }; - + /** I/O plugin handle */ typedef struct snd_pcm_ioplug snd_pcm_ioplug_t; /** Callback table of ioplug */ @@ -114,7 +114,7 @@ struct snd_pcm_ioplug { */ snd_pcm_t *pcm; - snd_pcm_stream_t stream; /**< stream direcion; read-only */ + snd_pcm_stream_t stream; /**< stream direcion; read-only */ snd_pcm_state_t state; /**< current PCM state; read-only */ volatile snd_pcm_uframes_t appl_ptr; /**< application pointer; read-only */ volatile snd_pcm_uframes_t hw_ptr; /**< hw pointer; read-only */ diff --git a/include/pcm_plugin.h b/include/pcm_plugin.h index f3e8f3b5..fa95590d 100644 --- a/include/pcm_plugin.h +++ b/include/pcm_plugin.h @@ -38,7 +38,7 @@ * See the \ref pcm_plugins page for more details. * \{ */ - + #define SND_PCM_PLUGIN_RATE_MIN 4000 /**< minimal rate for the rate plugin */ #define SND_PCM_PLUGIN_RATE_MAX 768000 /**< maximal rate for the rate plugin */ @@ -81,8 +81,8 @@ int snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int close_slave); int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, - snd_pcm_stream_t stream, int mode); - + snd_pcm_stream_t stream, int mode); + /* * Linear conversion plugin */ @@ -111,7 +111,7 @@ int snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name, int close_slave); int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, - snd_pcm_stream_t stream, int mode); + snd_pcm_stream_t stream, int mode); /* * Linear<->a-Law conversion plugin @@ -207,8 +207,8 @@ int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name, snd_config_t *capture_conf, snd_pcm_stream_t stream, int mode); int _snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, - snd_pcm_stream_t stream, int mode); + snd_config_t *root, snd_config_t *conf, + snd_pcm_stream_t stream, int mode); /** \} */ diff --git a/include/seq.h b/include/seq.h index 17bcfa53..686f69dd 100644 --- a/include/seq.h +++ b/include/seq.h @@ -135,7 +135,7 @@ typedef enum snd_seq_client_type { SND_SEQ_USER_CLIENT = 1, /**< user client */ SND_SEQ_KERNEL_CLIENT = 2 /**< kernel client */ } snd_seq_client_type_t; - + /** client MIDI version */ enum { SND_SEQ_CLIENT_LEGACY_MIDI = 0, /**< Legacy client */ diff --git a/include/seq_event.h b/include/seq_event.h index b27ce36c..268578b8 100644 --- a/include/seq_event.h +++ b/include/seq_event.h @@ -61,7 +61,7 @@ enum snd_seq_event_type { SND_SEQ_EVENT_NOTEOFF, /** key pressure change (aftertouch); event data type = #snd_seq_ev_note_t */ SND_SEQ_EVENT_KEYPRESS, - + /** controller; event data type = #snd_seq_ev_ctrl_t */ SND_SEQ_EVENT_CONTROLLER = 10, /** program change; event data type = #snd_seq_ev_ctrl_t */ @@ -87,7 +87,7 @@ enum snd_seq_event_type { SND_SEQ_EVENT_TIMESIGN, /** SMF Key Signature event; event data type = #snd_seq_ev_ctrl_t */ SND_SEQ_EVENT_KEYSIGN, - + /** MIDI Real Time Start message; event data type = #snd_seq_ev_queue_control_t */ SND_SEQ_EVENT_START = 30, /** MIDI Real Time Continue message; event data type = #snd_seq_ev_queue_control_t */ @@ -329,7 +329,7 @@ typedef struct snd_seq_event { snd_seq_event_type_t type; /**< event type */ unsigned char flags; /**< event flags */ unsigned char tag; /**< tag */ - + unsigned char queue; /**< schedule queue */ snd_seq_timestamp_t time; /**< schedule time */ diff --git a/include/seqmid.h b/include/seqmid.h index 6d22692f..1df03bad 100644 --- a/include/seqmid.h +++ b/include/seqmid.h @@ -48,7 +48,7 @@ extern "C" { /** * \brief initialize event record * \param ev event record pointer - * + * * This macro clears the given event record pointer to the default status. */ static inline void snd_seq_ev_clear(snd_seq_event_t *ev) @@ -130,7 +130,7 @@ static inline void snd_seq_ump_ev_clear(snd_seq_ump_event_t *ev) * * This macro sets the event to the direct passing mode * to be delivered immediately without queueing. - * + * * \sa snd_seq_ev_schedule_tick(), snd_seq_ev_schedule_real() */ #define snd_seq_ev_set_direct(ev) \ diff --git a/include/sound/uapi/asequencer.h b/include/sound/uapi/asequencer.h index 9682795b..aa4d6942 100644 --- a/include/sound/uapi/asequencer.h +++ b/include/sound/uapi/asequencer.h @@ -29,7 +29,7 @@ #define SNDRV_SEQ_EVENT_NOTEON 6 #define SNDRV_SEQ_EVENT_NOTEOFF 7 #define SNDRV_SEQ_EVENT_KEYPRESS 8 - + /** control messages (channel specific) * event data type = #snd_seq_ev_ctrl */ @@ -49,13 +49,13 @@ #define SNDRV_SEQ_EVENT_QFRAME 22 /* midi time code quarter frame */ #define SNDRV_SEQ_EVENT_TIMESIGN 23 /* SMF Time Signature event */ #define SNDRV_SEQ_EVENT_KEYSIGN 24 /* SMF Key Signature event */ - + /** timer messages * event data type = snd_seq_ev_queue_control */ #define SNDRV_SEQ_EVENT_START 30 /* midi Real Time Start message */ #define SNDRV_SEQ_EVENT_CONTINUE 31 /* midi Real Time Continue message */ -#define SNDRV_SEQ_EVENT_STOP 32 /* midi Real Time Stop message */ +#define SNDRV_SEQ_EVENT_STOP 32 /* midi Real Time Stop message */ #define SNDRV_SEQ_EVENT_SETPOS_TICK 33 /* set tick queue position */ #define SNDRV_SEQ_EVENT_SETPOS_TIME 34 /* set realtime queue position */ #define SNDRV_SEQ_EVENT_TEMPO 35 /* (SMF) Tempo event */ @@ -282,7 +282,7 @@ struct snd_seq_event { snd_seq_event_type_t type; /* event type */ unsigned char flags; /* event flags */ char tag; - + unsigned char queue; /* schedule queue */ union snd_seq_timestamp time; /* schedule time */ @@ -352,7 +352,7 @@ typedef int __bitwise snd_seq_client_type_t; #define NO_CLIENT ((snd_seq_client_type_t) 0) #define USER_CLIENT ((snd_seq_client_type_t) 1) #define KERNEL_CLIENT ((snd_seq_client_type_t) 2) - + /* event filter flags */ #define SNDRV_SEQ_FILTER_BROADCAST (1U<<0) /* accept broadcast messages */ #define SNDRV_SEQ_FILTER_MULTICAST (1U<<1) /* accept multicast messages */ diff --git a/include/sound/uapi/asound.h b/include/sound/uapi/asound.h index 1f91d994..bdc9a05e 100644 --- a/include/sound/uapi/asound.h +++ b/include/sound/uapi/asound.h @@ -409,7 +409,7 @@ struct snd_pcm_hw_params { SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; struct snd_mask mres[5]; /* reserved masks */ struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1]; + SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1]; struct snd_interval ires[9]; /* reserved intervals */ unsigned int rmask; /* W: requested masks */ unsigned int cmask; /* R: changed masks */ diff --git a/include/sound/uapi/emu10k1.h b/include/sound/uapi/emu10k1.h index 78d794c0..b6b9f597 100644 --- a/include/sound/uapi/emu10k1.h +++ b/include/sound/uapi/emu10k1.h @@ -188,7 +188,7 @@ #define A_EXTIN_SPDIF_CD_L 0x02 /* digital CD left */ #define A_EXTIN_SPDIF_CD_R 0x03 /* digital CD left */ #define A_EXTIN_OPT_SPDIF_L 0x04 /* audigy drive Optical SPDIF - left */ -#define A_EXTIN_OPT_SPDIF_R 0x05 /* right */ +#define A_EXTIN_OPT_SPDIF_R 0x05 /* right */ #define A_EXTIN_LINE2_L 0x08 /* audigy drive line2/mic2 - left */ #define A_EXTIN_LINE2_R 0x09 /* right */ #define A_EXTIN_ADC_L 0x0a /* Philips ADC - left */ diff --git a/include/sound/uapi/hdsp.h b/include/sound/uapi/hdsp.h index b8df62b6..4f797fcc 100644 --- a/include/sound/uapi/hdsp.h +++ b/include/sound/uapi/hdsp.h @@ -4,7 +4,7 @@ /* * Copyright (C) 2003 Thomas Charbonnel (thomas@undata.org) - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -65,7 +65,7 @@ struct hdsp_config_info { unsigned char clock_source; unsigned char autosync_ref; unsigned char line_out; - unsigned char passthru; + unsigned char passthru; unsigned char da_gain; unsigned char ad_gain; unsigned char phone_gain; diff --git a/include/sound/uapi/sb16_csp.h b/include/sound/uapi/sb16_csp.h index 55db0b44..8a8dc93f 100644 --- a/include/sound/uapi/sb16_csp.h +++ b/include/sound/uapi/sb16_csp.h @@ -5,7 +5,7 @@ * * SB16ASP/AWE32 CSP control * - * This program is free software; you can redistribute it and/or modify + * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. diff --git a/include/timer.h b/include/timer.h index 09283ce0..7a41331a 100644 --- a/include/timer.h +++ b/include/timer.h @@ -99,13 +99,13 @@ typedef enum _snd_timer_event { SND_TIMER_EVENT_MCONTINUE = SND_TIMER_EVENT_CONTINUE + 10, SND_TIMER_EVENT_MPAUSE = SND_TIMER_EVENT_PAUSE + 10, SND_TIMER_EVENT_MSUSPEND = SND_TIMER_EVENT_SUSPEND + 10, - SND_TIMER_EVENT_MRESUME = SND_TIMER_EVENT_RESUME + 10 + SND_TIMER_EVENT_MRESUME = SND_TIMER_EVENT_RESUME + 10 } snd_timer_event_t; /** timer read structure */ typedef struct _snd_timer_read { unsigned int resolution; /**< tick resolution in nanoseconds */ - unsigned int ticks; /**< count of happened ticks */ + unsigned int ticks; /**< count of happened ticks */ } snd_timer_read_t; /** timer tstamp + event read structure */ diff --git a/include/use-case.h b/include/use-case.h index b54f2124..fb8be446 100644 --- a/include/use-case.h +++ b/include/use-case.h @@ -239,14 +239,14 @@ int snd_use_case_free_list(const char *list[], int items); * */ int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr, - const char *identifier, - const char **list[]); + const char *identifier, + const char **list[]); /** * \brief Get current - string * \param uc_mgr Use case manager - * \param identifier + * \param identifier * \param value Value pointer * \return Zero if success, otherwise a negative error code * @@ -410,14 +410,14 @@ int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr, * increase latency. */ int snd_use_case_get(snd_use_case_mgr_t *uc_mgr, - const char *identifier, - const char **value); + const char *identifier, + const char **value); /** * \brief Get current - integer * \param uc_mgr Use case manager - * \param identifier - * \param value result + * \param identifier + * \param value result * \return Zero if success, otherwise a negative error code * * Known identifiers: @@ -456,8 +456,8 @@ int snd_use_case_geti(snd_use_case_mgr_t *uc_mgr, * - check transmit sequence firstly */ int snd_use_case_set(snd_use_case_mgr_t *uc_mgr, - const char *identifier, - const char *value); + const char *identifier, + const char *value); /** * \brief Open and initialise use case core for sound card @@ -482,7 +482,7 @@ int snd_use_case_set(snd_use_case_mgr_t *uc_mgr, * only one ALSA sound card in this case. */ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr, - const char *card_name); + const char *card_name); /** diff --git a/modules/mixer/simple/ac97.c b/modules/mixer/simple/ac97.c index a87b446b..b37cbd22 100644 --- a/modules/mixer/simple/ac97.c +++ b/modules/mixer/simple/ac97.c @@ -75,7 +75,7 @@ int alsa_mixer_simple_init(snd_mixer_class_t *class) { struct bclass_base_ops *ops; int err; - + err = mixer_simple_basic_dlopen(class, &ops); if (err < 0) return 0; diff --git a/modules/mixer/simple/hda.c b/modules/mixer/simple/hda.c index e62d4b05..49d1cd42 100644 --- a/modules/mixer/simple/hda.c +++ b/modules/mixer/simple/hda.c @@ -76,7 +76,7 @@ int alsa_mixer_simple_init(snd_mixer_class_t *class) { struct bclass_base_ops *ops; int err; - + err = mixer_simple_basic_dlopen(class, &ops); if (err < 0) return 0; diff --git a/modules/mixer/simple/python.c b/modules/mixer/simple/python.c index 1df31049..cf6799c0 100644 --- a/modules/mixer/simple/python.c +++ b/modules/mixer/simple/python.c @@ -68,24 +68,24 @@ static PyInterpreterState *main_interpreter; static inline int get_long(PyObject *o, long *val) { #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(o)) { - *val = PyInt_AsLong(o); - return 0; - } + if (PyInt_Check(o)) { + *val = PyInt_AsLong(o); + return 0; + } #endif - if (PyLong_Check(o)) { - *val = PyLong_AsLong(o); - return 0; - } - return 1; + if (PyLong_Check(o)) { + *val = PyLong_AsLong(o); + return 0; + } + return 1; } static inline PyObject *InternFromString(const char *name) { #if PY_MAJOR_VERSION < 3 - return PyString_InternFromString(name); + return PyString_InternFromString(name); #else - return PyUnicode_InternFromString(name); + return PyUnicode_InternFromString(name); #endif } @@ -191,12 +191,12 @@ static int is_ops(snd_mixer_elem_t *elem, int dir, int cmd, int val) } static int get_x_range_ops(snd_mixer_elem_t *elem, int dir, - long *min, long *max, const char *attr) + long *min, long *max, const char *attr) { PyObject *obj1, *t1, *t2, *res; struct pymelem *pymelem = melem_to_pymelem(elem); int err; - + obj1 = PyTuple_New(1); PyTuple_SET_ITEM(obj1, 0, PyInt_FromLong(dir)); err = pcall(pymelem, attr, obj1, &res); @@ -225,13 +225,13 @@ static int get_x_range_ops(snd_mixer_elem_t *elem, int dir, } static int get_range_ops(snd_mixer_elem_t *elem, int dir, - long *min, long *max) + long *min, long *max) { return get_x_range_ops(elem, dir, min, max, "opsGetRange"); } static int set_range_ops(snd_mixer_elem_t *elem, int dir, - long min, long max) + long min, long max) { PyObject *obj1; struct pymelem *pymelem = melem_to_pymelem(elem); @@ -244,13 +244,13 @@ static int set_range_ops(snd_mixer_elem_t *elem, int dir, } static int get_x_ops(snd_mixer_elem_t *elem, int dir, - long channel, long *value, - const char *attr) + long channel, long *value, + const char *attr) { PyObject *obj1, *t1, *res; struct pymelem *pymelem = melem_to_pymelem(elem); int err; - + obj1 = PyTuple_New(2); PyTuple_SET_ITEM(obj1, 0, PyInt_FromLong(dir)); PyTuple_SET_ITEM(obj1, 1, PyInt_FromLong(channel)); @@ -283,7 +283,7 @@ static int get_volume_ops(snd_mixer_elem_t *elem, int dir, } static int get_switch_ops(snd_mixer_elem_t *elem, int dir, - snd_mixer_selem_channel_id_t channel, int *value) + snd_mixer_selem_channel_id_t channel, int *value) { long value1; int res; @@ -309,7 +309,7 @@ static int ask_dB_vol_ops(snd_mixer_elem_t *elem, PyObject *obj1, *t1, *res; struct pymelem *pymelem = melem_to_pymelem(elem); int err; - + obj1 = PyTuple_New(3); PyTuple_SET_ITEM(obj1, 0, PyInt_FromLong(dir)); PyTuple_SET_ITEM(obj1, 1, PyInt_FromLong(value)); @@ -337,21 +337,21 @@ static int ask_dB_vol_ops(snd_mixer_elem_t *elem, } static int get_dB_ops(snd_mixer_elem_t *elem, - int dir, - snd_mixer_selem_channel_id_t channel, - long *value) + int dir, + snd_mixer_selem_channel_id_t channel, + long *value) { return get_x_ops(elem, dir, channel, value, "opsGetDB"); } static int get_dB_range_ops(snd_mixer_elem_t *elem, int dir, - long *min, long *max) + long *min, long *max) { return get_x_range_ops(elem, dir, min, max, "opsGetDBRange"); } static int set_volume_ops(snd_mixer_elem_t *elem, int dir, - snd_mixer_selem_channel_id_t channel, long value) + snd_mixer_selem_channel_id_t channel, long value) { PyObject *obj1; struct pymelem *pymelem = melem_to_pymelem(elem); @@ -364,7 +364,7 @@ static int set_volume_ops(snd_mixer_elem_t *elem, int dir, } static int set_switch_ops(snd_mixer_elem_t *elem, int dir, - snd_mixer_selem_channel_id_t channel, int value) + snd_mixer_selem_channel_id_t channel, int value) { PyObject *obj1; struct pymelem *pymelem = melem_to_pymelem(elem); @@ -377,8 +377,8 @@ static int set_switch_ops(snd_mixer_elem_t *elem, int dir, } static int set_dB_ops(snd_mixer_elem_t *elem, int dir, - snd_mixer_selem_channel_id_t channel, - long db_gain, int xdir) + snd_mixer_selem_channel_id_t channel, + long db_gain, int xdir) { PyObject *obj1; struct pymelem *pymelem = melem_to_pymelem(elem); @@ -392,15 +392,15 @@ static int set_dB_ops(snd_mixer_elem_t *elem, int dir, } static int enum_item_name_ops(snd_mixer_elem_t *elem, - unsigned int item, - size_t maxlen, char *buf) + unsigned int item, + size_t maxlen, char *buf) { PyObject *obj1, *obj2, *t1, *res; struct pymelem *pymelem = melem_to_pymelem(elem); int err; unsigned int len; char *s; - + obj1 = PyTuple_New(1); PyTuple_SET_ITEM(obj1, 0, PyInt_FromLong(item)); err = pcall(pymelem, "opsGetEnumItemName", obj1, &res); @@ -441,13 +441,13 @@ errlbl: } static int get_enum_item_ops(snd_mixer_elem_t *elem, - snd_mixer_selem_channel_id_t channel, - unsigned int *itemp) + snd_mixer_selem_channel_id_t channel, + unsigned int *itemp) { PyObject *obj1, *t1, *res; struct pymelem *pymelem = melem_to_pymelem(elem); int err; - + obj1 = PyTuple_New(1); PyTuple_SET_ITEM(obj1, 0, PyInt_FromLong(channel)); err = pcall(pymelem, "opsGetEnumItem", obj1, &res); @@ -473,8 +473,8 @@ static int get_enum_item_ops(snd_mixer_elem_t *elem, } static int set_enum_item_ops(snd_mixer_elem_t *elem, - snd_mixer_selem_channel_id_t channel, - unsigned int item) + snd_mixer_selem_channel_id_t channel, + unsigned int item) { PyObject *obj1; struct pymelem *pymelem = melem_to_pymelem(elem); @@ -486,21 +486,21 @@ static int set_enum_item_ops(snd_mixer_elem_t *elem, } static struct sm_elem_ops simple_python_ops = { - .is = is_ops, - .get_range = get_range_ops, - .get_dB_range = get_dB_range_ops, - .set_range = set_range_ops, - .ask_vol_dB = ask_vol_dB_ops, - .ask_dB_vol = ask_dB_vol_ops, - .get_volume = get_volume_ops, - .get_dB = get_dB_ops, - .set_volume = set_volume_ops, - .set_dB = set_dB_ops, - .get_switch = get_switch_ops, - .set_switch = set_switch_ops, - .enum_item_name = enum_item_name_ops, - .get_enum_item = get_enum_item_ops, - .set_enum_item = set_enum_item_ops + .is = is_ops, + .get_range = get_range_ops, + .get_dB_range = get_dB_range_ops, + .set_range = set_range_ops, + .ask_vol_dB = ask_vol_dB_ops, + .ask_dB_vol = ask_dB_vol_ops, + .get_volume = get_volume_ops, + .get_dB = get_dB_ops, + .set_volume = set_volume_ops, + .set_dB = set_dB_ops, + .get_switch = get_switch_ops, + .set_switch = set_switch_ops, + .enum_item_name = enum_item_name_ops, + .get_enum_item = get_enum_item_ops, + .set_enum_item = set_enum_item_ops }; static void selem_free(snd_mixer_elem_t *elem) @@ -578,7 +578,7 @@ pymelem_attach(struct pymelem *pymelem, PyObject *args) PyObject *obj; snd_hctl_elem_t *helem; int err; - + if (!PyArg_ParseTuple(args, "O", &obj)) return NULL; helem = (snd_hctl_elem_t *)get_C_ptr(obj, "get_C_helem"); @@ -587,7 +587,7 @@ pymelem_attach(struct pymelem *pymelem, PyObject *args) err = snd_mixer_elem_attach(pymelem->melem, helem); if (err < 0) { PyErr_Format(PyExc_RuntimeError, "Cannot attach hcontrol element to mixer element: %s", snd_strerror(err)); - return NULL; + return NULL; } Py_RETURN_NONE; } @@ -598,7 +598,7 @@ pymelem_detach(struct pymelem *pymelem, PyObject *args) PyObject *obj; snd_hctl_elem_t *helem; int err; - + if (!PyArg_ParseTuple(args, "O", &obj)) return NULL; helem = (snd_hctl_elem_t *)get_C_ptr(obj, "get_C_helem"); @@ -607,7 +607,7 @@ pymelem_detach(struct pymelem *pymelem, PyObject *args) err = snd_mixer_elem_detach(pymelem->melem, helem); if (err < 0) { PyErr_Format(PyExc_RuntimeError, "Cannot detach hcontrol element to mixer element: %s", snd_strerror(err)); - return NULL; + return NULL; } Py_RETURN_NONE; } @@ -679,14 +679,14 @@ static PyGetSetDef pymelem_getseters[] = { {"name", (getter)pymelem_get_name, NULL, NULL, NULL}, {"index", (getter)pymelem_get_index, NULL, NULL, NULL}, - + {NULL,NULL,NULL,NULL,NULL} }; static PyMethodDef pymelem_methods[] = { {"attach", (PyCFunction)pymelem_attach, METH_VARARGS, NULL}, {"detach", (PyCFunction)pymelem_detach, METH_VARARGS, NULL}, - + /* "default" functions - no functionality */ {"opsIsActive", (PyCFunction)pymelem_ignore1, METH_VARARGS, NULL}, {"opsIsMono", (PyCFunction)pymelem_ignore, METH_VARARGS, NULL}, @@ -695,7 +695,7 @@ static PyMethodDef pymelem_methods[] = { {"opsIsEnumCnt", (PyCFunction)pymelem_ignore, METH_VARARGS, NULL}, {"opsGetDB", (PyCFunction)pymelem_error, METH_VARARGS, NULL}, - + {"eventInfo", (PyCFunction)pymelem_event_info, METH_VARARGS, NULL}, {"eventValue", (PyCFunction)pymelem_event_value, METH_VARARGS, NULL}, @@ -703,18 +703,18 @@ static PyMethodDef pymelem_methods[] = { }; static PyTypeObject pymelem_type = { - PyVarObject_HEAD_INIT(NULL, 0) - tp_name: "smixer_python.InternalMElement", - tp_basicsize: sizeof(struct pymelem), - tp_dealloc: (destructor)pymelem_dealloc, - tp_flags: Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - tp_doc: NULL /* mixerinit__doc__ */, - tp_getset: pymelem_getseters, - tp_init: (initproc)pymelem_init, - tp_alloc: PyType_GenericAlloc, - tp_new: PyType_GenericNew, - tp_free: PyObject_Del, - tp_methods: pymelem_methods, + PyVarObject_HEAD_INIT(NULL, 0) + tp_name: "smixer_python.InternalMElement", + tp_basicsize: sizeof(struct pymelem), + tp_dealloc: (destructor)pymelem_dealloc, + tp_flags: Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + tp_doc: NULL /* mixerinit__doc__ */, + tp_getset: pymelem_getseters, + tp_init: (initproc)pymelem_init, + tp_alloc: PyType_GenericAlloc, + tp_new: PyType_GenericNew, + tp_free: PyObject_Del, + tp_methods: pymelem_methods, }; static PyObject * @@ -724,7 +724,7 @@ pymixer_attach_hctl(struct pymixer *pymixer, PyObject *args) snd_hctl_t *hctl; void **hctls; int err; - + if (!PyArg_ParseTuple(args, "O", &obj)) return NULL; hctl = (snd_hctl_t *)get_C_ptr(obj, "get_C_hctl"); @@ -752,7 +752,7 @@ static PyObject * pymixer_register(struct pymixer *pymixer, PyObject *args) { int err; - + if (!PyArg_ParseTuple(args, "")) return NULL; err = snd_mixer_class_register(pymixer->class, pymixer->mixer); @@ -769,7 +769,7 @@ pymixer_melement_new(struct pymixer *pymixer, PyObject *args) PyObject *obj, *obj1, *obj2; char *class, *name; long index, weight; - + if (!PyArg_ParseTuple(args, "ssii", &class, &name, &index, &weight)) return NULL; obj = PyDict_GetItemString(pymixer->mdict, class); @@ -808,14 +808,14 @@ pymixer_melement_add(struct pymixer *pymixer, PyObject *args) PyObject *obj; struct pymelem *pymelem; int err; - + if (!PyArg_ParseTuple(args, "O", &obj)) return NULL; pymelem = (struct pymelem *)obj; err = snd_mixer_elem_add(pymelem->melem, pymixer->class); if (err < 0) { PyErr_Format(PyExc_RuntimeError, "Cannot add mixer element: %s", snd_strerror(err)); - return NULL; + return NULL; } Py_RETURN_NONE; } @@ -842,7 +842,7 @@ static void pymixer_free(struct pymixer *self) { int idx; - + for (idx = 0; idx < self->hctl_count; idx++) { snd_mixer_detach_hctl(self->mixer, self->hctl[idx*2]); Py_DECREF((PyObject *)self->hctl[idx*2+1]); @@ -884,18 +884,18 @@ static PyMethodDef pymixer_methods[] = { }; static PyTypeObject pymixer_type = { - PyVarObject_HEAD_INIT(NULL, 0) - tp_name: "smixer_python.InternalMixer", - tp_basicsize: sizeof(struct pymixer), - tp_dealloc: (destructor)pymixer_dealloc, - tp_flags: Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - tp_doc: NULL /* mixerinit__doc__ */, - tp_getset: pymixer_getseters, - tp_init: (initproc)pymixer_init, - tp_alloc: PyType_GenericAlloc, - tp_new: PyType_GenericNew, - tp_free: PyObject_Del, - tp_methods: pymixer_methods, + PyVarObject_HEAD_INIT(NULL, 0) + tp_name: "smixer_python.InternalMixer", + tp_basicsize: sizeof(struct pymixer), + tp_dealloc: (destructor)pymixer_dealloc, + tp_flags: Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + tp_doc: NULL /* mixerinit__doc__ */, + tp_getset: pymixer_getseters, + tp_init: (initproc)pymixer_init, + tp_alloc: PyType_GenericAlloc, + tp_new: PyType_GenericNew, + tp_free: PyObject_Del, + tp_methods: pymixer_methods, }; static PyMethodDef python_methods[] = { @@ -984,20 +984,20 @@ int alsa_mixer_simple_event(snd_mixer_class_t *class, unsigned int mask, tstate = PyThreadState_New(main_interpreter); PyThreadState_Swap(tstate); - - t = PyTuple_New(3); - if (t) { - PyTuple_SET_ITEM(t, 0, (PyObject *)PyInt_FromLong(mask)); - o = find_helem(priv, helem); - if (mask & SND_CTL_EVENT_MASK_ADD) { - if (o == NULL) - o = new_helem(priv, helem); + + t = PyTuple_New(3); + if (t) { + PyTuple_SET_ITEM(t, 0, (PyObject *)PyInt_FromLong(mask)); + o = find_helem(priv, helem); + if (mask & SND_CTL_EVENT_MASK_ADD) { + if (o == NULL) + o = new_helem(priv, helem); } - if (o == NULL) - return 0; + if (o == NULL) + return 0; PyTuple_SET_ITEM(t, 1, o); Py_INCREF(o); - o = melem ? find_melem(priv, melem) : Py_None; + o = melem ? find_melem(priv, melem) : Py_None; PyTuple_SET_ITEM(t, 2, o); Py_INCREF(o); r = PyObject_CallObject(priv->py_event_func, t); @@ -1019,7 +1019,7 @@ int alsa_mixer_simple_event(snd_mixer_class_t *class, unsigned int mask, res = -EIO; } } - + return res; } @@ -1039,8 +1039,8 @@ static void alsa_mixer_simple_free(snd_mixer_class_t *class) } static int alsa_mixer_simple_pyinit(struct python_priv *priv, - PyObject *py_mod, - FILE *fp, + PyObject *py_mod, + FILE *fp, const char *file, snd_mixer_class_t *class, snd_mixer_t *mixer, @@ -1091,15 +1091,15 @@ static int alsa_mixer_simple_pyinit(struct python_priv *priv, #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef smixer_python_module = { - PyModuleDef_HEAD_INIT, - "smixer_python", - NULL, - 0, - python_methods, - NULL, - NULL, - NULL, - NULL + PyModuleDef_HEAD_INIT, + "smixer_python", + NULL, + 0, + python_methods, + NULL, + NULL, + NULL, + NULL }; #endif @@ -1131,7 +1131,7 @@ int alsa_mixer_simple_finit(snd_mixer_class_t *class, snd_error(MIXER, "Unable to find python module '%s'", file); return -ENODEV; } - + Py_Initialize(); if (PyType_Ready(&pymelem_type) < 0 || PyType_Ready(&pymixer_type) < 0) { diff --git a/modules/mixer/simple/sbase.c b/modules/mixer/simple/sbase.c index 29c853a0..f2687a24 100644 --- a/modules/mixer/simple/sbase.c +++ b/modules/mixer/simple/sbase.c @@ -43,7 +43,7 @@ static int selem_read(snd_mixer_elem_t *elem); static unsigned int chanmap_to_channels(unsigned int chanmap) { unsigned int i, res; - + for (i = 0, res = 0; i < MAX_CHANNEL; i++) if (chanmap & (1 << i)) res++; @@ -61,11 +61,11 @@ static long to_user(struct selem_base *s, int dir, struct helem_base *c, long va } static long from_user(struct selem_base *s, int dir, struct helem_base *c, long value) -{ - int64_t n; +{ + int64_t n; if (s->dir[dir].max == s->dir[dir].min) return c->min; - n = (int64_t) (value - s->dir[dir].min) * (c->max - c->min); + n = (int64_t) (value - s->dir[dir].min) * (c->max - c->min); return c->min + (n + (s->dir[dir].max - s->dir[dir].min) / 2) / (s->dir[dir].max - s->dir[dir].min); } #endif @@ -77,7 +77,7 @@ static void update_ranges(struct selem_base *s) unsigned int dir, ok_flag; struct list_head *pos; struct helem_base *helem; - + for (dir = 0; dir < 2; dir++) { s->dir[dir].min = 0; s->dir[dir].max = 0; @@ -139,7 +139,7 @@ static int is_ops(snd_mixer_elem_t *elem, int dir, int cmd, int val) helem = list_entry(s->helems.next, struct helem_base, list); return !!(helem->purpose == PURPOSE_ENUMLIST); } - + case SM_OPS_IS_ENUMCNT: { struct helem_base *helem; helem = list_entry(s->helems.next, struct helem_base, list); @@ -147,7 +147,7 @@ static int is_ops(snd_mixer_elem_t *elem, int dir, int cmd, int val) } } - + return 1; } @@ -155,7 +155,7 @@ static int get_range_ops(snd_mixer_elem_t *elem, int dir, long *min, long *max) { struct selem_base *s = snd_mixer_elem_get_private(elem); - + *min = s->dir[dir].min; *max = s->dir[dir].max; @@ -179,7 +179,7 @@ static int set_range_ops(snd_mixer_elem_t *elem, int dir, s->dir[dir].forced_range = 1; s->dir[dir].min = min; s->dir[dir].max = max; - + if ((err = selem_read(elem)) < 0) return err; return 0; @@ -189,7 +189,7 @@ static int get_volume_ops(snd_mixer_elem_t *elem, int dir, snd_mixer_selem_channel_id_t channel, long *value) { struct selem_base *s = snd_mixer_elem_get_private(elem); - + *value = s->dir[dir].vol[channel]; return 0; } @@ -330,7 +330,7 @@ static int simple_event_add1(snd_mixer_class_t *class, struct bclass_sid *bsid; struct melem_sids *sid; unsigned int ui; - + list_for_each(pos, &priv->sids) { bsid = list_entry(pos, struct bclass_sid, list); for (ui = 0; ui < bsid->count; ui++) { @@ -361,7 +361,7 @@ static int simple_event_add1(snd_mixer_class_t *class, min = max = 0; break; } - + printf("event add: %p, %p (%s)\n", helem, sel, snd_hctl_elem_get_name(helem)); if (snd_mixer_selem_id_malloc(&id)) return -ENOMEM; @@ -374,7 +374,7 @@ static int simple_event_add1(snd_mixer_class_t *class, case PURPOSE_SWITCH: if (ctype != SND_CTL_ELEM_TYPE_BOOLEAN) { __invalid_type: - snd_mixer_selem_id_free(id); + snd_mixer_selem_id_free(id); free(hsimple); return -EINVAL; } @@ -446,9 +446,9 @@ static int simple_event_add1(snd_mixer_class_t *class, err = snd_mixer_elem_value(melem); return err; __error: - if (new) - snd_mixer_elem_free(melem); - return -EINVAL; + if (new) + snd_mixer_elem_free(melem); + return -EINVAL; } static int simple_event_add(snd_mixer_class_t *class, snd_hctl_elem_t *helem) diff --git a/modules/mixer/simple/sbasedl.c b/modules/mixer/simple/sbasedl.c index 3ad7bdf4..67a36a88 100644 --- a/modules/mixer/simple/sbasedl.c +++ b/modules/mixer/simple/sbasedl.c @@ -97,8 +97,8 @@ int mixer_simple_basic_dlopen(snd_mixer_class_t *class, return 1; __error: - if (initflag) - free(priv); + if (initflag) + free(priv); if (h) snd_dlclose(h); free(xlib); diff --git a/src/async.c b/src/async.c index 4564c723..f85980fa 100644 --- a/src/async.c +++ b/src/async.c @@ -109,7 +109,7 @@ static void snd_async_handler(int signo ATTRIBUTE_UNUSED, siginfo_t *siginfo, vo * * \see snd_async_add_pcm_handler, snd_async_add_ctl_handler */ -int snd_async_add_handler(snd_async_handler_t **handler, int fd, +int snd_async_add_handler(snd_async_handler_t **handler, int fd, snd_async_callback_t callback, void *private_data) { snd_async_handler_t *h; diff --git a/src/conf.c b/src/conf.c index ac63a1c0..357d72ba 100644 --- a/src/conf.c +++ b/src/conf.c @@ -51,7 +51,7 @@ any surplus whitespace is discarded. For example, the two sequences and \code - a 1 + a 1 b 2 \endcode @@ -255,8 +255,8 @@ name [=] value [,|;] # Compound assignment (first style) name [=] { - name1 [=] value [,|;] - ... + name1 [=] value [,|;] + ... } # Compound assignment (second style) @@ -264,9 +264,9 @@ name.name1 [=] value [,|;] # Array assignment (first style) name [ - value0 [,|;] - value1 [,|;] - ... + value0 [,|;] + value1 [,|;] + ... ] # Array assignment (second style) @@ -377,7 +377,7 @@ values in the current compound are used as configuration for the function. If the compound func.\ is defined in the root node, then the library and function from this compound configuration are used, otherwise 'snd_func_' is prefixed to the string and code from the ALSA library is used. -The definition of a function looks like:

+The definition of a function looks like:

\code func.remove_first_char { @@ -868,10 +868,10 @@ static int get_char_skip_comments(input_t *input) break; } } - + return c; } - + static int get_nonwhite(input_t *input) { @@ -1057,7 +1057,7 @@ static int get_freestring(char **string, int id, input_t *input) free_local_string(&str); return c; } - + static int get_delimstring(char **string, int delim, input_t *input) { struct local_string str; @@ -1145,7 +1145,7 @@ static int _snd_config_make(snd_config_t **config, char **id, snd_config_type_t *config = n; return 0; } - + static int _snd_config_make_add(snd_config_t **config, char **id, snd_config_type_t type, snd_config_t *parent) @@ -1162,7 +1162,7 @@ static int _snd_config_make_add(snd_config_t **config, char **id, return 0; } -static int _snd_config_search(snd_config_t *config, +static int _snd_config_search(snd_config_t *config, const char *id, int len, snd_config_t **result) { snd_config_iterator_t i, next; @@ -1225,16 +1225,16 @@ static int parse_value(snd_config_t **_n, snd_config_t *parent, input_t *input, return -EINVAL; } } else { - if (i <= INT_MAX) + if (i <= INT_MAX) err = _snd_config_make_add(&n, id, SND_CONFIG_TYPE_INTEGER, parent); else err = _snd_config_make_add(&n, id, SND_CONFIG_TYPE_INTEGER64, parent); if (err < 0) return err; } - if (n->type == SND_CONFIG_TYPE_INTEGER) + if (n->type == SND_CONFIG_TYPE_INTEGER) n->u.integer = (long) i; - else + else n->u.integer64 = i; *_n = n; return 0; @@ -1341,7 +1341,7 @@ static int parse_array_def(snd_config_t *parent, input_t *input, int *idx, int s err = 0; __end: free(id); - return err; + return err; } static int parse_array_defs(snd_config_t *parent, input_t *input, int skip, int override) @@ -1505,7 +1505,7 @@ static int parse_def(snd_config_t *parent, input_t *input, int skip, int overrid free(id); return err; } - + static int parse_defs(snd_config_t *parent, input_t *input, int skip, int override) { int c, err; @@ -2774,7 +2774,7 @@ __make: int snd_config_imake_integer(snd_config_t **config, const char *id, const long value) { int err; - + err = snd_config_make(config, id, SND_CONFIG_TYPE_INTEGER); if (err < 0) return err; @@ -2804,7 +2804,7 @@ int snd_config_imake_integer(snd_config_t **config, const char *id, const long v int snd_config_imake_integer64(snd_config_t **config, const char *id, const long long value) { int err; - + err = snd_config_make(config, id, SND_CONFIG_TYPE_INTEGER64); if (err < 0) return err; @@ -2831,7 +2831,7 @@ int snd_config_imake_integer64(snd_config_t **config, const char *id, const long int snd_config_imake_real(snd_config_t **config, const char *id, const double value) { int err; - + err = snd_config_make(config, id, SND_CONFIG_TYPE_REAL); if (err < 0) return err; @@ -2862,7 +2862,7 @@ int snd_config_imake_string(snd_config_t **config, const char *id, const char *v { int err; snd_config_t *tmp; - + err = snd_config_make(&tmp, id, SND_CONFIG_TYPE_STRING); if (err < 0) return err; @@ -2950,7 +2950,7 @@ int snd_config_imake_safe_string(snd_config_t **config, const char *id, const ch int snd_config_imake_pointer(snd_config_t **config, const char *id, const void *value) { int err; - + err = snd_config_make(config, id, SND_CONFIG_TYPE_POINTER); if (err < 0) return err; @@ -4422,7 +4422,7 @@ static int _snd_config_hook_table(snd_config_t *root, snd_config_t *config, snd_ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config, snd_config_t **dst, snd_config_t *private_data ATTRIBUTE_UNUSED) { int card = -1, err; - + do { err = snd_card_next(&card); if (err < 0) @@ -4478,7 +4478,7 @@ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config, SND_DLSYM_BUILD_VERSION(snd_config_hook_load_for_all_cards, SND_CONFIG_DLSYM_VERSION_HOOK); #endif -/** +/** * \brief Updates a configuration tree by rereading the configuration files (if needed). * \param[in,out] _top Address of the handle to the top-level node. * \param[in,out] _update Address of a pointer to private update information. @@ -4514,7 +4514,7 @@ int snd_config_update_r(snd_config_t **_top, snd_config_update_t **_update, cons snd_config_update_t *local; snd_config_update_t *update; snd_config_t *top; - + assert(_top && _update); top = *_top; update = *_update; @@ -4608,12 +4608,12 @@ int snd_config_update_r(snd_config_t **_top, snd_config_update_t **_update, cons return err; _reread: - *_top = NULL; - *_update = NULL; - if (update) { - snd_config_update_free(update); - update = NULL; - } + *_top = NULL; + *_update = NULL; + if (update) { + snd_config_update_free(update); + update = NULL; + } if (top) { snd_config_delete(top); top = NULL; @@ -4648,7 +4648,7 @@ int snd_config_update_r(snd_config_t **_top, snd_config_update_t **_update, cons return 1; } -/** +/** * \brief Updates #snd_config by rereading the global configuration files (if needed). * \return 0 if #snd_config was up to date, 1 if #snd_config was * updated, otherwise a negative error code. @@ -4744,7 +4744,7 @@ void snd_config_unref(snd_config_t *cfg) snd_config_unlock(); } -/** +/** * \brief Frees a private update structure. * \param[in] update The private update structure to free. * \return Zero if successful, otherwise a negative error code. @@ -4761,7 +4761,7 @@ int snd_config_update_free(snd_config_update_t *update) return 0; } -/** +/** * \brief Frees the global configuration tree in #snd_config. * \return Zero if successful, otherwise a negative error code. * @@ -4881,7 +4881,7 @@ typedef int (*snd_config_walk_callback_t)(snd_config_t *src, static int snd_config_walk(snd_config_t *src, snd_config_t *root, - snd_config_t **dst, + snd_config_t **dst, snd_config_walk_callback_t callback, snd_config_expand_fcn_t fcn, void *private_data) @@ -5221,7 +5221,7 @@ static int _snd_config_evaluate(snd_config_t *src, * replaces those nodes with the respective function results. */ int snd_config_evaluate(snd_config_t *config, snd_config_t *root, - snd_config_t *private_data, snd_config_t **result) + snd_config_t *private_data, snd_config_t **result) { /* FIXME: Only in place evaluation is currently implemented */ assert(result == NULL); @@ -5408,7 +5408,7 @@ static int parse_string(const char **ptr, char **val) buf[idx++] = c; } } - + /* Parse var=val or val */ static int parse_arg(const char **ptr, unsigned int *varlen, char **val) @@ -5508,7 +5508,7 @@ static int parse_args(snd_config_t *subs, const char *str, snd_config_t *defs) } return 0; } - + while (1) { char buf[256]; const char *var = buf; @@ -5725,7 +5725,7 @@ int snd_config_expand(snd_config_t *config, snd_config_t *root, const char *args *result = res; err = 1; _end: - if (subs) + if (subs) snd_config_delete(subs); return err; } diff --git a/src/confmisc.c b/src/confmisc.c index 39aa1f04..c1f5410c 100644 --- a/src/confmisc.c +++ b/src/confmisc.c @@ -5,7 +5,7 @@ * \author Abramo Bagnara * \author Jaroslav Kysela * \date 2000-2001 - * + * * Configuration helper functions. * * See the \ref conffunc page for more details. @@ -176,7 +176,7 @@ int snd_config_get_card(const snd_config_t *conf) * \brief Gets the control interface index from the given ASCII string. * \param ascii The string to be parsed. * \return The control interface index if successful, otherwise a negative error code. - */ + */ int snd_config_get_ctl_iface_ascii(const char *ascii) { long v; @@ -199,7 +199,7 @@ int snd_config_get_ctl_iface_ascii(const char *ascii) * \brief Gets the control interface index from a configuration node. * \param conf Handle to the configuration node to be parsed. * \return The control interface index if successful, otherwise a negative error code. - */ + */ int snd_config_get_ctl_iface(const snd_config_t *conf) { long v; @@ -251,7 +251,7 @@ int snd_config_get_ctl_iface(const snd_config_t *conf) default 0 } \endcode - */ + */ int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src, snd_config_t *private_data) { @@ -260,7 +260,7 @@ int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src, const char *res, *id; char *def = NULL; int idx = 0, err, hit; - + err = snd_config_search(src, "vars", &n); if (err < 0) { snd_error(CORE, "field vars not found"); @@ -351,7 +351,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_getenv, SND_CONFIG_DLSYM_VERSION_EVALUATE); default 0 } \endcode - */ + */ int snd_func_igetenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src, snd_config_t *private_data) { @@ -385,7 +385,7 @@ int snd_func_igetenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src, #ifndef DOC_HIDDEN SND_DLSYM_BUILD_VERSION(snd_func_igetenv, SND_CONFIG_DLSYM_VERSION_EVALUATE); #endif - + /** * \brief Merges the given strings. * \param dst The function puts the handle to the result configuration node @@ -402,7 +402,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_igetenv, SND_CONFIG_DLSYM_VERSION_EVALUATE); strings [ "a1" "b2" "c3" ] } \endcode - */ + */ int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src, snd_config_t *private_data) { @@ -411,7 +411,7 @@ int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src, const char *id; char *res = NULL, *tmp; int idx = 0, len = 0, len1, err, hit; - + err = snd_config_search(src, "strings", &n); if (err < 0) { snd_error(CORE, "field strings not found"); @@ -490,7 +490,7 @@ static int snd_func_iops(snd_config_t **dst, char *res = NULL; long result = 0, val; int idx = 0, err, hit; - + err = snd_config_search(src, "integers", &n); if (err < 0) { snd_error(CORE, "field integers not found"); @@ -556,9 +556,9 @@ static int snd_func_iops(snd_config_t **dst, integers [ 2 3 5 ] } \endcode - */ + */ int snd_func_iadd(snd_config_t **dst, snd_config_t *root, - snd_config_t *src, snd_config_t *private_data) + snd_config_t *src, snd_config_t *private_data) { return snd_func_iops(dst, root, src, private_data, 0); } @@ -582,7 +582,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_iadd, SND_CONFIG_DLSYM_VERSION_EVALUATE); integers [ 2 3 2 ] } \endcode - */ + */ int snd_func_imul(snd_config_t **dst, snd_config_t *root, snd_config_t *src, snd_config_t *private_data) { @@ -607,13 +607,13 @@ SND_DLSYM_BUILD_VERSION(snd_func_imul, SND_CONFIG_DLSYM_VERSION_EVALUATE); @func datadir } \endcode - */ + */ int snd_func_datadir(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *src, snd_config_t *private_data ATTRIBUTE_UNUSED) { int err; const char *id; - + err = snd_config_get_id(src, &id); if (err < 0) return err; @@ -683,7 +683,7 @@ notfound: @func private_string } \endcode - */ + */ int snd_func_private_string(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *src, snd_config_t *private_data) { @@ -797,7 +797,7 @@ int snd_determine_driver(int card, char **driver) @func private_card_driver } \endcode - */ + */ int snd_func_private_card_driver(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *src, snd_config_t *private_data) { @@ -834,7 +834,7 @@ static int parse_card(snd_config_t *root, snd_config_t *src, snd_config_t *n; char *str; int card, err; - + err = snd_config_search(src, "card", &n); if (err < 0) { snd_error(CORE, "field card not found"); @@ -873,13 +873,13 @@ static int parse_card(snd_config_t *root, snd_config_t *src, card '0' } \endcode - */ + */ int snd_func_card_inum(snd_config_t **dst, snd_config_t *root, snd_config_t *src, snd_config_t *private_data) { const char *id; int card, err; - + card = parse_card(root, src, private_data); if (card < 0) return card; @@ -908,13 +908,13 @@ SND_DLSYM_BUILD_VERSION(snd_func_card_inum, SND_CONFIG_DLSYM_VERSION_EVALUATE); card 0 } \endcode - */ + */ int snd_func_card_driver(snd_config_t **dst, snd_config_t *root, snd_config_t *src, snd_config_t *private_data) { snd_config_t *val; int card, err; - + card = parse_card(root, src, private_data); if (card < 0) return card; @@ -945,7 +945,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_card_driver, SND_CONFIG_DLSYM_VERSION_EVALUATE) card 0 } \endcode - */ + */ int snd_func_card_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, snd_config_t *private_data) { @@ -953,7 +953,7 @@ int snd_func_card_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, snd_ctl_card_info_t info = {0}; const char *id; int card, err; - + card = parse_card(root, src, private_data); if (card < 0) return card; @@ -972,8 +972,8 @@ int snd_func_card_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, err = snd_config_imake_string(dst, id, snd_ctl_card_info_get_id(&info)); __error: - if (ctl) - snd_ctl_close(ctl); + if (ctl) + snd_ctl_close(ctl); return err; } #ifndef DOC_HIDDEN @@ -996,7 +996,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_card_id, SND_CONFIG_DLSYM_VERSION_EVALUATE); card 0 } \endcode - */ + */ int snd_func_card_name(snd_config_t **dst, snd_config_t *root, snd_config_t *src, snd_config_t *private_data) { @@ -1004,7 +1004,7 @@ int snd_func_card_name(snd_config_t **dst, snd_config_t *root, snd_ctl_card_info_t info = {0}; const char *id; int card, err; - + card = parse_card(root, src, private_data); if (card < 0) return card; @@ -1023,8 +1023,8 @@ int snd_func_card_name(snd_config_t **dst, snd_config_t *root, err = snd_config_imake_safe_string(dst, id, snd_ctl_card_info_get_name(&info)); __error: - if (ctl) - snd_ctl_close(ctl); + if (ctl) + snd_ctl_close(ctl); return err; } #ifndef DOC_HIDDEN @@ -1033,7 +1033,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_card_name, SND_CONFIG_DLSYM_VERSION_EVALUATE); #ifdef DOXYGEN /* For consistency with the PCM Interface module, include documentation even - * when PCM module is not included in the build. */ + * when PCM module is not included in the build. */ #ifndef BUILD_PCM #define BUILD_PCM #endif @@ -1060,7 +1060,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_card_name, SND_CONFIG_DLSYM_VERSION_EVALUATE); subdevice 0 # optional } \endcode - */ + */ int snd_func_pcm_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data) { snd_config_t *n; @@ -1069,7 +1069,7 @@ int snd_func_pcm_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, v const char *id; long card, device, subdevice = 0; int err; - + card = parse_card(root, src, private_data); if (card < 0) return card; @@ -1117,8 +1117,8 @@ int snd_func_pcm_id(snd_config_t **dst, snd_config_t *root, snd_config_t *src, v err = snd_config_imake_string(dst, id, snd_pcm_info_get_id(&info)); __error: - if (ctl) - snd_ctl_close(ctl); + if (ctl) + snd_ctl_close(ctl); return err; } #ifndef DOC_HIDDEN @@ -1144,7 +1144,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_pcm_id, SND_CONFIG_DLSYM_VERSION_EVALUATE); index 0 } \endcode - */ + */ int snd_func_pcm_args_by_class(snd_config_t **dst, snd_config_t *root, snd_config_t *src, void *private_data) { snd_config_t *n; @@ -1217,14 +1217,14 @@ int snd_func_pcm_args_by_class(snd_config_t **dst, snd_config_t *root, snd_confi index == idx++) goto __out; } - snd_ctl_close(ctl); + snd_ctl_close(ctl); ctl = NULL; } err = -ENODEV; __out: - if (ctl) - snd_ctl_close(ctl); + if (ctl) + snd_ctl_close(ctl); if (err < 0) return err; if((err = snd_config_get_id(src, &id)) >= 0) { @@ -1254,7 +1254,7 @@ SND_DLSYM_BUILD_VERSION(snd_func_pcm_args_by_class, SND_CONFIG_DLSYM_VERSION_EVA @func private_pcm_subdevice } \endcode - */ + */ int snd_func_private_pcm_subdevice(snd_config_t **dst, snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *src, snd_config_t *private_data) { @@ -1314,14 +1314,14 @@ SND_DLSYM_BUILD_VERSION(snd_func_private_pcm_subdevice, SND_CONFIG_DLSYM_VERSION name "id1.id2.id3" } \endcode - */ + */ int snd_func_refer(snd_config_t **dst, snd_config_t *root, snd_config_t *src, snd_config_t *private_data) { snd_config_t *n; const char *file = NULL, *name = NULL; int err; - + err = snd_config_search(src, "file", &n); if (err >= 0) { err = snd_config_evaluate(n, root, private_data, NULL); diff --git a/src/control/cards.c b/src/control/cards.c index a93f10a4..49e343a9 100644 --- a/src/control/cards.c +++ b/src/control/cards.c @@ -108,7 +108,7 @@ int snd_card_load(int card) int snd_card_next(int *rcard) { int card; - + if (rcard == NULL) return -EINVAL; card = *rcard; @@ -194,7 +194,7 @@ int snd_card_get_name(int card, char **name) snd_ctl_t *handle; snd_ctl_card_info_t info; int err; - + if (name == NULL) return -EINVAL; if ((err = snd_ctl_hw_open(&handle, NULL, card, 0)) < 0) @@ -224,7 +224,7 @@ int snd_card_get_longname(int card, char **name) snd_ctl_t *handle; snd_ctl_card_info_t info; int err; - + if (name == NULL) return -EINVAL; if ((err = snd_ctl_hw_open(&handle, NULL, card, 0)) < 0) diff --git a/src/control/control.c b/src/control/control.c index 18841280..a08ffea6 100644 --- a/src/control/control.c +++ b/src/control/control.c @@ -52,7 +52,7 @@ file. The format is: \verbatim index [ID ] Driver - name - longname + longname \endverbatim Note that the mixername and components are not listed. @@ -279,7 +279,7 @@ int snd_ctl_new(snd_ctl_t **ctlp, snd_ctl_type_t type, const char *name, int mod *ctlp = ctl; return 0; } - + /** * \brief set async mode @@ -353,7 +353,7 @@ int snd_ctl_poll_descriptors_revents(snd_ctl_t *ctl, struct pollfd *pfds, unsign return ctl->ops->poll_revents(ctl, pfds, nfds, revents); if (nfds == 1) { *revents = pfds->revents; - return 0; + return 0; } return -EINVAL; } @@ -1039,7 +1039,7 @@ int snd_ctl_elem_write(snd_ctl_t *ctl, snd_ctl_elem_value_t *data) static int snd_ctl_tlv_do(snd_ctl_t *ctl, int op_flag, const snd_ctl_elem_id_t *id, - unsigned int *tlv, unsigned int tlv_size) + unsigned int *tlv, unsigned int tlv_size) { snd_ctl_elem_info_t *info = NULL; int err; @@ -1060,8 +1060,8 @@ static int snd_ctl_tlv_do(snd_ctl_t *ctl, int op_flag, } err = ctl->ops->element_tlv(ctl, op_flag, id->numid, tlv, tlv_size); __err: - if (info) - free(info); + if (info) + free(info); return err; } @@ -1402,7 +1402,7 @@ int snd_ctl_wait(snd_ctl_t *ctl, int timeout) * \param private_data Callback private data * \return 0 otherwise a negative error code on failure */ -int snd_async_add_ctl_handler(snd_async_handler_t **handler, snd_ctl_t *ctl, +int snd_async_add_ctl_handler(snd_async_handler_t **handler, snd_ctl_t *ctl, snd_async_callback_t callback, void *private_data) { int err; @@ -1752,7 +1752,7 @@ int snd_ctl_elem_list_alloc_space(snd_ctl_elem_list_t *obj, unsigned int entries } obj->space = entries; return 0; -} +} /** * \brief free previously allocated space for CTL element identifiers list diff --git a/src/control/control_ext.c b/src/control/control_ext.c index f4ddb2ae..f3e91501 100644 --- a/src/control/control_ext.c +++ b/src/control/control_ext.c @@ -42,7 +42,7 @@ const char *_snd_module_control_ext = ""; static int snd_ctl_ext_close(snd_ctl_t *handle) { snd_ctl_ext_t *ext = handle->private_data; - + if (ext->callback->close) ext->callback->close(ext); return 0; @@ -458,7 +458,7 @@ static int snd_ctl_ext_poll_revents(snd_ctl_t *handle, struct pollfd *pfds, unsi return ext->callback->poll_revents(ext, pfds, nfds, revents); if (nfds == 1) { *revents = pfds->revents; - return 0; + return 0; } return -EINVAL; } @@ -529,7 +529,7 @@ usually you will call the external plugin API function #snd_ctl_ext_create(). The control handle must be filled *phandle in return. Then this function must return either a value 0 when succeeded, or a -negative value as the error code. +negative value as the error code. Finally, add #SND_CTL_PLUGIN_SYMBOL() with the name of your plugin as the argument at the end. This defines the proper versioned @@ -625,7 +625,7 @@ PCM. \section ctl_ext_impl_cb Callback Functions of External Control Plugins The callback functions in #snd_ctl_ext_callback_t define the real -behavior of the driver. There are many callbacks but many of them are optional. +behavior of the driver. There are many callbacks but many of them are optional. The close callback is called when the PCM is closed. If the plugin allocates private resources, this is the place to release them @@ -650,7 +650,7 @@ if you use get, read and write callbacks as follows. If you need to create a record dynamically (e.g. via malloc) at each find_elem call, the allocated record can be released with the optional free_key callback. -The get_attribute is a mandatory callback, which returns the attribute of the +The get_attribute is a mandatory callback, which returns the attribute of the control element given via a key value (converted with find_elem callback). It must fill the control element type (#snd_ctl_elem_type_t), the access type (#snd_ctl_ext_access_t), and the count (element array size). The callback returns diff --git a/src/control/control_hw.c b/src/control/control_hw.c index 8db38f92..962cd796 100644 --- a/src/control/control_hw.c +++ b/src/control/control_hw.c @@ -225,20 +225,20 @@ static int snd_ctl_hw_elem_tlv(snd_ctl_t *handle, int op_flag, unsigned int inum; snd_ctl_hw_t *hw = handle->private_data; struct snd_ctl_tlv *xtlv; - + /* we don't support TLV on protocol ver 2.0.3 or earlier */ if (hw->protocol < SNDRV_PROTOCOL_VERSION(2, 0, 4)) return -ENXIO; switch (op_flag) { case -1: inum = SNDRV_CTL_IOCTL_TLV_COMMAND; break; - case 0: inum = SNDRV_CTL_IOCTL_TLV_READ; break; + case 0: inum = SNDRV_CTL_IOCTL_TLV_READ; break; case 1: inum = SNDRV_CTL_IOCTL_TLV_WRITE; break; default: return -EINVAL; } xtlv = malloc(sizeof(struct snd_ctl_tlv) + tlv_size); if (xtlv == NULL) - return -ENOMEM; + return -ENOMEM; xtlv->numid = numid; xtlv->length = tlv_size; memcpy(xtlv->tlv, tlv, tlv_size); @@ -435,7 +435,7 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode) snd_ctl_hw_t *hw; int err; - *handle = NULL; + *handle = NULL; if (CHECK_SANITY(card < 0 || card >= SND_MAX_CARDS)) { snd_check(CONTROL, "Invalid card index %d", card); diff --git a/src/control/control_local.h b/src/control/control_local.h index 2afa62cc..02530e89 100644 --- a/src/control/control_local.h +++ b/src/control/control_local.h @@ -85,7 +85,7 @@ struct _snd_hctl_elem { struct _snd_hctl { snd_ctl_t *ctl; struct list_head elems; /* list of all controls */ - unsigned int alloc; + unsigned int alloc; unsigned int count; snd_hctl_elem_t **pelems; snd_hctl_compare_t compare; diff --git a/src/control/control_shm.c b/src/control/control_shm.c index 44c0df45..abf8174a 100644 --- a/src/control/control_shm.c +++ b/src/control/control_shm.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include #include #include @@ -420,7 +420,7 @@ static int make_local_socket(const char *filename) sock = socket(PF_LOCAL, SOCK_STREAM, 0); if (sock < 0) return -errno; - + addr->sun_family = AF_LOCAL; memcpy(addr->sun_path, filename, l); @@ -492,7 +492,7 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname result = -errno; goto _err; } - + shm = calloc(1, sizeof(snd_ctl_shm_t)); if (!shm) { result = -ENOMEM; diff --git a/src/control/control_symbols.c b/src/control/control_symbols.c index 5e6c4e9f..cf97c65c 100644 --- a/src/control/control_symbols.c +++ b/src/control/control_symbols.c @@ -31,7 +31,7 @@ static const char **snd_control_open_objects[] = { &_snd_module_control_empty, #include "ctl_symbols_list.c" }; - + void *snd_control_open_symbols(void) { return snd_control_open_objects; diff --git a/src/control/ctlparse.c b/src/control/ctlparse.c index ecb5cf91..b23234d7 100644 --- a/src/control/ctlparse.c +++ b/src/control/ctlparse.c @@ -253,7 +253,7 @@ int __snd_ctl_ascii_elem_id_parse(snd_ctl_elem_id_t *dst, const char *str, if (*str) goto out; } - } + } err = 0; out: @@ -277,12 +277,12 @@ int snd_ctl_ascii_elem_id_parse(snd_ctl_elem_id_t *dst, const char *str) static int get_ctl_enum_item_index(snd_ctl_t *handle, snd_ctl_elem_info_t *info, const char **ptrp) -{ +{ char *ptr = (char *)*ptrp; int items, i, len; const char *name; char end; - + items = snd_ctl_elem_info_get_items(info); if (items <= 0) return -1; @@ -362,7 +362,7 @@ int snd_ctl_ascii_value_parse(snd_ctl_t *handle, if (count > get_ctl_type_max_elements(type)) count = get_ctl_type_max_elements(type); - + for (idx = 0; idx < count && ptr && *ptr; idx++) { if (*ptr == ',') goto skip; diff --git a/src/control/hcontrol.c b/src/control/hcontrol.c index ec842926..5f985faa 100644 --- a/src/control/hcontrol.c +++ b/src/control/hcontrol.c @@ -71,7 +71,7 @@ int snd_hctl_open(snd_hctl_t **hctlp, const char *name, int mode) { snd_ctl_t *ctl; int err; - + if ((err = snd_ctl_open(&ctl, name, mode)) < 0) return err; err = snd_hctl_open_ctl(hctlp, ctl); @@ -294,7 +294,7 @@ static int get_compare_weight(const snd_ctl_elem_id_t *id) }; const char *name = (char *)id->name, *name1; int res, res1; - + if ((res = snd_hctl_compare_mixer_priority_lookup((const char **)&name, names, 1000000)) == NOT_FOUND) return NOT_FOUND; if (*name == '\0') @@ -346,7 +346,7 @@ static int _snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *id, in static int snd_hctl_elem_add(snd_hctl_t *hctl, snd_hctl_elem_t *elem) { int dir; - int idx; + int idx; elem->compare_weight = get_compare_weight(&elem->id); if (hctl->count == hctl->alloc) { snd_hctl_elem_t **h; @@ -677,7 +677,7 @@ int snd_hctl_wait(snd_hctl_t *hctl, int timeout) struct pollfd *pfd; unsigned short *revents; int i, npfds, pollio, err, err_poll; - + npfds = snd_hctl_poll_descriptors_count(hctl); if (npfds <= 0 || npfds >= 16) { snd_error(CONTROL, "Invalid poll_fds %d", npfds); @@ -781,7 +781,7 @@ int snd_hctl_handle_events(snd_hctl_t *hctl) snd_ctl_event_t event; int res; unsigned int count = 0; - + assert(hctl); assert(hctl->ctl); while ((res = snd_ctl_read(hctl->ctl, &event)) != 0 && diff --git a/src/control/namehint.c b/src/control/namehint.c index e7e4e912..4b2f98b6 100644 --- a/src/control/namehint.c +++ b/src/control/namehint.c @@ -37,7 +37,7 @@ struct hint_list { const char *siface; snd_ctl_elem_iface_t iface; snd_ctl_t *ctl; - snd_ctl_card_info_t *info; + snd_ctl_card_info_t *info; int card; int device; long device_input; @@ -173,7 +173,7 @@ static char *get_dev_name(struct hint_list *list) { char *str1, *str2, *res; int device; - + device = list->device_input >= 0 ? list->device_input : list->device; if (get_dev_name1(list, &str1, device, 1) < 0) return NULL; @@ -261,7 +261,7 @@ static int try_config(snd_config_t *config, snd_config_get_string(cfg, &str) >= 0 && ((strncmp(base, str, strlen(base)) == 0 && str[strlen(base)] == '.') || strchr(str, '.') == NULL)) - goto __skip_add; + goto __skip_add; if (list->card >= 0 && list->device >= 0) sprintf(buf, "%s:CARD=%s,DEV=%i", name, snd_ctl_card_info_get_id(list->info), list->device); else if (list->card >= 0) @@ -294,7 +294,7 @@ static int try_config(snd_config_t *config, cfg1 = res; level = 0; __hint: - level++; + level++; if (snd_config_search(cfg1, "type", &cfg) >= 0 && snd_config_get_string(cfg, &str) >= 0 && strcmp(str, "hw") == 0) { @@ -306,7 +306,7 @@ static int try_config(snd_config_t *config, } } } - + if (snd_config_search(cfg1, "hint", &cfg) >= 0) { if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { snd_error(CONTROL, "hint (%s) must be a compound", buf); @@ -363,7 +363,7 @@ static int try_config(snd_config_t *config, goto __skip_add; if (snd_config_search(cfg1, "slave", &cfg) >= 0 && snd_config_search(cfg, base, &cfg1) >= 0) - goto __hint; + goto __hint; snd_config_delete(res); res = NULL; cleanup_res = 0; @@ -395,38 +395,38 @@ static int try_config(snd_config_t *config, __ok: err = 0; __cleanup: - if (err >= 0) { - list->device = dev; - str = list->card >= 0 ? get_dev_name(list) : NULL; - if (str != NULL) { - level = (buf1 == NULL ? 0 : strlen(buf1)) + 1 + strlen(str); - buf2 = realloc((char *)str, level + 1); - if (buf2 != NULL) { - if (buf1 != NULL) { - str = strchr(buf2, '|'); - if (str != NULL) + if (err >= 0) { + list->device = dev; + str = list->card >= 0 ? get_dev_name(list) : NULL; + if (str != NULL) { + level = (buf1 == NULL ? 0 : strlen(buf1)) + 1 + strlen(str); + buf2 = realloc((char *)str, level + 1); + if (buf2 != NULL) { + if (buf1 != NULL) { + str = strchr(buf2, '|'); + if (str != NULL) memmove(buf2 + (level - strlen(str)), str, strlen(str)); else str = buf2 + strlen(buf2); - *(char *)str++ = '\n'; - memcpy((char *)str, buf1, strlen(buf1)); - buf2[level] = '\0'; + *(char *)str++ = '\n'; + memcpy((char *)str, buf1, strlen(buf1)); + buf2[level] = '\0'; free(buf1); } buf1 = buf2; } else { free((char *)str); } - } else if (list->device >= 0) - goto __skip_add; - err = hint_list_add(list, buf, buf1); + } else if (list->device >= 0) + goto __skip_add; + err = hint_list_add(list, buf, buf1); } __skip_add: if (res && cleanup_res) - snd_config_delete(res); + snd_config_delete(res); if (buf1) free(buf1); - free(buf); + free(buf); return err; } @@ -455,7 +455,7 @@ static int add_card(snd_config_t *config, snd_config_t *rw_config, struct hint_l char ctl_name[16]; snd_ctl_card_info_t info = {0}; int device, max_device = 0; - + list->info = &info; err = snd_config_search(config, list->siface, &conf); if (err < 0) @@ -471,7 +471,7 @@ static int add_card(snd_config_t *config, snd_config_t *rw_config, struct hint_l n = snd_config_iterator_entry(i); if (snd_config_get_id(n, &str) < 0) continue; - + if (next_devices[list->iface] != NULL) { list->card = card; device = max_device = -1; @@ -510,7 +510,7 @@ static int add_card(snd_config_t *config, snd_config_t *rw_config, struct hint_l } err = 0; __error: - snd_ctl_close(list->ctl); + snd_ctl_close(list->ctl); return err; } @@ -665,9 +665,9 @@ int snd_device_name_hint(int card, const char *iface, void ***hints) if (!err && !list.list) err = hint_list_add(&list, NULL, NULL); if (err < 0) - snd_device_name_free_hint((void **)list.list); + snd_device_name_free_hint((void **)list.list); else - *hints = (void **)list.list; + *hints = (void **)list.list; free(list.cardname); if (local_config_rw) snd_config_delete(local_config_rw); @@ -726,7 +726,7 @@ char *snd_device_name_get_hint(const void *hint, const char *id) return NULL; hint1 = delim + 1; continue; - } + } if (delim == NULL) return strdup(hint1 + 4); size = delim - hint1 - 4; diff --git a/src/control/setup.c b/src/control/setup.c index adcd00c2..7ae7b3e9 100644 --- a/src/control/setup.c +++ b/src/control/setup.c @@ -564,14 +564,14 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da if (err < 0) goto _err; } - + err = snd_config_get_ctl_elem_value(value, h->ctl, elem->val, elem->mask, elem->info); if (err < 0) goto _err; list_add_tail(&elem->list, &h->elems); _err: - if (err < 0 && elem) { + if (err < 0 && elem) { if (elem->id) snd_ctl_elem_id_free(elem->id); if (elem->info) diff --git a/src/dlmisc.c b/src/dlmisc.c index 4686ed38..2856cd7b 100644 --- a/src/dlmisc.c +++ b/src/dlmisc.c @@ -211,7 +211,7 @@ static int snd_dlsym_verify(void *handle, const char *name, const char *version) #ifdef HAVE_LIBDL int res; char *vname; - + if (handle == NULL) return -EINVAL; vname = alloca(1 + strlen(name) + strlen(version) + 1); @@ -332,8 +332,8 @@ snd_dlobj_cache_get0(const char *lib, const char *name, errbuf[0] = '\0'; dlobj = INTERNAL(snd_dlopen)(lib, RTLD_NOW, - verbose ? errbuf : 0, - verbose ? sizeof(errbuf) : 0); + verbose ? errbuf : 0, + verbose ? sizeof(errbuf) : 0); if (dlobj == NULL) { if (verbose) snd_error(CORE, "Cannot open shared library %s (%s)", diff --git a/src/hwdep/hwdep.c b/src/hwdep/hwdep.c index 82f09434..8c4a94ea 100644 --- a/src/hwdep/hwdep.c +++ b/src/hwdep/hwdep.c @@ -209,7 +209,7 @@ int snd_hwdep_open_lconf(snd_hwdep_t **hwdep, const char *name, int snd_hwdep_close(snd_hwdep_t *hwdep) { int err; - assert(hwdep); + assert(hwdep); err = hwdep->ops->close(hwdep); if (hwdep->dl_handle) snd_dlclose(hwdep->dl_handle); @@ -296,14 +296,14 @@ int snd_hwdep_poll_descriptors(snd_hwdep_t *hwdep, struct pollfd *pfds, unsigned */ int snd_hwdep_poll_descriptors_revents(snd_hwdep_t *hwdep, struct pollfd *pfds, unsigned int nfds, unsigned short *revents) { - assert(hwdep && pfds && revents); - if (nfds == 1) { - *revents = pfds->revents; - return 0; - } - return -EINVAL; -} - + assert(hwdep && pfds && revents); + if (nfds == 1) { + *revents = pfds->revents; + return 0; + } + return -EINVAL; +} + /** * \brief set nonblock mode * \param hwdep HwDep handle diff --git a/src/hwdep/hwdep_hw.c b/src/hwdep/hwdep_hw.c index 8e2ef1c5..01bce05e 100644 --- a/src/hwdep/hwdep_hw.c +++ b/src/hwdep/hwdep_hw.c @@ -111,7 +111,7 @@ int snd_hwdep_hw_open(snd_hwdep_t **handle, const char *name, int card, int devi assert(handle); *handle = NULL; - + if (card < 0 || card >= SND_MAX_CARDS) return -EINVAL; sprintf(filename, SNDRV_FILE_HWDEP, card, device); diff --git a/src/hwdep/hwdep_symbols.c b/src/hwdep/hwdep_symbols.c index d6f74fa6..77005a35 100644 --- a/src/hwdep/hwdep_symbols.c +++ b/src/hwdep/hwdep_symbols.c @@ -25,7 +25,7 @@ extern const char *_snd_module_hwdep_hw; static const char **snd_hwdep_open_objects[] = { &_snd_module_hwdep_hw }; - + void *snd_hwdep_open_symbols(void) { return snd_hwdep_open_objects; diff --git a/src/input.c b/src/input.c index aa1cef5f..9bd17b0c 100644 --- a/src/input.c +++ b/src/input.c @@ -95,7 +95,7 @@ char *snd_input_gets(snd_input_t *input, char *str, size_t size) { return (input->ops->gets)(input, str, size); } - + /** * \brief Reads a character from an input handle (like \c fgetc(3)). * \param input The input handle. @@ -144,7 +144,7 @@ static char *snd_input_stdio_gets(snd_input_t *input, char *str, size_t size) snd_input_stdio_t *stdio = input->private_data; return fgets(str, (int) size, stdio->fp); } - + static int snd_input_stdio_getc(snd_input_t *input) { snd_input_stdio_t *stdio = input->private_data; @@ -197,7 +197,7 @@ int snd_input_stdio_attach(snd_input_t **inputp, FILE *fp, int _close) *inputp = input; return 0; } - + /** * \brief Creates a new input object reading from a file. * \param inputp The functions puts the pointer to the new input object @@ -262,7 +262,7 @@ static char *snd_input_buffer_gets(snd_input_t *input, char *str, size_t size) *str = '\0'; return str; } - + static int snd_input_buffer_getc(snd_input_t *input) { snd_input_buffer_t *buffer = input->private_data; @@ -334,4 +334,4 @@ int snd_input_buffer_open(snd_input_t **inputp, const char *buf, ssize_t size) *inputp = input; return 0; } - + diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c index 7dd5c47a..2ec3195f 100644 --- a/src/mixer/mixer.c +++ b/src/mixer/mixer.c @@ -752,7 +752,7 @@ int snd_mixer_poll_descriptors_revents(snd_mixer_t *mixer, struct pollfd *pfds, { unsigned int idx; unsigned short res; - assert(mixer && pfds && revents); + assert(mixer && pfds && revents); if (nfds == 0) return -EINVAL; res = 0; @@ -781,7 +781,7 @@ int snd_mixer_wait(snd_mixer_t *mixer, int timeout) pfds = alloca(count * sizeof(*pfds)); if (!pfds) return -ENOMEM; - err = snd_mixer_poll_descriptors(mixer, pfds, + err = snd_mixer_poll_descriptors(mixer, pfds, (unsigned int) count); assert(err == count); } diff --git a/src/mixer/mixer_local.h b/src/mixer/mixer_local.h index 667242b4..26868f51 100644 --- a/src/mixer/mixer_local.h +++ b/src/mixer/mixer_local.h @@ -46,7 +46,7 @@ struct _snd_mixer_class { struct list_head list; snd_mixer_t *mixer; snd_mixer_event_t event; - void *private_data; + void *private_data; void (*private_free)(snd_mixer_class_t *class); snd_mixer_compare_t compare; }; diff --git a/src/mixer/simple.c b/src/mixer/simple.c index 1ef2f975..74915b56 100644 --- a/src/mixer/simple.c +++ b/src/mixer/simple.c @@ -122,7 +122,7 @@ int snd_mixer_selem_compare(const snd_mixer_elem_t *c1, const snd_mixer_elem_t * return s1->id->index - s2->id->index; } #endif - + /** * \brief Find a mixer simple element * \param mixer Mixer handle @@ -304,7 +304,7 @@ int snd_mixer_selem_get_playback_dB_range(snd_mixer_elem_t *elem, * \param min minimum volume value * \param max maximum volume value */ -int snd_mixer_selem_set_playback_volume_range(snd_mixer_elem_t *elem, +int snd_mixer_selem_set_playback_volume_range(snd_mixer_elem_t *elem, long min, long max) { CHECK_BASIC(elem); @@ -610,7 +610,7 @@ int snd_mixer_selem_get_capture_dB_range(snd_mixer_elem_t *elem, * \param min minimum volume value * \param max maximum volume value */ -int snd_mixer_selem_set_capture_volume_range(snd_mixer_elem_t *elem, +int snd_mixer_selem_set_capture_volume_range(snd_mixer_elem_t *elem, long min, long max) { CHECK_BASIC(elem); diff --git a/src/mixer/simple_abst.c b/src/mixer/simple_abst.c index 18a69f1d..7d48c8ed 100644 --- a/src/mixer/simple_abst.c +++ b/src/mixer/simple_abst.c @@ -243,7 +243,7 @@ static int find_module(snd_mixer_class_t *class, snd_config_t *top) static void private_free(snd_mixer_class_t *class) { class_priv_t *priv = snd_mixer_class_get_private(class); - + if (priv->private_free) priv->private_free(class); if (priv->dlhandle) @@ -350,7 +350,7 @@ int snd_mixer_simple_basic_register(snd_mixer_t *mixer, __error: if (top) snd_config_delete(top); - if (class) + if (class) snd_mixer_class_free(class); return err; } diff --git a/src/mixer/simple_none.c b/src/mixer/simple_none.c index 1ff4277e..4c47b168 100644 --- a/src/mixer/simple_none.c +++ b/src/mixer/simple_none.c @@ -649,7 +649,7 @@ static int selem_write_main(snd_mixer_elem_t *elem) static int selem_write(snd_mixer_elem_t *elem) { int err; - + err = selem_write_main(elem); if (err < 0) selem_read(elem); @@ -883,7 +883,7 @@ static int simple_update(snd_mixer_elem_t *melem) simple->str[SM_CAPT].max = cmax != LONG_MIN ? cmax : 0; } return 0; -} +} #ifndef DOC_HIDDEN static const struct suf { @@ -961,7 +961,7 @@ static int base_len(const char *name, selem_ctl_type_t *type) /* * Simple Mixer Operations */ - + static int _snd_mixer_selem_set_volume(snd_mixer_elem_t *elem, int dir, snd_mixer_selem_channel_id_t channel, long value) { selem_none_t *s = snd_mixer_elem_get_private(elem); @@ -971,7 +971,7 @@ static int _snd_mixer_selem_set_volume(snd_mixer_elem_t *elem, int dir, snd_mixe return 0; if (value < s->str[dir].min || value > s->str[dir].max) return 0; - if (s->selem.caps & + if (s->selem.caps & (dir == SM_PLAY ? SM_CAP_PVOLUME_JOIN : SM_CAP_CVOLUME_JOIN)) channel = 0; if (value != s->str[dir].vol[channel]) { @@ -986,7 +986,7 @@ static int _snd_mixer_selem_set_switch(snd_mixer_elem_t *elem, int dir, snd_mixe selem_none_t *s = snd_mixer_elem_get_private(elem); if ((unsigned int) channel >= s->str[dir].channels) return 0; - if (s->selem.caps & + if (s->selem.caps & (dir == SM_PLAY ? SM_CAP_PSWITCH_JOIN : SM_CAP_CSWITCH_JOIN)) channel = 0; if (value) { @@ -1006,7 +1006,7 @@ static int _snd_mixer_selem_set_switch(snd_mixer_elem_t *elem, int dir, snd_mixe static int is_ops(snd_mixer_elem_t *elem, int dir, int cmd, int val) { selem_none_t *s = snd_mixer_elem_get_private(elem); - + switch (cmd) { case SM_OPS_IS_ACTIVE: { @@ -1034,7 +1034,7 @@ static int is_ops(snd_mixer_elem_t *elem, int dir, int cmd, int val) if (s->selem.caps & (SM_CAP_CENUM | SM_CAP_PENUM) ) return 1; return 0; - + case SM_OPS_IS_ENUMCNT: /* Both */ if ( (s->selem.caps & (SM_CAP_CENUM | SM_CAP_PENUM)) == (SM_CAP_CENUM | SM_CAP_PENUM) ) { @@ -1054,7 +1054,7 @@ static int is_ops(snd_mixer_elem_t *elem, int dir, int cmd, int val) } } - + return 1; } @@ -1174,7 +1174,7 @@ static int get_dB_range(snd_hctl_elem_t *ctl, struct selem_str *rec, return snd_tlv_get_dB_range(rec->db_info, rec->min, rec->max, min, max); } - + static int get_dB_range_ops(snd_mixer_elem_t *elem, int dir, long *min, long *max) { @@ -1215,9 +1215,9 @@ static int ask_vol_dB_ops(snd_mixer_elem_t *elem, } static int get_dB_ops(snd_mixer_elem_t *elem, - int dir, - snd_mixer_selem_channel_id_t channel, - long *value) + int dir, + snd_mixer_selem_channel_id_t channel, + long *value) { selem_none_t *s = snd_mixer_elem_get_private(elem); selem_ctl_t *c; @@ -1264,7 +1264,7 @@ static int set_volume_ops(snd_mixer_elem_t *elem, int dir, } static int ask_dB_vol_ops(snd_mixer_elem_t *elem, int dir, - long dbValue, long *value, int xdir) + long dbValue, long *value, int xdir) { selem_none_t *s = snd_mixer_elem_get_private(elem); selem_ctl_t *c; @@ -1446,7 +1446,7 @@ static int simple_add1(snd_mixer_class_t *class, const char *name, if (ctype == SND_CTL_ELEM_TYPE_ENUMERATED) type = CTL_GLOBAL_ENUM; else if (ctype != SND_CTL_ELEM_TYPE_BOOLEAN && - ctype != SND_CTL_ELEM_TYPE_INTEGER) + ctype != SND_CTL_ELEM_TYPE_INTEGER) return 0; break; case CTL_GLOBAL_ROUTE: diff --git a/src/names.c b/src/names.c index 922ef781..0214727d 100644 --- a/src/names.c +++ b/src/names.c @@ -35,7 +35,7 @@ #include #include -/** +/** * \brief This function is unimplemented. * \deprecated Since 1.0.14 */ diff --git a/src/output.c b/src/output.c index 0e402b51..e9c414df 100644 --- a/src/output.c +++ b/src/output.c @@ -100,7 +100,7 @@ int snd_output_puts(snd_output_t *output, const char *str) { return output->ops->puts(output, str); } - + /** * \brief Writes a character to an output handle (like \c putc(3)). * \param output The output handle. @@ -152,7 +152,7 @@ static int snd_output_stdio_puts(snd_output_t *output, const char *str) snd_output_stdio_t *stdio = output->private_data; return fputs(str, stdio->fp); } - + static int snd_output_stdio_putc(snd_output_t *output, int c) { snd_output_stdio_t *stdio = output->private_data; @@ -206,7 +206,7 @@ int snd_output_stdio_attach(snd_output_t **outputp, FILE *fp, int _close) *outputp = output; return 0; } - + /** * \brief Creates a new output object writing to a file. * \param outputp The function puts the pointer to the new output object @@ -307,7 +307,7 @@ static int snd_output_buffer_puts(snd_output_t *output, const char *str) buffer->size += size; return size; } - + static int snd_output_buffer_putc(snd_output_t *output, int c) { snd_output_buffer_t *buffer = output->private_data; diff --git a/src/pcm/interval.c b/src/pcm/interval.c index 719e5086..cc43b959 100644 --- a/src/pcm/interval.c +++ b/src/pcm/interval.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #define SND_INTERVAL_C #define SND_INTERVAL_INLINE @@ -32,7 +32,7 @@ static inline void div64_32(uint64_t *n, uint32_t d, uint32_t *rem) *n /= d; } -static inline unsigned int div32(unsigned int a, unsigned int b, +static inline unsigned int div32(unsigned int a, unsigned int b, unsigned int *r) { if (b == 0) { @@ -378,7 +378,7 @@ void snd_interval_print(const snd_interval_t *i, snd_output_t *out) { if (snd_interval_empty(i)) snd_output_printf(out, "NONE"); - else if (i->min == 0 && i->openmin == 0 && + else if (i->min == 0 && i->openmin == 0 && i->max == UINT_MAX && i->openmax == 0) snd_output_printf(out, "ALL"); else if (snd_interval_single(i) && i->integer) diff --git a/src/pcm/interval.h b/src/pcm/interval.h index 04996c9f..b7a76123 100644 --- a/src/pcm/interval.h +++ b/src/pcm/interval.h @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + typedef struct _snd_interval snd_interval_t; #ifdef SND_INTERVAL_INLINE @@ -62,9 +62,9 @@ void snd_interval_add(const snd_interval_t *a, const snd_interval_t *b, snd_inte void snd_interval_sub(const snd_interval_t *a, const snd_interval_t *b, snd_interval_t *c); void snd_interval_mul(const snd_interval_t *a, const snd_interval_t *b, snd_interval_t *c); void snd_interval_div(const snd_interval_t *a, const snd_interval_t *b, snd_interval_t *c); -void snd_interval_muldiv(const snd_interval_t *a, const snd_interval_t *b, +void snd_interval_muldiv(const snd_interval_t *a, const snd_interval_t *b, const snd_interval_t *c, snd_interval_t *d); -void snd_interval_muldivk(const snd_interval_t *a, const snd_interval_t *b, +void snd_interval_muldivk(const snd_interval_t *a, const snd_interval_t *b, unsigned int k, snd_interval_t *c); void snd_interval_mulkdiv(const snd_interval_t *a, unsigned int k, const snd_interval_t *b, snd_interval_t *c); diff --git a/src/pcm/interval_inline.h b/src/pcm/interval_inline.h index d9a30b2a..2c2c0a3e 100644 --- a/src/pcm/interval_inline.h +++ b/src/pcm/interval_inline.h @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #define INTERVAL_INLINE static inline INTERVAL_INLINE void snd_interval_any(snd_interval_t *i) @@ -50,7 +50,7 @@ INTERVAL_INLINE int snd_interval_empty(const snd_interval_t *i) INTERVAL_INLINE int snd_interval_single(const snd_interval_t *i) { assert(!snd_interval_empty(i)); - return (i->min == i->max || + return (i->min == i->max || (i->min + 1 == i->max && (i->openmin || i->openmax))); } @@ -146,8 +146,8 @@ INTERVAL_INLINE int snd_interval_always_eq(const snd_interval_t *i1, const snd_i INTERVAL_INLINE int snd_interval_never_eq(const snd_interval_t *i1, const snd_interval_t *i2) { - - return (i1->max < i2->min || + + return (i1->max < i2->min || (i1->max == i2->min && (i1->openmax || i1->openmin)) || i1->min > i2->max || diff --git a/src/pcm/ladspa.h b/src/pcm/ladspa.h index 5c30a8a4..e8d4d373 100644 --- a/src/pcm/ladspa.h +++ b/src/pcm/ladspa.h @@ -3,17 +3,17 @@ Linux Audio Developer's Simple Plugin API Version 1.1[LGPL]. Copyright (C) 2000-2002 Richard W.E. Furse, Paul Barton-Davis, Stefan Westerfeld. - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -32,7 +32,7 @@ extern "C" { /*****************************************************************************/ -/* Overview: +/* Overview: There is a large number of synthesis packages in use or development on the Linux platform at this time. This API (`The Linux Audio @@ -76,7 +76,7 @@ extern "C" { /* Fundamental data type passed in and out of plugin. This data type is used to communicate audio samples and control values. It is assumed that the plugin will work sensibly given any numeric input - value although it may have a preferred range (see hints below). + value although it may have a preferred range (see hints below). For audio it is generally assumed that 1.0f is the `0dB' reference amplitude and is a `normal' signal level. */ @@ -85,8 +85,8 @@ typedef float LADSPA_Data; /*****************************************************************************/ -/* Special Plugin Properties: - +/* Special Plugin Properties: + Optional features of the plugin type are encapsulated in the LADSPA_Properties type. This is assembled by ORing individual properties together. */ @@ -122,7 +122,7 @@ typedef int LADSPA_Properties; (3) The plugin will not access files, devices, pipes, sockets, IPC or any other mechanism that might result in process or thread blocking. - + (4) The plugin will take an amount of time to execute a run() or run_adding() call approximately of form (A+B*SampleCount) where A and B depend on the machine and host in use. This amount of time @@ -137,7 +137,7 @@ typedef int LADSPA_Properties; /*****************************************************************************/ -/* Plugin Ports: +/* Plugin Ports: Plugins have `ports' that are inputs or outputs for audio or data. Ports can communicate arrays of LADSPA_Data (for audio @@ -172,23 +172,23 @@ typedef int LADSPA_PortDescriptor; /*****************************************************************************/ -/* Plugin Port Range Hints: +/* Plugin Port Range Hints: The host may wish to provide a representation of data entering or leaving a plugin (e.g. to generate a GUI automatically). To make this more meaningful, the plugin should provide `hints' to the host describing the usual values taken by the data. - + Note that these are only hints. The host may ignore them and the plugin must not assume that data supplied to it is meaningful. If the plugin receives invalid input data it is expected to continue to run without failure and, where possible, produce a sensible output (e.g. a high-pass filter given a negative cutoff frequency might switch to an all-pass mode). - + Hints are meaningful for all input and output ports but hints for input control ports are expected to be particularly useful. - + More hint information is encapsulated in the LADSPA_PortRangeHintDescriptor type which is assembled by ORing individual hint types together. Hints may require further @@ -316,23 +316,23 @@ typedef int LADSPA_PortRangeHintDescriptor; #define LADSPA_IS_HINT_HAS_DEFAULT(x) ((x) & LADSPA_HINT_DEFAULT_MASK) #define LADSPA_IS_HINT_DEFAULT_MINIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_MINIMUM) + == LADSPA_HINT_DEFAULT_MINIMUM) #define LADSPA_IS_HINT_DEFAULT_LOW(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_LOW) + == LADSPA_HINT_DEFAULT_LOW) #define LADSPA_IS_HINT_DEFAULT_MIDDLE(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_MIDDLE) + == LADSPA_HINT_DEFAULT_MIDDLE) #define LADSPA_IS_HINT_DEFAULT_HIGH(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_HIGH) + == LADSPA_HINT_DEFAULT_HIGH) #define LADSPA_IS_HINT_DEFAULT_MAXIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_MAXIMUM) + == LADSPA_HINT_DEFAULT_MAXIMUM) #define LADSPA_IS_HINT_DEFAULT_0(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_0) + == LADSPA_HINT_DEFAULT_0) #define LADSPA_IS_HINT_DEFAULT_1(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_1) + == LADSPA_HINT_DEFAULT_1) #define LADSPA_IS_HINT_DEFAULT_100(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_100) + == LADSPA_HINT_DEFAULT_100) #define LADSPA_IS_HINT_DEFAULT_440(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ - == LADSPA_HINT_DEFAULT_440) + == LADSPA_HINT_DEFAULT_440) typedef struct _LADSPA_PortRangeHint { @@ -353,7 +353,7 @@ typedef struct _LADSPA_PortRangeHint { /*****************************************************************************/ -/* Plugin Handles: +/* Plugin Handles: This plugin handle indicates a particular instance of the plugin concerned. It is valid to compare this to NULL (0 for C++) but @@ -364,13 +364,13 @@ typedef void * LADSPA_Handle; /*****************************************************************************/ -/* Descriptor for a Type of Plugin: +/* Descriptor for a Type of Plugin: This structure is used to describe a plugin type. It provides a number of functions to examine the type, instantiate it, link it to buffers and workspaces and to run it. */ -typedef struct _LADSPA_Descriptor { +typedef struct _LADSPA_Descriptor { /* This numeric identifier indicates the plugin type uniquely. Plugin programmers may reserve ranges of IDs from a @@ -430,12 +430,12 @@ typedef struct _LADSPA_Descriptor { instantiation function accepts a sample rate as a parameter. The plugin descriptor from which this instantiate function was found must also be passed. This function must return NULL if - instantiation fails. + instantiation fails. Note that instance initialisation should generally occur in activate() rather than here. */ LADSPA_Handle (*instantiate)(const struct _LADSPA_Descriptor * Descriptor, - unsigned long SampleRate); + unsigned long SampleRate); /* This member is a function pointer that connects a port on an instantiated plugin to a memory location at which a block of data @@ -464,8 +464,8 @@ typedef struct _LADSPA_Descriptor { However, overlapped buffers or use of a single buffer for both audio and control data may result in unexpected behaviour. */ void (*connect_port)(LADSPA_Handle Instance, - unsigned long Port, - LADSPA_Data * DataLocation); + unsigned long Port, + LADSPA_Data * DataLocation); /* This member is a function pointer that initialises a plugin instance and activates it for use. This is separated from @@ -503,7 +503,7 @@ typedef struct _LADSPA_Descriptor { then there are various things that the plugin should not do within the run() or run_adding() functions (see above). */ void (*run)(LADSPA_Handle Instance, - unsigned long SampleCount); + unsigned long SampleCount); /* This method is a function pointer that runs an instance of a plugin for a block. This has identical behaviour to run() except @@ -519,7 +519,7 @@ typedef struct _LADSPA_Descriptor { this function pointer must be set to NULL. When it is provided, the function set_run_adding_gain() must be provided also. */ void (*run_adding)(LADSPA_Handle Instance, - unsigned long SampleCount); + unsigned long SampleCount); /* This method is a function pointer that sets the output gain for use when run_adding() is called (see above). If this function is @@ -531,7 +531,7 @@ typedef struct _LADSPA_Descriptor { run_adding() function is provided. When it is absent this function pointer must be set to NULL. */ void (*set_run_adding_gain)(LADSPA_Handle Instance, - LADSPA_Data Gain); + LADSPA_Data Gain); /* This is the counterpart to activate() (see above). If there is nothing for deactivate() to do then the plugin writer may provide @@ -551,7 +551,7 @@ typedef struct _LADSPA_Descriptor { /* Once an instance of a plugin has been finished with it can be deleted using the following function. The instance handle passed ceases to be valid after this call. - + If activate() was called for a plugin instance then a corresponding call to deactivate() must be made before cleanup() is called. */ @@ -589,7 +589,7 @@ typedef struct _LADSPA_Descriptor { const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index); /* Datatype corresponding to the ladspa_descriptor() function. */ -typedef const LADSPA_Descriptor * +typedef const LADSPA_Descriptor * (*LADSPA_Descriptor_Function)(unsigned long Index); /**********************************************************************/ diff --git a/src/pcm/mask.c b/src/pcm/mask.c index 6bd218da..bf97cefc 100644 --- a/src/pcm/mask.c +++ b/src/pcm/mask.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #define SND_MASK_C #define SND_MASK_INLINE diff --git a/src/pcm/mask.h b/src/pcm/mask.h index 7f30587b..6934ac93 100644 --- a/src/pcm/mask.h +++ b/src/pcm/mask.h @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + typedef struct _snd_mask snd_mask_t; #define SND_MASK_MAX 64 diff --git a/src/pcm/mask_inline.h b/src/pcm/mask_inline.h index 75ad3594..6de3686d 100644 --- a/src/pcm/mask_inline.h +++ b/src/pcm/mask_inline.h @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include #include @@ -32,36 +32,36 @@ MASK_INLINE unsigned int ld2(uint32_t v) { - unsigned r = 0; + unsigned r = 0; - if (v >= 0x10000) { - v >>= 16; - r += 16; - } - if (v >= 0x100) { - v >>= 8; - r += 8; - } - if (v >= 0x10) { - v >>= 4; - r += 4; - } - if (v >= 4) { - v >>= 2; - r += 2; - } - if (v >= 2) - r++; - return r; + if (v >= 0x10000) { + v >>= 16; + r += 16; + } + if (v >= 0x100) { + v >>= 8; + r += 8; + } + if (v >= 0x10) { + v >>= 4; + r += 4; + } + if (v >= 4) { + v >>= 2; + r += 2; + } + if (v >= 2) + r++; + return r; } MASK_INLINE unsigned int hweight32(uint32_t v) { - v = (v & 0x55555555) + ((v >> 1) & 0x55555555); - v = (v & 0x33333333) + ((v >> 2) & 0x33333333); - v = (v & 0x0F0F0F0F) + ((v >> 4) & 0x0F0F0F0F); - v = (v & 0x00FF00FF) + ((v >> 8) & 0x00FF00FF); - return (v & 0x0000FFFF) + ((v >> 16) & 0x0000FFFF); + v = (v & 0x55555555) + ((v >> 1) & 0x55555555); + v = (v & 0x33333333) + ((v >> 2) & 0x33333333); + v = (v & 0x0F0F0F0F) + ((v >> 4) & 0x0F0F0F0F); + v = (v & 0x00FF00FF) + ((v >> 8) & 0x00FF00FF); + return (v & 0x0000FFFF) + ((v >> 16) & 0x0000FFFF); } MASK_INLINE size_t snd_mask_sizeof(void) diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index ec751707..c8804f3b 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -153,7 +153,7 @@ using #snd_pcm_state() call. There are these states: \par SND_PCM_STATE_OPEN The PCM device is in the open state. After the #snd_pcm_open() open call, the device is in this state. Also, when #snd_pcm_hw_params() call fails, -then this state is entered to force application calling +then this state is entered to force application calling #snd_pcm_hw_params() function to set right communication parameters. @@ -799,7 +799,7 @@ int snd_pcm_close(snd_pcm_t *pcm) if (err < 0) res = err; return res; -} +} /** * \brief set nonblock mode @@ -925,7 +925,7 @@ int snd_pcm_hw_params_current(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) params->rate_den = pcm->rate_den; params->fifo_size = pcm->fifo_size; return 0; -} +} /** \brief Install one PCM hardware configuration chosen from a configuration space and #snd_pcm_prepare it * \param pcm PCM handle @@ -933,7 +933,7 @@ int snd_pcm_hw_params_current(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) * \return 0 on success otherwise a negative error code * * The configuration is chosen fixing single parameters in this order: - * first access, first format, first subformat, min channels, min rate, + * first access, first format, first subformat, min channels, min rate, * min period time, max buffer size, min tick time. If no mutually * compatible set of parameters can be chosen, a negative error code * will be returned. @@ -1565,7 +1565,7 @@ use_default_symbol_version(__snd_pcm_forward, snd_pcm_forward, ALSA_0.9.0rc8); * If the non-blocking behaviour is selected, then routine doesn't wait at all. * * The function is thread-safe when built with the proper option. - */ + */ snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size) { int err; @@ -1604,7 +1604,7 @@ snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_ufr * If the non-blocking behaviour is selected, then routine doesn't wait at all. * * The function is thread-safe when built with the proper option. - */ + */ snd_pcm_sframes_t snd_pcm_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size) { int err; @@ -1643,7 +1643,7 @@ snd_pcm_sframes_t snd_pcm_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t * If the non-blocking behaviour is selected, then routine doesn't wait at all. * * The function is thread-safe when built with the proper option. - */ + */ snd_pcm_sframes_t snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size) { int err; @@ -1682,7 +1682,7 @@ snd_pcm_sframes_t snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t * If the non-blocking behaviour is selected, then routine doesn't wait at all. * * The function is thread-safe when built with the proper option. - */ + */ snd_pcm_sframes_t snd_pcm_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size) { int err; @@ -1710,7 +1710,7 @@ snd_pcm_sframes_t snd_pcm_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t s * \return 0 on success otherwise a negative error code * * The two PCMs will start/stop/prepare in sync. - */ + */ int snd_pcm_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2) { int err = 0; @@ -1899,10 +1899,10 @@ static int __snd_pcm_poll_revents(snd_pcm_t *pcm, struct pollfd *pfds, #define HW_PARAM(v) [SND_PCM_HW_PARAM_##v] = #v #define SW_PARAM(v) [SND_PCM_SW_PARAM_##v] = #v #define FORMAT(v) [SND_PCM_FORMAT_##v] = #v -#define SUBFORMAT(v) [SND_PCM_SUBFORMAT_##v] = #v +#define SUBFORMAT(v) [SND_PCM_SUBFORMAT_##v] = #v #define FORMATD(v, d) [SND_PCM_FORMAT_##v] = d -#define SUBFORMATD(v, d) [SND_PCM_SUBFORMAT_##v] = d +#define SUBFORMATD(v, d) [SND_PCM_SUBFORMAT_##v] = d static const char *const snd_pcm_stream_names[] = { @@ -1923,7 +1923,7 @@ static const char *const snd_pcm_state_names[] = { }; static const char *const snd_pcm_access_names[] = { - ACCESS(MMAP_INTERLEAVED), + ACCESS(MMAP_INTERLEAVED), ACCESS(MMAP_NONINTERLEAVED), ACCESS(MMAP_COMPLEX), ACCESS(RW_INTERLEAVED), @@ -1999,7 +1999,7 @@ static const char *const snd_pcm_format_aliases[SND_PCM_FORMAT_LAST+1] = { }; static const char *const snd_pcm_format_descriptions[] = { - FORMATD(S8, "Signed 8 bit"), + FORMATD(S8, "Signed 8 bit"), FORMATD(U8, "Unsigned 8 bit"), FORMATD(S16_LE, "Signed 16 bit Little Endian"), FORMATD(S16_BE, "Signed 16 bit Big Endian"), @@ -2053,29 +2053,29 @@ static const char *const snd_pcm_format_descriptions[] = { }; static const char *const snd_pcm_type_names[] = { - PCMTYPE(HW), - PCMTYPE(HOOKS), - PCMTYPE(MULTI), - PCMTYPE(FILE), - PCMTYPE(NULL), - PCMTYPE(SHM), - PCMTYPE(INET), - PCMTYPE(COPY), - PCMTYPE(LINEAR), - PCMTYPE(ALAW), - PCMTYPE(MULAW), - PCMTYPE(ADPCM), - PCMTYPE(RATE), - PCMTYPE(ROUTE), - PCMTYPE(PLUG), - PCMTYPE(SHARE), - PCMTYPE(METER), - PCMTYPE(MIX), - PCMTYPE(DROUTE), - PCMTYPE(LBSERVER), - PCMTYPE(LINEAR_FLOAT), - PCMTYPE(LADSPA), - PCMTYPE(DMIX), + PCMTYPE(HW), + PCMTYPE(HOOKS), + PCMTYPE(MULTI), + PCMTYPE(FILE), + PCMTYPE(NULL), + PCMTYPE(SHM), + PCMTYPE(INET), + PCMTYPE(COPY), + PCMTYPE(LINEAR), + PCMTYPE(ALAW), + PCMTYPE(MULAW), + PCMTYPE(ADPCM), + PCMTYPE(RATE), + PCMTYPE(ROUTE), + PCMTYPE(PLUG), + PCMTYPE(SHARE), + PCMTYPE(METER), + PCMTYPE(MIX), + PCMTYPE(DROUTE), + PCMTYPE(LBSERVER), + PCMTYPE(LINEAR_FLOAT), + PCMTYPE(LADSPA), + PCMTYPE(DMIX), PCMTYPE(JACK), PCMTYPE(DSNOOP), PCMTYPE(IEC958), @@ -2086,14 +2086,14 @@ static const char *const snd_pcm_type_names[] = { }; static const char *const snd_pcm_subformat_names[] = { - SUBFORMAT(STD), + SUBFORMAT(STD), SUBFORMAT(MSBITS_MAX), SUBFORMAT(MSBITS_20), SUBFORMAT(MSBITS_24), }; static const char *const snd_pcm_subformat_descriptions[] = { - SUBFORMATD(STD, "Standard"), + SUBFORMATD(STD, "Standard"), SUBFORMATD(MSBITS_MAX, "Maximum based on PCM format"), SUBFORMATD(MSBITS_20, "20 most significant bits"), SUBFORMATD(MSBITS_24, "24 most significant bits"), @@ -2343,7 +2343,7 @@ int snd_pcm_dump_hw_setup(snd_pcm_t *pcm, snd_output_t *out) snd_check(PCM, "PCM not set up"); return -EIO; } - snd_output_printf(out, " stream : %s\n", snd_pcm_stream_name(pcm->stream)); + snd_output_printf(out, " stream : %s\n", snd_pcm_stream_name(pcm->stream)); snd_output_printf(out, " access : %s\n", snd_pcm_access_name(pcm->access)); snd_output_printf(out, " format : %s\n", snd_pcm_format_name(pcm->format)); snd_output_printf(out, " subformat : %s\n", snd_pcm_subformat_name(pcm->subformat)); @@ -2513,7 +2513,7 @@ ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, long samples) * * The asynchronous callback is called when period boundary elapses. */ -int snd_async_add_pcm_handler(snd_async_handler_t **handler, snd_pcm_t *pcm, +int snd_async_add_pcm_handler(snd_async_handler_t **handler, snd_pcm_t *pcm, snd_async_callback_t callback, void *private_data) { int err; @@ -2570,8 +2570,8 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name, snd_config_iterator_t i, next; const char *id; const char *lib = NULL, *open_name = NULL; - int (*open_func)(snd_pcm_t **, const char *, - snd_config_t *, snd_config_t *, + int (*open_func)(snd_pcm_t **, const char *, + snd_config_t *, snd_config_t *, snd_pcm_stream_t, int) = NULL; #ifndef PIC extern void *snd_pcm_open_symbols(void); @@ -2741,7 +2741,7 @@ static int snd_pcm_open_noupdate(snd_pcm_t **pcmp, snd_config_t *root, * \param mode Open mode (see #SND_PCM_NONBLOCK, #SND_PCM_ASYNC) * \return 0 on success otherwise a negative error code */ -int snd_pcm_open(snd_pcm_t **pcmp, const char *name, +int snd_pcm_open(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t stream, int mode) { snd_config_t *top; @@ -2771,7 +2771,7 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name, * \param lconf Local configuration * \return 0 on success otherwise a negative error code */ -int snd_pcm_open_lconf(snd_pcm_t **pcmp, const char *name, +int snd_pcm_open_lconf(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t stream, int mode, snd_config_t *lconf) { @@ -2894,7 +2894,7 @@ int snd_pcm_open_named_slave(snd_pcm_t **pcmp, const char *name, * see also SND_PCM_WAIT_IO and SND_PCM_WAIT_DRAIN * \return a positive value on success otherwise a negative error code * (-EPIPE for the xrun and -ESTRPIPE for the suspended status, - * others for general errors) + * others for general errors) * \retval 0 timeout occurred * \retval 1 PCM stream is ready for I/O * @@ -2957,7 +2957,7 @@ static int __snd_pcm_wait_drain_timeout(snd_pcm_t *pcm) return timeout; } -/* +/* * like snd_pcm_wait() but doesn't check mmap_avail before calling poll() * * used in drain code in some plugins @@ -2969,7 +2969,7 @@ int snd_pcm_wait_nocheck(snd_pcm_t *pcm, int timeout) struct pollfd *pfd; unsigned short revents = 0; int npfds, err, err_poll; - + npfds = __snd_pcm_poll_descriptors_count(pcm); if (npfds <= 0 || npfds >= 16) { snd_error(PCM, "Invalid poll_fds %d", npfds); @@ -2995,9 +2995,9 @@ int snd_pcm_wait_nocheck(snd_pcm_t *pcm, int timeout) __snd_pcm_lock(pcm->fast_op_arg); if (err_poll < 0) { if (errno == EINTR && !PCMINABORT(pcm) && !(pcm->mode & SND_PCM_EINTR)) - continue; + continue; return -errno; - } + } if (! err_poll) break; err = __snd_pcm_poll_revents(pcm, pfd, npfds, &revents); @@ -3164,13 +3164,13 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes dst = snd_pcm_channel_area_addr(dst_area, dst_offset); width = snd_pcm_format_physical_width(format); silence = snd_pcm_format_silence_64(format); - /* - * Iterate copying silent sample for sample data aligned to 64 bit. - * This is a fast path. - */ - if (dst_area->step == (unsigned int) width && - width != 24 && - ((intptr_t)dst & 7) == 0) { + /* + * Iterate copying silent sample for sample data aligned to 64 bit. + * This is a fast path. + */ + if (dst_area->step == (unsigned int) width && + width != 24 && + ((intptr_t)dst & 7) == 0) { unsigned int dwords = samples * width / 64; uint64_t *dstp = (uint64_t *)dst; samples -= dwords * 64 / width; @@ -3487,7 +3487,7 @@ int snd_pcm_areas_copy(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_ d.first = dst_start->first; d.step = width; snd_pcm_area_copy(&d, dst_offset * chns, - &s, src_offset * chns, + &s, src_offset * chns, frames * chns, format); } channels -= chns; @@ -6354,10 +6354,10 @@ int snd_pcm_hw_params_get_min_align(const snd_pcm_hw_params_t *params, snd_pcm_u return err; // compute frame bits fb = snd_pcm_format_physical_width((snd_pcm_format_t)format) * channels; - min_align = 1; + min_align = 1; while (fb % 8) { fb *= 2; - min_align *= 2; + min_align *= 2; } if (val) *val = min_align; @@ -6793,7 +6793,7 @@ int snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *params, snd_pcm_ * \param val Start threshold in frames * \return 0 otherwise a negative error code * - * PCM is automatically started when playback frames available to PCM + * PCM is automatically started when playback frames available to PCM * are >= threshold or when requested capture frames are >= threshold */ #ifndef DOXYGEN @@ -6813,7 +6813,7 @@ int snd_pcm_sw_params_set_start_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *p * \param val Returned start threshold in frames * \return 0 otherwise a negative error code * - * PCM is automatically started when playback frames available to PCM + * PCM is automatically started when playback frames available to PCM * are >= threshold or when requested capture frames are >= threshold */ #ifndef DOXYGEN @@ -6878,10 +6878,10 @@ int snd_pcm_sw_params_get_stop_threshold(const snd_pcm_sw_params_t *params, snd_ * \brief Set silence threshold inside a software configuration container * \param pcm PCM handle * \param params Software configuration container - * \param val Silence threshold in frames + * \param val Silence threshold in frames * \return 0 otherwise a negative error code * - * A portion of playback buffer is overwritten with silence (see + * A portion of playback buffer is overwritten with silence (see * #snd_pcm_sw_params_set_silence_size) when playback underrun is nearer * than silence threshold. */ @@ -6908,7 +6908,7 @@ int snd_pcm_sw_params_set_silence_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t * \param val Returned silence threshold in frames * \return 0 otherwise a negative error value * - * A portion of playback buffer is overwritten with silence (see + * A portion of playback buffer is overwritten with silence (see * #snd_pcm_sw_params_set_silence_size) when playback underrun is nearer * than silence threshold. */ @@ -6932,7 +6932,7 @@ int snd_pcm_sw_params_get_silence_threshold(const snd_pcm_sw_params_t *params, s * \return 0 otherwise a negative error code * * A portion of playback buffer is overwritten with silence when playback - * underrun is nearer than silence threshold (see + * underrun is nearer than silence threshold (see * #snd_pcm_sw_params_set_silence_threshold) * * When drain silence (see #snd_pcm_hw_params_get_drain_silence) is disabled, @@ -6968,7 +6968,7 @@ int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm, snd_pcm_sw_params_t *para * \return 0 otherwise a negative error code * * A portion of playback buffer is overwritten with silence when playback - * underrun is nearer than silence threshold (see + * underrun is nearer than silence threshold (see * #snd_pcm_sw_params_set_silence_threshold) */ #ifndef DOXYGEN @@ -7026,7 +7026,7 @@ void snd_pcm_status_copy(snd_pcm_status_t *dst, const snd_pcm_status_t *src) *dst = *src; } -/** +/** * \brief Get state from a PCM status container (see #snd_pcm_state) * \param obj #snd_pcm_status_t pointer * \return PCM state @@ -7037,7 +7037,7 @@ snd_pcm_state_t snd_pcm_status_get_state(const snd_pcm_status_t *obj) return obj->state; } -/** +/** * \brief Get trigger timestamp from a PCM status container * \param obj #snd_pcm_status_t pointer * \param ptr Pointer to returned timestamp @@ -7053,7 +7053,7 @@ void snd_pcm_status_get_trigger_tstamp(const snd_pcm_status_t *obj, snd_timestam ptr->tv_usec = obj->trigger_tstamp.tv_nsec / 1000L; } -/** +/** * \brief Get trigger hi-res timestamp from a PCM status container * \param obj #snd_pcm_status_t pointer * \param ptr Pointer to returned timestamp @@ -7073,7 +7073,7 @@ void snd_pcm_status_get_trigger_htstamp(const snd_pcm_status_t *obj, snd_htimest } use_default_symbol_version(__snd_pcm_status_get_trigger_htstamp, snd_pcm_status_get_trigger_htstamp, ALSA_0.9.0rc8); -/** +/** * \brief Get "now" timestamp from a PCM status container * \param obj #snd_pcm_status_t pointer * \param ptr Pointer to returned timestamp @@ -7085,7 +7085,7 @@ void snd_pcm_status_get_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr ptr->tv_usec = obj->tstamp.tv_nsec / 1000L; } -/** +/** * \brief Get "now" hi-res timestamp from a PCM status container * \param obj pointer to #snd_pcm_status_t * \param ptr Pointer to returned timestamp @@ -7101,7 +7101,7 @@ void snd_pcm_status_get_htstamp(const snd_pcm_status_t *obj, snd_htimestamp_t *p } use_default_symbol_version(__snd_pcm_status_get_htstamp, snd_pcm_status_get_htstamp, ALSA_0.9.0rc8); -/** +/** * \brief Get "now" hi-res audio timestamp from a PCM status container * \param obj pointer to #snd_pcm_status_t * \param ptr Pointer to returned timestamp @@ -7166,7 +7166,7 @@ snd_pcm_sframes_t snd_pcm_status_get_delay(const snd_pcm_status_t *obj) return obj->delay; } -/** +/** * \brief Get number of frames available from a PCM status container (see #snd_pcm_avail_update) * \return Number of frames ready to be read/written */ @@ -7176,7 +7176,7 @@ snd_pcm_uframes_t snd_pcm_status_get_avail(const snd_pcm_status_t *obj) return obj->avail; } -/** +/** * \brief Get maximum number of frames available from a PCM status container after last #snd_pcm_status call * \return Maximum number of frames ready to be read/written * @@ -7188,7 +7188,7 @@ snd_pcm_uframes_t snd_pcm_status_get_avail_max(const snd_pcm_status_t *obj) return obj->avail_max; } -/** +/** * \brief Get count of ADC overrange detections since last call * \return Count of ADC overrange detections */ @@ -7413,7 +7413,7 @@ void snd_pcm_info_set_stream(snd_pcm_info_t *obj, snd_pcm_stream_t val) /** * \brief Application request to access a portion of direct (mmap) area - * \param pcm PCM handle + * \param pcm PCM handle * \param areas Returned mmap channel areas * \param offset Returned mmap area offset in area steps (== frames) * \param frames mmap area portion size in frames (wanted on entry, contiguous available on exit) @@ -7516,7 +7516,7 @@ int __snd_pcm_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, if (avail < 0) error(avail); // at this point, we can transfer at least 'avail' frames - + // we want to process frames in chunks (period_size) if (avail < period_size) goto _skip; @@ -7533,7 +7533,7 @@ int __snd_pcm_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, commitres = snd_pcm_mmap_commit(pcm_handle, offset, frames); if (commitres < 0 || commitres != frames) error(commitres >= 0 ? -EPIPE : commitres); - + size -= frames; } _skip: @@ -7591,7 +7591,7 @@ int _snd_pcm_poll_descriptor(snd_pcm_t *pcm) return pcm->poll_fd; } -void snd_pcm_areas_from_buf(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas, +void snd_pcm_areas_from_buf(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas, void *buf) { unsigned int channel; @@ -7607,7 +7607,7 @@ void snd_pcm_areas_from_buf(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas, snd_pcm_unlock(pcm); } -void snd_pcm_areas_from_bufs(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas, +void snd_pcm_areas_from_bufs(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas, void **bufs) { unsigned int channel; @@ -7677,7 +7677,7 @@ snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_ if (err < 0) break; goto _again; - + } frames = size; if (frames > (snd_pcm_uframes_t) avail) @@ -7938,13 +7938,13 @@ int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf, pcm_conf = NULL; err = 0; _err: - if (pcm_conf) - snd_config_delete(pcm_conf); + if (pcm_conf) + snd_config_delete(pcm_conf); if (to_free) snd_config_delete(conf); return err; } - + static void snd_pcm_set_ptr(snd_pcm_t *pcm, snd_pcm_rbptr_t *rbptr, volatile snd_pcm_uframes_t *hw_ptr, int fd, off_t offset) { @@ -7975,7 +7975,7 @@ static void snd_pcm_link_ptr(snd_pcm_t *pcm, snd_pcm_rbptr_t *pcm_rbptr, { snd_pcm_t **a; int idx; - + a = slave_rbptr->link_dst; for (idx = 0; idx < slave_rbptr->link_dst_count; idx++) if (a[idx] == NULL) { @@ -8017,7 +8017,7 @@ static void snd_pcm_unlink_ptr(snd_pcm_t *pcm, snd_pcm_rbptr_t *pcm_rbptr, return; __found: - pcm_rbptr->master = NULL; + pcm_rbptr->master = NULL; pcm_rbptr->ptr = NULL; pcm_rbptr->fd = -1; pcm_rbptr->offset = 0UL; @@ -8752,8 +8752,8 @@ _snd_pcm_parse_config_chmaps(snd_config_t *conf) /* * basic helpers */ - - + + /** * \brief Recover the stream state from an error or suspend * \param pcm PCM handle @@ -8772,39 +8772,39 @@ _snd_pcm_parse_config_chmaps(snd_config_t *conf) */ int snd_pcm_recover(snd_pcm_t *pcm, int err, int silent) { - if (err > 0) - err = -err; - if (err == -EINTR) /* nothing to do, continue */ - return 0; - if (err == -EPIPE) { - const char *s; - if (snd_pcm_stream(pcm) == SND_PCM_STREAM_PLAYBACK) - s = "underrun"; - else - s = "overrun"; - if (!silent) + if (err > 0) + err = -err; + if (err == -EINTR) /* nothing to do, continue */ + return 0; + if (err == -EPIPE) { + const char *s; + if (snd_pcm_stream(pcm) == SND_PCM_STREAM_PLAYBACK) + s = "underrun"; + else + s = "overrun"; + if (!silent) snd_error(PCM, "%s occurred", s); - err = snd_pcm_prepare(pcm); - if (err < 0) { + err = snd_pcm_prepare(pcm); + if (err < 0) { snd_error(PCM, "cannot recovery from %s, prepare failed: %s", s, snd_strerror(err)); - return err; - } - return 0; - } - if (err == -ESTRPIPE) { - while ((err = snd_pcm_resume(pcm)) == -EAGAIN) - /* wait until suspend flag is released */ - poll(NULL, 0, 1000); - if (err < 0) { - err = snd_pcm_prepare(pcm); - if (err < 0) { + return err; + } + return 0; + } + if (err == -ESTRPIPE) { + while ((err = snd_pcm_resume(pcm)) == -EAGAIN) + /* wait until suspend flag is released */ + poll(NULL, 0, 1000); + if (err < 0) { + err = snd_pcm_prepare(pcm); + if (err < 0) { snd_error(PCM, "cannot recovery from suspend, prepare failed: %s", snd_strerror(err)); - return err; - } - } - return 0; - } - return err; + return err; + } + } + return 0; + } + return err; } /** @@ -8819,12 +8819,12 @@ int snd_pcm_recover(snd_pcm_t *pcm, int err, int silent) * \return 0 on success otherwise a negative error code */ int snd_pcm_set_params(snd_pcm_t *pcm, - snd_pcm_format_t format, - snd_pcm_access_t access, - unsigned int channels, - unsigned int rate, - int soft_resample, - unsigned int latency) + snd_pcm_format_t format, + snd_pcm_access_t access, + unsigned int channels, + unsigned int rate, + int soft_resample, + unsigned int latency) { snd_pcm_hw_params_t params_saved, params = {0}; snd_pcm_sw_params_t swparams = {0}; @@ -8841,7 +8841,7 @@ int snd_pcm_set_params(snd_pcm_t *pcm, s); return err; - } + } /* set software resampling */ err = snd_pcm_hw_params_set_rate_resample(pcm, ¶ms, soft_resample); if (err < 0) { @@ -9028,8 +9028,8 @@ int snd_pcm_set_params(snd_pcm_t *pcm, * \return 0 on success otherwise a negative error code */ int snd_pcm_get_params(snd_pcm_t *pcm, - snd_pcm_uframes_t *buffer_size, - snd_pcm_uframes_t *period_size) + snd_pcm_uframes_t *buffer_size, + snd_pcm_uframes_t *period_size) { snd_pcm_hw_params_t params = {0}; int err; @@ -9037,7 +9037,7 @@ int snd_pcm_get_params(snd_pcm_t *pcm, assert(pcm); err = snd_pcm_hw_params_current(pcm, ¶ms); if (err < 0) - return err; + return err; err = INTERNAL(snd_pcm_hw_params_get_buffer_size)(¶ms, buffer_size); if (err < 0) return err; diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c index bd6f7da3..235b3592 100644 --- a/src/pcm/pcm_adpcm.c +++ b/src/pcm/pcm_adpcm.c @@ -32,7 +32,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + /* These routines convert 16 bit linear PCM samples to 4 bit ADPCM code and vice versa. The ADPCM code used is the Intel/DVI ADPCM code which @@ -376,7 +376,7 @@ static int snd_pcm_adpcm_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_ return err; return 0; } - + static int snd_pcm_adpcm_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) { @@ -477,7 +477,7 @@ snd_pcm_adpcm_write_areas(snd_pcm_t *pcm, if (size > *slave_sizep) size = *slave_sizep; adpcm->func(slave_areas, slave_offset, - areas, offset, + areas, offset, pcm->channels, size, adpcm->getput_idx, adpcm->states); *slave_sizep = size; @@ -496,7 +496,7 @@ snd_pcm_adpcm_read_areas(snd_pcm_t *pcm, snd_pcm_adpcm_t *adpcm = pcm->private_data; if (size > *slave_sizep) size = *slave_sizep; - adpcm->func(areas, offset, + adpcm->func(areas, offset, slave_areas, slave_offset, pcm->channels, size, adpcm->getput_idx, adpcm->states); @@ -507,7 +507,7 @@ snd_pcm_adpcm_read_areas(snd_pcm_t *pcm, static void snd_pcm_adpcm_dump(snd_pcm_t *pcm, snd_output_t *out) { snd_pcm_adpcm_t *adpcm = pcm->private_data; - snd_output_printf(out, "Ima-ADPCM conversion PCM (%s)\n", + snd_output_printf(out, "Ima-ADPCM conversion PCM (%s)\n", snd_pcm_format_name(adpcm->sformat)); if (pcm->setup) { snd_output_printf(out, "Its setup is:\n"); @@ -596,15 +596,15 @@ format and rate must match for both of them. \code pcm.name { - type adpcm # Ima-ADPCM conversion PCM - slave STR # Slave name - # or - slave { # Slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition - format STR # Slave format - } + type adpcm # Ima-ADPCM conversion PCM + slave STR # Slave name + # or + slave { # Slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + format STR # Slave format + } } \endcode @@ -631,7 +631,7 @@ pcm.name { * changed in future. */ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; @@ -663,7 +663,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name, return err; if (snd_pcm_format_linear(sformat) != 1 && sformat != SND_PCM_FORMAT_IMA_ADPCM) { - snd_config_delete(sconf); + snd_config_delete(sconf); snd_error(PCM, "invalid slave format"); return -EINVAL; } diff --git a/src/pcm/pcm_alaw.c b/src/pcm/pcm_alaw.c index 8fb0625f..5b8fd2fb 100644 --- a/src/pcm/pcm_alaw.c +++ b/src/pcm/pcm_alaw.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "bswap.h" #include "pcm_plugin.h" @@ -232,7 +232,7 @@ static int snd_pcm_alaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t * err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT, &format_mask); } else { - err = _snd_pcm_hw_params_set_format(params, + err = _snd_pcm_hw_params_set_format(params, SND_PCM_FORMAT_A_LAW); } if (err < 0) @@ -273,7 +273,7 @@ static int snd_pcm_alaw_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_p return err; return 0; } - + static int snd_pcm_alaw_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) { @@ -317,7 +317,7 @@ static int snd_pcm_alaw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) err = INTERNAL(snd_pcm_hw_params_get_format)(params, &format); if (err < 0) return err; - + if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { if (alaw->sformat == SND_PCM_FORMAT_A_LAW) { alaw->getput_idx = snd_pcm_linear_get_index(format, SND_PCM_FORMAT_S16); @@ -351,7 +351,7 @@ snd_pcm_alaw_write_areas(snd_pcm_t *pcm, if (size > *slave_sizep) size = *slave_sizep; alaw->func(slave_areas, slave_offset, - areas, offset, + areas, offset, pcm->channels, size, alaw->getput_idx); *slave_sizep = size; @@ -370,7 +370,7 @@ snd_pcm_alaw_read_areas(snd_pcm_t *pcm, snd_pcm_alaw_t *alaw = pcm->private_data; if (size > *slave_sizep) size = *slave_sizep; - alaw->func(areas, offset, + alaw->func(areas, offset, slave_areas, slave_offset, pcm->channels, size, alaw->getput_idx); @@ -381,7 +381,7 @@ snd_pcm_alaw_read_areas(snd_pcm_t *pcm, static void snd_pcm_alaw_dump(snd_pcm_t *pcm, snd_output_t *out) { snd_pcm_alaw_t *alaw = pcm->private_data; - snd_output_printf(out, "A-Law conversion PCM (%s)\n", + snd_output_printf(out, "A-Law conversion PCM (%s)\n", snd_pcm_format_name(alaw->sformat)); if (pcm->setup) { snd_output_printf(out, "Its setup is:\n"); @@ -420,7 +420,7 @@ static const snd_pcm_ops_t snd_pcm_alaw_ops = { * \warning Using of this function might be dangerous in the sense * of compatibility reasons. The prototype might be freely * changed in future. - */ + */ int snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave) { snd_pcm_t *pcm; @@ -471,15 +471,15 @@ format and rate must match for both of them. \code pcm.name { - type alaw # A-Law conversion PCM - slave STR # Slave name - # or - slave { # Slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition - format STR # Slave format - } + type alaw # A-Law conversion PCM + slave STR # Slave name + # or + slave { # Slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + format STR # Slave format + } } \endcode @@ -506,7 +506,7 @@ pcm.name { * changed in future. */ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; @@ -538,7 +538,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name, return err; if (snd_pcm_format_linear(sformat) != 1 && sformat != SND_PCM_FORMAT_A_LAW) { - snd_config_delete(sconf); + snd_config_delete(sconf); snd_error(PCM, "invalid slave format"); return -EINVAL; } diff --git a/src/pcm/pcm_asym.c b/src/pcm/pcm_asym.c index e8004707..baca92f5 100644 --- a/src/pcm/pcm_asym.c +++ b/src/pcm/pcm_asym.c @@ -22,21 +22,21 @@ Slave PCMs can be defined asymmetrically for both directions. \code pcm.name { - type asym # Asym PCM - playback STR # Playback slave name - # or - playback { # Playback slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition - } - capture STR # Capture slave name - # or - capture { # Capture slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition - } + type asym # Asym PCM + playback STR # Playback slave name + # or + playback { # Playback slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + } + capture STR # Capture slave name + # or + capture { # Capture slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + } } \endcode diff --git a/src/pcm/pcm_copy.c b/src/pcm/pcm_copy.c index c20a18bd..a078578e 100644 --- a/src/pcm/pcm_copy.c +++ b/src/pcm/pcm_copy.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_plugin.h" #include "bswap.h" @@ -73,7 +73,7 @@ static int snd_pcm_copy_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_p return err; return 0; } - + static int snd_pcm_copy_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) { @@ -133,7 +133,7 @@ snd_pcm_copy_read_areas(snd_pcm_t *pcm, { if (size > *slave_sizep) size = *slave_sizep; - snd_pcm_areas_copy(areas, offset, + snd_pcm_areas_copy(areas, offset, slave_areas, slave_offset, pcm->channels, size, pcm->format); *slave_sizep = size; @@ -222,7 +222,7 @@ int snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int \section pcm_plugins_copy Plugin: copy This plugin copies samples from master copy PCM to given slave PCM. -The channel count, format and rate must match for both of them. +The channel count, format and rate must match for both of them. \code pcm.name { @@ -260,7 +260,7 @@ pcm.name { * changed in future. */ int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c index 74455985..304c1883 100644 --- a/src/pcm/pcm_direct.c +++ b/src/pcm/pcm_direct.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include #include @@ -44,7 +44,7 @@ /* * */ - + #if !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__ANDROID__) union semun { int val; /* Value for SETVAL */ @@ -55,7 +55,7 @@ union semun { #endif }; #endif - + /* * FIXME: * add possibility to use futexes here @@ -96,14 +96,14 @@ static unsigned int snd_pcm_direct_magic(snd_pcm_direct_t *dmix) } /* - * global shared memory area + * global shared memory area */ int snd_pcm_direct_shm_create_or_connect(snd_pcm_direct_t *dmix) { struct shmid_ds buf; int tmpid, err, first_instance = 0; - + retryget: dmix->shmid = shmget(dmix->ipc_key, sizeof(snd_pcm_direct_share_t), dmix->ipc_perm); @@ -120,7 +120,7 @@ retryget: if ((tmpid = shmget(dmix->ipc_key, 0, dmix->ipc_perm)) != -1) if (!shmctl(tmpid, IPC_STAT, &buf)) if (!buf.shm_nattch) - /* no users so destroy the segment */ + /* no users so destroy the segment */ if (!shmctl(tmpid, IPC_RMID, NULL)) goto retryget; return err; @@ -221,7 +221,7 @@ static int make_local_socket(const char *filename, int server, mode_t ipc_perm, memset(addr, 0, size); /* make valgrind happy */ addr->sun_family = AF_LOCAL; memcpy(addr->sun_path, filename, l); - + if (server) { if (bind(sock, (struct sockaddr *) addr, size) < 0) { int result = -errno; @@ -309,7 +309,7 @@ static int _snd_send_fd(int sock, void *data, size_t len, int fd) msghdr.msg_name = NULL; msghdr.msg_namelen = 0; msghdr.msg_iov = &vec; - msghdr.msg_iovlen = 1; + msghdr.msg_iovlen = 1; msghdr.msg_control = cmsg; msghdr.msg_controllen = cmsg_len; msghdr.msg_flags = 0; @@ -342,7 +342,7 @@ static void server_job(snd_pcm_direct_t *dmix) if (i != dmix->server_fd && i != dmix->hw_fd) close(i); } - + /* detach from parent */ setsid(); @@ -431,7 +431,7 @@ int snd_pcm_direct_server_create(snd_pcm_direct_t *dmix) ret = get_tmp_name(dmix->shmptr->socket_name, sizeof(dmix->shmptr->socket_name)); if (ret < 0) return ret; - + ret = make_local_socket(dmix->shmptr->socket_name, 1, dmix->ipc_perm, dmix->ipc_gid); if (ret < 0) return ret; @@ -442,7 +442,7 @@ int snd_pcm_direct_server_create(snd_pcm_direct_t *dmix) close(dmix->server_fd); return ret; } - + ret = fork(); if (ret < 0) { close(dmix->server_fd); @@ -894,7 +894,7 @@ static int snd_interval_step(struct snd_interval *i, unsigned int min, int snd_pcm_direct_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) { snd_pcm_direct_t *dshare = pcm->private_data; - static const snd_mask_t access = { .bits = { + static const snd_mask_t access = { .bits = { (1<periods > 0) { unsigned int periods = params->periods; ret = INTERNAL(snd_pcm_hw_params_set_periods_near)(spcm, @@ -1329,7 +1329,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str return ret; } } - + ret = snd_pcm_hw_params(spcm, &hw_params); if (ret < 0) { snd_error(PCM, "unable to install hw params"); @@ -1420,7 +1420,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str snd_pcm_areas_silence(dst_areas, 0, spcm->channels, spcm->buffer_size, spcm->format); } - + ret = snd_pcm_start(spcm); if (ret < 0) { snd_error(PCM, "unable to start PCM stream"); @@ -1433,7 +1433,7 @@ int snd_pcm_direct_initialize_slave(snd_pcm_direct_t *dmix, snd_pcm_t *spcm, str } snd_pcm_poll_descriptors(spcm, &fd, 1); dmix->hw_fd = fd.fd; - + save_slave_setting(dmix, spcm); /* Currently, we assume that each dmix client has the same @@ -1601,7 +1601,7 @@ int snd_pcm_direct_open_secondary_client(snd_pcm_t **spcmp, snd_pcm_direct_t *dm snd_error(PCM, "unable to open hardware"); return ret; } - + spcm = *spcmp; spcm->donot_close = 1; spcm->setup = 1; diff --git a/src/pcm/pcm_direct.h b/src/pcm/pcm_direct.h index 2a398045..9a8c5527 100644 --- a/src/pcm/pcm_direct.h +++ b/src/pcm/pcm_direct.h @@ -19,7 +19,7 @@ * */ -#include "pcm_local.h" +#include "pcm_local.h" #include "../timer/timer_local.h" #define DIRECT_IPC_SEMS 1 @@ -103,8 +103,8 @@ typedef struct { unsigned int period_step; unsigned int sleep_min; /* not used */ unsigned int avail_min; - unsigned int start_threshold; - unsigned int stop_threshold; + unsigned int start_threshold; + unsigned int stop_threshold; unsigned int silence_threshold; unsigned int silence_size; unsigned int recoveries; /* no of executed recoveries on slave*/ diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c index e1e94c0e..22fcf3e5 100644 --- a/src/pcm/pcm_dmix.c +++ b/src/pcm/pcm_dmix.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include #include @@ -63,7 +63,7 @@ const char *_snd_module_pcm_dmix = ""; static int shm_sum_discard(snd_pcm_direct_t *dmix); /* - * sum ring buffer shared memory area + * sum ring buffer shared memory area */ static int shm_sum_create_or_connect(snd_pcm_direct_t *dmix) { @@ -73,7 +73,7 @@ static int shm_sum_create_or_connect(snd_pcm_direct_t *dmix) size = dmix->shmptr->s.channels * dmix->shmptr->s.buffer_size * - sizeof(signed int); + sizeof(signed int); retryshm: dmix->u.dmix.shmid_sum = shmget(dmix->ipc_key + 1, size, IPC_CREAT | dmix->ipc_perm); @@ -82,7 +82,7 @@ retryshm: if (errno == EINVAL) if ((tmpid = shmget(dmix->ipc_key + 1, 0, dmix->ipc_perm)) != -1) if (!shmctl(tmpid, IPC_STAT, &buf)) - if (!buf.shm_nattch) + if (!buf.shm_nattch) /* no users so destroy the segment */ if (!shmctl(tmpid, IPC_RMID, NULL)) goto retryshm; @@ -95,7 +95,7 @@ retryshm: } if (dmix->ipc_gid >= 0) { buf.shm_perm.gid = dmix->ipc_gid; - shmctl(dmix->u.dmix.shmid_sum, IPC_SET, &buf); + shmctl(dmix->u.dmix.shmid_sum, IPC_SET, &buf); } dmix->u.dmix.sum_buffer = shmat(dmix->u.dmix.shmid_sum, 0, 0); if (dmix->u.dmix.sum_buffer == (void *) -1) { @@ -162,7 +162,7 @@ static void mix_areas(snd_pcm_direct_t *dmix, unsigned int src_step, dst_step; unsigned int chn, dchn, channels, sample_size; mix_areas_t *do_mix_areas; - + channels = dmix->channels; switch (dmix->shmptr->s.format) { case SND_PCM_FORMAT_S16_LE: @@ -230,7 +230,7 @@ static void remix_areas(snd_pcm_direct_t *dmix, unsigned int src_step, dst_step; unsigned int chn, dchn, channels, sample_size; mix_areas_t *do_remix_areas; - + channels = dmix->channels; switch (dmix->shmptr->s.format) { case SND_PCM_FORMAT_S16_LE: @@ -315,7 +315,7 @@ static void snd_pcm_dmix_sync_area(snd_pcm_t *pcm) snd_pcm_uframes_t slave_hw_ptr, slave_appl_ptr, slave_size; snd_pcm_uframes_t appl_ptr, size, transfer; const snd_pcm_channel_area_t *src_areas, *dst_areas; - + /* calculate the size to transfer */ /* check the available size in the local buffer * last_appl_ptr keeps the last updated position @@ -391,7 +391,7 @@ static int snd_pcm_dmix_sync_ptr0(snd_pcm_t *pcm, snd_pcm_uframes_t slave_hw_ptr snd_pcm_direct_t *dmix = pcm->private_data; snd_pcm_uframes_t old_slave_hw_ptr, avail; snd_pcm_sframes_t diff; - + old_slave_hw_ptr = dmix->slave_hw_ptr; dmix->slave_hw_ptr = slave_hw_ptr; diff = pcm_frame_diff(slave_hw_ptr, old_slave_hw_ptr, dmix->slave_boundary); @@ -483,7 +483,7 @@ static int snd_pcm_dmix_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp) { snd_pcm_direct_t *dmix = pcm->private_data; int err; - + switch(dmix->state) { case SNDRV_PCM_STATE_DRAINING: case SNDRV_PCM_STATE_RUNNING: @@ -554,7 +554,7 @@ static int snd_pcm_dmix_start(snd_pcm_t *pcm) snd_pcm_direct_t *dmix = pcm->private_data; snd_pcm_sframes_t avail; int err; - + if (dmix->state != SND_PCM_STATE_PREPARED) return -EBADFD; avail = snd_pcm_mmap_playback_hw_avail(pcm); @@ -784,11 +784,11 @@ static int snd_pcm_dmix_close(snd_pcm_t *pcm) snd_timer_close(dmix->timer); snd_pcm_direct_semaphore_down(dmix, DIRECT_IPC_SEM_CLIENT); snd_pcm_close(dmix->spcm); - if (dmix->server) - snd_pcm_direct_server_discard(dmix); - if (dmix->client) - snd_pcm_direct_client_discard(dmix); - shm_sum_discard(dmix); + if (dmix->server) + snd_pcm_direct_server_discard(dmix); + if (dmix->client) + snd_pcm_direct_client_discard(dmix); + shm_sum_discard(dmix); if (snd_pcm_direct_shm_discard(dmix)) { if (snd_pcm_direct_semaphore_discard(dmix)) snd_pcm_direct_semaphore_final(dmix, DIRECT_IPC_SEM_CLIENT); @@ -837,7 +837,7 @@ static snd_pcm_sframes_t snd_pcm_dmix_avail_update(snd_pcm_t *pcm) { snd_pcm_direct_t *dmix = pcm->private_data; int err; - + if (dmix->state == SND_PCM_STATE_RUNNING || dmix->state == SND_PCM_STATE_DRAINING) { if ((err = snd_pcm_dmix_sync_ptr(pcm)) < 0) @@ -856,7 +856,7 @@ static int snd_pcm_dmix_htimestamp(snd_pcm_t *pcm, snd_pcm_direct_t *dmix = pcm->private_data; snd_pcm_uframes_t avail1; int ok = 0; - + while (1) { if (dmix->state == SND_PCM_STATE_RUNNING || dmix->state == SND_PCM_STATE_DRAINING) @@ -1000,13 +1000,13 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, snd_error(PCM, "unable to open slave"); goto _err; } - + if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) { snd_error(PCM, "dmix plugin can be only connected to hw plugin"); ret = -EINVAL; goto _err; } - + ret = snd_pcm_direct_initialize_slave(dmix, spcm, params); if (ret < 0) { snd_error(PCM, "unable to initialize slave"); @@ -1017,7 +1017,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, if (dmix->shmptr->use_server) { dmix->server_free = dmix_server_free; - + ret = snd_pcm_direct_server_create(dmix); if (ret < 0) { snd_error(PCM, "unable to create server"); @@ -1035,7 +1035,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, snd_error(PCM, "unable to connect client"); goto _err_nosem; } - + snd_pcm_direct_semaphore_down(dmix, DIRECT_IPC_SEM_CLIENT); ret = snd_pcm_direct_open_secondary_client(&spcm, dmix, "dmix_client"); if (ret < 0) @@ -1062,7 +1062,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, ret = -EINVAL; goto _err; } - + ret = snd_pcm_direct_initialize_secondary_slave(dmix, spcm, params); if (ret < 0) { snd_error(PCM, "unable to initialize slave"); @@ -1086,14 +1086,14 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, } mix_select_callbacks(dmix); - + pcm->poll_fd = dmix->poll_fd; pcm->poll_events = POLLIN; /* it's different than other plugins */ pcm->tstamp_type = spcm->tstamp_type; pcm->mmap_rw = 1; snd_pcm_set_hw_ptr(pcm, &dmix->hw_ptr, -1, 0); snd_pcm_set_appl_ptr(pcm, &dmix->appl_ptr, -1, 0); - + if (dmix->channels == UINT_MAX) dmix->channels = dmix->shmptr->s.channels; @@ -1101,7 +1101,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, *pcmp = pcm; return 0; - + _err: if (dmix->timer) snd_timer_close(dmix->timer); @@ -1317,7 +1317,7 @@ int _snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name, if (err < 0) return err; - /* set a reasonable default */ + /* set a reasonable default */ if (psize == -1 && params.period_time == -1) params.period_time = 125000; /* 0.125 seconds */ diff --git a/src/pcm/pcm_dmix_generic.c b/src/pcm/pcm_dmix_generic.c index 701c66c9..7d0b00af 100644 --- a/src/pcm/pcm_dmix_generic.c +++ b/src/pcm/pcm_dmix_generic.c @@ -289,12 +289,12 @@ static void generic_mix_areas_16_swap(unsigned int size, } static void generic_remix_areas_16_swap(unsigned int size, - volatile signed short *dst, - signed short *src, - volatile signed int *sum, - size_t dst_step, - size_t src_step, - size_t sum_step) + volatile signed short *dst, + signed short *src, + volatile signed int *sum, + size_t dst_step, + size_t src_step, + size_t sum_step) { register signed int sample; @@ -354,12 +354,12 @@ static void generic_mix_areas_32_swap(unsigned int size, } static void generic_remix_areas_32_swap(unsigned int size, - volatile signed int *dst, - signed int *src, - volatile signed int *sum, - size_t dst_step, - size_t src_step, - size_t sum_step) + volatile signed int *dst, + signed int *src, + volatile signed int *sum, + size_t dst_step, + size_t src_step, + size_t sum_step) { register signed int sample; diff --git a/src/pcm/pcm_dmix_i386.c b/src/pcm/pcm_dmix_i386.c index ea55d8ec..6413cb19 100644 --- a/src/pcm/pcm_dmix_i386.c +++ b/src/pcm/pcm_dmix_i386.c @@ -55,7 +55,7 @@ #undef LOCK_PREFIX #undef XADD #undef XSUB - + #define MIX_AREAS_16 remix_areas_16_smp #define MIX_AREAS_16_MMX remix_areas_16_smp_mmx #define MIX_AREAS_32 remix_areas_32_smp @@ -73,7 +73,7 @@ #undef LOCK_PREFIX #undef XADD #undef XSUB - + #define i386_dmix_supported_format \ ((1ULL << SND_PCM_FORMAT_S16_LE) |\ (1ULL << SND_PCM_FORMAT_S32_LE) |\ @@ -100,7 +100,7 @@ static void mix_select_callbacks(snd_pcm_direct_t *dmix) if (!smp) { FILE *in; char line[255]; - + /* try to determine the capabilities of the CPU */ in = fopen("/proc/cpuinfo", "r"); if (in) { @@ -117,7 +117,7 @@ static void mix_select_callbacks(snd_pcm_direct_t *dmix) fclose(in); } } - + if (mmx) { dmix->u.dmix.mix_areas_16 = smp > 1 ? mix_areas_16_smp_mmx : mix_areas_16_mmx; dmix->u.dmix.remix_areas_16 = smp > 1 ? remix_areas_16_smp_mmx : remix_areas_16_mmx; diff --git a/src/pcm/pcm_dmix_i386.h b/src/pcm/pcm_dmix_i386.h index 8dcba3d8..0a56e8c6 100644 --- a/src/pcm/pcm_dmix_i386.h +++ b/src/pcm/pcm_dmix_i386.h @@ -244,7 +244,7 @@ static void MIX_AREAS_16_MMX(unsigned int size, "\tdecl %[size]\n" "\tjnz 1b\n" "\temms\n" - "5:" + "5:" #ifdef BOUNDED_EBX "\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */ #endif diff --git a/src/pcm/pcm_dmix_x86_64.c b/src/pcm/pcm_dmix_x86_64.c index 1c80e181..84eb68f1 100644 --- a/src/pcm/pcm_dmix_x86_64.c +++ b/src/pcm/pcm_dmix_x86_64.c @@ -43,7 +43,7 @@ #undef LOCK_PREFIX #undef XADD #undef XSUB - + #define MIX_AREAS_16 remix_areas_16_smp #define MIX_AREAS_32 remix_areas_32_smp #define MIX_AREAS_24 remix_areas_24_smp @@ -57,7 +57,7 @@ #undef LOCK_PREFIX #undef XADD #undef XSUB - + #define x86_64_dmix_supported_format \ ((1ULL << SND_PCM_FORMAT_S16_LE) |\ (1ULL << SND_PCM_FORMAT_S32_LE) |\ @@ -69,7 +69,7 @@ static void mix_select_callbacks(snd_pcm_direct_t *dmix) { static int smp = 0; - + if (!dmix->direct_memory_access) { generic_mix_select_callbacks(dmix); return; diff --git a/src/pcm/pcm_dmix_x86_64.h b/src/pcm/pcm_dmix_x86_64.h index 1932be3e..8b62a45d 100644 --- a/src/pcm/pcm_dmix_x86_64.h +++ b/src/pcm/pcm_dmix_x86_64.h @@ -137,7 +137,7 @@ static void MIX_AREAS_16(unsigned int size, #ifdef BOUNDED_RBX , [old_rbx] "=m" (old_rbx) #endif - : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum), + : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum), [dst_step] "im" (dst_step), [src_step] "im" (src_step), [sum_step] "im" (sum_step) : "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc" @@ -279,7 +279,7 @@ static void MIX_AREAS_32(unsigned int size, #ifdef BOUNDED_RBX , [old_rbx] "=m" (old_rbx) #endif - : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum), + : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum), [dst_step] "im" (dst_step), [src_step] "im" (src_step), [sum_step] "im" (sum_step) : "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc" @@ -403,7 +403,7 @@ static void MIX_AREAS_24(unsigned int size, #ifdef BOUNDED_RBX , [old_rbx] "=m" (old_rbx) #endif - : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum), + : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum), [dst_step] "im" (dst_step), [src_step] "im" (src_step), [sum_step] "im" (sum_step) : "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc" diff --git a/src/pcm/pcm_dshare.c b/src/pcm/pcm_dshare.c index 3cb66de8..65da72a9 100644 --- a/src/pcm/pcm_dshare.c +++ b/src/pcm/pcm_dshare.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include #include @@ -111,7 +111,7 @@ static void snd_pcm_dshare_sync_area(snd_pcm_t *pcm) snd_pcm_uframes_t slave_hw_ptr, slave_appl_ptr, slave_size; snd_pcm_uframes_t appl_ptr, size; const snd_pcm_channel_area_t *src_areas, *dst_areas; - + /* calculate the size to transfer */ size = pcm_frame_diff(dshare->appl_ptr, dshare->last_appl_ptr, pcm->boundary); if (! size) @@ -259,7 +259,7 @@ static int snd_pcm_dshare_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp) { snd_pcm_direct_t *dshare = pcm->private_data; int err; - + switch (dshare->state) { case SNDRV_PCM_STATE_DRAINING: case SNDRV_PCM_STATE_RUNNING: @@ -328,7 +328,7 @@ static int snd_pcm_dshare_start(snd_pcm_t *pcm) snd_pcm_direct_t *dshare = pcm->private_data; snd_pcm_sframes_t avail; int err; - + if (dshare->state != SND_PCM_STATE_PREPARED) return -EBADFD; avail = snd_pcm_mmap_playback_hw_avail(pcm); @@ -484,10 +484,10 @@ static int snd_pcm_dshare_close(snd_pcm_t *pcm) snd_pcm_direct_semaphore_down(dshare, DIRECT_IPC_SEM_CLIENT); dshare->shmptr->u.dshare.chn_mask &= ~dshare->u.dshare.chn_mask; snd_pcm_close(dshare->spcm); - if (dshare->server) - snd_pcm_direct_server_discard(dshare); - if (dshare->client) - snd_pcm_direct_client_discard(dshare); + if (dshare->server) + snd_pcm_direct_server_discard(dshare); + if (dshare->client) + snd_pcm_direct_client_discard(dshare); if (snd_pcm_direct_shm_discard(dshare)) { if (snd_pcm_direct_semaphore_discard(dshare)) snd_pcm_direct_semaphore_final(dshare, DIRECT_IPC_SEM_CLIENT); @@ -537,7 +537,7 @@ static snd_pcm_sframes_t snd_pcm_dshare_avail_update(snd_pcm_t *pcm) { snd_pcm_direct_t *dshare = pcm->private_data; int err; - + if (dshare->state == SND_PCM_STATE_RUNNING || dshare->state == SND_PCM_STATE_DRAINING) { if ((err = snd_pcm_dshare_sync_ptr(pcm)) < 0) @@ -556,7 +556,7 @@ static int snd_pcm_dshare_htimestamp(snd_pcm_t *pcm, snd_pcm_direct_t *dshare = pcm->private_data; snd_pcm_uframes_t avail1; int ok = 0; - + while (1) { if (dshare->state == SND_PCM_STATE_RUNNING || dshare->state == SND_PCM_STATE_DRAINING) @@ -701,12 +701,12 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, snd_error(PCM, "unable to open slave"); goto _err; } - + if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) { snd_error(PCM, "dshare plugin can be only connected to hw plugin"); goto _err; } - + ret = snd_pcm_direct_initialize_slave(dshare, spcm, params); if (ret < 0) { snd_error(PCM, "unable to initialize slave"); @@ -714,7 +714,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, } dshare->spcm = spcm; - + if (dshare->shmptr->use_server) { ret = snd_pcm_direct_server_create(dshare); if (ret < 0) { @@ -733,7 +733,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, snd_error(PCM, "unable to connect client"); goto _err_nosem; } - + snd_pcm_direct_semaphore_down(dshare, DIRECT_IPC_SEM_CLIENT); ret = snd_pcm_direct_open_secondary_client(&spcm, dshare, "dshare_client"); if (ret < 0) @@ -761,7 +761,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, ret = -EINVAL; goto _err; } - + ret = snd_pcm_direct_initialize_secondary_slave(dshare, spcm, params); if (ret < 0) { snd_error(PCM, "unable to initialize slave"); @@ -784,7 +784,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, goto _err; } dshare->shmptr->u.dshare.chn_mask |= dshare->u.dshare.chn_mask; - + ret = snd_pcm_direct_initialize_poll_fd(dshare); if (ret < 0) { snd_error(PCM, "unable to initialize poll_fd"); @@ -797,12 +797,12 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name, pcm->mmap_rw = 1; snd_pcm_set_hw_ptr(pcm, &dshare->hw_ptr, -1, 0); snd_pcm_set_appl_ptr(pcm, &dshare->appl_ptr, -1, 0); - + snd_pcm_direct_semaphore_up(dshare, DIRECT_IPC_SEM_CLIENT); *pcmp = pcm; return 0; - + _err: if (dshare->shmptr != (void *) -1) dshare->shmptr->u.dshare.chn_mask &= ~dshare->u.dshare.chn_mask; diff --git a/src/pcm/pcm_dsnoop.c b/src/pcm/pcm_dsnoop.c index 684ed63f..8c3b53ae 100644 --- a/src/pcm/pcm_dsnoop.c +++ b/src/pcm/pcm_dsnoop.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include #include @@ -106,7 +106,7 @@ static void snd_pcm_dsnoop_sync_area(snd_pcm_t *pcm, snd_pcm_uframes_t slave_hw_ snd_pcm_uframes_t hw_ptr = dsnoop->hw_ptr; snd_pcm_uframes_t transfer; const snd_pcm_channel_area_t *src_areas, *dst_areas; - + /* add sample areas here */ dst_areas = snd_pcm_mmap_areas(pcm); src_areas = snd_pcm_mmap_areas(dsnoop->spcm); @@ -119,7 +119,7 @@ static void snd_pcm_dsnoop_sync_area(snd_pcm_t *pcm, snd_pcm_uframes_t slave_hw_ size -= transfer; snoop_areas(dsnoop, src_areas, dst_areas, slave_hw_ptr, hw_ptr, transfer); slave_hw_ptr += transfer; - slave_hw_ptr %= dsnoop->slave_buffer_size; + slave_hw_ptr %= dsnoop->slave_buffer_size; hw_ptr += transfer; hw_ptr %= pcm->buffer_size; } @@ -206,7 +206,7 @@ static int snd_pcm_dsnoop_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp) { snd_pcm_direct_t *dsnoop = pcm->private_data; int err; - + switch(dsnoop->state) { case SNDRV_PCM_STATE_DRAINING: case SNDRV_PCM_STATE_RUNNING: @@ -373,10 +373,10 @@ static int snd_pcm_dsnoop_close(snd_pcm_t *pcm) snd_timer_close(dsnoop->timer); snd_pcm_direct_semaphore_down(dsnoop, DIRECT_IPC_SEM_CLIENT); snd_pcm_close(dsnoop->spcm); - if (dsnoop->server) - snd_pcm_direct_server_discard(dsnoop); - if (dsnoop->client) - snd_pcm_direct_client_discard(dsnoop); + if (dsnoop->server) + snd_pcm_direct_server_discard(dsnoop); + if (dsnoop->client) + snd_pcm_direct_client_discard(dsnoop); if (snd_pcm_direct_shm_discard(dsnoop)) { if (snd_pcm_direct_semaphore_discard(dsnoop)) snd_pcm_direct_semaphore_final(dsnoop, DIRECT_IPC_SEM_CLIENT); @@ -414,7 +414,7 @@ static snd_pcm_sframes_t snd_pcm_dsnoop_avail_update(snd_pcm_t *pcm) { snd_pcm_direct_t *dsnoop = pcm->private_data; int err; - + if (dsnoop->state == SND_PCM_STATE_RUNNING) { err = snd_pcm_dsnoop_sync_ptr(pcm); if (err < 0) @@ -433,7 +433,7 @@ static int snd_pcm_dsnoop_htimestamp(snd_pcm_t *pcm, snd_pcm_direct_t *dsnoop = pcm->private_data; snd_pcm_uframes_t avail1; int ok = 0; - + while (1) { if (dsnoop->state == SND_PCM_STATE_RUNNING || dsnoop->state == SND_PCM_STATE_DRAINING) @@ -567,12 +567,12 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, snd_error(PCM, "unable to open slave"); goto _err; } - + if (snd_pcm_type(spcm) != SND_PCM_TYPE_HW) { snd_error(PCM, "dsnoop plugin can be only connected to hw plugin"); goto _err; } - + ret = snd_pcm_direct_initialize_slave(dsnoop, spcm, params); if (ret < 0) { snd_error(PCM, "unable to initialize slave"); @@ -580,7 +580,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, } dsnoop->spcm = spcm; - + if (dsnoop->shmptr->use_server) { ret = snd_pcm_direct_server_create(dsnoop); if (ret < 0) { @@ -599,7 +599,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, snd_error(PCM, "unable to connect client"); goto _err_nosem; } - + snd_pcm_direct_semaphore_down(dsnoop, DIRECT_IPC_SEM_CLIENT); ret = snd_pcm_direct_open_secondary_client(&spcm, dsnoop, "dsnoop_client"); @@ -627,7 +627,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, ret = -EINVAL; goto _err; } - + ret = snd_pcm_direct_initialize_secondary_slave(dsnoop, spcm, params); if (ret < 0) { snd_error(PCM, "unable to initialize slave"); @@ -650,17 +650,17 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, pcm->mmap_rw = 1; snd_pcm_set_hw_ptr(pcm, &dsnoop->hw_ptr, -1, 0); snd_pcm_set_appl_ptr(pcm, &dsnoop->appl_ptr, -1, 0); - + if (dsnoop->channels == UINT_MAX) dsnoop->channels = dsnoop->shmptr->s.channels; - + snd_pcm_direct_semaphore_up(dsnoop, DIRECT_IPC_SEM_CLIENT); *pcmp = pcm; return 0; - + _err: - if (dsnoop->timer) + if (dsnoop->timer) snd_timer_close(dsnoop->timer); if (dsnoop->server) snd_pcm_direct_server_discard(dsnoop); @@ -804,7 +804,7 @@ int _snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name, if (err < 0) return err; - /* set a reasonable default */ + /* set a reasonable default */ if (psize == -1 && params.period_time == -1) params.period_time = 125000; /* 0.125 seconds */ diff --git a/src/pcm/pcm_empty.c b/src/pcm/pcm_empty.c index 72065b94..0b8fb3a0 100644 --- a/src/pcm/pcm_empty.c +++ b/src/pcm/pcm_empty.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_plugin.h" @@ -77,8 +77,8 @@ pcm.name { * changed in future. */ int _snd_pcm_empty_open(snd_pcm_t **pcmp, const char *name ATTRIBUTE_UNUSED, - snd_config_t *root, snd_config_t *conf, - snd_pcm_stream_t stream, int mode) + snd_config_t *root, snd_config_t *conf, + snd_pcm_stream_t stream, int mode) { snd_config_t *slave = NULL, *sconf; snd_config_iterator_t i, next; diff --git a/src/pcm/pcm_extplug.c b/src/pcm/pcm_extplug.c index bb7933c8..14d7c14f 100644 --- a/src/pcm/pcm_extplug.c +++ b/src/pcm/pcm_extplug.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_plugin.h" #include "pcm_extplug.h" @@ -264,7 +264,7 @@ static int snd_pcm_extplug_hw_refine_schange(snd_pcm_t *pcm, return _snd_pcm_hw_params_refine(sparams, links, params); } - + static int snd_pcm_extplug_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) @@ -511,7 +511,7 @@ usually you will call the external plugin API function, #snd_pcm_extplug_create() or #snd_pcm_ioplug_create(), depending on the plugin type. The PCM handle must be filled *pcmp in return. Then this function must return either a value 0 when succeeded, or a -negative value as the error code. +negative value as the error code. Finally, add #SND_PCM_PLUGIN_SYMBOL() with the name of your plugin as the argument at the end. This defines the proper versioned @@ -596,7 +596,7 @@ Otherfields are optional and should be initialized with zero. The constant #SND_PCM_EXTPLUG_VERSION must be passed to the version field for the version check in alsa-lib. A non-NULL ASCII string -has to be passed to the name field. The callback field contains the +has to be passed to the name field. The callback field contains the table of callback functions for this plugin (defined as #snd_pcm_extplug_callback_t). @@ -611,7 +611,7 @@ The callback functions in #snd_pcm_extplug_callback_t define the real behavior of the driver. At least, transfer callback must be given. This callback is called at each time certain size of data block is transfered to the slave -PCM. Other callbacks are optional. +PCM. Other callbacks are optional. The close callback is called when the PCM is closed. If the plugin allocates private resources, this is the place to release them @@ -640,7 +640,7 @@ either #snd_pcm_extplug_set_slave_param_minmax() and as former functions. To clear the parameter constraints, call #snd_pcm_extplug_params_reset() -function. +function. When using snd_pcm_extplug_set_param_*() or snd_pcm_extplug_set_slave_param_*() for any parameter. This parameter is no longer linked between the client and diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c index a5208067..f2c73163 100644 --- a/src/pcm/pcm_file.c +++ b/src/pcm/pcm_file.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_plugin.h" #include "bswap.h" @@ -353,7 +353,7 @@ static int write_wav_header(snd_pcm_t *pcm) 'd', 'a', 't', 'a', 0, 0, 0, 0 }; - + setup_wav_header(pcm, &file->wav_header); res = safe_write(file->fd, header, sizeof(header)); @@ -472,7 +472,7 @@ static int snd_pcm_file_add_frames(snd_pcm_t *pcm, n = cont; if (n > avail) n = avail; - snd_pcm_areas_copy(file->wbuf_areas, file->appl_ptr, + snd_pcm_areas_copy(file->wbuf_areas, file->appl_ptr, areas, offset, pcm->channels, n, pcm->format); frames -= n; @@ -564,7 +564,7 @@ static snd_pcm_sframes_t snd_pcm_file_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t f snd_pcm_file_t *file = pcm->private_data; snd_pcm_sframes_t err; snd_pcm_uframes_t n; - + n = snd_pcm_frames_to_bytes(pcm, frames); if (n > file->wbuf_used_bytes) frames = snd_pcm_bytes_to_frames(pcm, file->wbuf_used_bytes); @@ -592,7 +592,7 @@ static snd_pcm_sframes_t snd_pcm_file_forward(snd_pcm_t *pcm, snd_pcm_uframes_t snd_pcm_file_t *file = pcm->private_data; snd_pcm_sframes_t err; snd_pcm_uframes_t n; - + n = snd_pcm_frames_to_bytes(pcm, frames); if (file->wbuf_used_bytes + n > file->wbuf_size_bytes) frames = snd_pcm_bytes_to_frames(pcm, file->wbuf_size_bytes - file->wbuf_used_bytes); @@ -690,7 +690,7 @@ static snd_pcm_sframes_t snd_pcm_file_readn(snd_pcm_t *pcm, void **bufs, snd_pcm } static snd_pcm_sframes_t snd_pcm_file_mmap_commit(snd_pcm_t *pcm, - snd_pcm_uframes_t offset, + snd_pcm_uframes_t offset, snd_pcm_uframes_t size) { snd_pcm_file_t *file = pcm->private_data; @@ -982,14 +982,14 @@ to a command, and optionally uses an existing file as an input data source \code pcm.name { - type file # File PCM - slave STR # Slave name - # or - slave { # Slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition - } + type file # File PCM + slave STR # Slave name + # or + slave { # Slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + } file STR # Output filename (or shell command the stream # will be piped to if STR starts with the pipe # char). @@ -1034,7 +1034,7 @@ pcm.name { * changed in future. */ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; diff --git a/src/pcm/pcm_generic.c b/src/pcm/pcm_generic.c index 8177adc7..8f93eec8 100644 --- a/src/pcm/pcm_generic.c +++ b/src/pcm/pcm_generic.c @@ -7,7 +7,7 @@ */ /* * PCM - Common generic plugin code - * Copyright (c) 2004 by Jaroslav Kysela + * Copyright (c) 2004 by Jaroslav Kysela * * * This library is free software; you can redistribute it and/or modify @@ -125,7 +125,7 @@ int snd_pcm_generic_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *info) } int snd_pcm_generic_status(snd_pcm_t *pcm, snd_pcm_status_t * status) -{ +{ snd_pcm_generic_t *generic = pcm->private_data; return snd_pcm_status(generic->slave, status); } @@ -256,7 +256,7 @@ snd_pcm_sframes_t snd_pcm_generic_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_ufr return _snd_pcm_readn(generic->slave, bufs, size); } -snd_pcm_sframes_t snd_pcm_generic_mmap_commit(snd_pcm_t *pcm, +snd_pcm_sframes_t snd_pcm_generic_mmap_commit(snd_pcm_t *pcm, snd_pcm_uframes_t offset, snd_pcm_uframes_t size) { diff --git a/src/pcm/pcm_generic.h b/src/pcm/pcm_generic.h index dfbe21a0..4d9100e3 100644 --- a/src/pcm/pcm_generic.h +++ b/src/pcm/pcm_generic.h @@ -18,11 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + typedef struct { snd_pcm_t *slave; int close_slave; -} snd_pcm_generic_t; +} snd_pcm_generic_t; /* make local functions really local */ #define snd_pcm_generic_close \ diff --git a/src/pcm/pcm_hooks.c b/src/pcm/pcm_hooks.c index c4afbccb..4df7522e 100644 --- a/src/pcm/pcm_hooks.c +++ b/src/pcm/pcm_hooks.c @@ -26,7 +26,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_generic.h" @@ -283,9 +283,9 @@ pcm.NAME { slave STR # Slave name # or slave { # Slave definition - pcm STR # Slave PCM name + pcm STR # Slave PCM name # or - pcm { } # Slave PCM definition + pcm { } # Slave PCM definition } hooks { ID STR # Hook name (see pcm_hook) @@ -480,7 +480,7 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_ * changed in future. */ int _snd_pcm_hooks_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index 207738ef..e4dc9085 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -26,7 +26,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "../control/control_local.h" #include "../timer/timer_local.h" @@ -375,7 +375,7 @@ static int snd_pcm_hw_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) if (pcm->tstamp_type != SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY) params->info |= SND_PCM_INFO_MONOTONIC; } - + return 0; } @@ -434,7 +434,7 @@ static int snd_pcm_hw_change_timer(snd_pcm_t *pcm, int enable) snd_timer_params_t params = {0}; unsigned int suspend, resume; int err; - + if (enable) { err = snd_timer_hw_open(&hw->period_timer, "hw-pcm-period-event", @@ -456,7 +456,7 @@ static int snd_pcm_hw_change_timer(snd_pcm_t *pcm, int enable) return -EINVAL; } hw->period_timer_pfd.events = POLLIN; - hw->period_timer_pfd.revents = 0; + hw->period_timer_pfd.revents = 0; snd_timer_poll_descriptors(hw->period_timer, &hw->period_timer_pfd, 1); hw->period_timer_need_poll = 0; @@ -473,7 +473,7 @@ static int snd_pcm_hw_change_timer(snd_pcm_t *pcm, int enable) * In older versions, check via poll before read() is * needed because of the confliction between * TIMER_START and FIONBIO ioctls. - */ + */ if (ver < SNDRV_PROTOCOL_VERSION(2, 0, 4)) hw->period_timer_need_poll = 1; /* @@ -1691,7 +1691,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd, return ret; } } - + hw = calloc(1, sizeof(snd_pcm_hw_t)); if (!hw) { close(fd); @@ -1785,7 +1785,7 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, sprintf(filename, filefmt, card, device); __again: - if (attempt++ > 3) { + if (attempt++ > 3) { ret = -EBUSY; goto _err; } @@ -2085,8 +2085,8 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, return 0; fail: - snd_pcm_free_chmaps(chmap); - return err; + snd_pcm_free_chmaps(chmap); + return err; } #ifndef DOC_HIDDEN @@ -2152,7 +2152,7 @@ static int use_old_hw_params_ioctl(int fd, unsigned int cmd, snd_pcm_hw_params_t struct sndrv_pcm_hw_params_old oparams; unsigned int cmask = 0; int res; - + snd_pcm_hw_convert_to_old_params(&oparams, params, &cmask); res = ioctl(fd, cmd, &oparams); snd_pcm_hw_convert_from_old_params(params, &oparams); diff --git a/src/pcm/pcm_iec958.c b/src/pcm/pcm_iec958.c index 90d4bbe6..d1bb8fb5 100644 --- a/src/pcm/pcm_iec958.c +++ b/src/pcm/pcm_iec958.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_plugin.h" #include "plugin_ops.h" @@ -295,7 +295,7 @@ static int snd_pcm_iec958_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd return err; return 0; } - + static int snd_pcm_iec958_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) { @@ -454,7 +454,7 @@ snd_pcm_iec958_write_areas(snd_pcm_t *pcm, if (size > *slave_sizep) size = *slave_sizep; iec->func(iec, slave_areas, slave_offset, - areas, offset, + areas, offset, pcm->channels, size); *slave_sizep = size; return size; @@ -472,7 +472,7 @@ snd_pcm_iec958_read_areas(snd_pcm_t *pcm, snd_pcm_iec958_t *iec = pcm->private_data; if (size > *slave_sizep) size = *slave_sizep; - iec->func(iec, areas, offset, + iec->func(iec, areas, offset, slave_areas, slave_offset, pcm->channels, size); *slave_sizep = size; @@ -489,7 +489,7 @@ static int snd_pcm_iec958_init(snd_pcm_t *pcm) static void snd_pcm_iec958_dump(snd_pcm_t *pcm, snd_output_t *out) { snd_pcm_iec958_t *iec = pcm->private_data; - snd_output_printf(out, "IEC958 subframe conversion PCM (%s)\n", + snd_output_printf(out, "IEC958 subframe conversion PCM (%s)\n", snd_pcm_format_name(iec->sformat)); if (pcm->setup) { snd_output_printf(out, "Its setup is:\n"); @@ -560,12 +560,12 @@ static const snd_pcm_ops_t snd_pcm_iec958_ops = { * \warning Using of this function might be dangerous in the sense * of compatibility reasons. The prototype might be freely * changed in future. - */ + */ int snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sformat, snd_pcm_t *slave, int close_slave, const unsigned char *status_bits, const unsigned char *preamble_vals, - int hdmi_mode) + int hdmi_mode) { snd_pcm_t *pcm; snd_pcm_iec958_t *iec; @@ -638,14 +638,14 @@ This plugin converts 32bit IEC958 subframe samples to linear, or linear to \code pcm.name { - type iec958 # IEC958 subframe conversion PCM - slave STR # Slave name - # or - slave { # Slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition - } + type iec958 # IEC958 subframe conversion PCM + slave STR # Slave name + # or + slave { # Slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + } [status status-bytes] # IEC958 status bits (given in byte array) # IEC958 preamble bits definitions # B/M/W or Z/X/Y, B = block start, M = even subframe, W = odd subframe @@ -684,7 +684,7 @@ by the HDMI HBR specification. * changed in future. */ int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; @@ -797,7 +797,7 @@ int _snd_pcm_iec958_open(snd_pcm_t **pcmp, const char *name, if (snd_pcm_format_linear(sformat) != 1 && sformat != SND_PCM_FORMAT_IEC958_SUBFRAME_LE && sformat != SND_PCM_FORMAT_IEC958_SUBFRAME_BE) { - snd_config_delete(sconf); + snd_config_delete(sconf); snd_error(PCM, "invalid slave format"); return -EINVAL; } diff --git a/src/pcm/pcm_ioplug.c b/src/pcm/pcm_ioplug.c index fbc59e90..aff4213d 100644 --- a/src/pcm/pcm_ioplug.c +++ b/src/pcm/pcm_ioplug.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_ioplug.h" #include "pcm_ext_parm.h" @@ -482,7 +482,7 @@ static int snd_pcm_ioplug_start(snd_pcm_t *pcm) { ioplug_priv_t *io = pcm->private_data; int err; - + if (io->data->state != SND_PCM_STATE_PREPARED) return -EBADFD; @@ -637,7 +637,7 @@ static snd_pcm_sframes_t ioplug_priv_transfer_areas(snd_pcm_t *pcm, { ioplug_priv_t *io = pcm->private_data; snd_pcm_sframes_t result; - + if (! size) return 0; if (io->data->callback->transfer) @@ -656,7 +656,7 @@ static snd_pcm_sframes_t snd_pcm_ioplug_writei(snd_pcm_t *pcm, const void *buffe else { snd_pcm_channel_area_t areas[pcm->channels]; snd_pcm_areas_from_buf(pcm, areas, (void*)buffer); - return snd_pcm_write_areas(pcm, areas, 0, size, + return snd_pcm_write_areas(pcm, areas, 0, size, ioplug_priv_transfer_areas); } } @@ -982,7 +982,7 @@ Otherfields are optional and should be initialized with zero. The constant #SND_PCM_IOPLUG_VERSION must be passed to the version field for the version check in alsa-lib. A non-NULL ASCII string -has to be passed to the name field. The callback field contains the +has to be passed to the name field. The callback field contains the table of callback functions for this plugin (defined as #snd_pcm_ioplug_callback_t). diff --git a/src/pcm/pcm_ladspa.c b/src/pcm/pcm_ladspa.c index 79b728d8..17d49409 100644 --- a/src/pcm/pcm_ladspa.c +++ b/src/pcm/pcm_ladspa.c @@ -31,7 +31,7 @@ * The LADSPA plugin rewrite was sponsored by MediaNet AG * http://www.medianet.ag */ - + #include "pcm_local.h" #include "pcm_plugin.h" #include @@ -64,17 +64,17 @@ typedef struct { unsigned int allocated; /* count of allocated samples */ LADSPA_Data *zero[2]; /* zero input or dummy output */ } snd_pcm_ladspa_t; - + typedef struct { - unsigned int size; - unsigned int *array; + unsigned int size; + unsigned int *array; } snd_pcm_ladspa_array_t; typedef struct { - snd_pcm_ladspa_array_t channels; - snd_pcm_ladspa_array_t ports; + snd_pcm_ladspa_array_t channels; + snd_pcm_ladspa_array_t ports; LADSPA_Data **m_data; - LADSPA_Data **data; + LADSPA_Data **data; } snd_pcm_ladspa_eps_t; typedef struct snd_pcm_ladspa_instance { @@ -111,14 +111,14 @@ typedef struct { #endif /* DOC_HIDDEN */ static unsigned int snd_pcm_ladspa_count_ports(snd_pcm_ladspa_plugin_t *lplug, - LADSPA_PortDescriptor pdesc) + LADSPA_PortDescriptor pdesc) { - unsigned int res = 0, idx; - for (idx = 0; idx < lplug->desc->PortCount; idx++) { - if ((lplug->desc->PortDescriptors[idx] & pdesc) == pdesc) - res++; - } - return res; + unsigned int res = 0, idx; + for (idx = 0; idx < lplug->desc->PortCount; idx++) { + if ((lplug->desc->PortDescriptors[idx] & pdesc) == pdesc) + res++; + } + return res; } static int snd_pcm_ladspa_find_port(unsigned int *res, @@ -182,8 +182,8 @@ static void snd_pcm_ladspa_free_plugins(struct list_head *plugins) { while (!list_empty(plugins)) { snd_pcm_ladspa_plugin_t *plugin = list_entry(plugins->next, snd_pcm_ladspa_plugin_t, list); - snd_pcm_ladspa_free_io(&plugin->input); - snd_pcm_ladspa_free_io(&plugin->output); + snd_pcm_ladspa_free_io(&plugin->input); + snd_pcm_ladspa_free_io(&plugin->output); if (plugin->dl_handle) dlclose(plugin->dl_handle); free(plugin->filename); @@ -194,15 +194,15 @@ static void snd_pcm_ladspa_free_plugins(struct list_head *plugins) static void snd_pcm_ladspa_free(snd_pcm_ladspa_t *ladspa) { - unsigned int idx; + unsigned int idx; snd_pcm_ladspa_free_plugins(&ladspa->pplugins); snd_pcm_ladspa_free_plugins(&ladspa->cplugins); for (idx = 0; idx < 2; idx++) { free(ladspa->zero[idx]); - ladspa->zero[idx] = NULL; - } - ladspa->allocated = 0; + ladspa->zero[idx] = NULL; + } + ladspa->allocated = 0; } static int snd_pcm_ladspa_close(snd_pcm_t *pcm) @@ -228,11 +228,11 @@ static int snd_pcm_ladspa_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, sn err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD); if (err < 0) return err; - if (ladspa->channels > 0 && pcm->stream == SND_PCM_STREAM_PLAYBACK) { - err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_CHANNELS, ladspa->channels, 0); - if (err < 0) - return err; - } + if (ladspa->channels > 0 && pcm->stream == SND_PCM_STREAM_PLAYBACK) { + err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_CHANNELS, ladspa->channels, 0); + if (err < 0) + return err; + } params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID); return 0; } @@ -246,8 +246,8 @@ static int snd_pcm_ladspa_hw_refine_sprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, sn &saccess_mask); _snd_pcm_hw_params_set_format(sparams, SND_PCM_FORMAT_FLOAT); _snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD); - if (ladspa->channels > 0 && pcm->stream == SND_PCM_STREAM_CAPTURE) - _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_CHANNELS, ladspa->channels, 0); + if (ladspa->channels > 0 && pcm->stream == SND_PCM_STREAM_CAPTURE) + _snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_CHANNELS, ladspa->channels, 0); return 0; } @@ -268,7 +268,7 @@ static int snd_pcm_ladspa_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd return err; return 0; } - + static int snd_pcm_ladspa_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) { @@ -320,7 +320,7 @@ static void snd_pcm_ladspa_free_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *lads { struct list_head *list, *pos, *pos1, *next1; unsigned int idx; - + list = pcm->stream == SND_PCM_STREAM_PLAYBACK ? &ladspa->pplugins : &ladspa->cplugins; list_for_each(pos, list) { snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list); @@ -332,17 +332,17 @@ static void snd_pcm_ladspa_free_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *lads if (plugin->desc->cleanup) plugin->desc->cleanup(instance->handle); if (instance->input.m_data) { - for (idx = 0; idx < instance->input.channels.size; idx++) + for (idx = 0; idx < instance->input.channels.size; idx++) free(instance->input.m_data[idx]); free(instance->input.m_data); - } + } if (instance->output.m_data) { - for (idx = 0; idx < instance->output.channels.size; idx++) + for (idx = 0; idx < instance->output.channels.size; idx++) free(instance->output.m_data[idx]); free(instance->output.m_data); - } - free(instance->input.data); - free(instance->output.data); + } + free(instance->input.data); + free(instance->output.data); list_del(&(instance->list)); snd_pcm_ladspa_free_eps(&instance->input); snd_pcm_ladspa_free_eps(&instance->output); @@ -359,48 +359,48 @@ static void snd_pcm_ladspa_free_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *lads } static int snd_pcm_ladspa_add_to_carray(snd_pcm_ladspa_array_t *array, - unsigned int idx, - unsigned int val) + unsigned int idx, + unsigned int val) { - unsigned int *narray; - unsigned int idx1; + unsigned int *narray; + unsigned int idx1; - if (idx >= array->size) { - narray = realloc(array->array, sizeof(unsigned int) * (idx + 1)); - if (narray == NULL) - return -ENOMEM; - for (idx1 = array->size; idx1 < idx; idx1++) - narray[idx1] = NO_ASSIGN; - array->array = narray; - array->size = idx + 1; - array->array[idx] = val; - return 0; - } - if (array->array[idx] == NO_ASSIGN) - array->array[idx] = val; - else - return -EINVAL; - return 0; + if (idx >= array->size) { + narray = realloc(array->array, sizeof(unsigned int) * (idx + 1)); + if (narray == NULL) + return -ENOMEM; + for (idx1 = array->size; idx1 < idx; idx1++) + narray[idx1] = NO_ASSIGN; + array->array = narray; + array->size = idx + 1; + array->array[idx] = val; + return 0; + } + if (array->array[idx] == NO_ASSIGN) + array->array[idx] = val; + else + return -EINVAL; + return 0; } static int snd_pcm_ladspa_add_to_array(snd_pcm_ladspa_array_t *array, - unsigned int idx, - unsigned int val) + unsigned int idx, + unsigned int val) { - unsigned int *narray; - unsigned int idx1; + unsigned int *narray; + unsigned int idx1; - if (idx >= array->size) { - narray = realloc(array->array, sizeof(unsigned int) * (idx + 1)); - if (narray == NULL) - return -ENOMEM; - for (idx1 = array->size; idx1 < idx; idx1++) - narray[idx1] = NO_ASSIGN; - array->array = narray; - array->size = idx + 1; - } - array->array[idx] = val; - return 0; + if (idx >= array->size) { + narray = realloc(array->array, sizeof(unsigned int) * (idx + 1)); + if (narray == NULL) + return -ENOMEM; + for (idx1 = array->size; idx1 < idx; idx1++) + narray[idx1] = NO_ASSIGN; + array->array = narray; + array->size = idx + 1; + } + array->array[idx] = val; + return 0; } static int snd_pcm_ladspa_connect_plugin1(snd_pcm_ladspa_plugin_t *plugin, @@ -412,31 +412,31 @@ static int snd_pcm_ladspa_connect_plugin1(snd_pcm_ladspa_plugin_t *plugin, assert(plugin->policy == SND_PCM_LADSPA_POLICY_NONE); channels = io->port_bindings_size > 0 ? - io->port_bindings_size : - snd_pcm_ladspa_count_ports(plugin, io->pdesc | LADSPA_PORT_AUDIO); + io->port_bindings_size : + snd_pcm_ladspa_count_ports(plugin, io->pdesc | LADSPA_PORT_AUDIO); for (idx = idx1 = 0; idx < channels; idx++) { if (io->port_bindings_size > 0) - port = io->port_bindings[idx]; - else { - err = snd_pcm_ladspa_find_port(&port, plugin, io->pdesc | LADSPA_PORT_AUDIO, idx); - if (err < 0) { + port = io->port_bindings[idx]; + else { + err = snd_pcm_ladspa_find_port(&port, plugin, io->pdesc | LADSPA_PORT_AUDIO, idx); + if (err < 0) { snd_error(PCM, "unable to find audio %s port %u plugin '%s'", io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", idx, plugin->desc->Name); - return err; - } - } - if (port == NO_ASSIGN) - continue; - err = snd_pcm_ladspa_add_to_carray(&eps->channels, idx1, idx); - if (err < 0) { + return err; + } + } + if (port == NO_ASSIGN) + continue; + err = snd_pcm_ladspa_add_to_carray(&eps->channels, idx1, idx); + if (err < 0) { snd_error(PCM, "unable to add channel %u for audio %s plugin '%s'", idx, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name); - return err; - } - err = snd_pcm_ladspa_add_to_array(&eps->ports, idx1, port); - if (err < 0) { + return err; + } + err = snd_pcm_ladspa_add_to_array(&eps->ports, idx1, port); + if (err < 0) { snd_error(PCM, "unable to add port %u for audio %s plugin '%s'", port, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name); - return err; - } - idx1++; + return err; + } + idx1++; } return 0; } @@ -444,21 +444,21 @@ static int snd_pcm_ladspa_connect_plugin1(snd_pcm_ladspa_plugin_t *plugin, static int snd_pcm_ladspa_connect_plugin(snd_pcm_ladspa_plugin_t *plugin, snd_pcm_ladspa_instance_t *instance) { - int err; - - err = snd_pcm_ladspa_connect_plugin1(plugin, &plugin->input, &instance->input); - if (err < 0) - return err; - err = snd_pcm_ladspa_connect_plugin1(plugin, &plugin->output, &instance->output); - if (err < 0) - return err; - return 0; + int err; + + err = snd_pcm_ladspa_connect_plugin1(plugin, &plugin->input, &instance->input); + if (err < 0) + return err; + err = snd_pcm_ladspa_connect_plugin1(plugin, &plugin->output, &instance->output); + if (err < 0) + return err; + return 0; } static int snd_pcm_ladspa_connect_plugin_duplicate1(snd_pcm_ladspa_plugin_t *plugin, - snd_pcm_ladspa_plugin_io_t *io, - snd_pcm_ladspa_eps_t *eps, - unsigned int idx) + snd_pcm_ladspa_plugin_io_t *io, + snd_pcm_ladspa_eps_t *eps, + unsigned int idx) { unsigned int port; int err; @@ -471,19 +471,19 @@ static int snd_pcm_ladspa_connect_plugin_duplicate1(snd_pcm_ladspa_plugin_t *plu if (err < 0) { snd_error(PCM, "unable to find audio %s port %u plugin '%s'", io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", (unsigned int)0, plugin->desc->Name); return err; - } + } } err = snd_pcm_ladspa_add_to_carray(&eps->channels, 0, idx); if (err < 0) { snd_error(PCM, "unable to add channel %u for audio %s plugin '%s'", idx, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name); - return err; - } - err = snd_pcm_ladspa_add_to_array(&eps->ports, 0, port); - if (err < 0) { + return err; + } + err = snd_pcm_ladspa_add_to_array(&eps->ports, 0, port); + if (err < 0) { snd_error(PCM, "unable to add port %u for audio %s plugin '%s'", port, io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name); - return err; - } - return 0; + return err; + } + return 0; } static int snd_pcm_ladspa_connect_plugin_duplicate(snd_pcm_ladspa_plugin_t *plugin, @@ -496,73 +496,73 @@ static int snd_pcm_ladspa_connect_plugin_duplicate(snd_pcm_ladspa_plugin_t *plug err = snd_pcm_ladspa_connect_plugin_duplicate1(plugin, in_io, &instance->input, idx); if (err < 0) - return err; + return err; err = snd_pcm_ladspa_connect_plugin_duplicate1(plugin, out_io, &instance->output, idx); if (err < 0) - return err; - return 0; + return err; + return 0; } -static void snd_pcm_ladspa_get_default_cvalue(const LADSPA_Descriptor * desc, unsigned int port, LADSPA_Data *val) +static void snd_pcm_ladspa_get_default_cvalue(const LADSPA_Descriptor * desc, unsigned int port, LADSPA_Data *val) { - LADSPA_PortRangeHintDescriptor hdesc; + LADSPA_PortRangeHintDescriptor hdesc; - hdesc = desc->PortRangeHints[port].HintDescriptor; - switch (hdesc & LADSPA_HINT_DEFAULT_MASK) { - case LADSPA_HINT_DEFAULT_MINIMUM: - *val = desc->PortRangeHints[port].LowerBound; - break; - case LADSPA_HINT_DEFAULT_LOW: - if (LADSPA_IS_HINT_LOGARITHMIC(hdesc)) { - *val = exp(log(desc->PortRangeHints[port].LowerBound) - * 0.75 - + log(desc->PortRangeHints[port].UpperBound) - * 0.25); - } else { - *val = (desc->PortRangeHints[port].LowerBound * 0.75) + - (desc->PortRangeHints[port].UpperBound * 0.25); - } - break; - case LADSPA_HINT_DEFAULT_MIDDLE: - if (LADSPA_IS_HINT_LOGARITHMIC(hdesc)) { - *val = sqrt(desc->PortRangeHints[port].LowerBound * - desc->PortRangeHints[port].UpperBound); - } else { - *val = 0.5 * - (desc->PortRangeHints[port].LowerBound + - desc->PortRangeHints[port].UpperBound); - } - break; - case LADSPA_HINT_DEFAULT_HIGH: - if (LADSPA_IS_HINT_LOGARITHMIC(hdesc)) { - *val = exp(log(desc->PortRangeHints[port].LowerBound) - * 0.25 - + log(desc->PortRangeHints[port].UpperBound) - * 0.75); - } else { - *val = (desc->PortRangeHints[port].LowerBound * 0.25) + - (desc->PortRangeHints[port].UpperBound * 0.75); - } - break; - case LADSPA_HINT_DEFAULT_MAXIMUM: - *val = desc->PortRangeHints[port].UpperBound; - break; - case LADSPA_HINT_DEFAULT_0: - *val = 0; - break; - case LADSPA_HINT_DEFAULT_1: - *val = 1; - break; - case LADSPA_HINT_DEFAULT_100: - *val = 100; - break; - case LADSPA_HINT_DEFAULT_440: - *val = 440; - break; - default: - *val = 0; /* reasonable default, if everything fails */ - break; - } + hdesc = desc->PortRangeHints[port].HintDescriptor; + switch (hdesc & LADSPA_HINT_DEFAULT_MASK) { + case LADSPA_HINT_DEFAULT_MINIMUM: + *val = desc->PortRangeHints[port].LowerBound; + break; + case LADSPA_HINT_DEFAULT_LOW: + if (LADSPA_IS_HINT_LOGARITHMIC(hdesc)) { + *val = exp(log(desc->PortRangeHints[port].LowerBound) + * 0.75 + + log(desc->PortRangeHints[port].UpperBound) + * 0.25); + } else { + *val = (desc->PortRangeHints[port].LowerBound * 0.75) + + (desc->PortRangeHints[port].UpperBound * 0.25); + } + break; + case LADSPA_HINT_DEFAULT_MIDDLE: + if (LADSPA_IS_HINT_LOGARITHMIC(hdesc)) { + *val = sqrt(desc->PortRangeHints[port].LowerBound * + desc->PortRangeHints[port].UpperBound); + } else { + *val = 0.5 * + (desc->PortRangeHints[port].LowerBound + + desc->PortRangeHints[port].UpperBound); + } + break; + case LADSPA_HINT_DEFAULT_HIGH: + if (LADSPA_IS_HINT_LOGARITHMIC(hdesc)) { + *val = exp(log(desc->PortRangeHints[port].LowerBound) + * 0.25 + + log(desc->PortRangeHints[port].UpperBound) + * 0.75); + } else { + *val = (desc->PortRangeHints[port].LowerBound * 0.25) + + (desc->PortRangeHints[port].UpperBound * 0.75); + } + break; + case LADSPA_HINT_DEFAULT_MAXIMUM: + *val = desc->PortRangeHints[port].UpperBound; + break; + case LADSPA_HINT_DEFAULT_0: + *val = 0; + break; + case LADSPA_HINT_DEFAULT_1: + *val = 1; + break; + case LADSPA_HINT_DEFAULT_100: + *val = 100; + break; + case LADSPA_HINT_DEFAULT_440: + *val = 440; + break; + default: + *val = 0; /* reasonable default, if everything fails */ + break; + } } static int snd_pcm_ladspa_connect_controls(snd_pcm_ladspa_plugin_t *plugin, @@ -574,8 +574,8 @@ static int snd_pcm_ladspa_connect_controls(snd_pcm_ladspa_plugin_t *plugin, for (idx = midx = 0; idx < plugin->desc->PortCount; idx++) if ((plugin->desc->PortDescriptors[idx] & (io->pdesc | LADSPA_PORT_CONTROL)) == (io->pdesc | LADSPA_PORT_CONTROL)) { if (io->controls_size > midx) { - if (!io->controls_initialized[midx]) - snd_pcm_ladspa_get_default_cvalue(plugin->desc, idx, &io->controls[midx]); + if (!io->controls_initialized[midx]) + snd_pcm_ladspa_get_default_cvalue(plugin->desc, idx, &io->controls[midx]); plugin->desc->connect_port(instance->handle, idx, &io->controls[midx]); } else { return -EINVAL; @@ -586,53 +586,53 @@ static int snd_pcm_ladspa_connect_controls(snd_pcm_ladspa_plugin_t *plugin, } static int snd_pcm_ladspa_check_connect(snd_pcm_ladspa_plugin_t *plugin, - snd_pcm_ladspa_plugin_io_t *io, - snd_pcm_ladspa_eps_t *eps, - unsigned int depth) + snd_pcm_ladspa_plugin_io_t *io, + snd_pcm_ladspa_eps_t *eps, + unsigned int depth) { - unsigned int idx, midx; - int err = 0; + unsigned int idx, midx; + int err = 0; for (idx = midx = 0; idx < plugin->desc->PortCount; idx++) if ((plugin->desc->PortDescriptors[idx] & (io->pdesc | LADSPA_PORT_AUDIO)) == (io->pdesc | LADSPA_PORT_AUDIO)) { - if (eps->channels.array[midx] == NO_ASSIGN) { + if (eps->channels.array[midx] == NO_ASSIGN) { snd_error(PCM, "%s port for plugin %s depth %u is not connected", io->pdesc & LADSPA_PORT_INPUT ? "input" : "output", plugin->desc->Name, depth); - err++; - } + err++; + } midx++; } - if (err > 0) { + if (err > 0) { snd_error(PCM, "%i connection errors total", err); - return -EINVAL; - } - return 0; + return -EINVAL; + } + return 0; } static int snd_pcm_ladspa_allocate_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *ladspa) { struct list_head *list, *pos; unsigned int depth, idx, count; - unsigned int in_channels; + unsigned int in_channels; unsigned int in_ports, out_ports; snd_pcm_ladspa_instance_t *instance = NULL; int err; - + list = pcm->stream == SND_PCM_STREAM_PLAYBACK ? &ladspa->pplugins : &ladspa->cplugins; in_channels = ladspa->channels > 0 ? ladspa->channels : - (pcm->stream == SND_PCM_STREAM_PLAYBACK ? pcm->channels : ladspa->plug.gen.slave->channels); + (pcm->stream == SND_PCM_STREAM_PLAYBACK ? pcm->channels : ladspa->plug.gen.slave->channels); depth = 0; list_for_each(pos, list) { snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list); - in_ports = snd_pcm_ladspa_count_ports(plugin, LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO); - out_ports = snd_pcm_ladspa_count_ports(plugin, LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO); + in_ports = snd_pcm_ladspa_count_ports(plugin, LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO); + out_ports = snd_pcm_ladspa_count_ports(plugin, LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO); count = 1; if (plugin->policy == SND_PCM_LADSPA_POLICY_DUPLICATE) { - if (in_ports == 1 && out_ports == 1) - count = in_channels; - else - plugin->policy = SND_PCM_LADSPA_POLICY_NONE; - } - for (idx = 0; idx < count; idx++) { + if (in_ports == 1 && out_ports == 1) + count = in_channels; + else + plugin->policy = SND_PCM_LADSPA_POLICY_NONE; + } + for (idx = 0; idx < count; idx++) { instance = (snd_pcm_ladspa_instance_t *)calloc(1, sizeof(snd_pcm_ladspa_instance_t)); if (instance == NULL) return -ENOMEM; @@ -652,11 +652,11 @@ static int snd_pcm_ladspa_allocate_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *l return err; } } else { - err = snd_pcm_ladspa_connect_plugin(plugin, instance); - if (err < 0) { + err = snd_pcm_ladspa_connect_plugin(plugin, instance); + if (err < 0) { snd_error(PCM, "Unable to connect plugin '%s' depth %u", plugin->desc->Name, depth); - return err; - } + return err; + } } err = snd_pcm_ladspa_connect_controls(plugin, &plugin->input, instance); assert(err >= 0); @@ -667,10 +667,10 @@ static int snd_pcm_ladspa_allocate_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *l } err = snd_pcm_ladspa_check_connect(plugin, &plugin->input, &instance->input, depth); if (err < 0) - return err; + return err; err = snd_pcm_ladspa_check_connect(plugin, &plugin->output, &instance->output, depth); if (err < 0) - return err; + return err; depth++; } return 0; @@ -678,9 +678,9 @@ static int snd_pcm_ladspa_allocate_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *l static LADSPA_Data *snd_pcm_ladspa_allocate_zero(snd_pcm_ladspa_t *ladspa, unsigned int idx) { - if (ladspa->zero[idx] == NULL) - ladspa->zero[idx] = calloc(ladspa->allocated, sizeof(LADSPA_Data)); - return ladspa->zero[idx]; + if (ladspa->zero[idx] == NULL) + ladspa->zero[idx] = calloc(ladspa->allocated, sizeof(LADSPA_Data)); + return ladspa->zero[idx]; } static int snd_pcm_ladspa_allocate_memory(snd_pcm_t *pcm, snd_pcm_ladspa_t *ladspa) @@ -691,20 +691,20 @@ static int snd_pcm_ladspa_allocate_memory(snd_pcm_t *pcm, snd_pcm_ladspa_t *lads unsigned int ichannels, ochannels; void **pchannels, **npchannels; unsigned int idx, chn; - - ladspa->allocated = 2048; - if (pcm->buffer_size > ladspa->allocated) - ladspa->allocated = pcm->buffer_size; - if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { - ichannels = pcm->channels; - ochannels = ladspa->plug.gen.slave->channels; - } else { - ichannels = ladspa->plug.gen.slave->channels; - ochannels = pcm->channels; - } + + ladspa->allocated = 2048; + if (pcm->buffer_size > ladspa->allocated) + ladspa->allocated = pcm->buffer_size; + if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { + ichannels = pcm->channels; + ochannels = ladspa->plug.gen.slave->channels; + } else { + ichannels = ladspa->plug.gen.slave->channels; + ochannels = pcm->channels; + } pchannels = calloc(1, sizeof(void *) * channels); if (pchannels == NULL) - return -ENOMEM; + return -ENOMEM; list = pcm->stream == SND_PCM_STREAM_PLAYBACK ? &ladspa->pplugins : &ladspa->cplugins; list_for_each(pos, list) { snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list); @@ -712,68 +712,68 @@ static int snd_pcm_ladspa_allocate_memory(snd_pcm_t *pcm, snd_pcm_ladspa_t *lads instance = list_entry(pos1, snd_pcm_ladspa_instance_t, list); nchannels = channels; for (idx = 0; idx < instance->input.channels.size; idx++) { - chn = instance->input.channels.array[idx]; - assert(instance->input.ports.array[idx] != NO_ASSIGN); - if (chn >= nchannels) - nchannels = chn + 1; - } + chn = instance->input.channels.array[idx]; + assert(instance->input.ports.array[idx] != NO_ASSIGN); + if (chn >= nchannels) + nchannels = chn + 1; + } for (idx = 0; idx < instance->output.channels.size; idx++) { - chn = instance->output.channels.array[idx]; - assert(instance->output.ports.array[idx] != NO_ASSIGN); - if (chn >= nchannels) - nchannels = chn + 1; - } - if (nchannels != channels) { - npchannels = realloc(pchannels, nchannels * sizeof(void *)); - if (npchannels == NULL) { - free(pchannels); - return -ENOMEM; - } - for (idx = channels; idx < nchannels; idx++) - npchannels[idx] = NULL; - pchannels = npchannels; - } - assert(instance->input.data == NULL); - assert(instance->input.m_data == NULL); - assert(instance->output.data == NULL); - assert(instance->output.m_data == NULL); - instance->input.data = calloc(instance->input.channels.size, sizeof(void *)); - instance->input.m_data = calloc(instance->input.channels.size, sizeof(void *)); - instance->output.data = calloc(instance->output.channels.size, sizeof(void *)); - instance->output.m_data = calloc(instance->output.channels.size, sizeof(void *)); - if (instance->input.data == NULL || - instance->input.m_data == NULL || - instance->output.data == NULL || - instance->output.m_data == NULL) { - free(pchannels); - return -ENOMEM; - } + chn = instance->output.channels.array[idx]; + assert(instance->output.ports.array[idx] != NO_ASSIGN); + if (chn >= nchannels) + nchannels = chn + 1; + } + if (nchannels != channels) { + npchannels = realloc(pchannels, nchannels * sizeof(void *)); + if (npchannels == NULL) { + free(pchannels); + return -ENOMEM; + } + for (idx = channels; idx < nchannels; idx++) + npchannels[idx] = NULL; + pchannels = npchannels; + } + assert(instance->input.data == NULL); + assert(instance->input.m_data == NULL); + assert(instance->output.data == NULL); + assert(instance->output.m_data == NULL); + instance->input.data = calloc(instance->input.channels.size, sizeof(void *)); + instance->input.m_data = calloc(instance->input.channels.size, sizeof(void *)); + instance->output.data = calloc(instance->output.channels.size, sizeof(void *)); + instance->output.m_data = calloc(instance->output.channels.size, sizeof(void *)); + if (instance->input.data == NULL || + instance->input.m_data == NULL || + instance->output.data == NULL || + instance->output.m_data == NULL) { + free(pchannels); + return -ENOMEM; + } for (idx = 0; idx < instance->input.channels.size; idx++) { - chn = instance->input.channels.array[idx]; - if (pchannels[chn] == NULL && chn < ichannels) { - instance->input.data[idx] = NULL; - continue; - } - instance->input.data[idx] = pchannels[chn]; - if (instance->input.data[idx] == NULL) { - instance->input.data[idx] = snd_pcm_ladspa_allocate_zero(ladspa, 0); - if (instance->input.data[idx] == NULL) { - free(pchannels); - return -ENOMEM; - } - } - } - for (idx = 0; idx < instance->output.channels.size; idx++) { - chn = instance->output.channels.array[idx]; - /* FIXME/OPTIMIZE: check if we can remove double alloc */ - /* if LADSPA plugin has no broken inplace */ - instance->output.data[idx] = malloc(sizeof(LADSPA_Data) * ladspa->allocated); - if (instance->output.data[idx] == NULL) { - free(pchannels); - return -ENOMEM; - } - pchannels[chn] = instance->output.m_data[idx] = instance->output.data[idx]; - } + chn = instance->input.channels.array[idx]; + if (pchannels[chn] == NULL && chn < ichannels) { + instance->input.data[idx] = NULL; + continue; + } + instance->input.data[idx] = pchannels[chn]; + if (instance->input.data[idx] == NULL) { + instance->input.data[idx] = snd_pcm_ladspa_allocate_zero(ladspa, 0); + if (instance->input.data[idx] == NULL) { + free(pchannels); + return -ENOMEM; + } + } + } + for (idx = 0; idx < instance->output.channels.size; idx++) { + chn = instance->output.channels.array[idx]; + /* FIXME/OPTIMIZE: check if we can remove double alloc */ + /* if LADSPA plugin has no broken inplace */ + instance->output.data[idx] = malloc(sizeof(LADSPA_Data) * ladspa->allocated); + if (instance->output.data[idx] == NULL) { + free(pchannels); + return -ENOMEM; + } + pchannels[chn] = instance->output.m_data[idx] = instance->output.data[idx]; + } } } /* OPTIMIZE: we have already allocated areas for ALSA output channels */ @@ -784,35 +784,35 @@ static int snd_pcm_ladspa_allocate_memory(snd_pcm_t *pcm, snd_pcm_ladspa_t *lads snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list); list_for_each(pos1, &plugin->instances) { instance = list_entry(pos1, snd_pcm_ladspa_instance_t, list); - for (idx = 0; idx < instance->output.channels.size; idx++) { - chn = instance->output.channels.array[idx]; - if (instance->output.data[idx] == pchannels[chn]) { + for (idx = 0; idx < instance->output.channels.size; idx++) { + chn = instance->output.channels.array[idx]; + if (instance->output.data[idx] == pchannels[chn]) { free(instance->output.m_data[idx]); instance->output.m_data[idx] = NULL; - if (chn < ochannels) { - instance->output.data[idx] = NULL; - } else { - instance->output.data[idx] = snd_pcm_ladspa_allocate_zero(ladspa, 1); - if (instance->output.data[idx] == NULL) { - free(pchannels); - return -ENOMEM; - } - } - } - } - } - } + if (chn < ochannels) { + instance->output.data[idx] = NULL; + } else { + instance->output.data[idx] = snd_pcm_ladspa_allocate_zero(ladspa, 1); + if (instance->output.data[idx] == NULL) { + free(pchannels); + return -ENOMEM; + } + } + } + } + } + } #if 0 - printf("zero[0] = %p\n", ladspa->zero[0]); - printf("zero[1] = %p\n", ladspa->zero[1]); + printf("zero[0] = %p\n", ladspa->zero[0]); + printf("zero[1] = %p\n", ladspa->zero[1]); list_for_each(pos, list) { snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list); list_for_each(pos1, &plugin->instances) { instance = list_entry(pos1, snd_pcm_ladspa_instance_t, list); - for (idx = 0; idx < instance->input.channels.size; idx++) - printf("%i:alloc-input%i: data = %p, m_data = %p\n", instance->depth, idx, instance->input.data[idx], instance->input.m_data[idx]); - for (idx = 0; idx < instance->output.channels.size; idx++) - printf("%i:alloc-output%i: data = %p, m_data = %p\n", instance->depth, idx, instance->output.data[idx], instance->output.m_data[idx]); + for (idx = 0; idx < instance->input.channels.size; idx++) + printf("%i:alloc-input%i: data = %p, m_data = %p\n", instance->depth, idx, instance->input.data[idx], instance->input.m_data[idx]); + for (idx = 0; idx < instance->output.channels.size; idx++) + printf("%i:alloc-output%i: data = %p, m_data = %p\n", instance->depth, idx, instance->output.data[idx], instance->output.m_data[idx]); } } #endif @@ -824,7 +824,7 @@ static int snd_pcm_ladspa_init(snd_pcm_t *pcm) { snd_pcm_ladspa_t *ladspa = pcm->private_data; int err; - + snd_pcm_ladspa_free_instances(pcm, ladspa, 1); err = snd_pcm_ladspa_allocate_instances(pcm, ladspa); if (err < 0) { @@ -861,47 +861,47 @@ snd_pcm_ladspa_write_areas(snd_pcm_t *pcm, struct list_head *pos, *pos1; LADSPA_Data *data; unsigned int idx, chn, size1, size2; - + if (size > *slave_sizep) size = *slave_sizep; - size2 = size; + size2 = size; #if 0 /* no processing - for testing purposes only */ snd_pcm_areas_copy(slave_areas, slave_offset, areas, offset, pcm->channels, size, pcm->format); #else - while (size > 0) { - size1 = size; - if (size1 > ladspa->allocated) - size1 = ladspa->allocated; - list_for_each(pos, &ladspa->pplugins) { - snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list); - list_for_each(pos1, &plugin->instances) { - instance = list_entry(pos1, snd_pcm_ladspa_instance_t, list); - for (idx = 0; idx < instance->input.channels.size; idx++) { - chn = instance->input.channels.array[idx]; - data = instance->input.data[idx]; - if (data == NULL) { - data = (LADSPA_Data *)((char *)areas[chn].addr + (areas[chn].first / 8)); - data += offset; - } - instance->desc->connect_port(instance->handle, instance->input.ports.array[idx], data); - } - for (idx = 0; idx < instance->output.channels.size; idx++) { - chn = instance->output.channels.array[idx]; - data = instance->output.data[idx]; - if (data == NULL) { - data = (LADSPA_Data *)((char *)slave_areas[chn].addr + (areas[chn].first / 8)); - data += slave_offset; - } + while (size > 0) { + size1 = size; + if (size1 > ladspa->allocated) + size1 = ladspa->allocated; + list_for_each(pos, &ladspa->pplugins) { + snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list); + list_for_each(pos1, &plugin->instances) { + instance = list_entry(pos1, snd_pcm_ladspa_instance_t, list); + for (idx = 0; idx < instance->input.channels.size; idx++) { + chn = instance->input.channels.array[idx]; + data = instance->input.data[idx]; + if (data == NULL) { + data = (LADSPA_Data *)((char *)areas[chn].addr + (areas[chn].first / 8)); + data += offset; + } + instance->desc->connect_port(instance->handle, instance->input.ports.array[idx], data); + } + for (idx = 0; idx < instance->output.channels.size; idx++) { + chn = instance->output.channels.array[idx]; + data = instance->output.data[idx]; + if (data == NULL) { + data = (LADSPA_Data *)((char *)slave_areas[chn].addr + (areas[chn].first / 8)); + data += slave_offset; + } instance->desc->connect_port(instance->handle, instance->output.ports.array[idx], data); - } - instance->desc->run(instance->handle, size1); - } - } - offset += size1; - slave_offset += size1; - size -= size1; + } + instance->desc->run(instance->handle, size1); + } + } + offset += size1; + slave_offset += size1; + size -= size1; } #endif *slave_sizep = size2; @@ -925,44 +925,44 @@ snd_pcm_ladspa_read_areas(snd_pcm_t *pcm, if (size > *slave_sizep) size = *slave_sizep; - size2 = size; + size2 = size; #if 0 /* no processing - for testing purposes only */ snd_pcm_areas_copy(areas, offset, slave_areas, slave_offset, pcm->channels, size, pcm->format); #else - while (size > 0) { - size1 = size; - if (size1 > ladspa->allocated) - size1 = ladspa->allocated; - list_for_each(pos, &ladspa->cplugins) { - snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list); - list_for_each(pos1, &plugin->instances) { - instance = list_entry(pos1, snd_pcm_ladspa_instance_t, list); - for (idx = 0; idx < instance->input.channels.size; idx++) { - chn = instance->input.channels.array[idx]; - data = instance->input.data[idx]; - if (data == NULL) { - data = (LADSPA_Data *)((char *)slave_areas[chn].addr + (areas[chn].first / 8)); - data += slave_offset; - } - instance->desc->connect_port(instance->handle, instance->input.ports.array[idx], data); - } - for (idx = 0; idx < instance->output.channels.size; idx++) { - chn = instance->output.channels.array[idx]; - data = instance->output.data[idx]; - if (data == NULL) { - data = (LADSPA_Data *)((char *)areas[chn].addr + (areas[chn].first / 8)); - data += offset; - } - instance->desc->connect_port(instance->handle, instance->output.ports.array[idx], data); - } - instance->desc->run(instance->handle, size1); - } - } - offset += size1; - slave_offset += size1; - size -= size1; + while (size > 0) { + size1 = size; + if (size1 > ladspa->allocated) + size1 = ladspa->allocated; + list_for_each(pos, &ladspa->cplugins) { + snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list); + list_for_each(pos1, &plugin->instances) { + instance = list_entry(pos1, snd_pcm_ladspa_instance_t, list); + for (idx = 0; idx < instance->input.channels.size; idx++) { + chn = instance->input.channels.array[idx]; + data = instance->input.data[idx]; + if (data == NULL) { + data = (LADSPA_Data *)((char *)slave_areas[chn].addr + (areas[chn].first / 8)); + data += slave_offset; + } + instance->desc->connect_port(instance->handle, instance->input.ports.array[idx], data); + } + for (idx = 0; idx < instance->output.channels.size; idx++) { + chn = instance->output.channels.array[idx]; + data = instance->output.data[idx]; + if (data == NULL) { + data = (LADSPA_Data *)((char *)areas[chn].addr + (areas[chn].first / 8)); + data += offset; + } + instance->desc->connect_port(instance->handle, instance->output.ports.array[idx], data); + } + instance->desc->run(instance->handle, size1); + } + } + offset += size1; + slave_offset += size1; + size -= size1; } #endif *slave_sizep = size2; @@ -970,8 +970,8 @@ snd_pcm_ladspa_read_areas(snd_pcm_t *pcm, } static void snd_pcm_ladspa_dump_direction(snd_pcm_ladspa_plugin_t *plugin, - snd_pcm_ladspa_plugin_io_t *io, - snd_output_t *out) + snd_pcm_ladspa_plugin_io_t *io, + snd_output_t *out) { unsigned int idx, midx; @@ -979,49 +979,49 @@ static void snd_pcm_ladspa_dump_direction(snd_pcm_ladspa_plugin_t *plugin, goto __control; snd_output_printf(out, " Audio %s port bindings:\n", io->pdesc == LADSPA_PORT_INPUT ? "input" : "output"); for (idx = 0; idx < io->port_bindings_size; idx++) { - if (io->port_bindings[idx] == NO_ASSIGN) + if (io->port_bindings[idx] == NO_ASSIGN) snd_output_printf(out, " %i -> NONE\n", idx); - else - snd_output_printf(out, " %i -> %i\n", idx, io->port_bindings[idx]); + else + snd_output_printf(out, " %i -> %i\n", idx, io->port_bindings[idx]); } __control: - if (io->controls_size == 0) - return; + if (io->controls_size == 0) + return; snd_output_printf(out, " Control %s port initial values:\n", io->pdesc == LADSPA_PORT_INPUT ? "input" : "output"); for (idx = midx = 0; idx < plugin->desc->PortCount; idx++) { if ((plugin->desc->PortDescriptors[idx] & (io->pdesc | LADSPA_PORT_CONTROL)) == (io->pdesc | LADSPA_PORT_CONTROL)) { - snd_output_printf(out, " %i \"%s\" = %.8f\n", idx, plugin->desc->PortNames[idx], io->controls[midx]); - midx++; - } - } + snd_output_printf(out, " %i \"%s\" = %.8f\n", idx, plugin->desc->PortNames[idx], io->controls[midx]); + midx++; + } + } } static void snd_pcm_ladspa_dump_array(snd_output_t *out, - snd_pcm_ladspa_array_t *array, - snd_pcm_ladspa_plugin_t *plugin) + snd_pcm_ladspa_array_t *array, + snd_pcm_ladspa_plugin_t *plugin) { - unsigned int size = array->size; - unsigned int val, idx = 0; + unsigned int size = array->size; + unsigned int val, idx = 0; - while (size-- > 0) { - if (idx > 0) { - snd_output_putc(out, ','); - snd_output_putc(out, ' '); - } - val = array->array[idx++]; - if (val == NO_ASSIGN) - snd_output_putc(out, '-'); - else - snd_output_printf(out, "%u", val); - if (plugin && val != NO_ASSIGN) - snd_output_printf(out, " \"%s\"", plugin->desc->PortNames[val]); - } + while (size-- > 0) { + if (idx > 0) { + snd_output_putc(out, ','); + snd_output_putc(out, ' '); + } + val = array->array[idx++]; + if (val == NO_ASSIGN) + snd_output_putc(out, '-'); + else + snd_output_printf(out, "%u", val); + if (plugin && val != NO_ASSIGN) + snd_output_printf(out, " \"%s\"", plugin->desc->PortNames[val]); + } } static void snd_pcm_ladspa_plugins_dump(struct list_head *list, snd_output_t *out) { struct list_head *pos, *pos2; - + list_for_each(pos, list) { snd_pcm_ladspa_plugin_t *plugin = list_entry(pos, snd_pcm_ladspa_plugin_t, list); snd_output_printf(out, " Policy: %s\n", plugin->policy == SND_PCM_LADSPA_POLICY_NONE ? "none" : "duplicate"); @@ -1029,19 +1029,19 @@ static void snd_pcm_ladspa_plugins_dump(struct list_head *list, snd_output_t *ou snd_output_printf(out, " Plugin Name: %s\n", plugin->desc->Name); snd_output_printf(out, " Plugin Label: %s\n", plugin->desc->Label); snd_output_printf(out, " Plugin Unique ID: %lu\n", plugin->desc->UniqueID); - snd_output_printf(out, " Instances:\n"); + snd_output_printf(out, " Instances:\n"); list_for_each(pos2, &plugin->instances) { - snd_pcm_ladspa_instance_t *in = (snd_pcm_ladspa_instance_t *) pos2; - snd_output_printf(out, " Depth: %i\n", in->depth); - snd_output_printf(out, " InChannels: "); - snd_pcm_ladspa_dump_array(out, &in->input.channels, NULL); - snd_output_printf(out, "\n InPorts: "); - snd_pcm_ladspa_dump_array(out, &in->input.ports, plugin); - snd_output_printf(out, "\n OutChannels: "); - snd_pcm_ladspa_dump_array(out, &in->output.channels, NULL); - snd_output_printf(out, "\n OutPorts: "); - snd_pcm_ladspa_dump_array(out, &in->output.ports, plugin); - snd_output_printf(out, "\n"); + snd_pcm_ladspa_instance_t *in = (snd_pcm_ladspa_instance_t *) pos2; + snd_output_printf(out, " Depth: %i\n", in->depth); + snd_output_printf(out, " InChannels: "); + snd_pcm_ladspa_dump_array(out, &in->input.channels, NULL); + snd_output_printf(out, "\n InPorts: "); + snd_pcm_ladspa_dump_array(out, &in->input.ports, plugin); + snd_output_printf(out, "\n OutChannels: "); + snd_pcm_ladspa_dump_array(out, &in->output.channels, NULL); + snd_output_printf(out, "\n OutPorts: "); + snd_pcm_ladspa_dump_array(out, &in->output.ports, plugin); + snd_output_printf(out, "\n"); } snd_pcm_ladspa_dump_direction(plugin, &plugin->input, out); snd_pcm_ladspa_dump_direction(plugin, &plugin->output, out); @@ -1105,24 +1105,24 @@ static int snd_pcm_ladspa_check_file(snd_pcm_ladspa_plugin_t * const plugin, if (strcmp(label, d->Label)) continue; #else - char *labellocale; - struct lconv *lc; - if (label != NULL) { - lc = localeconv (); - labellocale = malloc (strlen (label) + 1); - if (labellocale == NULL) { - dlclose(handle); - return -ENOMEM; + char *labellocale; + struct lconv *lc; + if (label != NULL) { + lc = localeconv (); + labellocale = malloc (strlen (label) + 1); + if (labellocale == NULL) { + dlclose(handle); + return -ENOMEM; } - strcpy (labellocale, label); - if (strrchr(labellocale, '.')) - *strrchr (labellocale, '.') = *lc->decimal_point; - if (strcmp(label, d->Label) && strcmp(labellocale, d->Label)) { - free(labellocale); - continue; - } - free (labellocale); - } + strcpy (labellocale, label); + if (strrchr(labellocale, '.')) + *strrchr (labellocale, '.') = *lc->decimal_point; + if (strcmp(label, d->Label) && strcmp(labellocale, d->Label)) { + free(labellocale); + continue; + } + free (labellocale); + } #endif if (ladspa_id > 0 && d->UniqueID != ladspa_id) continue; @@ -1151,22 +1151,22 @@ static int snd_pcm_ladspa_check_dir(snd_pcm_ladspa_plugin_t * const plugin, int len = strlen(path), err; int need_slash; char *filename; - + if (len < 1) return 0; need_slash = path[len - 1] != '/'; - + dir = opendir(path); if (!dir) return -ENOENT; - + while (1) { dirent = readdir64(dir); if (!dirent) { closedir(dir); return 0; } - + filename = malloc(len + strlen(dirent->d_name) + 1 + need_slash); if (filename == NULL) { closedir(dir); @@ -1199,7 +1199,7 @@ static int snd_pcm_ladspa_look_for_plugin(snd_pcm_ladspa_plugin_t * const plugin const char *c; size_t l; int err; - + for (c = path; (l = strcspn(c, ": ")) > 0; ) { char name[l + 1]; char *fullpath; @@ -1220,10 +1220,10 @@ static int snd_pcm_ladspa_look_for_plugin(snd_pcm_ladspa_plugin_t * const plugin c++; } return -ENOENT; -} +} static int snd_pcm_ladspa_add_default_controls(snd_pcm_ladspa_plugin_t *lplug, - snd_pcm_ladspa_plugin_io_t *io) + snd_pcm_ladspa_plugin_io_t *io) { unsigned int count = 0; LADSPA_Data *array; @@ -1246,11 +1246,11 @@ static int snd_pcm_ladspa_add_default_controls(snd_pcm_ladspa_plugin_t *lplug, io->controls = array; return 0; -} +} static int snd_pcm_ladspa_parse_controls(snd_pcm_ladspa_plugin_t *lplug, snd_pcm_ladspa_plugin_io_t *io, - snd_config_t *controls) + snd_config_t *controls) { snd_config_iterator_t i, next; int err; @@ -1296,7 +1296,7 @@ static int snd_pcm_ladspa_parse_controls(snd_pcm_ladspa_plugin_t *lplug, static int snd_pcm_ladspa_parse_bindings(snd_pcm_ladspa_plugin_t *lplug, snd_pcm_ladspa_plugin_io_t *io, - snd_config_t *bindings) + snd_config_t *bindings) { unsigned int count = 0; unsigned int *array; @@ -1382,7 +1382,7 @@ static int snd_pcm_ladspa_parse_ioconfig(snd_pcm_ladspa_plugin_t *lplug, snd_error(PCM, "error adding default controls"); return err; } - + if (conf == NULL) { return 0; } @@ -1408,14 +1408,14 @@ static int snd_pcm_ladspa_parse_ioconfig(snd_pcm_ladspa_plugin_t *lplug, /* ignore values of parameters for output controls */ if (controls && !(io->pdesc & LADSPA_PORT_OUTPUT)) { - err = snd_pcm_ladspa_parse_controls(lplug, io, controls); - if (err < 0) + err = snd_pcm_ladspa_parse_controls(lplug, io, controls); + if (err < 0) return err; } if (bindings) { - err = snd_pcm_ladspa_parse_bindings(lplug, io, bindings); - if (err < 0) + err = snd_pcm_ladspa_parse_bindings(lplug, io, bindings); + if (err < 0) return err; } @@ -1674,18 +1674,18 @@ Instances of LADSPA plugins are created dynamically. \code pcm.name { - type ladspa # ALSA<->LADSPA PCM - slave STR # Slave name - # or - slave { # Slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition - } - [channels INT] # count input channels (input to LADSPA plugin chain) + type ladspa # ALSA<->LADSPA PCM + slave STR # Slave name + # or + slave { # Slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + } + [channels INT] # count input channels (input to LADSPA plugin chain) [path STR] # Path (directory) with LADSPA plugins plugins | # Definition for both directions - playback_plugins | # Definition for playback direction + playback_plugins | # Definition for playback direction capture_plugins { # Definition for capture direction N { # Configuration for LADPSA plugin N [id INT] # LADSPA plugin ID (for example 1043) @@ -1697,7 +1697,7 @@ pcm.name { C INT or STR # C - channel, INT - audio port index, STR - audio port name } controls { - # valid only in the input block + # valid only in the input block I INT or REAL # I - control port index, INT or REAL - control value # or STR INT or REAL # STR - control port name, INT or REAL - control value @@ -1731,7 +1731,7 @@ pcm.name { * changed in future. */ int _snd_pcm_ladspa_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; @@ -1759,9 +1759,9 @@ int _snd_pcm_ladspa_open(snd_pcm_t **pcmp, const char *name, if (strcmp(id, "channels") == 0) { snd_config_get_integer(n, &channels); if (channels > 1024) - channels = 1024; - if (channels < 0) - channels = 0; + channels = 1024; + if (channels < 0) + channels = 0; continue; } if (strcmp(id, "plugins") == 0) { diff --git a/src/pcm/pcm_lfloat.c b/src/pcm/pcm_lfloat.c index 8df993d4..87b20463 100644 --- a/src/pcm/pcm_lfloat.c +++ b/src/pcm/pcm_lfloat.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_plugin.h" #include "plugin_ops.h" @@ -236,7 +236,7 @@ static int snd_pcm_lfloat_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd return err; return 0; } - + static int snd_pcm_lfloat_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) { @@ -309,7 +309,7 @@ snd_pcm_lfloat_write_areas(snd_pcm_t *pcm, if (size > *slave_sizep) size = *slave_sizep; lfloat->func(slave_areas, slave_offset, - areas, offset, + areas, offset, pcm->channels, size, lfloat->int32_idx, lfloat->float32_idx); *slave_sizep = size; @@ -328,7 +328,7 @@ snd_pcm_lfloat_read_areas(snd_pcm_t *pcm, snd_pcm_lfloat_t *lfloat = pcm->private_data; if (size > *slave_sizep) size = *slave_sizep; - lfloat->func(areas, offset, + lfloat->func(areas, offset, slave_areas, slave_offset, pcm->channels, size, lfloat->int32_idx, lfloat->float32_idx); @@ -339,7 +339,7 @@ snd_pcm_lfloat_read_areas(snd_pcm_t *pcm, static void snd_pcm_lfloat_dump(snd_pcm_t *pcm, snd_output_t *out) { snd_pcm_lfloat_t *lfloat = pcm->private_data; - snd_output_printf(out, "Linear Integer <-> Linear Float conversion PCM (%s)\n", + snd_output_printf(out, "Linear Integer <-> Linear Float conversion PCM (%s)\n", snd_pcm_format_name(lfloat->sformat)); if (pcm->setup) { snd_output_printf(out, "Its setup is:\n"); @@ -415,7 +415,7 @@ int snd_pcm_lfloat_open(snd_pcm_t **pcmp, const char *name, snd_pcm_format_t sfo snd_pcm_set_hw_ptr(pcm, &lfloat->plug.hw_ptr, -1, 0); snd_pcm_set_appl_ptr(pcm, &lfloat->plug.appl_ptr, -1, 0); *pcmp = pcm; - + return 0; } @@ -429,15 +429,15 @@ match for both of them. \code pcm.name { - type lfloat # Linear<->Float conversion PCM - slave STR # Slave name - # or - slave { # Slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition - format STR # Slave format - } + type lfloat # Linear<->Float conversion PCM + slave STR # Slave name + # or + slave { # Slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + format STR # Slave format + } } \endcode @@ -464,7 +464,7 @@ pcm.name { * changed in future. */ int _snd_pcm_lfloat_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; @@ -528,7 +528,7 @@ int snd_pcm_lfloat_open(snd_pcm_t **pcmp ATTRIBUTE_UNUSED, int _snd_pcm_lfloat_open(snd_pcm_t **pcmp ATTRIBUTE_UNUSED, const char *name ATTRIBUTE_UNUSED, snd_config_t *root ATTRIBUTE_UNUSED, - snd_config_t *conf ATTRIBUTE_UNUSED, + snd_config_t *conf ATTRIBUTE_UNUSED, snd_pcm_stream_t stream ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { diff --git a/src/pcm/pcm_linear.c b/src/pcm/pcm_linear.c index 9084eef6..9944bc86 100644 --- a/src/pcm/pcm_linear.c +++ b/src/pcm/pcm_linear.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_plugin.h" #include "plugin_ops.h" @@ -78,7 +78,7 @@ int snd_pcm_linear_convert_index(snd_pcm_format_t src_format, int snd_pcm_linear_get_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format) { int sign, width, pwidth, endian; - sign = (snd_pcm_format_signed(src_format) != + sign = (snd_pcm_format_signed(src_format) != snd_pcm_format_signed(dst_format)); #ifdef SND_LITTLE_ENDIAN endian = snd_pcm_format_big_endian(src_format); @@ -112,7 +112,7 @@ int snd_pcm_linear_get_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_f int snd_pcm_linear_put_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format) { int sign, width, pwidth, endian; - sign = (snd_pcm_format_signed(src_format) != + sign = (snd_pcm_format_signed(src_format) != snd_pcm_format_signed(dst_format)); #ifdef SND_LITTLE_ENDIAN endian = snd_pcm_format_big_endian(dst_format); @@ -264,7 +264,7 @@ static int snd_pcm_linear_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd return err; return 0; } - + static int snd_pcm_linear_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) { @@ -344,12 +344,12 @@ snd_pcm_linear_write_areas(snd_pcm_t *pcm, size = *slave_sizep; if (linear->use_getput) snd_pcm_linear_getput(slave_areas, slave_offset, - areas, offset, + areas, offset, pcm->channels, size, linear->get_idx, linear->put_idx); else snd_pcm_linear_convert(slave_areas, slave_offset, - areas, offset, + areas, offset, pcm->channels, size, linear->conv_idx); *slave_sizep = size; return size; @@ -368,12 +368,12 @@ snd_pcm_linear_read_areas(snd_pcm_t *pcm, if (size > *slave_sizep) size = *slave_sizep; if (linear->use_getput) - snd_pcm_linear_getput(areas, offset, + snd_pcm_linear_getput(areas, offset, slave_areas, slave_offset, pcm->channels, size, linear->get_idx, linear->put_idx); else - snd_pcm_linear_convert(areas, offset, + snd_pcm_linear_convert(areas, offset, slave_areas, slave_offset, pcm->channels, size, linear->conv_idx); *slave_sizep = size; @@ -383,7 +383,7 @@ snd_pcm_linear_read_areas(snd_pcm_t *pcm, static void snd_pcm_linear_dump(snd_pcm_t *pcm, snd_output_t *out) { snd_pcm_linear_t *linear = pcm->private_data; - snd_output_printf(out, "Linear conversion PCM (%s)\n", + snd_output_printf(out, "Linear conversion PCM (%s)\n", snd_pcm_format_name(linear->sformat)); if (pcm->setup) { snd_output_printf(out, "Its setup is:\n"); @@ -472,15 +472,15 @@ slave PCM. The channel count, format and rate must match for both of them. \code pcm.name { - type linear # Linear conversion PCM - slave STR # Slave name - # or - slave { # Slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition - format STR # Slave format - } + type linear # Linear conversion PCM + slave STR # Slave name + # or + slave { # Slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + format STR # Slave format + } } \endcode @@ -507,7 +507,7 @@ pcm.name { * changed in future. */ int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index 152c92c3..881451eb 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -401,9 +401,9 @@ snd_pcm_sframes_t snd_pcm_mmap_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_ufram snd_pcm_sframes_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size); snd_pcm_sframes_t snd_pcm_mmap_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size); -typedef snd_pcm_sframes_t (*snd_pcm_xfer_areas_func_t)(snd_pcm_t *pcm, +typedef snd_pcm_sframes_t (*snd_pcm_xfer_areas_func_t)(snd_pcm_t *pcm, const snd_pcm_channel_area_t *areas, - snd_pcm_uframes_t offset, + snd_pcm_uframes_t offset, snd_pcm_uframes_t size); snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_t *areas, @@ -606,13 +606,13 @@ static inline const snd_pcm_channel_area_t *snd_pcm_mmap_areas(snd_pcm_t *pcm) static inline snd_pcm_uframes_t snd_pcm_mmap_offset(snd_pcm_t *pcm) { - assert(pcm); + assert(pcm); return *pcm->appl.ptr % pcm->buffer_size; } static inline snd_pcm_uframes_t snd_pcm_mmap_hw_offset(snd_pcm_t *pcm) { - assert(pcm); + assert(pcm); return *pcm->hw.ptr % pcm->buffer_size; } @@ -1079,7 +1079,7 @@ const snd_config_t *snd_pcm_rate_get_default_converter(snd_config_t *root); (1U << (SND_PCM_FORMAT_U18_3LE - 32)) | \ (1U << (SND_PCM_FORMAT_S18_3BE - 32)) | \ (1U << (SND_PCM_FORMAT_U18_3BE - 32))) } - + #define SND_PCM_FMTBIT_FLOAT \ { ((1U << SND_PCM_FORMAT_FLOAT_LE) | \ diff --git a/src/pcm/pcm_meter.c b/src/pcm/pcm_meter.c index 05649a92..c027194d 100644 --- a/src/pcm/pcm_meter.c +++ b/src/pcm/pcm_meter.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_plugin.h" @@ -93,7 +93,7 @@ static void snd_pcm_meter_add_frames(snd_pcm_t *pcm, n = dst_cont; if (n > src_cont) n = src_cont; - snd_pcm_areas_copy(meter->buf_areas, dst_offset, + snd_pcm_areas_copy(meter->buf_areas, dst_offset, areas, src_offset, pcm->channels, n, pcm->format); frames -= n; @@ -259,7 +259,7 @@ static void *snd_pcm_meter_thread(void *data) if (scope->enabled) scope->ops->update(scope); } - nanosleep(&meter->delay, NULL); + nanosleep(&meter->delay, NULL); } list_for_each(pos, &meter->scopes) { scope = list_entry(pos, snd_pcm_scope_t, list); @@ -404,7 +404,7 @@ static int snd_pcm_meter_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_ return err; return 0; } - + static int snd_pcm_meter_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) { @@ -716,14 +716,14 @@ pcm_scope.name { } pcm.name { - type meter # Meter PCM - slave STR # Slave name - # or - slave { # Slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition - } + type meter # Meter PCM + slave STR # Slave name + # or + slave { # Slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + } [frequency INT] # Updates per second scopes { ID STR # Scope name (see pcm_scope) @@ -756,7 +756,7 @@ pcm.name { * changed in future. */ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; @@ -1174,7 +1174,7 @@ static const snd_pcm_scope_ops_t s16_ops = { * \param scopep Pointer to newly created and added scope * \return 0 on success otherwise a negative error code * - * s16 pseudo scope convert #SND_PCM_TYPE_METER PCM frames in CPU endian + * s16 pseudo scope convert #SND_PCM_TYPE_METER PCM frames in CPU endian * 16 bit frames for use with other scopes. Don't forget to insert it before * and to not insert it more time (see #snd_pcm_meter_search_scope) */ diff --git a/src/pcm/pcm_misc.c b/src/pcm/pcm_misc.c index 8a00d1c4..570ecd97 100644 --- a/src/pcm/pcm_misc.c +++ b/src/pcm/pcm_misc.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "bswap.h" #include @@ -519,7 +519,7 @@ uint64_t snd_pcm_format_silence_64(snd_pcm_format_t format) return bswap_64(u.i); #endif } - case SNDRV_PCM_FORMAT_FLOAT_BE: + case SNDRV_PCM_FORMAT_FLOAT_BE: { union { float f[2]; @@ -547,7 +547,7 @@ uint64_t snd_pcm_format_silence_64(snd_pcm_format_t format) } case SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE: case SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE: - return 0; + return 0; case SNDRV_PCM_FORMAT_MU_LAW: return 0x7f7f7f7f7f7f7f7fULL; case SNDRV_PCM_FORMAT_A_LAW: diff --git a/src/pcm/pcm_mmap.c b/src/pcm/pcm_mmap.c index 88b1f45f..ba8d9504 100644 --- a/src/pcm/pcm_mmap.c +++ b/src/pcm/pcm_mmap.c @@ -85,8 +85,8 @@ static snd_pcm_sframes_t snd_pcm_mmap_write_areas(snd_pcm_t *pcm, __snd_pcm_mmap_begin(pcm, &pcm_areas, &pcm_offset, &frames); snd_pcm_areas_copy(pcm_areas, pcm_offset, - areas, offset, - pcm->channels, + areas, offset, + pcm->channels, frames, pcm->format); result = __snd_pcm_mmap_commit(pcm, pcm_offset, frames); if (result < 0) @@ -114,11 +114,11 @@ static snd_pcm_sframes_t snd_pcm_mmap_read_areas(snd_pcm_t *pcm, snd_pcm_uframes_t pcm_offset; snd_pcm_uframes_t frames = size; snd_pcm_sframes_t result; - + __snd_pcm_mmap_begin(pcm, &pcm_areas, &pcm_offset, &frames); snd_pcm_areas_copy(areas, offset, pcm_areas, pcm_offset, - pcm->channels, + pcm->channels, frames, pcm->format); result = __snd_pcm_mmap_commit(pcm, pcm_offset, frames); if (result < 0) @@ -255,7 +255,7 @@ int snd_pcm_channel_info_shm(snd_pcm_t *pcm, snd_pcm_channel_info_t *info, int s } else info->type = SND_PCM_AREA_LOCAL; return 0; -} +} int snd_pcm_mmap(snd_pcm_t *pcm) { @@ -306,12 +306,12 @@ int snd_pcm_mmap(snd_pcm_t *pcm) size_t size; unsigned int c1; if (i->addr) { - a->addr = i->addr; - a->first = i->first; - a->step = i->step; - continue; - } - size = i->first + i->step * (pcm->buffer_size - 1) + pcm->sample_bits; + a->addr = i->addr; + a->first = i->first; + a->step = i->step; + continue; + } + size = i->first + i->step * (pcm->buffer_size - 1) + pcm->sample_bits; for (c1 = c + 1; c1 < pcm->channels; ++c1) { snd_pcm_channel_info_t *i1 = &pcm->mmap_channels[c1]; size_t s; @@ -415,7 +415,7 @@ int snd_pcm_mmap(snd_pcm_t *pcm) switch (i1->type) { case SND_PCM_AREA_MMAP: if (i1->u.mmap.fd != i->u.mmap.fd || - i1->u.mmap.offset != i->u.mmap.offset) + i1->u.mmap.offset != i->u.mmap.offset) continue; break; case SND_PCM_AREA_SHM: @@ -425,7 +425,7 @@ int snd_pcm_mmap(snd_pcm_t *pcm) case SND_PCM_AREA_LOCAL: if (pcm->access != SND_PCM_ACCESS_MMAP_INTERLEAVED && pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED) - continue; + continue; break; default: assert(0); diff --git a/src/pcm/pcm_mmap_emul.c b/src/pcm/pcm_mmap_emul.c index b0bf61e0..40821974 100644 --- a/src/pcm/pcm_mmap_emul.c +++ b/src/pcm/pcm_mmap_emul.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_generic.h" diff --git a/src/pcm/pcm_mulaw.c b/src/pcm/pcm_mulaw.c index 1dd8b613..c6705b2d 100644 --- a/src/pcm/pcm_mulaw.c +++ b/src/pcm/pcm_mulaw.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_plugin.h" #include "plugin_ops.h" @@ -287,7 +287,7 @@ static int snd_pcm_mulaw_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_ return err; return 0; } - + static int snd_pcm_mulaw_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) { @@ -365,7 +365,7 @@ snd_pcm_mulaw_write_areas(snd_pcm_t *pcm, if (size > *slave_sizep) size = *slave_sizep; mulaw->func(slave_areas, slave_offset, - areas, offset, + areas, offset, pcm->channels, size, mulaw->getput_idx); *slave_sizep = size; @@ -384,7 +384,7 @@ snd_pcm_mulaw_read_areas(snd_pcm_t *pcm, snd_pcm_mulaw_t *mulaw = pcm->private_data; if (size > *slave_sizep) size = *slave_sizep; - mulaw->func(areas, offset, + mulaw->func(areas, offset, slave_areas, slave_offset, pcm->channels, size, mulaw->getput_idx); @@ -395,7 +395,7 @@ snd_pcm_mulaw_read_areas(snd_pcm_t *pcm, static void snd_pcm_mulaw_dump(snd_pcm_t *pcm, snd_output_t *out) { snd_pcm_mulaw_t *mulaw = pcm->private_data; - snd_output_printf(out, "Mu-Law conversion PCM (%s)\n", + snd_output_printf(out, "Mu-Law conversion PCM (%s)\n", snd_pcm_format_name(mulaw->sformat)); if (pcm->setup) { snd_output_printf(out, "Its setup is:\n"); @@ -484,15 +484,15 @@ format and rate must match for both of them. \code pcm.name { - type mulaw # Mu-Law conversion PCM - slave STR # Slave name - # or - slave { # Slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition - format STR # Slave format - } + type mulaw # Mu-Law conversion PCM + slave STR # Slave name + # or + slave { # Slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + format STR # Slave format + } } \endcode @@ -519,7 +519,7 @@ pcm.name { * changed in future. */ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; diff --git a/src/pcm/pcm_multi.c b/src/pcm/pcm_multi.c index 1bdc0657..7a601763 100644 --- a/src/pcm/pcm_multi.c +++ b/src/pcm/pcm_multi.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_generic.h" #include @@ -208,7 +208,7 @@ static int snd_pcm_multi_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, return err; return 0; } - + static int snd_pcm_multi_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, unsigned int slave_idx ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params, @@ -523,7 +523,7 @@ static int snd_pcm_multi_reset(snd_pcm_t *pcm) for (i = 0; i < multi->slaves_count; ++i) { /* Reset each slave, as well as in prepare */ err = snd_pcm_reset(multi->slaves[i].pcm); - if (err < 0) + if (err < 0) result = err; } multi->hw_ptr = multi->appl_ptr = 0; @@ -735,7 +735,7 @@ static int snd_pcm_multi_resume(snd_pcm_t *pcm) * including the first one has to be relinked to the given master. */ static int snd_pcm_multi_link_slaves(snd_pcm_t *pcm, snd_pcm_t *master) -{ +{ snd_pcm_multi_t *multi = pcm->private_data; unsigned int i; int err; @@ -993,7 +993,7 @@ static void snd_pcm_multi_dump(snd_pcm_t *pcm, snd_output_t *out) snd_pcm_multi_channel_t *c = &multi->channels[k]; if (c->slave_idx < 0) continue; - snd_output_printf(out, " %d: slave %d, channel %d\n", + snd_output_printf(out, " %d: slave %d, channel %d\n", k, c->slave_idx, c->slave_channel); } if (pcm->setup) { @@ -1097,7 +1097,7 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, } stream = slaves_pcm[0]->stream; - + multi->slaves_count = slaves_count; multi->master_slave = master_slave; multi->slaves = calloc(slaves_count, sizeof(*multi->slaves)); @@ -1160,8 +1160,8 @@ This plugin converts multiple streams to one. \code pcm.name { - type multi # Multiple streams conversion PCM - slaves { # Slaves definition + type multi # Multiple streams conversion PCM + slaves { # Slaves definition ID STR # Slave PCM name # or ID { @@ -1170,7 +1170,7 @@ pcm.name { pcm { } # Slave PCM definition channels INT # Slave channels } - } + } bindings { # Bindings table N { slave STR # Slave key @@ -1412,7 +1412,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, err = -EINVAL; goto _free; } - if (schannel < 0 || + if (schannel < 0 || (unsigned int) schannel >= slaves_channels[slave]) { snd_error(PCM, "Invalid or missing schannel for channel %s", id); err = -EINVAL; @@ -1421,7 +1421,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, channels_sidx[cchannel] = slave; channels_schannel[cchannel] = schannel; } - + for (idx = 0; idx < slaves_count; ++idx) { err = snd_pcm_open_slave(&slaves_pcm[idx], root, slaves_conf[idx], stream, mode, diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c index 47f423a8..fe545ff1 100644 --- a/src/pcm/pcm_null.c +++ b/src/pcm/pcm_null.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_plugin.h" #include "bswap.h" @@ -82,11 +82,11 @@ static int snd_pcm_null_info(snd_pcm_t *pcm, snd_pcm_info_t * info) static snd_pcm_sframes_t snd_pcm_null_avail_update(snd_pcm_t *pcm) { snd_pcm_null_t *null = pcm->private_data; - if (null->state == SND_PCM_STATE_PREPARED) { - /* it is required to return the correct avail count for */ - /* the prepared stream, otherwise the start is not called */ - return snd_pcm_mmap_avail(pcm); - } + if (null->state == SND_PCM_STATE_PREPARED) { + /* it is required to return the correct avail count for */ + /* the prepared stream, otherwise the start is not called */ + return snd_pcm_mmap_avail(pcm); + } return pcm->buffer_size; } @@ -403,7 +403,7 @@ int snd_pcm_null_open(snd_pcm_t **pcmp, const char *name, snd_pcm_stream_t strea } null->poll_fd = fd; null->state = SND_PCM_STATE_OPEN; - + err = snd_pcm_new(&pcm, SND_PCM_TYPE_NULL, name, stream, mode); if (err < 0) { close(fd); @@ -434,7 +434,7 @@ and /dev/full (capture, must be readable). \code pcm.name { - type null # Null PCM + type null # Null PCM [chmap MAP] # Provide channel maps; MAP is a string array } \endcode @@ -462,7 +462,7 @@ pcm.name { * changed in future. */ int _snd_pcm_null_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf, + snd_config_t *root ATTRIBUTE_UNUSED, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; diff --git a/src/pcm/pcm_params.c b/src/pcm/pcm_params.c index deca344f..833d0dc9 100644 --- a/src/pcm/pcm_params.c +++ b/src/pcm/pcm_params.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #ifndef NDEBUG @@ -124,7 +124,7 @@ void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params) params->info = ~0U; } -/* Return the value for field PAR if it's fixed in configuration space +/* Return the value for field PAR if it's fixed in configuration space defined by PARAMS. Return -EINVAL otherwise */ int snd_pcm_hw_param_get(const snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, @@ -267,12 +267,12 @@ static int _snd_pcm_hw_param_set_integer(snd_pcm_hw_params_t *params, } return changed; } - -/* Inside configuration space defined by PARAMS remove from PAR all + +/* Inside configuration space defined by PARAMS remove from PAR all non integer values. Reduce configuration space accordingly. Return -EINVAL if the configuration space is empty */ -int snd_pcm_hw_param_set_integer(snd_pcm_t *pcm, +int snd_pcm_hw_param_set_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_set_mode_t mode, snd_pcm_hw_param_t var) @@ -328,12 +328,12 @@ static int _snd_pcm_hw_param_set_first(snd_pcm_hw_params_t *params, } -/* Inside configuration space defined by PARAMS remove from PAR all +/* Inside configuration space defined by PARAMS remove from PAR all values > minimum. Reduce configuration space accordingly. Return the minimum. */ -int snd_pcm_hw_param_set_first(snd_pcm_t *pcm, - snd_pcm_hw_params_t *params, +int snd_pcm_hw_param_set_first(snd_pcm_t *pcm, + snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, unsigned int *rval, int *dir) { @@ -370,11 +370,11 @@ static int _snd_pcm_hw_param_set_last(snd_pcm_hw_params_t *params, } -/* Inside configuration space defined by PARAMS remove from PAR all +/* Inside configuration space defined by PARAMS remove from PAR all values < maximum. Reduce configuration space accordingly. Return the maximum. */ -int snd_pcm_hw_param_set_last(snd_pcm_t *pcm, +int snd_pcm_hw_param_set_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, unsigned int *rval, int *dir) @@ -422,7 +422,7 @@ int _snd_pcm_hw_param_set_min(snd_pcm_hw_params_t *params, return changed; } -/* Inside configuration space defined by PARAMS remove from PAR all +/* Inside configuration space defined by PARAMS remove from PAR all values < VAL. Reduce configuration space accordingly. Return new minimum or -EINVAL if the configuration space is empty */ @@ -499,7 +499,7 @@ int _snd_pcm_hw_param_set_max(snd_pcm_hw_params_t *params, return changed; } -/* Inside configuration space defined by PARAMS remove from PAR all +/* Inside configuration space defined by PARAMS remove from PAR all values >= VAL + 1. Reduce configuration space accordingly. Return new maximum or -EINVAL if the configuration space is empty */ @@ -610,7 +610,7 @@ int _snd_pcm_hw_param_set_minmax(snd_pcm_hw_params_t *params, return changed; } -/* Inside configuration space defined by PARAMS remove from PAR all +/* Inside configuration space defined by PARAMS remove from PAR all values < MIN and all values > MAX. Reduce configuration space accordingly. Return 0 or -EINVAL if the configuration space is empty */ @@ -636,7 +636,7 @@ int snd_pcm_hw_param_set_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, assert(0); return -EINVAL; } - err = _snd_pcm_hw_param_set_minmax(params, var, + err = _snd_pcm_hw_param_set_minmax(params, var, *min, mindir ? *mindir : 0, *max, maxdir ? *maxdir : 0); if (err < 0) @@ -707,7 +707,7 @@ int _snd_pcm_hw_param_set(snd_pcm_hw_params_t *params, return changed; } -/* Inside configuration space defined by PARAMS remove from PAR all +/* Inside configuration space defined by PARAMS remove from PAR all values != VAL. Reduce configuration space accordingly. Return -EINVAL if the configuration space is empty */ @@ -845,7 +845,7 @@ int snd_pcm_hw_param_set_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, dump_hw_params(params, "set_near", var, *val, err); return err; } - + if (err >= 0) { snd_pcm_hw_params_t params1; if (min == saved_min && mindir == valdir) @@ -887,7 +887,7 @@ int snd_pcm_hw_param_set_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, Return the value found. */ int snd_pcm_hw_param_set_next(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, + snd_pcm_hw_param_t var, unsigned int best, int bestdir, unsigned int val, int *dir) { @@ -1110,7 +1110,7 @@ static int snd_pcm_hw_params_choose(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) if (err >= 0) err = snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_PERIOD_TIME, &max, &dir); if (err >= 0 && (long)min < pcm->minperiodtime && - (long)max > pcm->minperiodtime) { + (long)max > pcm->minperiodtime) { min = pcm->minperiodtime; dir = 1; snd_pcm_hw_param_set_min(pcm, params, SND_CHANGE, SND_PCM_HW_PARAM_PERIOD_TIME, &min, &dir); } @@ -1187,7 +1187,7 @@ int _snd_pcm_hw_param_refine(snd_pcm_hw_params_t *params, } return changed; } - + #if 0 static void _snd_pcm_hw_param_copy(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, const snd_pcm_hw_params_t *src) @@ -1474,7 +1474,7 @@ unsigned int snd_pcm_hw_strategy_simple_near_min_badness(const snd_pcm_hw_params diff = -diff; return diff * p->mul; } - + int snd_pcm_hw_strategy_simple_near_next_value(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, int value, int *dir, @@ -1510,7 +1510,7 @@ unsigned int snd_pcm_hw_strategy_simple_choices_min_badness(const snd_pcm_hw_par assert(0); return UINT_MAX; } - + int snd_pcm_hw_strategy_simple_choices_next_value(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var, int value, int *dir, @@ -1638,7 +1638,7 @@ int snd_pcm_hw_params_try_explain_failure1(snd_pcm_t *pcm, i = *success; _snd_pcm_hw_param_copy(&i, var, fail); err = snd_pcm_hw_refine(pcm, &i); - if (err == 0 && + if (err == 0 && snd_pcm_hw_params_try_explain_failure1(pcm, fail, &i, depth - 1, out) < 0) continue; snd_output_printf(out, "%s: ", snd_pcm_hw_param_name(var)); @@ -1801,133 +1801,133 @@ static const snd_pcm_hw_rule_t refine_rules[] = { .private_data = 0, }, { - .var = SND_PCM_HW_PARAM_SAMPLE_BITS, + .var = SND_PCM_HW_PARAM_SAMPLE_BITS, .func = snd_pcm_hw_rule_sample_bits, - .deps = { SND_PCM_HW_PARAM_FORMAT, + .deps = { SND_PCM_HW_PARAM_FORMAT, SND_PCM_HW_PARAM_SAMPLE_BITS, -1 }, .private_data = 0, }, { - .var = SND_PCM_HW_PARAM_SAMPLE_BITS, + .var = SND_PCM_HW_PARAM_SAMPLE_BITS, .func = snd_pcm_hw_rule_div, .deps = { SND_PCM_HW_PARAM_FRAME_BITS, SND_PCM_HW_PARAM_CHANNELS, -1 }, .private_data = 0, }, { - .var = SND_PCM_HW_PARAM_FRAME_BITS, + .var = SND_PCM_HW_PARAM_FRAME_BITS, .func = snd_pcm_hw_rule_mul, .deps = { SND_PCM_HW_PARAM_SAMPLE_BITS, SND_PCM_HW_PARAM_CHANNELS, -1 }, .private_data = 0, }, { - .var = SND_PCM_HW_PARAM_FRAME_BITS, + .var = SND_PCM_HW_PARAM_FRAME_BITS, .func = snd_pcm_hw_rule_mulkdiv, .deps = { SND_PCM_HW_PARAM_PERIOD_BYTES, SND_PCM_HW_PARAM_PERIOD_SIZE, -1 }, .private_data = (void*) 8, }, { - .var = SND_PCM_HW_PARAM_FRAME_BITS, + .var = SND_PCM_HW_PARAM_FRAME_BITS, .func = snd_pcm_hw_rule_mulkdiv, .deps = { SND_PCM_HW_PARAM_BUFFER_BYTES, SND_PCM_HW_PARAM_BUFFER_SIZE, -1 }, .private_data = (void*) 8, }, { - .var = SND_PCM_HW_PARAM_CHANNELS, + .var = SND_PCM_HW_PARAM_CHANNELS, .func = snd_pcm_hw_rule_div, .deps = { SND_PCM_HW_PARAM_FRAME_BITS, SND_PCM_HW_PARAM_SAMPLE_BITS, -1 }, .private_data = 0, }, { - .var = SND_PCM_HW_PARAM_RATE, + .var = SND_PCM_HW_PARAM_RATE, .func = snd_pcm_hw_rule_mulkdiv, .deps = { SND_PCM_HW_PARAM_PERIOD_SIZE, SND_PCM_HW_PARAM_PERIOD_TIME, -1 }, .private_data = (void*) 1000000, }, { - .var = SND_PCM_HW_PARAM_RATE, + .var = SND_PCM_HW_PARAM_RATE, .func = snd_pcm_hw_rule_mulkdiv, .deps = { SND_PCM_HW_PARAM_BUFFER_SIZE, SND_PCM_HW_PARAM_BUFFER_TIME, -1 }, .private_data = (void*) 1000000, }, { - .var = SND_PCM_HW_PARAM_PERIODS, + .var = SND_PCM_HW_PARAM_PERIODS, .func = snd_pcm_hw_rule_div, .deps = { SND_PCM_HW_PARAM_BUFFER_SIZE, SND_PCM_HW_PARAM_PERIOD_SIZE, -1 }, .private_data = 0, }, { - .var = SND_PCM_HW_PARAM_PERIOD_SIZE, + .var = SND_PCM_HW_PARAM_PERIOD_SIZE, .func = snd_pcm_hw_rule_div, .deps = { SND_PCM_HW_PARAM_BUFFER_SIZE, SND_PCM_HW_PARAM_PERIODS, -1 }, .private_data = 0, }, { - .var = SND_PCM_HW_PARAM_PERIOD_SIZE, + .var = SND_PCM_HW_PARAM_PERIOD_SIZE, .func = snd_pcm_hw_rule_mulkdiv, .deps = { SND_PCM_HW_PARAM_PERIOD_BYTES, SND_PCM_HW_PARAM_FRAME_BITS, -1 }, .private_data = (void*) 8, }, { - .var = SND_PCM_HW_PARAM_PERIOD_SIZE, + .var = SND_PCM_HW_PARAM_PERIOD_SIZE, .func = snd_pcm_hw_rule_muldivk, .deps = { SND_PCM_HW_PARAM_PERIOD_TIME, SND_PCM_HW_PARAM_RATE, -1 }, .private_data = (void*) 1000000, }, { - .var = SND_PCM_HW_PARAM_BUFFER_SIZE, + .var = SND_PCM_HW_PARAM_BUFFER_SIZE, .func = snd_pcm_hw_rule_mul, .deps = { SND_PCM_HW_PARAM_PERIOD_SIZE, SND_PCM_HW_PARAM_PERIODS, -1 }, .private_data = 0, }, { - .var = SND_PCM_HW_PARAM_BUFFER_SIZE, + .var = SND_PCM_HW_PARAM_BUFFER_SIZE, .func = snd_pcm_hw_rule_mulkdiv, .deps = { SND_PCM_HW_PARAM_BUFFER_BYTES, SND_PCM_HW_PARAM_FRAME_BITS, -1 }, .private_data = (void*) 8, }, { - .var = SND_PCM_HW_PARAM_BUFFER_SIZE, + .var = SND_PCM_HW_PARAM_BUFFER_SIZE, .func = snd_pcm_hw_rule_muldivk, .deps = { SND_PCM_HW_PARAM_BUFFER_TIME, SND_PCM_HW_PARAM_RATE, -1 }, .private_data = (void*) 1000000, }, { - .var = SND_PCM_HW_PARAM_PERIOD_BYTES, + .var = SND_PCM_HW_PARAM_PERIOD_BYTES, .func = snd_pcm_hw_rule_muldivk, .deps = { SND_PCM_HW_PARAM_PERIOD_SIZE, SND_PCM_HW_PARAM_FRAME_BITS, -1 }, .private_data = (void*) 8, }, { - .var = SND_PCM_HW_PARAM_BUFFER_BYTES, + .var = SND_PCM_HW_PARAM_BUFFER_BYTES, .func = snd_pcm_hw_rule_muldivk, .deps = { SND_PCM_HW_PARAM_BUFFER_SIZE, SND_PCM_HW_PARAM_FRAME_BITS, -1 }, .private_data = (void*) 8, }, { - .var = SND_PCM_HW_PARAM_PERIOD_TIME, + .var = SND_PCM_HW_PARAM_PERIOD_TIME, .func = snd_pcm_hw_rule_mulkdiv, .deps = { SND_PCM_HW_PARAM_PERIOD_SIZE, SND_PCM_HW_PARAM_RATE, -1 }, .private_data = (void*) 1000000, }, { - .var = SND_PCM_HW_PARAM_BUFFER_TIME, + .var = SND_PCM_HW_PARAM_BUFFER_TIME, .func = snd_pcm_hw_rule_mulkdiv, .deps = { SND_PCM_HW_PARAM_BUFFER_SIZE, SND_PCM_HW_PARAM_RATE, -1 }, @@ -2015,7 +2015,7 @@ static const snd_mask_t refine_masks[SND_PCM_HW_PARAM_LAST_MASK - SND_PCM_HW_PAR }, }, }; - + static const snd_interval_t refine_intervals[SND_PCM_HW_PARAM_LAST_INTERVAL - SND_PCM_HW_PARAM_FIRST_INTERVAL + 1] = { [SND_PCM_HW_PARAM_SAMPLE_BITS - SND_PCM_HW_PARAM_FIRST_INTERVAL] = { .min = 1, .max = UINT_MAX, @@ -2433,14 +2433,14 @@ int _snd_pcm_hw_params_internal(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) min_align *= 2; } pcm->min_align = min_align; - + pcm->hw_flags = params->flags; pcm->info = params->info; pcm->msbits = params->msbits; pcm->rate_num = params->rate_num; pcm->rate_den = params->rate_den; pcm->fifo_size = params->fifo_size; - + /* Default sw params */ memset(&sw, 0, sizeof(sw)); err = snd_pcm_sw_params_default(pcm, &sw); @@ -2450,7 +2450,7 @@ int _snd_pcm_hw_params_internal(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) if (err < 0) return err; - if (pcm->mmap_rw || + if (pcm->mmap_rw || pcm->access == SND_PCM_ACCESS_MMAP_INTERLEAVED || pcm->access == SND_PCM_ACCESS_MMAP_NONINTERLEAVED || pcm->access == SND_PCM_ACCESS_MMAP_COMPLEX) { diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c index 1bae89d0..5172a7d2 100644 --- a/src/pcm/pcm_plug.c +++ b/src/pcm/pcm_plug.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_plugin.h" @@ -85,7 +85,7 @@ static int snd_pcm_plug_info(snd_pcm_t *pcm, snd_pcm_info_t *info) snd_pcm_plug_t *plug = pcm->private_data; snd_pcm_t *slave = plug->req_slave; int err; - + if ((err = snd_pcm_info(slave, info)) < 0) return err; return 0; @@ -743,7 +743,7 @@ static int snd_pcm_plug_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t * { snd_pcm_plug_t *plug = pcm->private_data; int err; - + _snd_pcm_hw_params_any(sparams); if (plug->sformat >= 0) { _snd_pcm_hw_params_set_format(sparams, plug->sformat); @@ -782,7 +782,7 @@ static int check_access_change(snd_pcm_hw_params_t *cparams, /* no mmap support - we need mmap emulation */ if (!snd_pcm_access_mask_test(smask, SND_PCM_ACCESS_RW_INTERLEAVED) && - !snd_pcm_access_mask_test(smask, SND_PCM_ACCESS_RW_NONINTERLEAVED)) + !snd_pcm_access_mask_test(smask, SND_PCM_ACCESS_RW_NONINTERLEAVED)) return -EINVAL; /* even no RW access? no way! */ cmask = (const snd_pcm_access_mask_t *) @@ -832,7 +832,7 @@ static int snd_pcm_plug_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p if (err < 0) return err; } - + if (plug->schannels == -2 || (pcm->mode & SND_PCM_NO_AUTO_CHANNELS)) links |= SND_PCM_HW_PARBIT_CHANNELS; else { @@ -909,7 +909,7 @@ static int snd_pcm_plug_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p return err; return 0; } - + static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) @@ -964,8 +964,8 @@ static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, } return -EINVAL; } - - err = _snd_pcm_hw_param_set_mask(params, + + err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT, &fmt_mask); if (err < 0) return err; @@ -978,7 +978,7 @@ static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, else { unsigned int rate_min, srate_min; int rate_mindir, srate_mindir; - + /* This is a temporary hack, waiting for a better solution */ err = snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_RATE, &rate_min, &rate_mindir); if (err < 0) @@ -1172,7 +1172,7 @@ int snd_pcm_plug_open(snd_pcm_t **pcmp, plug->tt_ssize = tt_ssize; plug->tt_cused = tt_cused; plug->tt_sused = tt_sused; - + err = snd_pcm_new(&pcm, SND_PCM_TYPE_PLUG, name, slave->stream, slave->mode); if (err < 0) { free(plug); @@ -1210,17 +1210,17 @@ This plugin converts channels, rate and format on request. \code pcm.name { - type plug # Automatic conversion PCM - slave STR # Slave name - # or - slave { # Slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition + type plug # Automatic conversion PCM + slave STR # Slave name + # or + slave { # Slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition [format STR] # Slave format (default nearest) or "unchanged" [channels INT] # Slave channels (default nearest) or "unchanged" [rate INT] # Slave rate (default nearest) or "unchanged" - } + } route_policy STR # route policy for automatic ttable generation # STR can be 'default', 'average', 'copy', 'duplicate' # average: result is average of input channels @@ -1263,7 +1263,7 @@ pcm.name { * changed in future. */ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; @@ -1357,7 +1357,7 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name, } } #endif - + #ifdef BUILD_PCM_PLUGIN_RATE if (! rate_converter) rate_converter = snd_pcm_rate_get_default_converter(root); diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c index 100e12a7..4fb5345b 100644 --- a/src/pcm/pcm_plugin.c +++ b/src/pcm/pcm_plugin.c @@ -81,7 +81,7 @@ pcm.rate44100Hz { \endcode */ - + #include "pcm_local.h" #include "pcm_plugin.h" #include @@ -197,8 +197,8 @@ snd_pcm_sframes_t snd_pcm_plugin_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames frames = n; if (frames == 0) return 0; - - sframes = frames; + + sframes = frames; sframes = snd_pcm_rewind(plugin->gen.slave, sframes); if (sframes < 0) return sframes; @@ -221,8 +221,8 @@ snd_pcm_sframes_t snd_pcm_plugin_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frame frames = n; if (frames == 0) return 0; - - sframes = frames; + + sframes = frames; sframes = INTERNAL(snd_pcm_forward)(plugin->gen.slave, sframes); if (sframes < 0) return sframes; @@ -246,7 +246,7 @@ static snd_pcm_sframes_t snd_pcm_plugin_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_t *slave_areas; snd_pcm_uframes_t slave_offset; snd_pcm_uframes_t slave_frames = ULONG_MAX; - + result = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames); if (result < 0) { err = result; @@ -298,13 +298,13 @@ static snd_pcm_sframes_t snd_pcm_plugin_read_areas(snd_pcm_t *pcm, snd_pcm_uframes_t xfer = 0; snd_pcm_sframes_t result; int err; - + while (size > 0) { snd_pcm_uframes_t frames = size; const snd_pcm_channel_area_t *slave_areas; snd_pcm_uframes_t slave_offset; snd_pcm_uframes_t slave_frames = ULONG_MAX; - + result = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames); if (result < 0) { err = result; @@ -324,7 +324,7 @@ static snd_pcm_sframes_t snd_pcm_plugin_read_areas(snd_pcm_t *pcm, result = snd_pcm_mmap_commit(slave, slave_offset, slave_frames); if (result > 0 && (snd_pcm_uframes_t)result != slave_frames) { snd_pcm_sframes_t res; - + res = plugin->undo_read(slave, areas, offset, frames, slave_frames - result); if (res < 0) { err = res; @@ -353,7 +353,7 @@ snd_pcm_plugin_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size { snd_pcm_channel_area_t areas[pcm->channels]; snd_pcm_areas_from_buf(pcm, areas, (void*)buffer); - return snd_pcm_write_areas(pcm, areas, 0, size, + return snd_pcm_write_areas(pcm, areas, 0, size, snd_pcm_plugin_write_areas); } @@ -427,7 +427,7 @@ snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm, result = snd_pcm_mmap_commit(slave, slave_offset, slave_frames); if (result > 0 && (snd_pcm_uframes_t)result != slave_frames) { snd_pcm_sframes_t res; - + res = plugin->undo_write(pcm, slave_areas, slave_offset + result, slave_frames, slave_frames - result); if (res < 0) { err = res; @@ -532,8 +532,8 @@ static snd_pcm_sframes_t snd_pcm_plugin_sync_hw_ptr(snd_pcm_t *pcm, pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED && pcm->access != SND_PCM_ACCESS_RW_NONINTERLEAVED) return snd_pcm_plugin_sync_hw_ptr_capture(pcm, slave_size); - *pcm->hw.ptr = slave_hw_ptr; - return slave_size; + *pcm->hw.ptr = slave_hw_ptr; + return slave_size; } static snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm) diff --git a/src/pcm/pcm_plugin.h b/src/pcm/pcm_plugin.h index 9896ee8e..1062d9c5 100644 --- a/src/pcm/pcm_plugin.h +++ b/src/pcm/pcm_plugin.h @@ -18,16 +18,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_generic.h" typedef snd_pcm_uframes_t (*snd_pcm_slave_xfer_areas_func_t) - (snd_pcm_t *pcm, + (snd_pcm_t *pcm, const snd_pcm_channel_area_t *areas, - snd_pcm_uframes_t offset, + snd_pcm_uframes_t offset, snd_pcm_uframes_t size, const snd_pcm_channel_area_t *slave_areas, - snd_pcm_uframes_t slave_offset, + snd_pcm_uframes_t slave_offset, snd_pcm_uframes_t *slave_sizep); typedef snd_pcm_sframes_t (*snd_pcm_slave_xfer_areas_undo_func_t) @@ -45,7 +45,7 @@ typedef struct { snd_pcm_slave_xfer_areas_undo_func_t undo_write; int (*init)(snd_pcm_t *pcm); snd_pcm_uframes_t appl_ptr, hw_ptr; -} snd_pcm_plugin_t; +} snd_pcm_plugin_t; /* make local functions really local */ #define snd_pcm_plugin_init \ diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index 3e2a2dcb..85bde241 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -195,7 +195,7 @@ static int snd_pcm_rate_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p return err; return 0; } - + static int snd_pcm_rate_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) { @@ -237,10 +237,10 @@ static int snd_pcm_rate_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p period_size->openmin && period_size->openmax && period_size->min + 1 == period_size->max) { if (period_size->min > 0 && (buffer_size->min / period_size->min) * period_size->min == buffer_size->min) { - snd_interval_set_value(period_size, period_size->min); - } else if ((buffer_size->max / period_size->max) * period_size->max == buffer_size->max) { - snd_interval_set_value(period_size, period_size->max); - } + snd_interval_set_value(period_size, period_size->min); + } else if ((buffer_size->max / period_size->max) * period_size->max == buffer_size->max) { + snd_interval_set_value(period_size, period_size->max); + } } } #ifdef DEBUG_REFINE @@ -266,7 +266,7 @@ static int snd_pcm_rate_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p return 0; } -static int snd_pcm_rate_hw_refine(snd_pcm_t *pcm, +static int snd_pcm_rate_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) { return snd_pcm_hw_refine_slave(pcm, params, @@ -756,15 +756,15 @@ static snd_pcm_sframes_t snd_pcm_rate_forwardable(snd_pcm_t *pcm ATTRIBUTE_UNUSE } static snd_pcm_sframes_t snd_pcm_rate_rewind(snd_pcm_t *pcm ATTRIBUTE_UNUSED, - snd_pcm_uframes_t frames ATTRIBUTE_UNUSED) + snd_pcm_uframes_t frames ATTRIBUTE_UNUSED) { - return 0; + return 0; } static snd_pcm_sframes_t snd_pcm_rate_forward(snd_pcm_t *pcm ATTRIBUTE_UNUSED, - snd_pcm_uframes_t frames ATTRIBUTE_UNUSED) + snd_pcm_uframes_t frames ATTRIBUTE_UNUSED) { - return 0; + return 0; } static int snd_pcm_rate_commit_area(snd_pcm_t *pcm, snd_pcm_rate_t *rate, @@ -845,7 +845,7 @@ static int snd_pcm_rate_commit_area(snd_pcm_t *pcm, snd_pcm_rate_t *rate, if (xfer == slave_size) goto commit_done; - + /* commit second fragment */ cont = slave_size - cont; slave_frames = cont; @@ -958,7 +958,7 @@ static int snd_pcm_rate_grab_next_period(snd_pcm_t *pcm, snd_pcm_uframes_t hw_of } #endif snd_pcm_areas_copy(rate->sareas, xfer, - slave_areas, slave_offset, + slave_areas, slave_offset, pcm->channels, cont, rate->gen.slave->format); result = snd_pcm_mmap_commit(rate->gen.slave, slave_offset, cont); @@ -1046,7 +1046,7 @@ static snd_pcm_sframes_t snd_pcm_rate_avail_update_capture(snd_pcm_t *pcm, snd_pcm_rate_t *rate = pcm->private_data; snd_pcm_t *slave = rate->gen.slave; snd_pcm_uframes_t xfer, hw_offset, size; - + xfer = snd_pcm_mmap_capture_avail(pcm); size = pcm->buffer_size - xfer; hw_offset = snd_pcm_mmap_hw_offset(pcm); @@ -1197,7 +1197,7 @@ static int snd_pcm_rate_start(snd_pcm_t *pcm) { snd_pcm_rate_t *rate = pcm->private_data; snd_pcm_sframes_t avail; - + if (pcm->stream == SND_PCM_STREAM_CAPTURE) return snd_pcm_start(rate->gen.slave); @@ -1253,10 +1253,10 @@ static void snd_pcm_rate_dump(snd_pcm_t *pcm, snd_output_t *out) { snd_pcm_rate_t *rate = pcm->private_data; if (rate->sformat == SND_PCM_FORMAT_UNKNOWN) - snd_output_printf(out, "Rate conversion PCM (%d)\n", + snd_output_printf(out, "Rate conversion PCM (%d)\n", rate->srate); else - snd_output_printf(out, "Rate conversion PCM (%d, sformat=%s)\n", + snd_output_printf(out, "Rate conversion PCM (%d, sformat=%s)\n", rate->srate, snd_pcm_format_name(rate->sformat)); if (rate->ops.dump) @@ -1627,15 +1627,15 @@ This plugin converts a stream rate. The input and output formats must be linear. \code pcm.name { type rate # Rate PCM - slave STR # Slave name - # or - slave { # Slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition - rate INT # Slave rate - [format STR] # Slave format - } + slave STR # Slave name + # or + slave { # Slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + rate INT # Slave rate + [format STR] # Slave format + } converter STR # optional # or converter [ STR1 STR2 ... ] # optional @@ -1672,7 +1672,7 @@ pcm.name { * changed in future. */ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; @@ -1713,7 +1713,7 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name, return err; if (sformat != SND_PCM_FORMAT_UNKNOWN && snd_pcm_format_linear(sformat) != 1) { - snd_config_delete(sconf); + snd_config_delete(sconf); snd_error(PCM, "slave format is not linear"); return -EINVAL; } diff --git a/src/pcm/pcm_rate_linear.c b/src/pcm/pcm_rate_linear.c index f4fc0afc..913a192a 100644 --- a/src/pcm/pcm_rate_linear.c +++ b/src/pcm/pcm_rate_linear.c @@ -1,6 +1,6 @@ /* * Linear rate converter plugin - * + * * Copyright (c) 2000 by Abramo Bagnara * 2004 by Jaroslav Kysela * 2006 by Takashi Iwai @@ -83,7 +83,7 @@ static void linear_expand(struct rate_linear *rate, unsigned int dst_frames1; int16_t sample = 0; unsigned int pos; - + for (channel = 0; channel < rate->channels; ++channel) { const snd_pcm_channel_area_t *src_area = &src_areas[channel]; const snd_pcm_channel_area_t *dst_area = &dst_areas[channel]; @@ -129,7 +129,7 @@ static void linear_expand(struct rate_linear *rate, src += src_step; src_frames1++; } - } + } rate->old_sample[channel] = new_sample; } } @@ -146,7 +146,7 @@ static void linear_expand_s16(struct rate_linear *rate, unsigned int dst_frames1; unsigned int get_threshold = rate->pitch; unsigned int pos; - + for (channel = 0; channel < rate->channels; ++channel) { const snd_pcm_channel_area_t *src_area = &src_areas[channel]; const snd_pcm_channel_area_t *dst_area = &dst_areas[channel]; @@ -181,7 +181,7 @@ static void linear_expand_s16(struct rate_linear *rate, src += src_step; src_frames1++; } - } + } rate->old_sample[channel] = new_sample; } } @@ -223,7 +223,7 @@ static void linear_shrink(struct rate_linear *rate, src_frames1 = 0; dst_frames1 = 0; while (src_frames1 < src_frames) { - + goto *get; #define GET16_END after_get #include "plugin_ops.h" @@ -285,7 +285,7 @@ static void linear_shrink_s16(struct rate_linear *rate, src_frames1 = 0; dst_frames1 = 0; while (src_frames1 < src_frames) { - + new_sample = *src; src += src_step; src_frames1++; @@ -307,7 +307,7 @@ static void linear_shrink_s16(struct rate_linear *rate, } } -static void linear_convert(void *obj, +static void linear_convert(void *obj, const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, unsigned int dst_frames, const snd_pcm_channel_area_t *src_areas, @@ -364,7 +364,7 @@ static int linear_adjust_pitch(void *obj, snd_pcm_rate_info_t *info) rate->pitch = (((uint64_t)info->out.period_size * LINEAR_DIV) + (info->in.period_size/2) ) / info->in.period_size; - + cframes = input_frames(rate, info->out.period_size); while (cframes != info->in.period_size) { snd_pcm_uframes_t cframes_new; diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index 15a28bb3..2fd84e83 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include "pcm_plugin.h" #include "plugin_ops.h" @@ -155,7 +155,7 @@ static void snd_pcm_route_convert1_one(const snd_pcm_channel_area_t *dst_area, frames, ttable, params); return; } - + conv = conv_labels[params->conv_idx]; src = snd_pcm_channel_area_addr(src_area, src_offset); dst = snd_pcm_channel_area_addr(dst_area, dst_offset); @@ -206,7 +206,7 @@ static void snd_pcm_route_convert1_one_getput(const snd_pcm_channel_area_t *dst_ frames, ttable, params); return; } - + get = get32_labels[params->get_idx]; put = put32_labels[params->put_idx]; src = snd_pcm_channel_area_addr(src_area, src_offset); @@ -315,7 +315,7 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area, /* Zero sum */ goto *zero; - zero_int64: + zero_int64: sum.as_sint64 = 0; goto zero_end; #if SND_PCM_PLUGIN_ROUTE_FLOAT @@ -326,7 +326,7 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area, zero_end: for (srcidx = 0; srcidx < nsrcs; ++srcidx) { const char *src = srcs[srcidx]; - + /* Get sample */ goto *get32; #define GET32_END after_get @@ -356,7 +356,7 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area, srcs[srcidx] += src_steps[srcidx]; ttp++; } - + /* Normalization */ goto *norm; norm_int64_att: @@ -383,14 +383,14 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area, goto after_norm; #endif after_norm: - + /* Put sample */ goto *put32; #define PUT32_END after_put32 #include "plugin_ops.h" #undef PUT32_END after_put32: - + dst += dst_step; } } @@ -499,7 +499,7 @@ static int snd_pcm_route_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t * SND_PCM_HW_PARBIT_BUFFER_TIME | SND_PCM_HW_PARBIT_TICK_TIME); if (route->sformat == SND_PCM_FORMAT_UNKNOWN) - links |= (SND_PCM_HW_PARBIT_FORMAT | + links |= (SND_PCM_HW_PARBIT_FORMAT | SND_PCM_HW_PARBIT_SUBFORMAT | SND_PCM_HW_PARBIT_SAMPLE_BITS); if (route->schannels < 0) @@ -509,7 +509,7 @@ static int snd_pcm_route_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t * return err; return 0; } - + static int snd_pcm_route_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) { @@ -523,7 +523,7 @@ static int snd_pcm_route_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t * SND_PCM_HW_PARBIT_BUFFER_TIME | SND_PCM_HW_PARBIT_TICK_TIME); if (route->sformat == SND_PCM_FORMAT_UNKNOWN) - links |= (SND_PCM_HW_PARBIT_FORMAT | + links |= (SND_PCM_HW_PARBIT_FORMAT | SND_PCM_HW_PARBIT_SUBFORMAT | SND_PCM_HW_PARBIT_SAMPLE_BITS); if (route->schannels < 0) @@ -599,7 +599,7 @@ snd_pcm_route_write_areas(snd_pcm_t *pcm, if (size > *slave_sizep) size = *slave_sizep; snd_pcm_route_convert(slave_areas, slave_offset, - areas, offset, + areas, offset, pcm->channels, slave->channels, size, &route->params); @@ -620,7 +620,7 @@ snd_pcm_route_read_areas(snd_pcm_t *pcm, snd_pcm_t *slave = route->plug.gen.slave; if (size > *slave_sizep) size = *slave_sizep; - snd_pcm_route_convert(areas, offset, + snd_pcm_route_convert(areas, offset, slave_areas, slave_offset, slave->channels, pcm->channels, @@ -686,7 +686,7 @@ static void snd_pcm_route_dump(snd_pcm_t *pcm, snd_output_t *out) if (route->sformat == SND_PCM_FORMAT_UNKNOWN) snd_output_printf(out, "Route conversion PCM\n"); else - snd_output_printf(out, "Route conversion PCM (sformat=%s)\n", + snd_output_printf(out, "Route conversion PCM (sformat=%s)\n", snd_pcm_format_name(route->sformat)); snd_output_puts(out, " Transformation table:\n"); for (dst = 0; dst < route->params.ndsts; dst++) { @@ -1025,7 +1025,7 @@ int snd_pcm_route_open(snd_pcm_t **pcmp, const char *name, snd_pcm_route_t *route; int err; assert(pcmp && slave && ttable); - if (sformat != SND_PCM_FORMAT_UNKNOWN && + if (sformat != SND_PCM_FORMAT_UNKNOWN && snd_pcm_format_linear(sformat) != 1) return -EINVAL; route = calloc(1, sizeof(snd_pcm_route_t)); @@ -1166,7 +1166,7 @@ static int _snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_ent if (snd_config_get_id(in, &id) < 0) continue; err = safe_strtol(id, &cchannel); - if (err < 0 || + if (err < 0 || cchannel < 0 || (unsigned int) cchannel > tt_csize) { snd_error(PCM, "Invalid client channel: %s", id); return -EINVAL; @@ -1245,22 +1245,22 @@ If so, a matching channel map will be selected for the slave. \code pcm.name { - type route # Route & Volume conversion PCM - slave STR # Slave name - # or - slave { # Slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition - [format STR] # Slave format - [channels INT] # Slave channels - } - ttable { # Transfer table (bi-dimensional compound of cchannels * schannels numbers) - CCHANNEL { - SCHANNEL REAL # route value (0.0 - 1.0) - } - } - [chmap MAP] # Override channel maps; MAP is a string array + type route # Route & Volume conversion PCM + slave STR # Slave name + # or + slave { # Slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + [format STR] # Slave format + [channels INT] # Slave channels + } + ttable { # Transfer table (bi-dimensional compound of cchannels * schannels numbers) + CCHANNEL { + SCHANNEL REAL # route value (0.0 - 1.0) + } + } + [chmap MAP] # Override channel maps; MAP is a string array } \endcode @@ -1287,7 +1287,7 @@ pcm.name { * changed in future. */ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; @@ -1352,7 +1352,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name, } if (sformat != SND_PCM_FORMAT_UNKNOWN && snd_pcm_format_linear(sformat) != 1) { - snd_config_delete(sconf); + snd_config_delete(sconf); snd_error(PCM, "slave format is not linear"); snd_pcm_free_chmaps(chmaps); return -EINVAL; diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c index 0b22c58d..7927b646 100644 --- a/src/pcm/pcm_share.c +++ b/src/pcm/pcm_share.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include #include @@ -122,7 +122,7 @@ static snd_pcm_uframes_t snd_pcm_share_slave_avail(snd_pcm_share_slave_t *slave) { snd_pcm_sframes_t avail; snd_pcm_t *pcm = slave->pcm; - avail = slave->hw_ptr - *pcm->appl.ptr; + avail = slave->hw_ptr - *pcm->appl.ptr; if (pcm->stream == SND_PCM_STREAM_PLAYBACK) avail += pcm->buffer_size; if (avail < 0) @@ -188,7 +188,7 @@ static snd_pcm_uframes_t _snd_pcm_share_slave_forward(snd_pcm_share_slave_t *sla } -/* +/* - stop PCM on xrun - update poll status - draining silencing @@ -566,7 +566,7 @@ static int snd_pcm_share_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_ return err; return 0; } - + static int snd_pcm_share_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) { @@ -635,7 +635,7 @@ static int snd_pcm_share_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) if (err < 0) goto _err; err = _snd_pcm_hw_param_set_minmax(params, SND_PCM_HW_PARAM_RATE, - spcm->rate, 0, + spcm->rate, 0, spcm->rate, 1); if (err < 0) goto _err; @@ -1253,7 +1253,7 @@ static int snd_pcm_share_drop(snd_pcm_t *pcm) assert(0); break; } - + share->appl_ptr = share->hw_ptr = 0; _end: Pthread_mutex_unlock(&slave->mutex); @@ -1435,7 +1435,7 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, const char *sname, free(share); return -errno; } - + if (stream == SND_PCM_STREAM_PLAYBACK) { int bufsize = 1; err = setsockopt(sd[0], SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)); @@ -1533,7 +1533,7 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, const char *sname, share->pcm = pcm; share->client_socket = sd[0]; share->slave_socket = sd[1]; - + pcm->mmap_rw = 1; pcm->ops = &snd_pcm_share_ops; pcm->fast_ops = &snd_pcm_share_fast_ops; @@ -1569,17 +1569,17 @@ doesn't need the explicit server but access to the shared buffer. \code pcm.name { - type share # Share PCM - slave STR # Slave name - # or - slave { # Slave definition - pcm STR # Slave PCM name - [format STR] # Slave format - [channels INT] # Slave channels - [rate INT] # Slave rate - [period_time INT] # Slave period time in us - [buffer_time INT] # Slave buffer time in us - } + type share # Share PCM + slave STR # Slave name + # or + slave { # Slave definition + pcm STR # Slave PCM name + [format STR] # Slave format + [channels INT] # Slave channels + [rate INT] # Slave rate + [period_time INT] # Slave period time in us + [buffer_time INT] # Slave buffer time in us + } bindings { N INT # Slave channel INT for client channel N } @@ -1624,7 +1624,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, int srate = -1; int speriod_time= -1, sbuffer_time = -1; unsigned int schannel_max = 0; - + snd_config_for_each(i, next, conf) { snd_config_t *n = snd_config_iterator_entry(i); const char *id; @@ -1720,7 +1720,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, } if (schannels <= 0) schannels = schannel_max + 1; - err = snd_pcm_share_open(pcmp, name, sname, sformat, srate, + err = snd_pcm_share_open(pcmp, name, sname, sformat, srate, (unsigned int) schannels, speriod_time, sbuffer_time, channels, channels_map, stream, mode); diff --git a/src/pcm/pcm_shm.c b/src/pcm/pcm_shm.c index a523f237..c0f904eb 100644 --- a/src/pcm/pcm_shm.c +++ b/src/pcm/pcm_shm.c @@ -25,7 +25,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "pcm_local.h" #include #include @@ -91,7 +91,7 @@ static int snd_pcm_shm_new_rbptr(snd_pcm_t *pcm, snd_pcm_shm_t *shm, size_t mmap_size, mmap_offset, offset; int fd; long result; - + shm->ctrl->cmd = &pcm->hw == rbptr ? SND_PCM_IOCTL_HW_PTR_FD : SND_PCM_IOCTL_APPL_PTR_FD; result = snd_pcm_shm_action_fd0(pcm, &fd); if (result < 0) @@ -240,7 +240,7 @@ static int snd_pcm_shm_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pc return err; return 0; } - + static int snd_pcm_shm_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) { @@ -283,7 +283,7 @@ static int snd_pcm_shm_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) snd_pcm_shm_hw_refine_slave); } -static int snd_pcm_shm_hw_params_slave(snd_pcm_t *pcm, +static int snd_pcm_shm_hw_params_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) { snd_pcm_shm_t *shm = pcm->private_data; @@ -644,7 +644,7 @@ static int make_local_socket(const char *filename) snd_errornum(PCM, "socket failed"); return -errno; } - + addr->sun_family = AF_LOCAL; memcpy(addr->sun_path, filename, l); @@ -732,7 +732,7 @@ int snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, result = -errno; goto _err; } - + shm = calloc(1, sizeof(snd_pcm_shm_t)); if (!shm) { result = -ENOMEM; @@ -781,7 +781,7 @@ performance. \code pcm.name { - type shm # Shared memory PCM + type shm # Shared memory PCM server STR # Server name pcm STR # PCM name } diff --git a/src/pcm/pcm_simple.c b/src/pcm/pcm_simple.c index a991315a..c0bc1a2a 100644 --- a/src/pcm/pcm_simple.c +++ b/src/pcm/pcm_simple.c @@ -58,7 +58,7 @@ static int set_hw_params(snd_pcm_t *pcm, /* * hardware parameters - */ + */ err = snd_pcm_hw_params_any(pcm, hw_params); if (err < 0) return err; @@ -93,7 +93,7 @@ static int set_hw_params(snd_pcm_t *pcm, err = INTERNAL(snd_pcm_hw_params_get_period_time)(hw_params, period_time, NULL); if (err < 0) return err; - } + } } else { err = snd_pcm_hw_params_set_period_time(pcm, hw_params, *period_time, 0); if (err < 0) @@ -105,15 +105,15 @@ static int set_hw_params(snd_pcm_t *pcm, if (err < 0) return err; return 0; -} +} static int set_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *sw_params, - snd_spcm_xrun_type_t xrun_type) + snd_spcm_xrun_type_t xrun_type) { int err; - err = snd_pcm_sw_params_current(pcm, sw_params); + err = snd_pcm_sw_params_current(pcm, sw_params); if (err < 0) return err; err = snd_pcm_sw_params_set_start_threshold(pcm, sw_params, (pcm->buffer_size / pcm->period_size) * pcm->period_size); @@ -236,10 +236,10 @@ int snd_spcm_init_duplex(snd_pcm_t *playback_pcm, /* * hardware parameters */ - err = set_buffer_time(latency, &xbuffer_time); + err = set_buffer_time(latency, &xbuffer_time); if (err < 0) return err; - + for (i = 0; i < 2; i++) { buffer_time[i] = xbuffer_time; period_time[i] = i > 0 ? period_time[0] : 0; diff --git a/src/pcm/pcm_softvol.c b/src/pcm/pcm_softvol.c index 71ed8a46..ec8ca223 100644 --- a/src/pcm/pcm_softvol.c +++ b/src/pcm/pcm_softvol.c @@ -294,7 +294,7 @@ static inline short MULTI_DIV_short(short a, unsigned int b, int swap) } \ } \ } while (0) - + #define GET_VOL_SCALE \ switch (ch) { \ case 0: \ @@ -349,7 +349,7 @@ static void softvol_convert_stereo_vol(snd_pcm_softvol_t *svol, case SND_PCM_FORMAT_S16_LE: case SND_PCM_FORMAT_S16_BE: /* 16bit samples */ - CONVERT_AREA(short, + CONVERT_AREA(short, !snd_pcm_format_cpu_endian(svol->sformat)); break; case SND_PCM_FORMAT_S32_LE: @@ -404,7 +404,7 @@ static void softvol_convert_mono_vol(snd_pcm_softvol_t *svol, case SND_PCM_FORMAT_S16_LE: case SND_PCM_FORMAT_S16_BE: /* 16bit samples */ - CONVERT_AREA(short, + CONVERT_AREA(short, !snd_pcm_format_cpu_endian(svol->sformat)); break; case SND_PCM_FORMAT_S32_LE: @@ -475,7 +475,7 @@ static int snd_pcm_softvol_hw_refine_cprepare(snd_pcm_t *pcm, (1ULL << SND_PCM_FORMAT_S16_BE) | (1ULL << SND_PCM_FORMAT_S24_LE) | (1ULL << SND_PCM_FORMAT_S32_LE) | - (1ULL << SND_PCM_FORMAT_S32_BE), + (1ULL << SND_PCM_FORMAT_S32_BE), (1ULL << (SND_PCM_FORMAT_S24_3LE - 32)) } }; @@ -562,7 +562,7 @@ static int snd_pcm_softvol_hw_refine_schange(snd_pcm_t *pcm, SND_PCM_HW_PARBIT_BUFFER_TIME | SND_PCM_HW_PARBIT_TICK_TIME); if (svol->sformat == SND_PCM_FORMAT_UNKNOWN) - links |= (SND_PCM_HW_PARBIT_FORMAT | + links |= (SND_PCM_HW_PARBIT_FORMAT | SND_PCM_HW_PARBIT_SUBFORMAT | SND_PCM_HW_PARBIT_SAMPLE_BITS); err = _snd_pcm_hw_params_refine(sparams, links, params); @@ -575,7 +575,7 @@ static int snd_pcm_softvol_hw_refine_schange(snd_pcm_t *pcm, return 0; } - + static int snd_pcm_softvol_hw_refine_cchange(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_hw_params_t *sparams) @@ -591,7 +591,7 @@ static int snd_pcm_softvol_hw_refine_cchange(snd_pcm_t *pcm, SND_PCM_HW_PARBIT_BUFFER_TIME | SND_PCM_HW_PARBIT_TICK_TIME); if (svol->sformat == SND_PCM_FORMAT_UNKNOWN) - links |= (SND_PCM_HW_PARBIT_FORMAT | + links |= (SND_PCM_HW_PARBIT_FORMAT | SND_PCM_HW_PARBIT_SUBFORMAT | SND_PCM_HW_PARBIT_SAMPLE_BITS); err = _snd_pcm_hw_params_refine(params, links, sparams); @@ -628,7 +628,7 @@ static int snd_pcm_softvol_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * param return err; if (slave->format != SND_PCM_FORMAT_S16_LE && slave->format != SND_PCM_FORMAT_S16_BE && - slave->format != SND_PCM_FORMAT_S24_3LE && + slave->format != SND_PCM_FORMAT_S24_3LE && slave->format != SND_PCM_FORMAT_S24_LE && slave->format != SND_PCM_FORMAT_S32_LE && slave->format != SND_PCM_FORMAT_S32_BE) { @@ -727,7 +727,7 @@ static int add_user_ctl(snd_pcm_softvol_t *svol, snd_ctl_elem_info_t *cinfo, int err; int i; unsigned int def_val; - + if (svol->max_val == 1) { snd_ctl_elem_info_set_read_write(cinfo, 1, 1); err = snd_ctl_add_boolean_elem_set(svol->ctl, cinfo, 1, count); @@ -795,7 +795,7 @@ static int softvol_load_control(snd_pcm_t *pcm, snd_pcm_softvol_t *svol, else svol->zero_dB_val = (min_dB / (min_dB - max_dB)) * svol->max_val; - + snd_ctl_elem_info_set_id(&cinfo, ctl_id); if ((err = snd_ctl_elem_info(svol->ctl, &cinfo)) < 0) { if (err != -ENOENT) { @@ -926,7 +926,7 @@ int snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name, if (sformat != SND_PCM_FORMAT_UNKNOWN && sformat != SND_PCM_FORMAT_S16_LE && sformat != SND_PCM_FORMAT_S16_BE && - sformat != SND_PCM_FORMAT_S24_3LE && + sformat != SND_PCM_FORMAT_S24_3LE && sformat != SND_PCM_FORMAT_S24_LE && sformat != SND_PCM_FORMAT_S32_LE && sformat != SND_PCM_FORMAT_S32_BE) @@ -1101,17 +1101,17 @@ any changes. \code pcm.name { - type softvol # Soft Volume conversion PCM - slave STR # Slave name - # or - slave { # Slave definition - pcm STR # Slave PCM name - # or - pcm { } # Slave PCM definition - [format STR] # Slave format - } - control { - name STR # control element id string + type softvol # Soft Volume conversion PCM + slave STR # Slave name + # or + slave { # Slave definition + pcm STR # Slave PCM name + # or + pcm { } # Slave PCM definition + [format STR] # Slave format + } + control { + name STR # control element id string [card STR] # control card index [iface STR] # interface of the element [index INT] # index of the element @@ -1149,7 +1149,7 @@ pcm.name { * changed in future. */ int _snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name, - snd_config_t *root, snd_config_t *conf, + snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode) { snd_config_iterator_t i, next; @@ -1245,7 +1245,7 @@ int _snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name, if (sformat != SND_PCM_FORMAT_UNKNOWN && sformat != SND_PCM_FORMAT_S16_LE && sformat != SND_PCM_FORMAT_S16_BE && - sformat != SND_PCM_FORMAT_S24_3LE && + sformat != SND_PCM_FORMAT_S24_3LE && sformat != SND_PCM_FORMAT_S24_LE && sformat != SND_PCM_FORMAT_S32_LE && sformat != SND_PCM_FORMAT_S32_BE) { diff --git a/src/pcm/pcm_symbols.c b/src/pcm/pcm_symbols.c index c8596ed3..821c8ca5 100644 --- a/src/pcm/pcm_symbols.c +++ b/src/pcm/pcm_symbols.c @@ -55,7 +55,7 @@ static const char **snd_pcm_open_objects[] = { &_snd_module_pcm_hw, #include "pcm_symbols_list.c" }; - + void *snd_pcm_open_symbols(void) { return snd_pcm_open_objects; diff --git a/src/pcm/plugin_ops.h b/src/pcm/plugin_ops.h index 6392073c..57734a0a 100644 --- a/src/pcm/plugin_ops.h +++ b/src/pcm/plugin_ops.h @@ -260,7 +260,7 @@ conv_xx12_xxx2: as_u8(dst) = as_u16c(src) & 0xff; goto CONV_END; conv_xx12_x210: as_u32(dst) = sx24((uint32_t)bswap_16(as_u16c(src)) << 8); goto CONV_END; conv_xx12_012x: as_u32(dst) = sx24s((uint32_t)as_u16c(src) << 8); goto CONV_END; conv_xx12_2100: as_u32(dst) = (uint32_t)bswap_16(as_u16c(src)) << 16; goto CONV_END; -conv_xx12_0012: as_u32(dst) = (uint32_t)as_u16c(src); goto CONV_END; +conv_xx12_0012: as_u32(dst) = (uint32_t)as_u16c(src); goto CONV_END; conv_xx12_xxxA: as_u8(dst) = (as_u16c(src) ^ 0x80) & 0xff; goto CONV_END; conv_xx12_xxA1: as_u16(dst) = bswap_16(as_u16c(src) ^ 0x80); goto CONV_END; conv_xx12_xx1A: as_u16(dst) = as_u16c(src) ^ 0x80; goto CONV_END; @@ -681,35 +681,35 @@ static void *const get32float_labels[2 * 2] = { #ifdef GET32F_END get32f_1234F_1234: tmp_float.f = as_floatc(src); if (tmp_float.f >= 1.0) - sample = 0x7fffffff; + sample = 0x7fffffff; else if (tmp_float.f <= -1.0) - sample = 0x80000000; + sample = 0x80000000; else - sample = (int32_t)(tmp_float.f * (float_t)0x80000000UL); + sample = (int32_t)(tmp_float.f * (float_t)0x80000000UL); goto GET32F_END; get32f_4321F_1234: tmp_float.i = bswap_32(as_u32c(src)); if (tmp_float.f >= 1.0) - sample = 0x7fffffff; + sample = 0x7fffffff; else if (tmp_float.f <= -1.0) - sample = 0x80000000; + sample = 0x80000000; else - sample = (int32_t)(tmp_float.f * (float_t)0x80000000UL); + sample = (int32_t)(tmp_float.f * (float_t)0x80000000UL); goto GET32F_END; get32f_1234D_1234: tmp_double.d = as_doublec(src); if (tmp_double.d >= 1.0) - sample = 0x7fffffff; + sample = 0x7fffffff; else if (tmp_double.d <= -1.0) - sample = 0x80000000; + sample = 0x80000000; else - sample = (int32_t)(tmp_double.d * (double_t)0x80000000UL); + sample = (int32_t)(tmp_double.d * (double_t)0x80000000UL); goto GET32F_END; get32f_4321D_1234: tmp_double.l = bswap_64(as_u64c(src)); if (tmp_double.d >= 1.0) - sample = 0x7fffffff; + sample = 0x7fffffff; else if (tmp_double.d <= -1.0) - sample = 0x80000000; + sample = 0x80000000; else - sample = (int32_t)(tmp_double.d * (double_t)0x80000000UL); + sample = (int32_t)(tmp_double.d * (double_t)0x80000000UL); goto GET32F_END; #endif diff --git a/src/pcm/scopes/level.c b/src/pcm/scopes/level.c index d5589969..a10e73d7 100644 --- a/src/pcm/scopes/level.c +++ b/src/pcm/scopes/level.c @@ -58,7 +58,7 @@ static int level_enable(snd_pcm_scope_t *scope) snd_pcm_scope_set_callback_private(scope, level); level->win = initscr(); winsdelln(level->win, snd_pcm_meter_get_channels(level->pcm)); - getyx(level->win, y, x); + getyx(level->win, y, x); level->top = y; return 0; } diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c index 1021f1c4..4728b08a 100644 --- a/src/rawmidi/rawmidi.c +++ b/src/rawmidi/rawmidi.c @@ -86,7 +86,7 @@ is passed to \link ::snd_rawmidi_open() \endlink or \link ::snd_rawmidi_open_lco It contains two parts: device name and arguments. Devices and arguments are described in configuration files. The usual place for default definitions is at /usr/share/alsa/alsa.conf. -\subsection rawmidi_dev_names_default +\subsection rawmidi_dev_names_default The default device is equal to hw device. The defaults are used: @@ -143,7 +143,7 @@ This example shows open and read/write rawmidi operations. * \anchor example_test_rawmidi * Shows open and read/write rawmidi operations. */ - + #include "rawmidi_local.h" #include #include @@ -360,7 +360,7 @@ int snd_rawmidi_open_lconf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, int snd_rawmidi_close(snd_rawmidi_t *rawmidi) { int err; - assert(rawmidi); + assert(rawmidi); err = rawmidi->ops->close(rawmidi); free(rawmidi->name); if (rawmidi->open_func) @@ -448,12 +448,12 @@ int snd_rawmidi_poll_descriptors(snd_rawmidi_t *rawmidi, struct pollfd *pfds, un */ int snd_rawmidi_poll_descriptors_revents(snd_rawmidi_t *rawmidi, struct pollfd *pfds, unsigned int nfds, unsigned short *revents) { - assert(rawmidi && pfds && revents); - if (nfds == 1) { - *revents = pfds->revents; - return 0; - } - return -EINVAL; + assert(rawmidi && pfds && revents); + if (nfds == 1) { + *revents = pfds->revents; + return 0; + } + return -EINVAL; } /** diff --git a/src/rawmidi/rawmidi_hw.c b/src/rawmidi/rawmidi_hw.c index c4908a19..1cab935e 100644 --- a/src/rawmidi/rawmidi_hw.c +++ b/src/rawmidi/rawmidi_hw.c @@ -335,7 +335,7 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, *outputp = NULL; if (!inputp && !outputp) return -EINVAL; - + if ((ret = snd_ctl_hw_open(&ctl, NULL, card, 0)) < 0) return ret; if (is_ump) @@ -344,11 +344,11 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, sprintf(filename, SNDRV_FILE_RAWMIDI, card, device); __again: - if (attempt++ > 3) { - snd_ctl_close(ctl); - return -EBUSY; - } - ret = snd_ctl_rawmidi_prefer_subdevice(ctl, subdevice); + if (attempt++ > 3) { + snd_ctl_close(ctl); + return -EBUSY; + } + ret = snd_ctl_rawmidi_prefer_subdevice(ctl, subdevice); if (ret < 0) { snd_ctl_close(ctl); return ret; @@ -369,7 +369,7 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, if (mode & SND_RAWMIDI_NONBLOCK) { fmode |= O_NONBLOCK; } - + if (mode & SND_RAWMIDI_SYNC) { fmode |= O_SYNC; } diff --git a/src/rawmidi/rawmidi_symbols.c b/src/rawmidi/rawmidi_symbols.c index 83e36f87..8d1a96c5 100644 --- a/src/rawmidi/rawmidi_symbols.c +++ b/src/rawmidi/rawmidi_symbols.c @@ -31,7 +31,7 @@ static const char **snd_rawmidi_open_objects[] = { &_snd_module_rawmidi_virt #endif }; - + void *snd_rawmidi_open_symbols(void) { return snd_rawmidi_open_objects; diff --git a/src/rawmidi/rawmidi_virt.c b/src/rawmidi/rawmidi_virt.c index 04c485d3..75330fd1 100644 --- a/src/rawmidi/rawmidi_virt.c +++ b/src/rawmidi/rawmidi_virt.c @@ -52,7 +52,7 @@ typedef struct { int pending; } snd_rawmidi_virtual_t; -int _snd_seq_open_lconf(snd_seq_t **seqp, const char *name, +int _snd_seq_open_lconf(snd_seq_t **seqp, const char *name, int streams, int mode, snd_config_t *lconf, snd_config_t *parent_conf); #endif diff --git a/src/seq/seq.c b/src/seq/seq.c index 7a5fe27d..4807d481 100644 --- a/src/seq/seq.c +++ b/src/seq/seq.c @@ -9,7 +9,7 @@ * See \ref seq page for more details. */ -/* +/* * Sequencer Interface - main file * * This library is free software; you can redistribute it and/or modify @@ -58,12 +58,12 @@ A typical code would be like below: // create a new client snd_seq_t *open_client() { - snd_seq_t *handle; - int err; - err = snd_seq_open(&handle, "default", SND_SEQ_OPEN_INPUT, 0); - if (err < 0) - return NULL; - snd_seq_set_client_name(handle, "My Client"); + snd_seq_t *handle; + int err; + err = snd_seq_open(&handle, "default", SND_SEQ_OPEN_INPUT, 0); + if (err < 0) + return NULL; + snd_seq_set_client_name(handle, "My Client"); return handle; } \endcode @@ -138,13 +138,13 @@ Then, a connection from MIDI input port to this program is established. From this time, events from keyboard are automatically sent to this program. Timestamps will be updated according to the subscribed queue. \code - MIDI input port (keyboard) - | - V - ALSA sequencer - update timestamp - | - V - application port + MIDI input port (keyboard) + | + V + ALSA sequencer - update timestamp + | + V + application port \endcode There is another subscription type for opposite direction: @@ -155,13 +155,13 @@ to MIDI port for write. After this connection is established, events will be properly sent to MIDI output device. \code - application port - | - V - ALSA sequencer - events are scheduled - | - V - MIDI output port (WaveTable etc.) + application port + | + V + ALSA sequencer - events are scheduled + | + V + MIDI output port (WaveTable etc.) \endcode From the viewpoint of subscription, the examples above are special cases. @@ -178,13 +178,13 @@ The connection between ports can be done also by the "third" client. Thus, filter applications have to manage only input and output events regardless of receiver/sender addresses. \code - sequencer port #1 - | - V - ALSA sequencer (scheduled or real-time) - | - V - sequencer port #2 + sequencer port #1 + | + V + ALSA sequencer (scheduled or real-time) + | + V + sequencer port #2 \endcode For the detail about subscription, see the section \ref seq_subs_more. @@ -315,7 +315,7 @@ contains a combination of client id and port id numbers, defined as When an event is passed to sequencer from a client, sequencer fills source.client field with the sender's id automatically. -It is the responsibility of sender client to +It is the responsibility of sender client to fill the port id of source.port and both client and port of dest field. @@ -335,7 +335,7 @@ queue-control event like start, stop and continue queue, change tempo, etc. to the system timer port. Then the sequencer system handles the queue according to the received event. -This port supports subscription. The received timer events are +This port supports subscription. The received timer events are broadcasted to all subscribed clients. The latter port does not receive messages but supports subscription. @@ -454,11 +454,11 @@ For example, to set the tempo of the queue q to \code void set_tempo(snd_seq_t *handle, int queue) { - snd_seq_queue_tempo_t *tempo; - snd_seq_queue_tempo_alloca(&tempo); - snd_seq_queue_tempo_set_tempo(tempo, 1000000); // 60 BPM - snd_seq_queue_tempo_set_ppq(tempo, 48); // 48 PPQ - snd_seq_set_queue_tempo(handle, queue, tempo); + snd_seq_queue_tempo_t *tempo; + snd_seq_queue_tempo_alloca(&tempo); + snd_seq_queue_tempo_set_tempo(tempo, 1000000); // 60 BPM + snd_seq_queue_tempo_set_ppq(tempo, 48); // 48 PPQ + snd_seq_set_queue_tempo(handle, queue, tempo); } \endcode @@ -629,19 +629,19 @@ The application port must have capability #SND_SEQ_PORT_CAP_WRITE. \code void capture_keyboard(snd_seq_t *seq) { - snd_seq_addr_t sender, dest; - snd_seq_port_subscribe_t *subs; - sender.client = 64; - sender.port = 0; - dest.client = 128; - dest.port = 0; - snd_seq_port_subscribe_alloca(&subs); - snd_seq_port_subscribe_set_sender(subs, &sender); - snd_seq_port_subscribe_set_dest(subs, &dest); - snd_seq_port_subscribe_set_queue(subs, 1); - snd_seq_port_subscribe_set_time_update(subs, 1); - snd_seq_port_subscribe_set_time_real(subs, 1); - snd_seq_subscribe_port(seq, subs); + snd_seq_addr_t sender, dest; + snd_seq_port_subscribe_t *subs; + sender.client = 64; + sender.port = 0; + dest.client = 128; + dest.port = 0; + snd_seq_port_subscribe_alloca(&subs); + snd_seq_port_subscribe_set_sender(subs, &sender); + snd_seq_port_subscribe_set_dest(subs, &dest); + snd_seq_port_subscribe_set_queue(subs, 1); + snd_seq_port_subscribe_set_time_update(subs, 1); + snd_seq_port_subscribe_set_time_real(subs, 1); + snd_seq_subscribe_port(seq, subs); } \endcode @@ -652,23 +652,23 @@ The application port must have capability #SND_SEQ_PORT_CAP_READ. \code void subscribe_output(snd_seq_t *seq) { - snd_seq_addr_t sender, dest; - snd_seq_port_subscribe_t *subs; - sender.client = 128; - sender.port = 0; - dest.client = 65; - dest.port = 1; - snd_seq_port_subscribe_alloca(&subs); - snd_seq_port_subscribe_set_sender(subs, &sender); - snd_seq_port_subscribe_set_dest(subs, &dest); - snd_seq_subscribe_port(seq, subs); + snd_seq_addr_t sender, dest; + snd_seq_port_subscribe_t *subs; + sender.client = 128; + sender.port = 0; + dest.client = 65; + dest.port = 1; + snd_seq_port_subscribe_alloca(&subs); + snd_seq_port_subscribe_set_sender(subs, &sender); + snd_seq_port_subscribe_set_dest(subs, &dest); + snd_seq_subscribe_port(seq, subs); } \endcode This example can be simplified by using #snd_seq_connect_to() function. \code void subscribe_output(snd_seq_t *seq) { - snd_seq_connect_to(seq, 0, 65, 1); + snd_seq_connect_to(seq, 0, 65, 1); } \endcode @@ -686,16 +686,16 @@ and the receiver // ..in the third application (130:0) .. void coupling(snd_seq_t *seq) { - snd_seq_addr_t sender, dest; - snd_seq_port_subscribe_t *subs; - sender.client = 128; - sender.port = 0; - dest.client = 129; - dest.port = 0; - snd_seq_port_subscribe_alloca(&subs); - snd_seq_port_subscribe_set_sender(subs, &sender); - snd_seq_port_subscribe_set_dest(subs, &dest); - snd_seq_subscribe_port(seq, subs); + snd_seq_addr_t sender, dest; + snd_seq_port_subscribe_t *subs; + sender.client = 128; + sender.port = 0; + dest.client = 129; + dest.port = 0; + snd_seq_port_subscribe_alloca(&subs); + snd_seq_port_subscribe_set_sender(subs, &sender); + snd_seq_port_subscribe_set_dest(subs, &dest); + snd_seq_subscribe_port(seq, subs); } \endcode @@ -729,17 +729,17 @@ The program appears like this: \code void schedule_event(snd_seq_t *seq) { - snd_seq_event_t ev; + snd_seq_event_t ev; - snd_seq_ev_clear(&ev); - snd_seq_ev_set_source(&ev, my_port); - snd_seq_ev_set_subs(&ev); - snd_seq_ev_schedule_tick(&ev, Q, 0, t); - ... // set event type, data, so on.. + snd_seq_ev_clear(&ev); + snd_seq_ev_set_source(&ev, my_port); + snd_seq_ev_set_subs(&ev); + snd_seq_ev_schedule_tick(&ev, Q, 0, t); + ... // set event type, data, so on.. - snd_seq_event_output(seq, &ev); - ... - snd_seq_drain_output(seq); // if necessary + snd_seq_event_output(seq, &ev); + ... + snd_seq_drain_output(seq); // if necessary } \endcode Of course, you can use realtime stamp, too. @@ -754,16 +754,16 @@ The program can be more simplified as follows: \code void direct_delivery(snd_seq_t *seq) { - snd_seq_event_t ev; + snd_seq_event_t ev; - snd_seq_ev_clear(&ev); - snd_seq_ev_set_source(&ev, port); - snd_seq_ev_set_subs(&ev); - snd_seq_ev_set_direct(&ev); - ... // set event type, data, so on.. + snd_seq_ev_clear(&ev); + snd_seq_ev_set_source(&ev, port); + snd_seq_ev_set_subs(&ev); + snd_seq_ev_set_direct(&ev); + ... // set event type, data, so on.. - snd_seq_event_output(seq, &ev); - snd_seq_drain_output(seq); + snd_seq_event_output(seq, &ev); + snd_seq_drain_output(seq); } \endcode You should flush event soon after output event. @@ -778,15 +778,15 @@ after some modification, will appear as following: \code void event_filter(snd_seq_t *seq, snd_seq_event_t *ev) { - while (snd_seq_event_input(seq, &ev) >= 0) { - //.. modify input event .. + while (snd_seq_event_input(seq, &ev) >= 0) { + //.. modify input event .. - snd_seq_ev_set_source(ev, my_port); - snd_seq_ev_set_subs(ev); - snd_seq_ev_set_direct(ev); - snd_seq_event_output(seq, ev); - snd_seq_drain_output(seq); - } + snd_seq_ev_set_source(ev, my_port); + snd_seq_ev_set_subs(ev); + snd_seq_ev_set_direct(ev); + snd_seq_event_output(seq, ev); + snd_seq_drain_output(seq); + } } \endcode @@ -906,7 +906,7 @@ static int snd_seq_open_conf(snd_seq_t **seqp, const char *name, const char *id; const char *lib = NULL, *open_name = NULL; int (*open_func)(snd_seq_t **, const char *, - snd_config_t *, snd_config_t *, + snd_config_t *, snd_config_t *, int, int) = NULL; #ifndef PIC extern void *snd_seq_open_symbols(void); @@ -1047,7 +1047,7 @@ static int snd_seq_open_noupdate(snd_seq_t **seqp, snd_config_t *root, * \sa snd_seq_open_lconf(), snd_seq_close(), snd_seq_type(), snd_seq_name(), * snd_seq_nonblock(), snd_seq_client_id() */ -int snd_seq_open(snd_seq_t **seqp, const char *name, +int snd_seq_open(snd_seq_t **seqp, const char *name, int streams, int mode) { snd_config_t *top; @@ -1083,7 +1083,7 @@ int snd_seq_open(snd_seq_t **seqp, const char *name, * * \sa snd_seq_open() */ -int snd_seq_open_lconf(snd_seq_t **seqp, const char *name, +int snd_seq_open_lconf(snd_seq_t **seqp, const char *name, int streams, int mode, snd_config_t *lconf) { assert(seqp && name && lconf); @@ -1091,7 +1091,7 @@ int snd_seq_open_lconf(snd_seq_t **seqp, const char *name, } #ifndef DOC_HIDDEN -int _snd_seq_open_lconf(snd_seq_t **seqp, const char *name, +int _snd_seq_open_lconf(snd_seq_t **seqp, const char *name, int streams, int mode, snd_config_t *lconf, snd_config_t *parent_conf) { @@ -1212,12 +1212,12 @@ int snd_seq_poll_descriptors(snd_seq_t *seq, struct pollfd *pfds, unsigned int s */ int snd_seq_poll_descriptors_revents(snd_seq_t *seq, struct pollfd *pfds, unsigned int nfds, unsigned short *revents) { - assert(seq && pfds && revents); - if (nfds == 1) { - *revents = pfds->revents; - return 0; - } - return -EINVAL; + assert(seq && pfds && revents); + if (nfds == 1) { + *revents = pfds->revents; + return 0; + } + return -EINVAL; } /** @@ -1714,7 +1714,7 @@ const unsigned char *snd_seq_client_info_get_event_filter(const snd_seq_client_i * * Remove all event types added with #snd_seq_client_info_event_filter_add and clear * the event filtering flag of this client_info container. - * + * * \sa snd_seq_client_info_event_filter_add(), * snd_seq_client_info_event_filter_del(), * snd_seq_client_info_event_filter_check(), @@ -1732,8 +1732,8 @@ void snd_seq_client_info_event_filter_clear(snd_seq_client_info_t *info) * \brief Add an event type to the event filtering of a client_info container * \param info client_info container * \param event_type event type to be added - * - * Set the event filtering flag of this client_info and add the specified event type to the + * + * Set the event filtering flag of this client_info and add the specified event type to the * filter bitmap of this client_info container. * * \sa snd_seq_get_client_info(), @@ -1787,7 +1787,7 @@ int snd_seq_client_info_event_filter_check(snd_seq_client_info_t *info, int even { assert(info); return snd_seq_get_bit(event_type, info->event_filter); -} +} /** * \brief Get the number of opened ports of a client_info container @@ -2028,7 +2028,7 @@ void snd_seq_client_info_set_event_filter(snd_seq_client_info_t *info, unsigned * \param client client id * \param info the pointer to be stored * \return 0 on success otherwise a negative error code - * + * * Obtains the information of the client with a client id specified by * info argument. * The obtained information is written on info parameter. @@ -2950,7 +2950,7 @@ void snd_seq_port_subscribe_set_sender(snd_seq_port_subscribe_t *info, const snd assert(info); memcpy(&info->sender, addr, sizeof(*addr)); } - + /** * \brief Set destination address of a port_subscribe container * \param info port_subscribe container @@ -3196,7 +3196,7 @@ int snd_seq_query_subscribe_get_num_subs(const snd_seq_query_subscribe_t *info) { assert(info); return info->num_subs; -} +} /** * \brief Get the address of subscriber of a query_subscribe container @@ -3548,7 +3548,7 @@ int snd_seq_create_queue(snd_seq_t *seq, snd_seq_queue_info_t *info) * \return the queue id (zero or positive) on success otherwise a negative error code * * \sa snd_seq_alloc_queue() - */ + */ int snd_seq_alloc_named_queue(snd_seq_t *seq, const char *name) { snd_seq_queue_info_t info; @@ -3566,7 +3566,7 @@ int snd_seq_alloc_named_queue(snd_seq_t *seq, const char *name) * * \sa snd_seq_alloc_named_queue(), snd_seq_create_queue(), snd_seq_free_queue(), * snd_seq_get_queue_info() - */ + */ int snd_seq_alloc_queue(snd_seq_t *seq) { return snd_seq_alloc_named_queue(seq, NULL); @@ -3647,7 +3647,7 @@ int snd_seq_query_named_queue(snd_seq_t *seq, const char *name) * \brief Get the queue usage flag to the client * \param seq sequencer handle * \param q queue id - * \return 1 = client is allowed to access the queue, 0 = not allowed, + * \return 1 = client is allowed to access the queue, 0 = not allowed, * otherwise a negative error code * * \sa snd_seq_get_queue_info(), snd_seq_set_queue_usage() @@ -4164,7 +4164,7 @@ void snd_seq_queue_timer_set_type(snd_seq_queue_timer_t *info, snd_seq_queue_tim assert(info); info->type = (int)type; } - + /** * \brief Set the timer id of a queue_timer container * \param info queue_timer container @@ -4544,7 +4544,7 @@ static int snd_seq_event_retrieve_buffer(snd_seq_t *seq, snd_seq_event_t **retp) * \brief retrieve an event from sequencer * \param seq sequencer handle * \param ev event pointer to be stored - * \return + * \return * * Obtains an input event from sequencer. * The event is created via snd_seq_create_event(), and its pointer is stored on @@ -4597,7 +4597,7 @@ static int snd_seq_event_input_feed(snd_seq_t *seq, int timeout) snd_errornum(SEQUENCER, "poll"); return -errno; } - if (pfd.revents & POLLIN) + if (pfd.revents & POLLIN) return snd_seq_event_read_buffer(seq); return seq->ibuflen; } diff --git a/src/seq/seq_hw.c b/src/seq/seq_hw.c index 5ee41953..29dd01fe 100644 --- a/src/seq/seq_hw.c +++ b/src/seq/seq_hw.c @@ -522,7 +522,7 @@ int snd_seq_hw_open(snd_seq_t **handle, const char *name, int streams, int mode) assert(0); return -EINVAL; } - + if (mode & SND_SEQ_NONBLOCK) fmode |= O_NONBLOCK; diff --git a/src/seq/seq_symbols.c b/src/seq/seq_symbols.c index a024e67e..dd3391f1 100644 --- a/src/seq/seq_symbols.c +++ b/src/seq/seq_symbols.c @@ -25,7 +25,7 @@ extern const char *_snd_module_seq_hw; static const char **snd_seq_open_objects[] = { &_snd_module_seq_hw }; - + void *snd_seq_open_symbols(void) { return snd_seq_open_objects; diff --git a/src/seq/seqmid.c b/src/seq/seqmid.c index ca9686e4..604aa2dd 100644 --- a/src/seq/seqmid.c +++ b/src/seq/seqmid.c @@ -119,7 +119,7 @@ int snd_seq_delete_simple_port(snd_seq_t *seq, int port) int snd_seq_connect_from(snd_seq_t *seq, int myport, int src_client, int src_port) { snd_seq_port_subscribe_t subs; - + memset(&subs, 0, sizeof(subs)); subs.sender.client = src_client; subs.sender.port = src_port; @@ -146,7 +146,7 @@ int snd_seq_connect_from(snd_seq_t *seq, int myport, int src_client, int src_por int snd_seq_connect_to(snd_seq_t *seq, int myport, int dest_client, int dest_port) { snd_seq_port_subscribe_t subs; - + memset(&subs, 0, sizeof(subs)); /*subs.sender.client = seq->client;*/ subs.sender.client = snd_seq_client_id(seq); @@ -173,7 +173,7 @@ int snd_seq_connect_to(snd_seq_t *seq, int myport, int dest_client, int dest_por int snd_seq_disconnect_from(snd_seq_t *seq, int myport, int src_client, int src_port) { snd_seq_port_subscribe_t subs; - + memset(&subs, 0, sizeof(subs)); subs.sender.client = src_client; subs.sender.port = src_port; @@ -200,7 +200,7 @@ int snd_seq_disconnect_from(snd_seq_t *seq, int myport, int src_client, int src_ int snd_seq_disconnect_to(snd_seq_t *seq, int myport, int dest_client, int dest_port) { snd_seq_port_subscribe_t subs; - + memset(&subs, 0, sizeof(subs)); /*subs.sender.client = seq->client;*/ subs.sender.client = snd_seq_client_id(seq); @@ -400,7 +400,7 @@ int snd_seq_sync_output_queue(snd_seq_t *seq) pfd.fd = seq->poll_fd; pfd.events = POLLOUT; err = poll(&pfd, 1, -1); - /* restore the room size */ + /* restore the room size */ info.output_room = saved_room; snd_seq_set_client_pool(seq, &info); return err; diff --git a/src/socket.c b/src/socket.c index 971c434e..931d24e4 100644 --- a/src/socket.c +++ b/src/socket.c @@ -24,7 +24,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "local.h" #include #include @@ -60,7 +60,7 @@ int snd_send_fd(int sock, void *data, size_t len, int fd) msghdr.msg_name = NULL; msghdr.msg_namelen = 0; msghdr.msg_iov = &vec; - msghdr.msg_iovlen = 1; + msghdr.msg_iovlen = 1; msghdr.msg_control = cmsg; msghdr.msg_controllen = cmsg_len; msghdr.msg_flags = 0; diff --git a/src/timer/timer.c b/src/timer/timer.c index c4daa2a0..48eb80dc 100644 --- a/src/timer/timer.c +++ b/src/timer/timer.c @@ -248,7 +248,7 @@ int snd_timer_open_lconf(snd_timer_t **timer, const char *name, int snd_timer_close(snd_timer_t *timer) { int err; - assert(timer); + assert(timer); while (!list_empty(&timer->async_handlers)) { snd_async_handler_t *h = list_entry(timer->async_handlers.next, snd_async_handler_t, hlist); snd_async_del_handler(h); @@ -335,7 +335,7 @@ snd_timer_t *snd_async_handler_get_timer(snd_async_handler_t *handler) return NULL; } return handler->u.timer; -} +} /** * \brief get count of poll descriptors for timer handle @@ -388,12 +388,12 @@ int snd_timer_poll_descriptors(snd_timer_t *timer, struct pollfd *pfds, unsigned */ int snd_timer_poll_descriptors_revents(snd_timer_t *timer, struct pollfd *pfds, unsigned int nfds, unsigned short *revents) { - assert(timer && pfds && revents); - if (nfds == 1) { - *revents = pfds->revents; - return 0; - } - return -EINVAL; + assert(timer && pfds && revents); + if (nfds == 1) { + *revents = pfds->revents; + return 0; + } + return -EINVAL; } /** @@ -428,8 +428,8 @@ int snd_timer_nonblock(snd_timer_t *timer, int nonblock) int snd_timer_async(snd_timer_t *timer, int sig, pid_t pid) { assert(timer); - if (sig == 0) - sig = SIGIO; + if (sig == 0) + sig = SIGIO; if (pid == 0) pid = getpid(); return timer->ops->async(timer, sig, pid); diff --git a/src/timer/timer_hw.c b/src/timer/timer_hw.c index 3783491f..7aaaf180 100644 --- a/src/timer/timer_hw.c +++ b/src/timer/timer_hw.c @@ -227,7 +227,7 @@ int snd_timer_hw_open(snd_timer_t **handle, const char *name, int dev_class, int tmode = O_RDONLY; if (mode & SND_TIMER_OPEN_NONBLOCK) - tmode |= O_NONBLOCK; + tmode |= O_NONBLOCK; fd = snd_open_device(SNDRV_FILE_TIMER, tmode); if (fd < 0) return -errno; diff --git a/src/timer/timer_query.c b/src/timer/timer_query.c index 9fa14069..121cef6c 100644 --- a/src/timer/timer_query.c +++ b/src/timer/timer_query.c @@ -200,7 +200,7 @@ int snd_timer_query_open_lconf(snd_timer_query_t **timer, const char *name, int snd_timer_query_close(snd_timer_query_t *timer) { int err; - assert(timer); + assert(timer); err = timer->ops->close(timer); if (timer->dl_handle) snd_dlclose(timer->dl_handle); @@ -220,8 +220,8 @@ int snd_timer_query_close(snd_timer_query_t *timer) */ int snd_timer_query_next_device(snd_timer_query_t *timer, snd_timer_id_t *tid) { - assert(timer); - assert(tid); + assert(timer); + assert(tid); return timer->ops->next_device(timer, tid); } @@ -261,9 +261,9 @@ int snd_timer_ginfo_malloc(snd_timer_ginfo_t **info) void snd_timer_ginfo_free(snd_timer_ginfo_t *info) { assert(info); - free(info); + free(info); } - + /** * \brief copy one snd_timer_info_t structure to another * \param dst destination snd_timer_info_t structure @@ -389,8 +389,8 @@ EXPORT_SYMBOL int INTERNAL(snd_timer_query_info)(snd_timer_query_t *timer, snd_t int snd_timer_query_info(snd_timer_query_t *timer, snd_timer_ginfo_t *info) #endif { - assert(timer); - assert(info); + assert(timer); + assert(info); return timer->ops->info(timer, info); } use_default_symbol_version(__snd_timer_query_info, snd_timer_query_info, ALSA_0.9.0); @@ -407,8 +407,8 @@ EXPORT_SYMBOL int INTERNAL(snd_timer_query_params)(snd_timer_query_t *timer, snd int snd_timer_query_params(snd_timer_query_t *timer, snd_timer_gparams_t *params) #endif { - assert(timer); - assert(params); + assert(timer); + assert(params); return timer->ops->params(timer, params); } use_default_symbol_version(__snd_timer_query_params, snd_timer_query_params, ALSA_0.9.0); @@ -425,8 +425,8 @@ EXPORT_SYMBOL int INTERNAL(snd_timer_query_status)(snd_timer_query_t *timer, snd int snd_timer_query_status(snd_timer_query_t *timer, snd_timer_gstatus_t *status) #endif { - assert(timer); - assert(status); + assert(timer); + assert(status); return timer->ops->status(timer, status); } use_default_symbol_version(__snd_timer_query_status, snd_timer_query_status, ALSA_0.9.0); diff --git a/src/timer/timer_query_hw.c b/src/timer/timer_query_hw.c index 0e217e53..16c58393 100644 --- a/src/timer/timer_query_hw.c +++ b/src/timer/timer_query_hw.c @@ -92,7 +92,7 @@ int snd_timer_query_hw_open(snd_timer_query_t **handle, const char *name, int mo tmode = O_RDONLY; if (mode & SND_TIMER_OPEN_NONBLOCK) - tmode |= O_NONBLOCK; + tmode |= O_NONBLOCK; fd = snd_open_device(SNDRV_FILE_TIMER, tmode); if (fd < 0) return -errno; diff --git a/src/timer/timer_symbols.c b/src/timer/timer_symbols.c index 8393d125..e83910e2 100644 --- a/src/timer/timer_symbols.c +++ b/src/timer/timer_symbols.c @@ -25,7 +25,7 @@ extern const char *_snd_module_timer_hw; static const char **snd_timer_open_objects[] = { &_snd_module_timer_hw }; - + void *snd_timer_open_symbols(void) { return (void *)snd_timer_open_objects[0]; @@ -37,7 +37,7 @@ extern const char *_snd_module_timer_query_hw; static const char **snd_timer_query_open_objects[] = { &_snd_module_timer_query_hw }; - + void *snd_timer_query_open_symbols(void) { return snd_timer_query_open_objects; diff --git a/src/topology/builder.c b/src/topology/builder.c index f7cf8534..8d91b8ef 100644 --- a/src/topology/builder.c +++ b/src/topology/builder.c @@ -13,8 +13,8 @@ GNU Lesser General Public License for more details. Authors: Mengdong Lin - Yao Jin - Liam Girdwood + Yao Jin + Liam Girdwood */ #include "tplg_local.h" @@ -132,7 +132,7 @@ static int write_elem_block(snd_tplg_t *tplg, if (sub_pos == pos) break; } - /* the last elem of the current sub list as the head of + /* the last elem of the current sub list as the head of next sub list*/ sub_base = pos; count = 0; diff --git a/src/topology/channel.c b/src/topology/channel.c index 66c59707..2e001a5d 100644 --- a/src/topology/channel.c +++ b/src/topology/channel.c @@ -13,8 +13,8 @@ GNU Lesser General Public License for more details. Authors: Mengdong Lin - Yao Jin - Liam Girdwood + Yao Jin + Liam Girdwood */ #include "tplg_local.h" diff --git a/src/topology/ctl.c b/src/topology/ctl.c index 6c9c0718..8a84450c 100644 --- a/src/topology/ctl.c +++ b/src/topology/ctl.c @@ -13,8 +13,8 @@ GNU Lesser General Public License for more details. Authors: Mengdong Lin - Yao Jin - Liam Girdwood + Yao Jin + Liam Girdwood */ #include "tplg_local.h" diff --git a/src/topology/dapm.c b/src/topology/dapm.c index a02d724c..bb7fdf65 100644 --- a/src/topology/dapm.c +++ b/src/topology/dapm.c @@ -13,8 +13,8 @@ GNU Lesser General Public License for more details. Authors: Mengdong Lin - Yao Jin - Liam Girdwood + Yao Jin + Liam Girdwood */ #include "tplg_local.h" diff --git a/src/topology/data.c b/src/topology/data.c index 93fa6f0d..b1a2e23a 100644 --- a/src/topology/data.c +++ b/src/topology/data.c @@ -13,8 +13,8 @@ GNU Lesser General Public License for more details. Authors: Mengdong Lin - Yao Jin - Liam Girdwood + Yao Jin + Liam Girdwood */ #include "tplg_local.h" @@ -413,7 +413,7 @@ static int write_hex(char *buf, char *str, int width) long val; void *p = &val; - errno = 0; + errno = 0; if (safe_strtol_base(str, &val, 16) < 0) return -EINVAL; diff --git a/src/topology/elem.c b/src/topology/elem.c index 0ce11b04..feaeafbb 100644 --- a/src/topology/elem.c +++ b/src/topology/elem.c @@ -13,8 +13,8 @@ GNU Lesser General Public License for more details. Authors: Mengdong Lin - Yao Jin - Liam Girdwood + Yao Jin + Liam Girdwood */ #include "tplg_local.h" diff --git a/src/topology/ops.c b/src/topology/ops.c index 232073a3..b56f6868 100644 --- a/src/topology/ops.c +++ b/src/topology/ops.c @@ -13,8 +13,8 @@ GNU Lesser General Public License for more details. Authors: Mengdong Lin - Yao Jin - Liam Girdwood + Yao Jin + Liam Girdwood */ #include "tplg_local.h" diff --git a/src/topology/parser.c b/src/topology/parser.c index 5ecf98f5..9814a9f7 100644 --- a/src/topology/parser.c +++ b/src/topology/parser.c @@ -13,8 +13,8 @@ GNU Lesser General Public License for more details. Authors: Mengdong Lin - Yao Jin - Liam Girdwood + Yao Jin + Liam Girdwood */ #include "tplg_local.h" diff --git a/src/topology/pcm.c b/src/topology/pcm.c index cef5127c..db06d041 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -13,8 +13,8 @@ GNU Lesser General Public License for more details. Authors: Mengdong Lin - Yao Jin - Liam Girdwood + Yao Jin + Liam Girdwood */ #include "tplg_local.h" diff --git a/src/topology/text.c b/src/topology/text.c index c5022c19..f6d34392 100644 --- a/src/topology/text.c +++ b/src/topology/text.c @@ -13,8 +13,8 @@ GNU Lesser General Public License for more details. Authors: Mengdong Lin - Yao Jin - Liam Girdwood + Yao Jin + Liam Girdwood */ diff --git a/src/ucm/main.c b/src/ucm/main.c index 3a3c9c15..d9e031d3 100644 --- a/src/ucm/main.c +++ b/src/ucm/main.c @@ -10,7 +10,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software + * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Support for the verb/device/modifier core logic and API, @@ -1027,7 +1027,7 @@ static int set_defaults(snd_use_case_mgr_t *uc_mgr, bool force) static int import_master_config(snd_use_case_mgr_t *uc_mgr) { int err; - + err = uc_mgr_import_master_config(uc_mgr); if (err < 0) return err; @@ -1210,7 +1210,7 @@ static inline struct use_case_verb *find_verb(snd_use_case_mgr_t *uc_mgr, verb_name); } -static int is_devlist_supported(snd_use_case_mgr_t *uc_mgr, +static int is_devlist_supported(snd_use_case_mgr_t *uc_mgr, struct dev_list *dev_list) { struct dev_list_node *device; @@ -1243,13 +1243,13 @@ static int is_devlist_supported(snd_use_case_mgr_t *uc_mgr, return 1 - found_ret; } -static inline int is_modifier_supported(snd_use_case_mgr_t *uc_mgr, +static inline int is_modifier_supported(snd_use_case_mgr_t *uc_mgr, struct use_case_modifier *modifier) { return is_devlist_supported(uc_mgr, &modifier->dev_list); } -static inline int is_device_supported(snd_use_case_mgr_t *uc_mgr, +static inline int is_device_supported(snd_use_case_mgr_t *uc_mgr, struct use_case_device *device) { return is_devlist_supported(uc_mgr, &device->dev_list); @@ -1639,7 +1639,7 @@ static int dismantle_use_case(snd_use_case_mgr_t *uc_mgr) uc_mgr->active_verb = NULL; err = set_defaults(uc_mgr, true); - + return err; } diff --git a/src/ucm/parser.c b/src/ucm/parser.c index ac4a5fbc..59d20320 100644 --- a/src/ucm/parser.c +++ b/src/ucm/parser.c @@ -10,7 +10,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software + * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Support for the verb/device/modifier core logic and API, @@ -847,7 +847,7 @@ static int parse_transition(snd_use_case_mgr_t *uc_mgr, free(tseq); return err; } - + err = parse_sequence(uc_mgr, &tseq->transition_list, n); if (err < 0) { uc_mgr_free_transition_element(tseq); @@ -873,7 +873,7 @@ static int parse_compound(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, if (snd_config_get_id(cfg, &id) < 0) return -EINVAL; - + if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { uc_error("compound type expected for %s", id); return -EINVAL; @@ -886,7 +886,7 @@ static int parse_compound(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, uc_error("compound type expected for %s, is %d", id, snd_config_get_type(cfg)); return -EINVAL; } - + err = fcn(uc_mgr, n, data1, data2); if (err < 0) return err; @@ -1898,7 +1898,7 @@ static int parse_verb(snd_use_case_mgr_t *uc_mgr, snd_config_iterator_t i, next; snd_config_t *n; int err; - + /* in-place evaluation */ err = uc_mgr_evaluate_inplace(uc_mgr, cfg); if (err < 0) diff --git a/src/ucm/ucm_local.h b/src/ucm/ucm_local.h index b274277d..47cfa0d5 100644 --- a/src/ucm/ucm_local.h +++ b/src/ucm/ucm_local.h @@ -10,7 +10,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software + * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Support for the verb/device/modifier core logic and API, @@ -62,9 +62,9 @@ #define SEQUENCE_ELEMENT_TYPE_DEV_DISABLE_ALL 15 struct ucm_value { - struct list_head list; - char *name; - char *data; + struct list_head list; + char *name; + char *data; }; /* sequence of a component device */ diff --git a/src/ucm/utils.c b/src/ucm/utils.c index bc33ee5a..fc5fb1f4 100644 --- a/src/ucm/utils.c +++ b/src/ucm/utils.c @@ -10,7 +10,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software + * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Support for the verb/device/modifier core logic and API, @@ -412,7 +412,7 @@ void uc_mgr_free_value(struct list_head *base) { struct list_head *pos, *npos; struct ucm_value *val; - + list_for_each_safe(pos, npos, base) { val = list_entry(pos, struct ucm_value, list); uc_mgr_free_value1(val); @@ -423,7 +423,7 @@ void uc_mgr_free_dev_list(struct dev_list *dev_list) { struct list_head *pos, *npos; struct dev_list_node *dlist; - + list_for_each_safe(pos, npos, &dev_list->list) { dlist = list_entry(pos, struct dev_list_node, list); free(dlist->name); @@ -534,7 +534,7 @@ void uc_mgr_free_sequence(struct list_head *base) { struct list_head *pos, *npos; struct sequence_element *seq; - + list_for_each_safe(pos, npos, base) { seq = list_entry(pos, struct sequence_element, list); list_del(&seq->list); @@ -553,7 +553,7 @@ void uc_mgr_free_transition(struct list_head *base) { struct list_head *pos, *npos; struct transition_sequence *tseq; - + list_for_each_safe(pos, npos, base) { tseq = list_entry(pos, struct transition_sequence, list); list_del(&tseq->list); @@ -579,7 +579,7 @@ void uc_mgr_free_modifier(struct list_head *base) { struct list_head *pos, *npos; struct use_case_modifier *mod; - + list_for_each_safe(pos, npos, base) { mod = list_entry(pos, struct use_case_modifier, list); free(mod->name); @@ -611,7 +611,7 @@ void uc_mgr_free_device_list(struct list_head *base) { struct list_head *pos, *npos; struct use_case_device *dev; - + list_for_each_safe(pos, npos, base) { dev = list_entry(pos, struct use_case_device, list); uc_mgr_free_device(dev); diff --git a/src/userfile.c b/src/userfile.c index 492ea9cb..be80d31d 100644 --- a/src/userfile.c +++ b/src/userfile.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ - + #include "config.h" #include #include diff --git a/test/audio_time.c b/test/audio_time.c index 00619966..2fe6a0f4 100644 --- a/test/audio_time.c +++ b/test/audio_time.c @@ -390,7 +390,7 @@ int main(int argc, char *argv[]) } - printf("\t capture: systime: %lli nsec, audio time %lli nsec, \tsystime delta %lli \t resolution %d ns \n", + printf("\t capture: systime: %lli nsec, audio time %lli nsec, \tsystime delta %lli \t resolution %d ns \n", timediff(tstamp_c, trigger_tstamp_c), timestamp2ns(audio_tstamp_c), timediff(tstamp_c, trigger_tstamp_c) - timestamp2ns(audio_tstamp_c), audio_tstamp_report_c.accuracy diff --git a/test/control.c b/test/control.c index b0a3877e..ccb389e7 100644 --- a/test/control.c +++ b/test/control.c @@ -101,7 +101,7 @@ int main(void) } snd_ctl_close(handle); } - + snd_config_update_free_global(); return 0; } diff --git a/test/latency.c b/test/latency.c index c40b2ae7..38633253 100644 --- a/test/latency.c +++ b/test/latency.c @@ -251,9 +251,9 @@ int setparams(snd_pcm_t *phandle, snd_pcm_t *chandle, int *bufsize) } __again: - if (buffer_size > 0) - return -1; - if (last_bufsize == *bufsize) + if (buffer_size > 0) + return -1; + if (last_bufsize == *bufsize) *bufsize += 4; last_bufsize = *bufsize; if (*bufsize > latency_max) @@ -282,8 +282,8 @@ int setparams(snd_pcm_t *phandle, snd_pcm_t *chandle, int *bufsize) snd_pcm_hw_params_get_buffer_size(p_params, &p_size); playback_buffer_size = p_size; if (p_psize * 2 < p_size) { - snd_pcm_hw_params_get_periods_min(p_params, &val, NULL); - if (val > 2) { + snd_pcm_hw_params_get_periods_min(p_params, &val, NULL); + if (val > 2) { printf("playback device does not support 2 periods per buffer\n"); exit(0); } @@ -291,7 +291,7 @@ int setparams(snd_pcm_t *phandle, snd_pcm_t *chandle, int *bufsize) } snd_pcm_hw_params_get_buffer_size(c_params, &c_size); if (c_psize * 2 < c_size) { - snd_pcm_hw_params_get_periods_min(c_params, &val, NULL); + snd_pcm_hw_params_get_periods_min(c_params, &val, NULL); if (val > 2 ) { printf("capture device does not support 2 periods per buffer\n"); exit(0); @@ -490,7 +490,7 @@ void applyeffect(char* buffer,int r) y[chn][1] = y[chn][0]; x[chn][0] = samples[i*channels+chn]; - y[chn][0] = a0*x[chn][0] + a1*x[chn][1] + a2*x[chn][2] + y[chn][0] = a0*x[chn][0] + a1*x[chn][1] + a2*x[chn][2] - b1*y[chn][1] - b2*y[chn][2]; samples[i*channels+chn] = y[chn][0]; } @@ -537,14 +537,14 @@ void help(void) "-X,--realtime do a realtime check (buffering)\n" "-O,--policy set scheduler policy (RR, FIFO or OTHER)\n" ); - printf("Recognized sample formats are:"); - for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) { - const char *s = snd_pcm_format_name(k); - if (s) - printf(" %s", s); - } - printf("\n\n"); - printf( + printf("Recognized sample formats are:"); + for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) { + const char *s = snd_pcm_format_name(k); + if (s) + printf(" %s", s); + } + printf("\n\n"); + printf( "Tip #1 (usable latency with large periods, non-blocking mode, good CPU usage,\n" " superb xrun prevention):\n" " latency -m 8192 -M 8192 -t 1 -p\n" @@ -724,17 +724,17 @@ int main(int argc, char *argv[]) lfo = 0; dlfo = 2.*M_PI*FILTERSWEEP_LFO_FREQ/fs; - x[0] = (float*) malloc(channels*sizeof(float)); - x[1] = (float*) malloc(channels*sizeof(float)); - x[2] = (float*) malloc(channels*sizeof(float)); - y[0] = (float*) malloc(channels*sizeof(float)); - y[1] = (float*) malloc(channels*sizeof(float)); - y[2] = (float*) malloc(channels*sizeof(float)); + x[0] = (float*) malloc(channels*sizeof(float)); + x[1] = (float*) malloc(channels*sizeof(float)); + x[2] = (float*) malloc(channels*sizeof(float)); + y[0] = (float*) malloc(channels*sizeof(float)); + y[1] = (float*) malloc(channels*sizeof(float)); + y[2] = (float*) malloc(channels*sizeof(float)); } cap_avail_max = 0; pbk_fill_min = latency * 2; - + while (1) { frames_in = frames_out = 0; if (setparams(phandle, chandle, &latency) < 0) @@ -819,7 +819,7 @@ int main(int argc, char *argv[]) else { if (effect) applyeffect(buffer, r); - if (writebuf(phandle, buffer, r, &frames_out) < 0) + if (writebuf(phandle, buffer, r, &frames_out) < 0) ok = 0; } } diff --git a/test/midifile.c b/test/midifile.c index 8580108e..808dafc8 100644 --- a/test/midifile.c +++ b/test/midifile.c @@ -370,8 +370,8 @@ readtrack (void) /* read a track chunk */ old_currtempo = Mf_currtempo; old_realtime = Mf_realtime; if (revised_time != tempo_change_time) { - old_f_realtime = Mf_f_realtime; - old_currtime = save_time; + old_f_realtime = Mf_f_realtime; + old_currtime = save_time; } delta_secs = mf_ticks2sec (revised_time-old_currtime, Mf_division, save_tempo); #ifdef DEBUG_TIMES @@ -856,17 +856,17 @@ mf_write_track_chunk (int which_track, FILE *fp) eputc(laststatus = meta_event); eputc(end_of_track); - eputc(0); + eputc(0); */ /* It's impossible to know how long the track chunk will be beforehand, - so the position of the track length data is kept so that it can - be written after the chunk has been generated */ + so the position of the track length data is kept so that it can + be written after the chunk has been generated */ place_marker = ftell (fp); /* This method turned out not to be portable because the - parameter returned from ftell is not guaranteed to be - in bytes on every machine */ + parameter returned from ftell is not guaranteed to be + in bytes on every machine */ /* track.length = place_marker - offset - (long) sizeof(track); */ #ifdef DEBUG diff --git a/test/midifile.h b/test/midifile.h index 5d408421..93312f9a 100644 --- a/test/midifile.h +++ b/test/midifile.h @@ -66,7 +66,7 @@ extern void mferror(char *s); /* 7 bit controllers */ #define damper_pedal 0x40 -#define portamento 0x41 +#define portamento 0x41 #define sustenuto 0x42 #define soft_pedal 0x43 #define general_4 0x44 @@ -119,7 +119,7 @@ extern void mferror(char *s); #define Lexicon (0x06) /* Lexicon */ #define Tempi (0x20) /* Bon Tempi */ #define Siel (0x21) /* S.I.E.L. */ -#define Kawai (0x41) +#define Kawai (0x41) #define Roland (0x42) #define Korg (0x42) #define Yamaha (0x43) diff --git a/test/midiloop.c b/test/midiloop.c index d6548b59..df5a27bb 100644 --- a/test/midiloop.c +++ b/test/midiloop.c @@ -74,7 +74,7 @@ int main(int argc, char** argv) struct timeval start, end; long long diff; snd_rawmidi_status_t *istat, *ostat; - + for (i = 1 ; i 0) { - atomic_add(sum, *src); - src += src_step; - sum += sum_step; - } + while (size-- > 0) { + atomic_add(sum, *src); + src += src_step; + sum += sum_step; + } } void saturate(unsigned int size, - s16 *dst, const s32 *sum, - unsigned int dst_step, unsigned int sum_step) + s16 *dst, const s32 *sum, + unsigned int dst_step, unsigned int sum_step) { dst_step /= sizeof(*dst); sum_step /= sizeof(*sum); - while (size-- > 0) { - s32 sample = *sum; - if (unlikely(sample < -0x8000)) - *dst = -0x8000; - else if (unlikely(sample > 0x7fff)) - *dst = 0x7fff; - else - *dst = sample; - dst += dst_step; - sum += sum_step; - } + while (size-- > 0) { + s32 sample = *sum; + if (unlikely(sample < -0x8000)) + *dst = -0x8000; + else if (unlikely(sample > 0x7fff)) + *dst = 0x7fff; + else + *dst = sample; + dst += dst_step; + sum += sum_step; + } } void mix_areas0(unsigned int size, @@ -206,7 +206,7 @@ void init(s16 *dst, s32 *sum, int size) { int count; char *a; - + for (count = size - 1; count >= 0; count--) *sum++ = 0; for (count = size - 1; count >= 0; count--) @@ -226,16 +226,16 @@ int main(int argc, char **argv) int LOOP = 100; int i, t; unsigned long long begin, end, diff, diffS, diff0, diff1, diff1_mmx, diff2; - double cpu_clock = detect_cpu_clock(); + double cpu_clock = detect_cpu_clock(); s16 *dst = malloc(sizeof(*dst) * size); s32 *sum = calloc(size, sizeof(*sum)); s16 **srcs = malloc(sizeof(*srcs) * n); setscheduler(); #ifndef CONFIG_SMP - printf("CPU clock: %fMhz (UP)\n\n", cpu_clock / 10e5); + printf("CPU clock: %fMhz (UP)\n\n", cpu_clock / 10e5); #else - printf("CPU clock: %fMhz (SMP)\n\n", cpu_clock / 10e5); + printf("CPU clock: %fMhz (SMP)\n\n", cpu_clock / 10e5); #endif if (argc > 3) { size = atoi(argv[1]); diff --git a/test/omixer.c b/test/omixer.c index 119fa331..44000ef7 100644 --- a/test/omixer.c +++ b/test/omixer.c @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) return 0; } - if (strcmp(pname, "-")) { + if (strcmp(pname, "-")) { err = snd_pcm_open(&phandle, pname, SND_PCM_STREAM_PLAYBACK, 0); if (err < 0) { fprintf(stderr, "Playback PCM open error: %s\n", snd_strerror(err)); diff --git a/test/pcm.c b/test/pcm.c index 223edafc..6e8ae9e4 100644 --- a/test/pcm.c +++ b/test/pcm.c @@ -33,7 +33,7 @@ static snd_pcm_sframes_t buffer_size; static snd_pcm_sframes_t period_size; static snd_output_t *output = NULL; -static void generate_sine(const snd_pcm_channel_area_t *areas, +static void generate_sine(const snd_pcm_channel_area_t *areas, snd_pcm_uframes_t offset, int count, double *_phase) { @@ -224,7 +224,7 @@ static int set_swparams(snd_pcm_t *handle, snd_pcm_sw_params_t *swparams) /* * Underrun and suspend recovery */ - + static int xrun_recovery(snd_pcm_t *handle, int err) { if (verbose) @@ -279,7 +279,7 @@ static int write_loop(snd_pcm_t *handle, } } } - + /* * Transfer method - write and wait for room in buffer using poll */ @@ -401,7 +401,7 @@ static void async_callback(snd_async_handler_t *ahandler) snd_pcm_channel_area_t *areas = data->areas; snd_pcm_sframes_t avail; int err; - + avail = snd_pcm_avail_update(handle); while (avail >= period_size) { generate_sine(areas, 0, period_size, &data->phase); @@ -474,7 +474,7 @@ static void async_direct_callback(snd_async_handler_t *ahandler) snd_pcm_sframes_t avail, commitres; snd_pcm_state_t state; int first = 0, err; - + while (1) { state = snd_pcm_state(handle); if (state == SND_PCM_STATE_XRUN) { @@ -678,7 +678,7 @@ static int direct_loop(snd_pcm_t *handle, } } } - + /* * Transfer method - direct write only using mmap_write functions */ @@ -711,7 +711,7 @@ static int direct_write_loop(snd_pcm_t *handle, } } } - + /* * */ @@ -753,16 +753,16 @@ static void help(void) "-n,--noresample do not resample\n" "-e,--pevent enable poll event after each period\n" "\n"); - printf("Recognized sample formats are:"); - for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) { - const char *s = snd_pcm_format_name(k); - if (s) - printf(" %s", s); - } - printf("\n"); - printf("Recognized transfer methods are:"); - for (k = 0; transfer_methods[k].name; k++) - printf(" %s", transfer_methods[k].name); + printf("Recognized sample formats are:"); + for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) { + const char *s = snd_pcm_format_name(k); + if (s) + printf(" %s", s); + } + printf("\n"); + printf("Recognized transfer methods are:"); + for (k = 0; transfer_methods[k].name; k++) + printf(" %s", transfer_methods[k].name); printf("\n"); } @@ -889,7 +889,7 @@ int main(int argc, char *argv[]) printf("Playback open error: %s\n", snd_strerror(err)); return 0; } - + if ((err = set_hwparams(handle, hwparams, transfer_methods[method].access)) < 0) { printf("Setting of hwparams failed: %s\n", snd_strerror(err)); exit(EXIT_FAILURE); @@ -907,7 +907,7 @@ int main(int argc, char *argv[]) printf("No enough memory\n"); exit(EXIT_FAILURE); } - + areas = calloc(channels, sizeof(snd_pcm_channel_area_t)); if (areas == NULL) { printf("No enough memory\n"); diff --git a/test/pcm_min.c b/test/pcm_min.c index 4c120b4c..89c459e6 100644 --- a/test/pcm_min.c +++ b/test/pcm_min.c @@ -32,7 +32,7 @@ int main(void) exit(EXIT_FAILURE); } - for (i = 0; i < 16; i++) { + for (i = 0; i < 16; i++) { frames = snd_pcm_writei(handle, buffer, sizeof(buffer)); if (frames < 0) frames = snd_pcm_recover(handle, frames, 0); diff --git a/test/playmidi1.c b/test/playmidi1.c index 6ca0e397..27086911 100644 --- a/test/playmidi1.c +++ b/test/playmidi1.c @@ -1,5 +1,5 @@ /* - * MIDI file player for ALSA sequencer + * MIDI file player for ALSA sequencer * (type 0 only!, the library that is used doesn't support merging of tracks) * * Copyright (c) 1998 by Frank van de Pol @@ -166,15 +166,15 @@ static void do_header(int format, int ntracks, int division) snd_seq_queue_tempo_alloca(&tempo); /* ppq must be set before starting the timer */ if (snd_seq_get_queue_tempo(seq_handle, dest_queue, tempo) < 0) { - perror("get_queue_tempo"); - exit(1); + perror("get_queue_tempo"); + exit(1); } if ((slave_ppq = snd_seq_queue_tempo_get_ppq(tempo)) != ppq) { snd_seq_queue_tempo_set_ppq(tempo, ppq); if (snd_seq_set_queue_tempo(seq_handle, dest_queue, tempo) < 0) { - perror("set_queue_tempo"); - if (!slave && !shared_queue) - exit(1); + perror("set_queue_tempo"); + if (!slave && !shared_queue) + exit(1); else printf("different PPQ %d in SMF from queue PPQ %d\n", ppq, slave_ppq); } else @@ -186,10 +186,10 @@ static void do_header(int format, int ntracks, int division) /* start playing... */ if (slave) { if (verbose >= VERB_INFO) - printf("Wait till timer starts...\n"); + printf("Wait till timer starts...\n"); wait_start(); if (verbose >= VERB_INFO) - printf("Go!\n"); + printf("Go!\n"); } else if (shared_queue) { snd_seq_queue_status_t *stat; snd_seq_queue_status_alloca(&stat); @@ -369,7 +369,7 @@ static snd_seq_event_t *wait_for_event(void) { int left; snd_seq_event_t *input_event; - + if (use_blocking_mode) { /* read the event - blocked until any event is read */ left = snd_seq_event_input(seq_handle, &input_event); @@ -506,13 +506,13 @@ int main(int argc, char *argv[]) perror("open /dev/snd/seq"); exit(1); } - + tmp = snd_seq_nonblock(seq_handle, !use_blocking_mode); if (tmp < 0) { perror("block_mode"); exit(1); } - + /* set the name */ /* set the event filter to receive only the echo event */ /* if running in slave mode, also listen for a START event */ @@ -529,7 +529,7 @@ int main(int argc, char *argv[]) perror("create port"); exit(1); } - + if (snd_seq_parse_address(seq_handle, &dest_addr, addr) < 0) { perror("invalid destination address"); exit(1); @@ -560,17 +560,17 @@ int main(int argc, char *argv[]) exit(1); } - /* subscribe for the timer START event */ - if (slave) { + /* subscribe for the timer START event */ + if (slave) { tmp = snd_seq_connect_from(seq_handle, my_port, SND_SEQ_CLIENT_SYSTEM, dest_queue + 16 /*snd_seq_queue_sync_port(dest_queue)*/); if (tmp < 0) { perror("subscribe"); exit(1); - } + } } - + /* change the pool size */ if (snd_seq_set_client_pool_output(seq_handle, WRITE_POOL_SIZE) < 0 || snd_seq_set_client_pool_input(seq_handle, READ_POOL_SIZE) < 0 || @@ -578,7 +578,7 @@ int main(int argc, char *argv[]) perror("pool"); exit(1); } - + if (optind < argc) { F = fopen(argv[optind], "r"); if (F == NULL) { diff --git a/test/queue_timer.c b/test/queue_timer.c index 4e1fa967..ae157fdf 100644 --- a/test/queue_timer.c +++ b/test/queue_timer.c @@ -11,7 +11,7 @@ void normalize(struct timeval *tv) } else if (tv->tv_sec < 0) { while (tv->tv_usec <= -1000000) { tv->tv_usec += 1000000; --tv->tv_sec; } while (tv->tv_usec > 0) { tv->tv_usec -= 1000000; ++tv->tv_sec; } - } else { + } else { while (tv->tv_usec >= 1000000) { tv->tv_usec -= 1000000; ++tv->tv_sec; } while (tv->tv_usec < 0) { tv->tv_usec += 1000000; --tv->tv_sec; } } diff --git a/test/rawmidi.c b/test/rawmidi.c index 666acf63..f3f36875 100644 --- a/test/rawmidi.c +++ b/test/rawmidi.c @@ -42,12 +42,12 @@ int main(int argc,char** argv) int fd_in = -1,fd_out = -1; snd_rawmidi_t *handle_in = 0,*handle_out = 0; - + if (argc==1) { usage(); exit(0); } - + for (i = 1 ; idata.note.note, ev->data.note.velocity); break; - + case SND_SEQ_EVENT_CONTROLLER: printf("; ch=%d, param=%i, value=%i\n", ev->data.control.channel, @@ -162,32 +162,32 @@ int decode_event(snd_seq_event_t * ev) ev->data.control.channel, ev->data.control.value); break; - + case SND_SEQ_EVENT_CHANPRESS: case SND_SEQ_EVENT_PITCHBEND: printf("; ch=%d, value=%i\n", ev->data.control.channel, ev->data.control.value); break; - + case SND_SEQ_EVENT_SYSEX: { unsigned char *sysex = (unsigned char *) ev + sizeof(snd_seq_event_t); unsigned int c; - + printf("; len=%d [", ev->data.ext.len); - + for (c = 0; c < ev->data.ext.len; c++) { printf("%02x%s", sysex[c], c < ev->data.ext.len - 1 ? ":" : ""); } printf("]\n"); } break; - + case SND_SEQ_EVENT_QFRAME: printf("; frame=0x%02x\n", ev->data.control.value); break; - + case SND_SEQ_EVENT_CLOCK: case SND_SEQ_EVENT_START: case SND_SEQ_EVENT_CONTINUE: @@ -202,14 +202,14 @@ int decode_event(snd_seq_event_t * ev) case SND_SEQ_EVENT_ECHO: { int i; - + printf("; "); for (i = 0; i < 8; i++) { printf("%02i%s", ev->data.raw8.d[i], i < 7 ? ":" : "\n"); } } break; - + case SND_SEQ_EVENT_CLIENT_START: case SND_SEQ_EVENT_CLIENT_EXIT: case SND_SEQ_EVENT_CLIENT_CHANGE: @@ -340,7 +340,7 @@ void event_decoder(snd_seq_t *handle, int argc, char *argv[]) return; } } - + max = snd_seq_poll_descriptors_count(handle, POLLIN); pfds = alloca(sizeof(*pfds) * max); while (1) { diff --git a/test/seq-sender.c b/test/seq-sender.c index 5d8ac92c..7d11e536 100644 --- a/test/seq-sender.c +++ b/test/seq-sender.c @@ -71,7 +71,7 @@ void event_sender_start_timer(snd_seq_t *handle, snd_pcm_t *phandle ATTRIBUTE_UNUSED) { int err; - + #ifdef USE_PCM if (phandle) { snd_pcm_playback_info_t pinfo; @@ -90,7 +90,7 @@ void event_sender_start_timer(snd_seq_t *handle, fprintf(stderr, "Sequencer PCM timer setup failed: %s\n", snd_strerror(err)); exit(0); } - } + } #endif if ((err = snd_seq_start_queue(handle, queue, NULL))<0) fprintf(stderr, "Timer event output error: %s\n", snd_strerror(err)); @@ -108,11 +108,11 @@ void event_sender_filter(snd_seq_t *handle) } void send_event(snd_seq_t *handle, int queue, int client, int port, - snd_seq_addr_t *dest, int *time) + snd_seq_addr_t *dest, int *time) { int err; snd_seq_event_t ev; - + bzero(&ev, sizeof(ev)); ev.queue = queue; ev.source.client = ev.dest.client = client; @@ -222,7 +222,7 @@ void event_sender(snd_seq_t *handle, int argc, char *argv[]) } #endif event_sender_start_timer(handle, client, queue, phandle); - + /* send the first event */ send_event(handle, queue, client, port, &addr, &time); #ifdef USE_PCM diff --git a/test/seq.c b/test/seq.c index 04f7e5d4..a92a34ba 100644 --- a/test/seq.c +++ b/test/seq.c @@ -28,7 +28,7 @@ void set_name(snd_seq_t *handle) { int err; char name[64]; - + sprintf(name, "SeqUtil - %i", getpid()); if ((err = snd_seq_set_client_name(handle, name)) < 0) { fprintf(stderr, "Set client info error: %s\n", snd_strerror(err)); @@ -40,7 +40,7 @@ void system_info(snd_seq_t *handle) { int err; snd_seq_system_info_t *sysinfo; - + snd_seq_system_info_alloca(&sysinfo); if ((err = snd_seq_system_info(handle, sysinfo))<0) { fprintf(stderr, "System info error: %s\n", snd_strerror(err)); @@ -75,7 +75,7 @@ void show_queue_status(snd_seq_t *handle, int queue) exit(0); } printf("Queue %i info\n", snd_seq_queue_status_get_queue(status)); - printf(" Tick : %u\n", snd_seq_queue_status_get_tick_time(status)); + printf(" Tick : %u\n", snd_seq_queue_status_get_tick_time(status)); printf(" Realtime : %i.%i\n", snd_seq_queue_status_get_real_time(status)->tv_sec, snd_seq_queue_status_get_real_time(status)->tv_nsec); @@ -162,10 +162,10 @@ int main(int argc, char *argv[]) {"verbose", 0, NULL, HELPID_VERBOSE}, {"version", 0, NULL, HELPID_VERSION}, {NULL, 0, NULL, 0}, - }; - - morehelp = 0; - + }; + + morehelp = 0; + while (1) { int c; @@ -193,10 +193,10 @@ int main(int argc, char *argv[]) morehelp++; } } - if (morehelp) { - help(); - return 1; - } + if (morehelp) { + help(); + return 1; + } if (argc - optind <= 0) { fprintf(stderr, "seq: Specify command...\n"); return 0; @@ -208,7 +208,7 @@ int main(int argc, char *argv[]) set_name(handle); system_info(handle); - if (!strcmp(argv[optind], "system")) { + if (!strcmp(argv[optind], "system")) { show_system_info(handle); } else if (!strcmp(argv[optind], "queue")) { arg = argc - optind > 1 ? atoi(argv[optind + 1]) : -1; diff --git a/test/timer.c b/test/timer.c index 63ea4a54..d99ba7d2 100644 --- a/test/timer.c +++ b/test/timer.c @@ -9,7 +9,7 @@ void show_status(void *handle) { int err; snd_timer_status_t *status; - + snd_timer_status_alloca(&status); if ((err = snd_timer_status(handle, status)) < 0) { fprintf(stderr, "timer status %i (%s)\n", err, snd_strerror(err)); @@ -27,7 +27,7 @@ void read_loop(void *handle, int master_ticks, int timeout) int count, err; struct pollfd *fds; snd_timer_read_t tr; - + count = snd_timer_poll_descriptors_count(handle); fds = calloc(count, sizeof(struct pollfd)); if (fds == NULL) { @@ -60,7 +60,7 @@ static void async_callback(snd_async_handler_t *ahandler) snd_timer_t *handle = snd_async_handler_get_timer(ahandler); int *acount = snd_async_handler_get_callback_private(ahandler); snd_timer_read_t tr; - + while (snd_timer_read(handle, &tr, sizeof(tr)) == sizeof(tr)) { printf("TIMER: resolution = %uns, ticks = %u\n", tr.resolution, tr.ticks); diff --git a/test/user-ctl-element-set.c b/test/user-ctl-element-set.c index ceccdba7..13232bfb 100644 --- a/test/user-ctl-element-set.c +++ b/test/user-ctl-element-set.c @@ -270,7 +270,7 @@ static int add_iec958_elem_set(struct elem_set_trial *trial, err = snd_ctl_elem_add_iec958(trial->handle, trial->id); if (err < 0) - return err; + return err; /* * In historical reason, the above API is not allowed to fill all of From 11235095bfbdc920b29e33cb755b2134cfc93043 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 15:37:11 +0100 Subject: [PATCH 19/34] ucm: add a basic set of trace/debug log calls Signed-off-by: Jaroslav Kysela --- src/ucm/main.c | 65 ++++++++++++++++++++++++++++++++++++--------- src/ucm/ucm_exec.c | 10 ++++--- src/ucm/ucm_local.h | 5 ++++ src/ucm/utils.c | 4 +++ 4 files changed, 69 insertions(+), 15 deletions(-) diff --git a/src/ucm/main.c b/src/ucm/main.c index d9e031d3..e5195f1b 100644 --- a/src/ucm/main.c +++ b/src/ucm/main.c @@ -165,8 +165,8 @@ static int read_tlv_file(unsigned int **res, const char *filepath) { int err = 0; - int fd; - struct stat64 st; + int fd = -1; + struct stat64 st = { 0 }; size_t sz; ssize_t sz_read; struct snd_ctl_tlv *tlv; @@ -174,7 +174,7 @@ static int read_tlv_file(unsigned int **res, fd = open(filepath, O_RDONLY); if (fd < 0) { err = -errno; - return err; + goto __fail; } if (fstat64(fd, &st) == -1) { err = -errno; @@ -208,7 +208,9 @@ static int read_tlv_file(unsigned int **res, } __fail: - close(fd); + if (fd >= 0) + close(fd); + snd_trace(UCM, "read TLV from '%s' (size %llu)", filepath, (long long int)st.st_size); return err; } @@ -217,8 +219,8 @@ static int binary_file_parse(snd_ctl_elem_value_t *dst, const char *filepath) { int err = 0; - int fd; - struct stat64 st; + int fd = -1; + struct stat64 st = { 0 }; size_t sz; ssize_t sz_read; char *res; @@ -229,12 +231,12 @@ static int binary_file_parse(snd_ctl_elem_value_t *dst, if (type != SND_CTL_ELEM_TYPE_BYTES) { uc_error("only support byte type!"); err = -EINVAL; - return err; + goto __fail; } fd = open(filepath, O_RDONLY); if (fd < 0) { err = -errno; - return err; + goto __fail; } if (stat64(filepath, &st) == -1) { err = -errno; @@ -262,7 +264,9 @@ static int binary_file_parse(snd_ctl_elem_value_t *dst, __fail_read: free(res); __fail: - close(fd); + if (fd >= 0) + close(fd); + snd_trace(UCM, "read binary data from '%s' (size %llu)", filepath, (long long int)st.st_size); return err; } @@ -408,6 +412,8 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type) snd_ctl_elem_info_t *info, *info2 = NULL; unsigned int *res = NULL; + snd_trace(UCM, "execute cset [%d] '%s'", type, cset); + snd_ctl_elem_id_malloc(&id); snd_ctl_elem_value_malloc(&value); snd_ctl_elem_info_malloc(&info); @@ -526,6 +532,8 @@ static int execute_sysw(const char *sysw) int fd, myerrno; bool ignore_error = false; + snd_trace(UCM, "execute sysw '%s'", sysw); + if (sysw == NULL || *sysw == '\0') return 0; @@ -597,6 +605,8 @@ static int execute_cfgsave(snd_use_case_mgr_t *uc_mgr, const char *filename) bool with_root = false; int err = 0; + snd_trace(UCM, "execute cfgsave to '%s'", filename); + file = strdup(filename); if (!file) return -ENOMEM; @@ -678,6 +688,8 @@ static int run_device_sequence(snd_use_case_mgr_t *uc_mgr, struct use_case_verb { struct use_case_device *device; + snd_trace(UCM, "device sequence '%s/%s': %s", verb->name, name, uc_mgr_enable_str(enable)); + if (verb == NULL) { uc_error("error: enadev2 / disdev2 must be executed inside the verb context"); return -ENOENT; @@ -702,6 +714,8 @@ static int run_device_all_sequence(snd_use_case_mgr_t *uc_mgr, struct use_case_v struct list_head *pos; int err; + snd_trace(UCM, "disable all devices sequence for '%s'", verb->name); + if (verb == NULL) { uc_error("error: disdevall must be executed inside the verb context"); return -ENOENT; @@ -835,6 +849,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr, goto __fail; break; case SEQUENCE_ELEMENT_TYPE_SLEEP: + snd_trace(UCM, "sleeping %li", s->data.sleep); usleep(s->data.sleep); break; case SEQUENCE_ELEMENT_TYPE_EXEC: @@ -852,6 +867,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr, break; ignore_error = s->data.exec[0] == '-'; shell_retry: + snd_debug(UCM, "system command '%s'", s->data.exec + (ignore_error ? 1 : 0)); err = system(s->data.exec + (ignore_error ? 1 : 0)); if (WIFSIGNALED(err)) { err = -EINTR; @@ -935,6 +951,9 @@ static int execute_component_seq(snd_use_case_mgr_t *uc_mgr, struct list_head *seq; int err; + snd_trace(UCM, "execute component sequence '%s': %s", cmpt_seq->device ? + cmpt_seq->device->name : NULL, uc_mgr_enable_str(cmpt_seq->enable)); + /* enter component domain and store cdev for the component */ uc_mgr->in_component_domain = 1; uc_mgr->cdev = cdev; @@ -1511,6 +1530,8 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr, snd_use_case_mgr_t *mgr; int err; + snd_trace(UCM, "{API call} open '%s'", card_name); + /* create a new UCM */ mgr = calloc(1, sizeof(snd_use_case_mgr_t)); if (mgr == NULL) @@ -1563,11 +1584,13 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr, } *uc_mgr = mgr; + snd_trace(UCM, "{API call} open '%s' succeed", card_name); return 0; _err: uc_mgr_card_close(mgr); uc_mgr_free(mgr); + snd_trace(UCM, "{API call} open '%s' failed: %s", card_name, snd_strerror(err)); return err; } @@ -1575,6 +1598,8 @@ int snd_use_case_mgr_reload(snd_use_case_mgr_t *uc_mgr) { int err; + snd_trace(UCM, "{API call} reload"); + pthread_mutex_lock(&uc_mgr->mutex); do_reset(uc_mgr); @@ -2079,10 +2104,12 @@ int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr, const char **list[]) { char *str, *str1; - int err; + int err, i; - if (uc_mgr == NULL || identifier == NULL) - return uc_mgr_scan_master_configs(list); + if (uc_mgr == NULL || identifier == NULL) { + err = uc_mgr_scan_master_configs(list); + goto __end_unlocked; + } pthread_mutex_lock(&uc_mgr->mutex); if (strcmp(identifier, "_verbs") == 0) err = get_verb_list(uc_mgr, list); @@ -2120,6 +2147,10 @@ int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr, } __end: pthread_mutex_unlock(&uc_mgr->mutex); + __end_unlocked: + snd_trace(UCM, "{API call} get list '%s': %d (%s)", identifier, err, snd_strerror(err)); + for (i = 0; i < err; i++) + snd_trace(UCM, " [%d]='%s'", i, (*list)[i]); return err; } @@ -2374,6 +2405,7 @@ int snd_use_case_get(snd_use_case_mgr_t *uc_mgr, } __end: pthread_mutex_unlock(&uc_mgr->mutex); + snd_trace(UCM, "{API call} get string '%s'='%s' (error %s)", identifier, err >= 0 ? *value : NULL, snd_strerror(err)); return err; } @@ -2436,6 +2468,7 @@ int snd_use_case_geti(snd_use_case_mgr_t *uc_mgr, } __end: pthread_mutex_unlock(&uc_mgr->mutex); + snd_trace(UCM, "{API call} get integer '%s'=%li (error %s)", identifier, err >= 0 ? *value : -1, snd_strerror(err)); return err; } @@ -2518,6 +2551,8 @@ static int set_verb_user(snd_use_case_mgr_t *uc_mgr, struct use_case_verb *verb; int err = 0; + snd_trace(UCM, "{API call} set verb '%s'", verb_name); + if (uc_mgr->active_verb && strcmp(uc_mgr->active_verb->name, verb_name) == 0) return 0; @@ -2557,6 +2592,7 @@ static int set_device_user(snd_use_case_mgr_t *uc_mgr, { struct use_case_device *device; + snd_trace(UCM, "{API call} set device '%s'", device_name); if (uc_mgr->active_verb == NULL) return -ENOENT; device = find_device(uc_mgr, uc_mgr->active_verb, device_name, 1); @@ -2571,6 +2607,8 @@ static int set_modifier_user(snd_use_case_mgr_t *uc_mgr, { struct use_case_modifier *modifier; + snd_trace(UCM, "{API call} set modifier '%s': %s", modifier_name, uc_mgr_enable_str(enable)); + if (uc_mgr->active_verb == NULL) return -ENOENT; @@ -2589,6 +2627,7 @@ static int switch_device(snd_use_case_mgr_t *uc_mgr, struct list_head *pos; int err, seq_found = 0; + snd_trace(UCM, "{API call} switch device '%s'->'%s'", old_device, new_device); if (uc_mgr->active_verb == NULL) return -ENOENT; if (device_status(uc_mgr, old_device) == 0) { @@ -2644,6 +2683,7 @@ static int switch_modifier(snd_use_case_mgr_t *uc_mgr, struct list_head *pos; int err, seq_found = 0; + snd_trace(UCM, "{API call} switch modifier '%s'->'%s'", old_modifier, new_modifier); if (uc_mgr->active_verb == NULL) return -ENOENT; if (modifier_status(uc_mgr, old_modifier) == 0) { @@ -2695,6 +2735,7 @@ int snd_use_case_set(snd_use_case_mgr_t *uc_mgr, char *str, *str1; int err = 0; + snd_trace(UCM, "{API call} set '%s'='%s'", identifier, value); pthread_mutex_lock(&uc_mgr->mutex); if (strcmp(identifier, "_fboot") == 0) err = set_fixedboot_user(uc_mgr, value); diff --git a/src/ucm/ucm_exec.c b/src/ucm/ucm_exec.c index b79a84ae..1007ae20 100644 --- a/src/ucm/ucm_exec.c +++ b/src/ucm/ucm_exec.c @@ -191,8 +191,12 @@ int uc_mgr_exec(const char *prog) sigset_t omask; char **argv; - if (parse_args(&argv, 32, prog)) + snd_debug(UCM, "executing '%s'\n", prog); + + if (parse_args(&argv, 32, prog)) { + snd_info(UCM, "unable to parse exec arguments for '%s'", prog); return -EINVAL; + } prog = argv[0]; if (prog == NULL) { @@ -201,6 +205,7 @@ int uc_mgr_exec(const char *prog) } if (prog[0] != '/' && prog[0] != '.') { if (!find_exec(argv[0], bin, sizeof(bin))) { + snd_warn(UCM, "unable to find executable '%s'", argv[0]); err = -ENOEXEC; goto __error; } @@ -231,8 +236,7 @@ int uc_mgr_exec(const char *prog) if (p == -1) { err = -errno; pthread_mutex_unlock(&fork_lock); - uc_error("Unable to fork() for \"%s\" -- %s", prog, - strerror(errno)); + uc_error("Unable to fork() for \"%s\" -- %s", prog, strerror(errno)); goto __error; } diff --git a/src/ucm/ucm_local.h b/src/ucm/ucm_local.h index 47cfa0d5..f1e7e3c3 100644 --- a/src/ucm/ucm_local.h +++ b/src/ucm/ucm_local.h @@ -321,6 +321,11 @@ static inline int uc_mgr_has_local_config(snd_use_case_mgr_t *uc_mgr) snd_config_iterator_end(uc_mgr->local_config); } +static inline const char *uc_mgr_enable_str(bool enable) +{ + return enable ? "enable" : "disable"; +} + int uc_mgr_card_open(snd_use_case_mgr_t *uc_mgr); void uc_mgr_card_close(snd_use_case_mgr_t *uc_mgr); diff --git a/src/ucm/utils.c b/src/ucm/utils.c index fc5fb1f4..b37480f3 100644 --- a/src/ucm/utils.c +++ b/src/ucm/utils.c @@ -683,6 +683,8 @@ int uc_mgr_set_variable(snd_use_case_mgr_t *uc_mgr, const char *name, struct ucm_value *curr; char *val2; + snd_trace(UCM, "set variable '%s'='%s'", name, val); + list_for_each(pos, &uc_mgr->variable_list) { curr = list_entry(pos, struct ucm_value, list); if (strcmp(curr->name, name) == 0) { @@ -718,6 +720,8 @@ int uc_mgr_delete_variable(snd_use_case_mgr_t *uc_mgr, const char *name) struct list_head *pos; struct ucm_value *curr; + snd_trace(UCM, "delete variable '%s'", name); + list_for_each(pos, &uc_mgr->variable_list) { curr = list_entry(pos, struct ucm_value, list); if (strcmp(curr->name, name) == 0) { From 9ab488b86c9ef12b7f59eb55436c43e5b91459ff Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 15:46:16 +0100 Subject: [PATCH 20/34] ucm: replace uc_error with snd_error calls Signed-off-by: Jaroslav Kysela --- src/ucm/main.c | 107 ++++++++------- src/ucm/parser.c | 306 ++++++++++++++++++++++-------------------- src/ucm/ucm_cond.c | 66 ++++----- src/ucm/ucm_exec.c | 7 +- src/ucm/ucm_include.c | 20 +-- src/ucm/ucm_local.h | 2 - src/ucm/ucm_regex.c | 14 +- src/ucm/ucm_subs.c | 83 ++++++------ src/ucm/utils.c | 10 +- 9 files changed, 319 insertions(+), 296 deletions(-) diff --git a/src/ucm/main.c b/src/ucm/main.c index e5195f1b..d054b564 100644 --- a/src/ucm/main.c +++ b/src/ucm/main.c @@ -182,8 +182,9 @@ static int read_tlv_file(unsigned int **res, } sz = st.st_size; if (sz > 16 * 1024 * 1024 || sz < 8 || sz % 4) { - uc_error("File size should be less than 16 MB " - "and multiple of 4"); + snd_error(UCM, "File size should be less than 16 MB " + "and multiple of 4"); + err = -EINVAL; goto __fail; } @@ -201,7 +202,7 @@ static int read_tlv_file(unsigned int **res, /* Check if the tlv file specifies valid size. */ tlv = (struct snd_ctl_tlv *)(*res); if (tlv->length + 2 * sizeof(unsigned int) != sz) { - uc_error("Invalid tlv size: %d", tlv->length); + snd_error(UCM, "Invalid tlv size: %d", tlv->length); err = -EINVAL; free(*res); *res = NULL; @@ -229,7 +230,7 @@ static int binary_file_parse(snd_ctl_elem_value_t *dst, type = snd_ctl_elem_info_get_type(info); if (type != SND_CTL_ELEM_TYPE_BYTES) { - uc_error("only support byte type!"); + snd_error(UCM, "only support byte type!"); err = -EINVAL; goto __fail; } @@ -245,7 +246,7 @@ static int binary_file_parse(snd_ctl_elem_value_t *dst, sz = st.st_size; count = snd_ctl_elem_info_get_count(info); if (sz != count || sz > sizeof(dst->value.bytes)) { - uc_error("invalid parameter size %d!", sz); + snd_error(UCM, "invalid parameter size %d!", sz); err = -EINVAL; goto __fail; } @@ -308,11 +309,11 @@ static const char *parse_uint(const char *p, const char *prefix, size_t len, p += len; v = strtol(p, &end, 0); if (*end != '\0' && *end != ' ' && *end != ',') { - uc_error("unable to parse '%s'", prefix); + snd_error(UCM, "unable to parse '%s'", prefix); return NULL; } if ((unsigned int)v < min || (unsigned int)v > max) { - uc_error("value '%s' out of range %u-%u %(%ld)", min, max, v); + snd_error(UCM, "value '%s' out of range %u-%u %(%ld)", min, max, v); return NULL; } *rval = v; @@ -399,7 +400,7 @@ next: *pos = p; return 0; er: - uc_error("unknown syntax '%s'", p); + snd_error(UCM, "unknown syntax '%s'", p); return -EINVAL; } @@ -428,7 +429,7 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type) snd_ctl_elem_info_set_id(info2, id); err = parse_cset_new_info(info2, pos, &pos); if (err < 0 || !*pos) { - uc_error("undefined or wrong id config for cset-new", cset); + snd_error(UCM, "undefined or wrong id config for cset-new", cset); err = -EINVAL; goto __fail; } @@ -437,12 +438,12 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type) } if (!*pos) { if (type != SEQUENCE_ELEMENT_TYPE_CTL_REMOVE) { - uc_error("undefined value for cset >%s<", cset); + snd_error(UCM, "undefined value for cset >%s<", cset); err = -EINVAL; goto __fail; } } else if (type == SEQUENCE_ELEMENT_TYPE_CTL_REMOVE) { - uc_error("extra value for ctl-remove >%s<", cset); + snd_error(UCM, "extra value for ctl-remove >%s<", cset); err = -EINVAL; goto __fail; } @@ -454,7 +455,7 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type) if (err >= 0) { err = snd_ctl_elem_remove(ctl, id); if (err < 0) { - uc_error("unable to remove control"); + snd_error(UCM, "unable to remove control"); err = -EINVAL; goto __fail; } @@ -463,7 +464,7 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type) goto __ok; err = __snd_ctl_add_elem_set(ctl, info2, info2->owner, info2->count); if (err < 0) { - uc_error("unable to create new control"); + snd_error(UCM, "unable to create new control"); goto __fail; } /* new id copy */ @@ -574,7 +575,7 @@ static int execute_sysw(const char *sysw) free(s); if (ignore_error) return 0; - uc_error("unable to open '%s' for write", path); + snd_error(UCM, "unable to open '%s' for write", path); return -EINVAL; } wlen = write(fd, value, len); @@ -585,7 +586,7 @@ static int execute_sysw(const char *sysw) goto __end; if (wlen != (ssize_t)len) { - uc_error("unable to write '%s' to '%s': %s", value, path, strerror(myerrno)); + snd_error(UCM, "unable to write '%s' to '%s': %s", value, path, strerror(myerrno)); free(s); return -EINVAL; } @@ -619,14 +620,14 @@ static int execute_cfgsave(snd_use_case_mgr_t *uc_mgr, const char *filename) } err = snd_config_search(config, root, &config); if (err < 0) { - uc_error("Unable to find subtree '%s'", root); + snd_error(UCM, "Unable to find subtree '%s'", root); goto _err; } } err = snd_output_stdio_open(&out, file, "w+"); if (err < 0) { - uc_error("unable to open file '%s': %s", file, snd_strerror(err)); + snd_error(UCM, "unable to open file '%s': %s", file, snd_strerror(err)); goto _err; } if (!config || snd_config_is_empty(config)) { @@ -641,7 +642,7 @@ static int execute_cfgsave(snd_use_case_mgr_t *uc_mgr, const char *filename) } snd_output_close(out); if (err < 0) { - uc_error("unable to save configuration: %s", snd_strerror(err)); + snd_error(UCM, "unable to save configuration: %s", snd_strerror(err)); goto _err; } _err: @@ -691,13 +692,13 @@ static int run_device_sequence(snd_use_case_mgr_t *uc_mgr, struct use_case_verb snd_trace(UCM, "device sequence '%s/%s': %s", verb->name, name, uc_mgr_enable_str(enable)); if (verb == NULL) { - uc_error("error: enadev2 / disdev2 must be executed inside the verb context"); + snd_error(UCM, "error: enadev2 / disdev2 must be executed inside the verb context"); return -ENOENT; } device = find_device(uc_mgr, verb, name, 0); if (device == NULL) { - uc_error("error: unable to find device '%s'\n", name); + snd_error(UCM, "error: unable to find device '%s'\n", name); return -ENOENT; } @@ -717,7 +718,7 @@ static int run_device_all_sequence(snd_use_case_mgr_t *uc_mgr, struct use_case_v snd_trace(UCM, "disable all devices sequence for '%s'", verb->name); if (verb == NULL) { - uc_error("error: disdevall must be executed inside the verb context"); + snd_error(UCM, "error: disdevall must be executed inside the verb context"); return -ENOENT; } @@ -757,7 +758,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr, int err = 0; if (uc_mgr->sequence_hops > 100) { - uc_error("error: too many inner sequences!"); + snd_error(UCM, "error: too many inner sequences!"); return -EINVAL; } uc_mgr->sequence_hops++; @@ -781,7 +782,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr, * its parent's cdev stored by ucm manager. */ if (uc_mgr->cdev == NULL) { - uc_error("cdev is not defined!"); + snd_error(UCM, "cdev is not defined!"); return err; } @@ -797,7 +798,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr, value_list2, value_list3); if (err < 0 && err != -ENOENT) { - uc_error("cdev is not defined!"); + snd_error(UCM, "cdev is not defined!"); return err; } err = get_value3(uc_mgr, &capture_ctl, "CaptureCTL", @@ -806,12 +807,12 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr, value_list3); if (err < 0 && err != -ENOENT) { free(playback_ctl); - uc_error("cdev is not defined!"); + snd_error(UCM, "cdev is not defined!"); return err; } if (playback_ctl == NULL && capture_ctl == NULL) { - uc_error("cdev is not defined!"); + snd_error(UCM, "cdev is not defined!"); return -EINVAL; } if (playback_ctl != NULL && @@ -819,7 +820,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr, strcmp(playback_ctl, capture_ctl) != 0) { free(playback_ctl); free(capture_ctl); - uc_error("cdev is not equal for playback and capture!"); + snd_error(UCM, "cdev is not equal for playback and capture!"); return -EINVAL; } if (playback_ctl != NULL) { @@ -832,14 +833,14 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr, if (ctl == NULL) { err = uc_mgr_open_ctl(uc_mgr, &ctl_list, cdev, 1); if (err < 0) { - uc_error("unable to open ctl device '%s'", cdev); + snd_error(UCM, "unable to open ctl device '%s'", cdev); goto __fail; } ctl = ctl_list->ctl; } err = execute_cset(ctl, s->data.cset, s->type); if (err < 0) { - uc_error("unable to execute cset '%s'", s->data.cset); + snd_error(UCM, "unable to execute cset '%s'", s->data.cset); goto __fail; } break; @@ -858,7 +859,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr, ignore_error = s->data.exec[0] == '-'; err = uc_mgr_exec(s->data.exec + (ignore_error ? 1 : 0)); if (ignore_error == false && err != 0) { - uc_error("exec '%s' failed (exit code %d)", s->data.exec, err); + snd_error(UCM, "exec '%s' failed (exit code %d)", s->data.exec, err); goto __fail; } break; @@ -873,7 +874,7 @@ shell_retry: err = -EINTR; } if (WIFEXITED(err)) { if (ignore_error == false && WEXITSTATUS(err) != 0) { - uc_error("command '%s' failed (exit code %d)", s->data.exec, WEXITSTATUS(err)); + snd_error(UCM, "command '%s' failed (exit code %d)", s->data.exec, WEXITSTATUS(err)); err = -EINVAL; goto __fail; } @@ -915,7 +916,7 @@ shell_retry: goto __fail; break; default: - uc_error("unknown sequence command %i", s->type); + snd_error(UCM, "unknown sequence command %i", s->type); break; } } @@ -1031,7 +1032,7 @@ static int set_defaults(snd_use_case_mgr_t *uc_mgr, bool force) err = execute_sequence(uc_mgr, NULL, &uc_mgr->default_list, &uc_mgr->value_list, NULL, NULL); if (err < 0) { - uc_error("Unable to execute default sequence"); + snd_error(UCM, "Unable to execute default sequence"); return err; } uc_mgr->default_list_executed = 1; @@ -1499,7 +1500,7 @@ const char *parse_open_variables(snd_use_case_mgr_t *uc_mgr, const char *name) err = snd_config_load_string(&cfg, args, 0); if (err < 0) { - uc_error("error: open arguments are not valid (%s)", args); + snd_error(UCM, "error: open arguments are not valid (%s)", args); goto skip; } @@ -1572,14 +1573,15 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr, if (err < 0) { if (err == -ENXIO && mgr->suppress_nodev_errors) goto _err; - uc_error("error: failed to import %s use case configuration %d", - card_name, err); + snd_error(UCM, "error: failed to import %s use case configuration %d", + card_name, err); + goto _err; } err = check_empty_configuration(mgr); if (err < 0) { - uc_error("error: failed to import %s (empty configuration)", card_name); + snd_error(UCM, "error: failed to import %s (empty configuration)", card_name); goto _err; } @@ -1611,7 +1613,7 @@ int snd_use_case_mgr_reload(snd_use_case_mgr_t *uc_mgr) /* reload all use cases */ err = import_master_config(uc_mgr); if (err < 0) { - uc_error("error: failed to reload use cases"); + snd_error(UCM, "error: failed to reload use cases"); pthread_mutex_unlock(&uc_mgr->mutex); return -EINVAL; } @@ -1643,7 +1645,7 @@ static int dismantle_use_case(snd_use_case_mgr_t *uc_mgr) active_list); err = set_modifier(uc_mgr, modifier, 0); if (err < 0) - uc_error("Unable to disable modifier %s", modifier->name); + snd_error(UCM, "Unable to disable modifier %s", modifier->name); } INIT_LIST_HEAD(&uc_mgr->active_modifiers); @@ -1652,13 +1654,13 @@ static int dismantle_use_case(snd_use_case_mgr_t *uc_mgr) active_list); err = set_device(uc_mgr, device, 0); if (err < 0) - uc_error("Unable to disable device %s", device->name); + snd_error(UCM, "Unable to disable device %s", device->name); } INIT_LIST_HEAD(&uc_mgr->active_devices); err = set_verb(uc_mgr, uc_mgr->active_verb, 0); if (err < 0) { - uc_error("Unable to disable verb %s", uc_mgr->active_verb->name); + snd_error(UCM, "Unable to disable verb %s", uc_mgr->active_verb->name); return err; } uc_mgr->active_verb = NULL; @@ -2478,7 +2480,7 @@ static int set_fixedboot_user(snd_use_case_mgr_t *uc_mgr, int err; if (value != NULL && *value) { - uc_error("error: wrong value for _fboot (%s)", value); + snd_error(UCM, "error: wrong value for _fboot (%s)", value); return -EINVAL; } if (list_empty(&uc_mgr->fixedboot_list)) @@ -2486,7 +2488,7 @@ static int set_fixedboot_user(snd_use_case_mgr_t *uc_mgr, err = execute_sequence(uc_mgr, NULL, &uc_mgr->fixedboot_list, &uc_mgr->value_list, NULL, NULL); if (err < 0) { - uc_error("Unable to execute force boot sequence"); + snd_error(UCM, "Unable to execute force boot sequence"); return err; } return err; @@ -2498,7 +2500,7 @@ static int set_boot_user(snd_use_case_mgr_t *uc_mgr, int err; if (value != NULL && *value) { - uc_error("error: wrong value for _boot (%s)", value); + snd_error(UCM, "error: wrong value for _boot (%s)", value); return -EINVAL; } if (list_empty(&uc_mgr->boot_list)) @@ -2506,7 +2508,7 @@ static int set_boot_user(snd_use_case_mgr_t *uc_mgr, err = execute_sequence(uc_mgr, NULL, &uc_mgr->boot_list, &uc_mgr->value_list, NULL, NULL); if (err < 0) { - uc_error("Unable to execute boot sequence"); + snd_error(UCM, "Unable to execute boot sequence"); return err; } return err; @@ -2516,7 +2518,7 @@ static int set_defaults_user(snd_use_case_mgr_t *uc_mgr, const char *value) { if (value != NULL && *value) { - uc_error("error: wrong value for _defaults (%s)", value); + snd_error(UCM, "error: wrong value for _defaults (%s)", value); return -EINVAL; } return set_defaults(uc_mgr, false); @@ -2579,8 +2581,9 @@ static int set_verb_user(snd_use_case_mgr_t *uc_mgr, if (verb) { err = set_verb(uc_mgr, verb, 1); if (err < 0) - uc_error("error: failed to initialize new use case: %s", - verb_name); + snd_error(UCM, "error: failed to initialize new use case: %s", + verb_name); + } return err; } @@ -2631,11 +2634,11 @@ static int switch_device(snd_use_case_mgr_t *uc_mgr, if (uc_mgr->active_verb == NULL) return -ENOENT; if (device_status(uc_mgr, old_device) == 0) { - uc_error("error: device %s not enabled", old_device); + snd_error(UCM, "error: device %s not enabled", old_device); return -EINVAL; } if (device_status(uc_mgr, new_device) != 0) { - uc_error("error: device %s already enabled", new_device); + snd_error(UCM, "error: device %s already enabled", new_device); return -EINVAL; } xold = find_device(uc_mgr, uc_mgr->active_verb, old_device, 1); @@ -2687,11 +2690,11 @@ static int switch_modifier(snd_use_case_mgr_t *uc_mgr, if (uc_mgr->active_verb == NULL) return -ENOENT; if (modifier_status(uc_mgr, old_modifier) == 0) { - uc_error("error: modifier %s not enabled", old_modifier); + snd_error(UCM, "error: modifier %s not enabled", old_modifier); return -EINVAL; } if (modifier_status(uc_mgr, new_modifier) != 0) { - uc_error("error: modifier %s already enabled", new_modifier); + snd_error(UCM, "error: modifier %s already enabled", new_modifier); return -EINVAL; } xold = find_modifier(uc_mgr, uc_mgr->active_verb, old_modifier, 1); diff --git a/src/ucm/parser.c b/src/ucm/parser.c index 59d20320..3b90e49b 100644 --- a/src/ucm/parser.c +++ b/src/ucm/parser.c @@ -75,7 +75,7 @@ int uc_mgr_config_load_file(snd_use_case_mgr_t *uc_mgr, file); err = uc_mgr_config_load(uc_mgr->conf_format, filename, cfg); if (err < 0) { - uc_error("error: failed to open file %s: %d", filename, err); + snd_error(UCM, "error: failed to open file %s: %d", filename, err); return err; } return 0; @@ -187,7 +187,7 @@ static int parse_integer_substitute3(snd_use_case_mgr_t *uc_mgr, static int parse_is_name_safe(const char *name) { if (strchr(name, '.')) { - uc_error("char '.' not allowed in '%s'", name); + snd_error(UCM, "char '.' not allowed in '%s'", name); return 0; } return 1; @@ -237,11 +237,11 @@ static int error_node(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) err = parse_string_substitute3(uc_mgr, cfg, &s); if (err < 0) { - uc_error("error: failed to get Error string"); + snd_error(UCM, "error: failed to get Error string"); return err; } if (!uc_mgr->suppress_nodev_errors) - uc_error("%s", s); + snd_error(UCM, "%s", s); free(s); return -ENXIO; } @@ -258,16 +258,16 @@ static int parse_syntax_field(snd_use_case_mgr_t *uc_mgr, err = snd_config_search(cfg, "Syntax", &n); if (err < 0) { - uc_error("Syntax field not found in %s", filename); + snd_error(UCM, "Syntax field not found in %s", filename); return -EINVAL; } err = snd_config_get_integer(n, &l); if (err < 0) { - uc_error("Syntax field is invalid in %s", filename); + snd_error(UCM, "Syntax field is invalid in %s", filename); return err; } if (l < 2 || l > SYNTAX_VERSION_MAX) { - uc_error("Incompatible syntax %ld in %s", l, filename); + snd_error(UCM, "Incompatible syntax %ld in %s", l, filename); return -EINVAL; } /* delete this field to optimize strcmp() call in the parsing loop */ @@ -294,12 +294,12 @@ static int evaluate_regex(snd_use_case_mgr_t *uc_mgr, return err; if (snd_config_get_type(d) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for DefineRegex"); + snd_error(UCM, "compound type expected for DefineRegex"); return -EINVAL; } if (uc_mgr->conf_format < 3) { - uc_error("DefineRegex is supported in v3+ syntax"); + snd_error(UCM, "DefineRegex is supported in v3+ syntax"); return -EINVAL; } @@ -309,7 +309,7 @@ static int evaluate_regex(snd_use_case_mgr_t *uc_mgr, if (err < 0) return err; if (id[0] == '@') { - uc_error("error: value names starting with '@' are reserved for application variables"); + snd_error(UCM, "error: value names starting with '@' are reserved for application variables"); return -EINVAL; } err = uc_mgr_define_regex(uc_mgr, id, n); @@ -340,12 +340,12 @@ static int evaluate_define(snd_use_case_mgr_t *uc_mgr, return err; if (snd_config_get_type(d) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for Define"); + snd_error(UCM, "compound type expected for Define"); return -EINVAL; } if (uc_mgr->conf_format < 3) { - uc_error("Define is supported in v3+ syntax"); + snd_error(UCM, "Define is supported in v3+ syntax"); return -EINVAL; } @@ -363,7 +363,7 @@ static int evaluate_define(snd_use_case_mgr_t *uc_mgr, return err; if (id[0] == '@') { free(s); - uc_error("error: value names starting with '@' are reserved for application variables"); + snd_error(UCM, "error: value names starting with '@' are reserved for application variables"); return -EINVAL; } err = uc_mgr_set_variable(uc_mgr, id, s); @@ -393,12 +393,12 @@ static int evaluate_define_macro(snd_use_case_mgr_t *uc_mgr, return err; if (snd_config_get_type(d) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for DefineMacro"); + snd_error(UCM, "compound type expected for DefineMacro"); return -EINVAL; } if (uc_mgr->conf_format < 6) { - uc_error("DefineMacro is supported in v6+ syntax"); + snd_error(UCM, "DefineMacro is supported in v6+ syntax"); return -EINVAL; } @@ -424,7 +424,7 @@ static int evaluate_macro1(snd_use_case_mgr_t *uc_mgr, return err; err = snd_config_search(uc_mgr->macros, mid, &m); if (err < 0) { - uc_error("Macro '%s' is not defined", mid); + snd_error(UCM, "Macro '%s' is not defined", mid); return err; } @@ -448,7 +448,7 @@ static int evaluate_macro1(snd_use_case_mgr_t *uc_mgr, goto __err_path; snprintf(name, sizeof(name), "__%s", id); if (uc_mgr_get_variable(uc_mgr, name)) { - uc_error("Macro argument '%s' is already defined", name); + snd_error(UCM, "Macro argument '%s' is already defined", name); goto __err_path; } err = snd_config_get_ascii(n, &var); @@ -520,12 +520,12 @@ static int evaluate_macro(snd_use_case_mgr_t *uc_mgr, return err; if (snd_config_get_type(d) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for DefineMacro"); + snd_error(UCM, "compound type expected for DefineMacro"); return -EINVAL; } if (uc_mgr->conf_format < 6) { - uc_error("Macro is supported in v6+ syntax"); + snd_error(UCM, "Macro is supported in v6+ syntax"); return -EINVAL; } @@ -535,7 +535,7 @@ static int evaluate_macro(snd_use_case_mgr_t *uc_mgr, const char *id; if (snd_config_get_id(n, &id)) id = ""; - uc_error("compound type expected for Macro.%s", id); + snd_error(UCM, "compound type expected for Macro.%s", id); return -EINVAL; } snd_config_for_each(i2, next2, n) { @@ -607,7 +607,7 @@ static int evaluate_variant(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) return err; if (uc_mgr->conf_format < 6) { - uc_error("Variant is supported in v6+ syntax"); + snd_error(UCM, "Variant is supported in v6+ syntax"); return -EINVAL; } @@ -653,7 +653,7 @@ int uc_mgr_evaluate_inplace(snd_use_case_mgr_t *uc_mgr, while (err1 == 0 || err2 == 0 || err3 == 0 || err4 == 0 || err5 == 0) { if (iterations == 0) { - uc_error("Maximal inplace evaluation iterations number reached (recursive references?)"); + snd_error(UCM, "Maximal inplace evaluation iterations number reached (recursive references?)"); return -EINVAL; } iterations--; @@ -676,7 +676,7 @@ int uc_mgr_evaluate_inplace(snd_use_case_mgr_t *uc_mgr, continue; uc_mgr->macro_hops++; if (uc_mgr->macro_hops > 100) { - uc_error("Maximal macro hops reached!"); + snd_error(UCM, "Maximal macro hops reached!"); return -EINVAL; } err4 = evaluate_macro(uc_mgr, cfg); @@ -707,7 +707,7 @@ static int parse_libconfig1(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) return -EINVAL; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for %s", id); + snd_error(UCM, "compound type expected for %s", id); return -EINVAL; } @@ -735,7 +735,7 @@ static int parse_libconfig1(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) continue; } - uc_error("unknown field %s", id); + snd_error(UCM, "unknown field %s", id); return -EINVAL; } @@ -795,7 +795,7 @@ static int parse_libconfig(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) return -EINVAL; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for %s", id); + snd_error(UCM, "compound type expected for %s", id); return -EINVAL; } @@ -827,7 +827,7 @@ static int parse_transition(snd_use_case_mgr_t *uc_mgr, return -EINVAL; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for %s", id); + snd_error(UCM, "compound type expected for %s", id); return -EINVAL; } @@ -875,7 +875,7 @@ static int parse_compound(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, return -EINVAL; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for %s", id); + snd_error(UCM, "compound type expected for %s", id); return -EINVAL; } /* parse compound */ @@ -883,7 +883,7 @@ static int parse_compound(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, n = snd_config_iterator_entry(i); if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for %s, is %d", id, snd_config_get_type(cfg)); + snd_error(UCM, "compound type expected for %s, is %d", id, snd_config_get_type(cfg)); return -EINVAL; } @@ -901,8 +901,9 @@ static int strip_legacy_dev_index(char *name) if (!dot) return 0; if (dot[1] != '0' || dot[2] != '\0') { - uc_error("device name %s contains a '.'," - " and is not legacy foo.0 format", name); + snd_error(UCM, "device name %s contains a '.'," + " and is not legacy foo.0 format", name); + return -EINVAL; } *dot = '\0'; @@ -924,8 +925,9 @@ static int parse_device_list(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, int err; if (dev_list->type != DEVLIST_NONE) { - uc_error("error: multiple supported or" - " conflicting device lists"); + snd_error(UCM, "error: multiple supported or" + " conflicting device lists"); + return -EEXIST; } @@ -933,7 +935,7 @@ static int parse_device_list(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, return -EINVAL; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for %s", id); + snd_error(UCM, "compound type expected for %s", id); return -EINVAL; } @@ -1031,7 +1033,7 @@ static int parse_component_seq(snd_use_case_mgr_t *uc_mgr, cmpt_seq->device = find_component_dev(uc_mgr, val); if (!cmpt_seq->device) { - uc_error("error: Cannot find component device %s", val); + snd_error(UCM, "error: Cannot find component device %s", val); free(val); return -EINVAL; } @@ -1072,7 +1074,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr, const char *cmd = NULL; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("error: compound is expected for sequence definition"); + snd_error(UCM, "error: compound is expected for sequence definition"); return -EINVAL; } @@ -1085,7 +1087,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr, continue; if (idx == 1) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_STRING) { - uc_error("error: string type is expected for sequence command"); + snd_error(UCM, "error: string type is expected for sequence command"); return -EINVAL; } snd_config_get_string(n, &cmd); @@ -1102,7 +1104,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr, curr->type = SEQUENCE_ELEMENT_TYPE_CDEV; err = parse_string_substitute3(uc_mgr, n, &curr->data.cdev); if (err < 0) { - uc_error("error: cdev requires a string!"); + snd_error(UCM, "error: cdev requires a string!"); return err; } continue; @@ -1113,7 +1115,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr, cset: err = parse_string_substitute3(uc_mgr, n, &curr->data.cset); if (err < 0) { - uc_error("error: %s requires a string!", cmd); + snd_error(UCM, "error: %s requires a string!", cmd); return err; } continue; @@ -1127,7 +1129,7 @@ cset: strcmp(cmd, "enadev") == 0, &curr->data.cmpt_seq); if (err < 0) { - uc_error("error: %s requires a valid device!", cmd); + snd_error(UCM, "error: %s requires a valid device!", cmd); return err; } continue; @@ -1143,7 +1145,7 @@ cset: device: err = parse_string_substitute3(uc_mgr, n, &curr->data.device); if (err < 0) { - uc_error("error: %s requires a valid device!", cmd); + snd_error(UCM, "error: %s requires a valid device!", cmd); return err; } continue; @@ -1178,7 +1180,7 @@ device: curr->type = SEQUENCE_ELEMENT_TYPE_SYSSET; err = parse_string_substitute3(uc_mgr, n, &curr->data.sysw); if (err < 0) { - uc_error("error: sysw requires a string!"); + snd_error(UCM, "error: sysw requires a string!"); return err; } continue; @@ -1188,7 +1190,7 @@ device: curr->type = SEQUENCE_ELEMENT_TYPE_SLEEP; err = parse_integer_substitute3(uc_mgr, n, &curr->data.sleep); if (err < 0) { - uc_error("error: usleep requires integer!"); + snd_error(UCM, "error: usleep requires integer!"); return err; } continue; @@ -1198,7 +1200,7 @@ device: curr->type = SEQUENCE_ELEMENT_TYPE_SLEEP; err = parse_integer_substitute3(uc_mgr, n, &curr->data.sleep); if (err < 0) { - uc_error("error: msleep requires integer!"); + snd_error(UCM, "error: msleep requires integer!"); return err; } curr->data.sleep *= 1000L; @@ -1210,7 +1212,7 @@ device: exec: err = parse_string_substitute3(uc_mgr, n, &curr->data.exec); if (err < 0) { - uc_error("error: exec requires a string!"); + snd_error(UCM, "error: exec requires a string!"); return err; } continue; @@ -1225,7 +1227,7 @@ exec: curr->type = SEQUENCE_ELEMENT_TYPE_CFGSAVE; err = parse_string_substitute3(uc_mgr, n, &curr->data.cfgsave); if (err < 0) { - uc_error("error: sysw requires a string!"); + snd_error(UCM, "error: sysw requires a string!"); return err; } continue; @@ -1234,7 +1236,7 @@ exec: if (strcmp(cmd, "comment") == 0) goto skip; - uc_error("error: sequence command '%s' is ignored", cmd); + snd_error(UCM, "error: sequence command '%s' is ignored", cmd); skip: list_del(&curr->list); @@ -1287,7 +1289,7 @@ static int parse_value(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, int err; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("error: compound is expected for value definition"); + snd_error(UCM, "error: compound is expected for value definition"); return -EINVAL; } @@ -1310,19 +1312,19 @@ static int parse_value(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, case SND_CONFIG_TYPE_REAL: err = snd_config_get_ascii(n, &s); if (err < 0) { - uc_error("error: unable to parse value for id '%s': %s!", id, snd_strerror(err)); + snd_error(UCM, "error: unable to parse value for id '%s': %s!", id, snd_strerror(err)); return err; } break; case SND_CONFIG_TYPE_STRING: err = parse_string_substitute(uc_mgr, n, &s); if (err < 0) { - uc_error("error: unable to parse a string for id '%s'!", id); + snd_error(UCM, "error: unable to parse a string for id '%s'!", id); return err; } break; default: - uc_error("error: invalid type %i in Value compound '%s'", type, id); + snd_error(UCM, "error: invalid type %i in Value compound '%s'", type, id); return -EINVAL; } err = uc_mgr_add_value(base, id, s); @@ -1419,7 +1421,7 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "Comment") == 0) { err = parse_string_substitute3(uc_mgr, n, &modifier->comment); if (err < 0) { - uc_error("error: failed to get modifier comment"); + snd_error(UCM, "error: failed to get modifier comment"); return err; } continue; @@ -1429,8 +1431,9 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr, err = parse_device_list(uc_mgr, &modifier->dev_list, DEVLIST_SUPPORTED, n); if (err < 0) { - uc_error("error: failed to parse supported" - " device list"); + snd_error(UCM, "error: failed to parse supported" + " device list"); + return err; } } @@ -1439,8 +1442,9 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr, err = parse_device_list(uc_mgr, &modifier->dev_list, DEVLIST_CONFLICTING, n); if (err < 0) { - uc_error("error: failed to parse conflicting" - " device list"); + snd_error(UCM, "error: failed to parse conflicting" + " device list"); + return err; } } @@ -1448,8 +1452,9 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "EnableSequence") == 0) { err = parse_sequence(uc_mgr, &modifier->enable_list, n); if (err < 0) { - uc_error("error: failed to parse modifier" - " enable sequence"); + snd_error(UCM, "error: failed to parse modifier" + " enable sequence"); + return err; } continue; @@ -1458,8 +1463,9 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "DisableSequence") == 0) { err = parse_sequence(uc_mgr, &modifier->disable_list, n); if (err < 0) { - uc_error("error: failed to parse modifier" - " disable sequence"); + snd_error(UCM, "error: failed to parse modifier" + " disable sequence"); + return err; } continue; @@ -1468,8 +1474,9 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "TransitionSequence") == 0) { err = parse_transition(uc_mgr, &modifier->transition_list, n); if (err < 0) { - uc_error("error: failed to parse transition" - " modifier"); + snd_error(UCM, "error: failed to parse transition" + " modifier"); + return err; } continue; @@ -1478,7 +1485,7 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "Value") == 0) { err = parse_value(uc_mgr, &modifier->value_list, n); if (err < 0) { - uc_error("error: failed to parse Value"); + snd_error(UCM, "error: failed to parse Value"); return err; } continue; @@ -1564,7 +1571,7 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "Comment") == 0) { err = parse_string_substitute3(uc_mgr, n, &device->comment); if (err < 0) { - uc_error("error: failed to get device comment"); + snd_error(UCM, "error: failed to get device comment"); return err; } continue; @@ -1574,8 +1581,9 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, err = parse_device_list(uc_mgr, &device->dev_list, DEVLIST_SUPPORTED, n); if (err < 0) { - uc_error("error: failed to parse supported" - " device list"); + snd_error(UCM, "error: failed to parse supported" + " device list"); + return err; } } @@ -1584,8 +1592,9 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, err = parse_device_list(uc_mgr, &device->dev_list, DEVLIST_CONFLICTING, n); if (err < 0) { - uc_error("error: failed to parse conflicting" - " device list"); + snd_error(UCM, "error: failed to parse conflicting" + " device list"); + return err; } } @@ -1594,8 +1603,9 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, uc_dbg("EnableSequence"); err = parse_sequence(uc_mgr, &device->enable_list, n); if (err < 0) { - uc_error("error: failed to parse device enable" - " sequence"); + snd_error(UCM, "error: failed to parse device enable" + " sequence"); + return err; } continue; @@ -1605,8 +1615,9 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, uc_dbg("DisableSequence"); err = parse_sequence(uc_mgr, &device->disable_list, n); if (err < 0) { - uc_error("error: failed to parse device disable" - " sequence"); + snd_error(UCM, "error: failed to parse device disable" + " sequence"); + return err; } continue; @@ -1616,8 +1627,9 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, uc_dbg("TransitionSequence"); err = parse_transition(uc_mgr, &device->transition_list, n); if (err < 0) { - uc_error("error: failed to parse transition" - " device"); + snd_error(UCM, "error: failed to parse transition" + " device"); + return err; } continue; @@ -1626,7 +1638,7 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "Value") == 0) { err = parse_value(uc_mgr, &device->value_list, n); if (err < 0) { - uc_error("error: failed to parse Value"); + snd_error(UCM, "error: failed to parse Value"); return err; } continue; @@ -1660,7 +1672,7 @@ static int parse_dev_name_list(snd_use_case_mgr_t *uc_mgr, return -EINVAL; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for %s", id); + snd_error(UCM, "compound type expected for %s", id); return -EINVAL; } @@ -1677,7 +1689,7 @@ static int parse_dev_name_list(snd_use_case_mgr_t *uc_mgr, err = parse_string_substitute3(uc_mgr, n, &name2); if (err < 0) { free(name1s); - uc_error("error: failed to get target device name for '%s'", name1); + snd_error(UCM, "error: failed to get target device name for '%s'", name1); return err; } @@ -1789,14 +1801,15 @@ static int verb_dev_list_add(struct use_case_verb *verb, if (list_empty(&device->dev_list.list)) { device->dev_list.type = dst_type; } else { - uc_error("error: incompatible device list type ('%s', '%s')", - device->name, src); + snd_error(UCM, "error: incompatible device list type ('%s', '%s')", + device->name, src); + return -EINVAL; } } return uc_mgr_put_to_dev_list(&device->dev_list, src); } - uc_error("error: unable to find device '%s'", dst); + snd_error(UCM, "error: unable to find device '%s'", dst); return -ENOENT; } @@ -1831,7 +1844,7 @@ static int verb_device_management(struct use_case_verb *verb) dev = list_entry(pos, struct ucm_dev_name, list); err = uc_mgr_rename_device(verb, dev->name1, dev->name2); if (err < 0) { - uc_error("error: cannot rename device '%s' to '%s'", dev->name1, dev->name2); + snd_error(UCM, "error: cannot rename device '%s' to '%s'", dev->name1, dev->name2); return err; } } @@ -1841,7 +1854,7 @@ static int verb_device_management(struct use_case_verb *verb) dev = list_entry(pos, struct ucm_dev_name, list); err = uc_mgr_remove_device(verb, dev->name2); if (err < 0) { - uc_error("error: cannot remove device '%s'", dev->name2); + snd_error(UCM, "error: cannot remove device '%s'", dev->name2); return err; } } @@ -1915,7 +1928,7 @@ static int parse_verb(snd_use_case_mgr_t *uc_mgr, uc_dbg("Parse EnableSequence"); err = parse_sequence(uc_mgr, &verb->enable_list, n); if (err < 0) { - uc_error("error: failed to parse verb enable sequence"); + snd_error(UCM, "error: failed to parse verb enable sequence"); return err; } continue; @@ -1925,7 +1938,7 @@ static int parse_verb(snd_use_case_mgr_t *uc_mgr, uc_dbg("Parse DisableSequence"); err = parse_sequence(uc_mgr, &verb->disable_list, n); if (err < 0) { - uc_error("error: failed to parse verb disable sequence"); + snd_error(UCM, "error: failed to parse verb disable sequence"); return err; } continue; @@ -1935,7 +1948,7 @@ static int parse_verb(snd_use_case_mgr_t *uc_mgr, uc_dbg("Parse TransitionSequence"); err = parse_transition(uc_mgr, &verb->transition_list, n); if (err < 0) { - uc_error("error: failed to parse transition sequence"); + snd_error(UCM, "error: failed to parse transition sequence"); return err; } continue; @@ -2022,8 +2035,9 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "SectionVerb") == 0) { err = parse_verb(uc_mgr, verb, n); if (err < 0) { - uc_error("error: %s failed to parse verb", - file); + snd_error(UCM, "error: %s failed to parse verb", + file); + goto _err; } continue; @@ -2034,8 +2048,9 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr, err = parse_compound(uc_mgr, n, parse_device_name, verb, NULL); if (err < 0) { - uc_error("error: %s failed to parse device", - file); + snd_error(UCM, "error: %s failed to parse device", + file); + goto _err; } continue; @@ -2046,8 +2061,9 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr, err = parse_compound(uc_mgr, n, parse_modifier_name, verb, NULL); if (err < 0) { - uc_error("error: %s failed to parse modifier", - file); + snd_error(UCM, "error: %s failed to parse modifier", + file); + goto _err; } continue; @@ -2057,8 +2073,9 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "RenameDevice") == 0) { err = parse_dev_name_list(uc_mgr, n, &verb->rename_list); if (err < 0) { - uc_error("error: %s failed to parse device rename", - file); + snd_error(UCM, "error: %s failed to parse device rename", + file); + goto _err; } continue; @@ -2068,8 +2085,9 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "RemoveDevice") == 0) { err = parse_dev_name_list(uc_mgr, n, &verb->remove_list); if (err < 0) { - uc_error("error: %s failed to parse device remove", - file); + snd_error(UCM, "error: %s failed to parse device remove", + file); + goto _err; } continue; @@ -2079,7 +2097,7 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr, if (uc_mgr->conf_format > 3 && strcmp(id, "LibraryConfig") == 0) { err = parse_libconfig(uc_mgr, n); if (err < 0) { - uc_error("error: failed to parse LibConfig"); + snd_error(UCM, "error: failed to parse LibConfig"); goto _err; } continue; @@ -2090,14 +2108,14 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr, /* use case verb must have at least 1 device */ if (list_empty(&verb->device_list)) { - uc_error("error: no use case device defined", file); + snd_error(UCM, "error: no use case device defined", file); return -EINVAL; } /* do device rename and delete */ err = verb_device_management(verb); if (err < 0) { - uc_error("error: device management error in verb '%s'", verb->name); + snd_error(UCM, "error: device management error in verb '%s'", verb->name); return err; } @@ -2131,7 +2149,7 @@ static int parse_variant(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, if (_vfile) { err = parse_string_substitute3(uc_mgr, n, &file); if (err < 0) { - uc_error("failed to get File"); + snd_error(UCM, "failed to get File"); goto __error; } } @@ -2143,14 +2161,14 @@ static int parse_variant(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, if (_vcomment) { err = parse_string_substitute3(uc_mgr, n, &comment); if (err < 0) { - uc_error("error: failed to get Comment"); + snd_error(UCM, "error: failed to get Comment"); goto __error; } } continue; } - uc_error("unknown field '%s' in Variant section", id); + snd_error(UCM, "unknown field '%s' in Variant section", id); err = -EINVAL; goto __error; } @@ -2181,13 +2199,13 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, int err; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for use case section"); + snd_error(UCM, "compound type expected for use case section"); return -EINVAL; } err = parse_get_safe_name(uc_mgr, cfg, NULL, &use_case_name); if (err < 0) { - uc_error("unable to get name for use case section"); + snd_error(UCM, "unable to get name for use case section"); return err; } @@ -2209,7 +2227,7 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, if (strcmp(id, "File") == 0) { err = parse_string_substitute3(uc_mgr, n, &file); if (err < 0) { - uc_error("failed to get File"); + snd_error(UCM, "failed to get File"); goto __error; } continue; @@ -2219,7 +2237,7 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, if (strncmp(id, "Comment", 7) == 0) { err = parse_string_substitute3(uc_mgr, n, &comment); if (err < 0) { - uc_error("error: failed to get Comment"); + snd_error(UCM, "error: failed to get Comment"); goto __error; } continue; @@ -2243,11 +2261,11 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, continue; } - uc_error("unknown field '%s' in SectionUseCase", id); + snd_error(UCM, "unknown field '%s' in SectionUseCase", id); } if (variant && !variant_ok) { - uc_error("error: undefined variant '%s'", use_case_name); + snd_error(UCM, "error: undefined variant '%s'", use_case_name); err = -EINVAL; goto __error; } @@ -2257,7 +2275,7 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, /* do we have both use case name and file ? */ if (!file) { - uc_error("error: use case missing file"); + snd_error(UCM, "error: use case missing file"); err = -EINVAL; goto __error; } @@ -2304,12 +2322,12 @@ static int parse_controls_fixedboot(snd_use_case_mgr_t *uc_mgr, snd_config_t *cf int err; if (!list_empty(&uc_mgr->fixedboot_list)) { - uc_error("FixedBoot list is not empty"); + snd_error(UCM, "FixedBoot list is not empty"); return -EINVAL; } err = parse_sequence(uc_mgr, &uc_mgr->fixedboot_list, cfg); if (err < 0) { - uc_error("Unable to parse FixedBootSequence"); + snd_error(UCM, "Unable to parse FixedBootSequence"); return err; } @@ -2324,12 +2342,12 @@ static int parse_controls_boot(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) int err; if (!list_empty(&uc_mgr->boot_list)) { - uc_error("Boot list is not empty"); + snd_error(UCM, "Boot list is not empty"); return -EINVAL; } err = parse_sequence(uc_mgr, &uc_mgr->boot_list, cfg); if (err < 0) { - uc_error("Unable to parse BootSequence"); + snd_error(UCM, "Unable to parse BootSequence"); return err; } @@ -2344,12 +2362,12 @@ static int parse_controls(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) int err; if (!list_empty(&uc_mgr->default_list)) { - uc_error("Default list is not empty"); + snd_error(UCM, "Default list is not empty"); return -EINVAL; } err = parse_sequence(uc_mgr, &uc_mgr->default_list, cfg); if (err < 0) { - uc_error("Unable to parse SectionDefaults"); + snd_error(UCM, "Unable to parse SectionDefaults"); return err; } @@ -2412,7 +2430,7 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) int err; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for master file"); + snd_error(UCM, "compound type expected for master file"); return -EINVAL; } @@ -2437,7 +2455,7 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) if (strcmp(id, "Comment") == 0) { err = parse_string_substitute3(uc_mgr, n, &uc_mgr->comment); if (err < 0) { - uc_error("error: failed to get master comment"); + snd_error(UCM, "error: failed to get master comment"); return err; } continue; @@ -2481,7 +2499,7 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) if (strcmp(id, "ValueDefaults") == 0) { err = parse_value(uc_mgr, &uc_mgr->value_list, n); if (err < 0) { - uc_error("error: failed to parse ValueDefaults"); + snd_error(UCM, "error: failed to parse ValueDefaults"); return err; } continue; @@ -2491,7 +2509,7 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) if (uc_mgr->conf_format > 3 && strcmp(id, "LibraryConfig") == 0) { err = parse_libconfig(uc_mgr, n); if (err < 0) { - uc_error("error: failed to parse LibraryConfig"); + snd_error(UCM, "error: failed to parse LibraryConfig"); return err; } continue; @@ -2505,7 +2523,7 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) if (strcmp(id, "Syntax") == 0) continue; - uc_error("unknown master file field %s", id); + snd_error(UCM, "unknown master file field %s", id); } return 0; } @@ -2538,7 +2556,7 @@ static int get_by_card_name(snd_use_case_mgr_t *mgr, const char *card_name) card = -1; if (snd_card_next(&card) < 0 || card < 0) { - uc_error("no soundcards found..."); + snd_error(UCM, "no soundcards found..."); return -1; } @@ -2562,7 +2580,7 @@ static int get_by_card_name(snd_use_case_mgr_t *mgr, const char *card_name) } if (snd_card_next(&card) < 0) { - uc_error("snd_card_next"); + snd_error(UCM, "snd_card_next"); break; } } @@ -2591,7 +2609,7 @@ static int parse_toplevel_path(snd_use_case_mgr_t *uc_mgr, int err; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for UseCasePath node"); + snd_error(UCM, "compound type expected for UseCasePath node"); return -EINVAL; } @@ -2600,7 +2618,7 @@ static int parse_toplevel_path(snd_use_case_mgr_t *uc_mgr, n = snd_config_iterator_entry(i); if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for UseCasePath.something node"); + snd_error(UCM, "compound type expected for UseCasePath.something node"); return -EINVAL; } @@ -2619,11 +2637,11 @@ static int parse_toplevel_path(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "Version") == 0) { err = parse_integer_substitute(uc_mgr, n2, &version); if (err < 0) { - uc_error("unable to parse UcmDirectory"); + snd_error(UCM, "unable to parse UcmDirectory"); goto __error; } if (version < 1 || version > 2) { - uc_error("Version must be 1 or 2"); + snd_error(UCM, "Version must be 1 or 2"); err = -EINVAL; goto __error; } @@ -2633,7 +2651,7 @@ static int parse_toplevel_path(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "Directory") == 0) { err = parse_string_substitute(uc_mgr, n2, &dir); if (err < 0) { - uc_error("unable to parse Directory"); + snd_error(UCM, "unable to parse Directory"); goto __error; } continue; @@ -2642,21 +2660,21 @@ static int parse_toplevel_path(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "File") == 0) { err = parse_string_substitute(uc_mgr, n2, &file); if (err < 0) { - uc_error("unable to parse File"); + snd_error(UCM, "unable to parse File"); goto __error; } continue; } - uc_error("unknown UseCasePath field %s", id); + snd_error(UCM, "unknown UseCasePath field %s", id); } if (dir == NULL) { - uc_error("Directory is not defined in %s!", filename); + snd_error(UCM, "Directory is not defined in %s!", filename); goto __next; } if (file == NULL) { - uc_error("File is not defined in %s!", filename); + snd_error(UCM, "File is not defined in %s!", filename); goto __next; } @@ -2736,7 +2754,7 @@ static int parse_toplevel_config(snd_use_case_mgr_t *uc_mgr, int err; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for toplevel file"); + snd_error(UCM, "compound type expected for toplevel file"); return -EINVAL; } @@ -2767,7 +2785,7 @@ static int parse_toplevel_config(snd_use_case_mgr_t *uc_mgr, if (uc_mgr->conf_format > 3 && strcmp(id, "LibraryConfig") == 0) { err = parse_libconfig(uc_mgr, n); if (err < 0) { - uc_error("error: failed to parse LibConfig"); + snd_error(UCM, "error: failed to parse LibConfig"); return err; } continue; @@ -2777,7 +2795,7 @@ static int parse_toplevel_config(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "Syntax") == 0) continue; - uc_error("unknown toplevel field %s", id); + snd_error(UCM, "unknown toplevel field %s", id); } return -ENOENT; @@ -2793,7 +2811,7 @@ static int load_toplevel_config(snd_use_case_mgr_t *uc_mgr, ucm_filename(filename, sizeof(filename), 2, NULL, "ucm.conf"); if (access(filename, R_OK) != 0) { - uc_error("Unable to find the top-level configuration file '%s'.", filename); + snd_error(UCM, "Unable to find the top-level configuration file '%s'.", filename); return -ENOENT; } @@ -2809,8 +2827,9 @@ static int load_toplevel_config(snd_use_case_mgr_t *uc_mgr, err = uc_mgr_config_load(uc_mgr->conf_format, filename, cfg); if (err < 0) { - uc_error("error: could not parse configuration for card %s", - uc_mgr->card_name); + snd_error(UCM, "error: could not parse configuration for card %s", + uc_mgr->card_name); + goto __error; } @@ -2840,7 +2859,7 @@ int uc_mgr_import_master_config(snd_use_case_mgr_t *uc_mgr) if (strncmp(name, "hw:", 3) == 0) { err = get_by_card(uc_mgr, name); if (err < 0) { - uc_error("card '%s' is not valid", name); + snd_error(UCM, "card '%s' is not valid", name); goto __error; } } else if (strncmp(name, "strict:", 7)) { @@ -2943,8 +2962,9 @@ int uc_mgr_scan_master_configs(const char **_list[]) err = scandir64(filename, &namelist, filename_filter, SORTFUNC); if (err < 0) { err = -errno; - uc_error("error: could not scan directory %s: %s", - filename, strerror(-err)); + snd_error(UCM, "error: could not scan directory %s: %s", + filename, strerror(-err)); + return err; } cnt = err; @@ -2982,7 +3002,7 @@ int uc_mgr_scan_master_configs(const char **_list[]) if (err == -ENOENT || err == -ENXIO) continue; if (err < 0) { - uc_error("Unable to open '%s': %s", fn, snd_strerror(err)); + snd_error(UCM, "Unable to open '%s': %s", fn, snd_strerror(err)); goto __err; } err = snd_use_case_get(uc_mgr, "comment", (const char **)&s); @@ -3020,18 +3040,18 @@ int uc_mgr_scan_master_configs(const char **_list[]) goto __err; err = snd_config_search(cfg, "Syntax", &c); if (err < 0) { - uc_error("Syntax field not found in %s", d_name); + snd_error(UCM, "Syntax field not found in %s", d_name); snd_config_delete(cfg); continue; } err = snd_config_get_integer(c, &l); if (err < 0) { - uc_error("Syntax field is invalid in %s", d_name); + snd_error(UCM, "Syntax field is invalid in %s", d_name); snd_config_delete(cfg); goto __err; } if (l < 2 || l > SYNTAX_VERSION_MAX) { - uc_error("Incompatible syntax %d in %s", l, d_name); + snd_error(UCM, "Incompatible syntax %d in %s", l, d_name); snd_config_delete(cfg); goto __err; } diff --git a/src/ucm/ucm_cond.c b/src/ucm/ucm_cond.c index 87bc9762..5db25d2d 100644 --- a/src/ucm/ucm_cond.c +++ b/src/ucm/ucm_cond.c @@ -47,7 +47,7 @@ static int if_eval_string(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval) if (uc_mgr->conf_format >= 3) { err = get_string(eval, "Empty", &string1); if (err < 0 && err != -ENOENT) { - uc_error("String error (If.Condition.Empty)"); + snd_error(UCM, "String error (If.Condition.Empty)"); return -EINVAL; } @@ -63,23 +63,23 @@ static int if_eval_string(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval) err = get_string(eval, "String1", &string1); if (err < 0 && err != -ENOENT) { - uc_error("String error (If.Condition.String1)"); + snd_error(UCM, "String error (If.Condition.String1)"); return -EINVAL; } err = get_string(eval, "String2", &string2); if (err < 0 && err != -ENOENT) { - uc_error("String error (If.Condition.String2)"); + snd_error(UCM, "String error (If.Condition.String2)"); return -EINVAL; } if (string1 || string2) { if (string1 == NULL) { - uc_error("If.Condition.String1 not defined"); + snd_error(UCM, "If.Condition.String1 not defined"); return -EINVAL; } if (string2 == NULL) { - uc_error("If.Condition.String2 not defined"); + snd_error(UCM, "If.Condition.String2 not defined"); return -EINVAL; } err = uc_mgr_get_substituted_value(uc_mgr, &s1, string1); @@ -98,23 +98,23 @@ static int if_eval_string(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval) err = get_string(eval, "Haystack", &string1); if (err < 0 && err != -ENOENT) { - uc_error("String error (If.Condition.Haystack)"); + snd_error(UCM, "String error (If.Condition.Haystack)"); return -EINVAL; } err = get_string(eval, "Needle", &string2); if (err < 0 && err != -ENOENT) { - uc_error("String error (If.Condition.Needle)"); + snd_error(UCM, "String error (If.Condition.Needle)"); return -EINVAL; } if (string1 || string2) { if (string1 == NULL) { - uc_error("If.Condition.Haystack not defined"); + snd_error(UCM, "If.Condition.Haystack not defined"); return -EINVAL; } if (string2 == NULL) { - uc_error("If.Condition.Needle not defined"); + snd_error(UCM, "If.Condition.Needle not defined"); return -EINVAL; } err = uc_mgr_get_substituted_value(uc_mgr, &s1, string1); @@ -131,7 +131,7 @@ static int if_eval_string(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval) return err; } - uc_error("Unknown String condition arguments"); + snd_error(UCM, "Unknown String condition arguments"); return -EINVAL; } @@ -146,13 +146,13 @@ static int if_eval_regex_match(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval) err = get_string(eval, "String", &string); if (err < 0) { - uc_error("RegexMatch error (If.Condition.String)"); + snd_error(UCM, "RegexMatch error (If.Condition.String)"); return -EINVAL; } err = get_string(eval, "Regex", ®ex_string); if (err < 0) { - uc_error("RegexMatch error (If.Condition.Regex)"); + snd_error(UCM, "RegexMatch error (If.Condition.Regex)"); return -EINVAL; } @@ -161,7 +161,7 @@ static int if_eval_regex_match(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval) return err; err = regcomp(&re, s, options); if (err) { - uc_error("Regex '%s' compilation failed (code %d)", s, err); + snd_error(UCM, "Regex '%s' compilation failed (code %d)", s, err); free(s); return -EINVAL; } @@ -194,19 +194,19 @@ static int if_eval_control_exists(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval err = get_string(eval, "Device", &device); if (err < 0 && err != -ENOENT) { - uc_error("ControlExists error (If.Condition.Device)"); + snd_error(UCM, "ControlExists error (If.Condition.Device)"); return -EINVAL; } err = get_string(eval, "Control", &ctldef); if (err < 0) { - uc_error("ControlExists error (If.Condition.Control)"); + snd_error(UCM, "ControlExists error (If.Condition.Control)"); return -EINVAL; } err = get_string(eval, "ControlEnum", &enumval); if (err < 0 && err != -ENOENT) { - uc_error("ControlExists error (If.Condition.ControlEnum)"); + snd_error(UCM, "ControlExists error (If.Condition.ControlEnum)"); return -EINVAL; } @@ -216,14 +216,14 @@ static int if_eval_control_exists(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval err = snd_ctl_ascii_elem_id_parse(elem_id, s); free(s); if (err < 0) { - uc_error("unable to parse element identificator (%s)", ctldef); + snd_error(UCM, "unable to parse element identificator (%s)", ctldef); return -EINVAL; } if (device == NULL) { ctl = uc_mgr_get_ctl(uc_mgr); if (ctl == NULL) { - uc_error("cannot determine control device"); + snd_error(UCM, "cannot determine control device"); return -EINVAL; } } else { @@ -277,19 +277,19 @@ static int if_eval_path(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval) char *s; if (uc_mgr->conf_format < 4) { - uc_error("Path condition is supported in v4+ syntax"); + snd_error(UCM, "Path condition is supported in v4+ syntax"); return -EINVAL; } err = get_string(eval, "Path", &path); if (err < 0) { - uc_error("Path error (If.Condition.Path)"); + snd_error(UCM, "Path error (If.Condition.Path)"); return -EINVAL; } err = get_string(eval, "Mode", &mode); if (err < 0 && err != -ENOENT) { - uc_error("Path error (If.Condition.Mode)"); + snd_error(UCM, "Path error (If.Condition.Mode)"); return -EINVAL; } @@ -309,7 +309,7 @@ static int if_eval_path(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval) } else if (strcasecmp(s, "exec") == 0) { amode = X_OK; } else { - uc_error("Path unknown mode '%s' (If.Condition.Mode)", s); + snd_error(UCM, "Path unknown mode '%s' (If.Condition.Mode)", s); free(s); return -EINVAL; } @@ -339,13 +339,13 @@ static int if_eval(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval) int err; if (snd_config_get_type(eval) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for If.Condition"); + snd_error(UCM, "compound type expected for If.Condition"); return -EINVAL; } err = get_string(eval, "Type", &type); if (err < 0) { - uc_error("type block error (If.Condition)"); + snd_error(UCM, "type block error (If.Condition)"); return -EINVAL; } @@ -364,7 +364,7 @@ static int if_eval(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval) if (strcmp(type, "Path") == 0) return if_eval_path(uc_mgr, eval); - uc_error("unknown If.Condition.Type"); + snd_error(UCM, "unknown If.Condition.Type"); return -EINVAL; } @@ -380,36 +380,36 @@ static int if_eval_one(snd_use_case_mgr_t *uc_mgr, *result = NULL; if (snd_config_get_type(cond) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for If.1"); + snd_error(UCM, "compound type expected for If.1"); return -EINVAL; } if (snd_config_search(cond, "Condition", &expr) < 0) { - uc_error("condition block expected (If)"); + snd_error(UCM, "condition block expected (If)"); return -EINVAL; } err = snd_config_search(cond, "True", &_true); if (err < 0 && err != -ENOENT) { - uc_error("true block error (If)"); + snd_error(UCM, "true block error (If)"); return -EINVAL; } err = snd_config_search(cond, "False", &_false); if (err < 0 && err != -ENOENT) { - uc_error("false block error (If)"); + snd_error(UCM, "false block error (If)"); return -EINVAL; } err = snd_config_search(cond, "Before", before); if (err < 0 && err != -ENOENT) { - uc_error("before block identifier error"); + snd_error(UCM, "before block identifier error"); return -EINVAL; } err = snd_config_search(cond, "After", after); if (err < 0 && err != -ENOENT) { - uc_error("before block identifier error"); + snd_error(UCM, "before block identifier error"); return -EINVAL; } @@ -448,12 +448,12 @@ int uc_mgr_evaluate_condition(snd_use_case_mgr_t *uc_mgr, int err; if (uc_mgr->conf_format < 2) { - uc_error("conditions are not supported for v1 syntax"); + snd_error(UCM, "conditions are not supported for v1 syntax"); return -EINVAL; } if (snd_config_get_type(cond) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for If"); + snd_error(UCM, "compound type expected for If"); return -EINVAL; } diff --git a/src/ucm/ucm_exec.c b/src/ucm/ucm_exec.c index 1007ae20..b5a22023 100644 --- a/src/ucm/ucm_exec.c +++ b/src/ucm/ucm_exec.c @@ -236,15 +236,16 @@ int uc_mgr_exec(const char *prog) if (p == -1) { err = -errno; pthread_mutex_unlock(&fork_lock); - uc_error("Unable to fork() for \"%s\" -- %s", prog, strerror(errno)); + snd_error(UCM, "Unable to fork() for \"%s\" -- %s", prog, strerror(errno)); goto __error; } if (p == 0) { f = open("/dev/null", O_RDWR); if (f == -1) { - uc_error("pid %d cannot open /dev/null for redirect %s -- %s", - getpid(), prog, strerror(errno)); + snd_error(UCM, "pid %d cannot open /dev/null for redirect %s -- %s", + getpid(), prog, strerror(errno)); + exit(1); } diff --git a/src/ucm/ucm_include.c b/src/ucm/ucm_include.c index 7def2d31..e31f2ceb 100644 --- a/src/ucm/ucm_include.c +++ b/src/ucm/ucm_include.c @@ -50,25 +50,25 @@ static int include_eval_one(snd_use_case_mgr_t *uc_mgr, *result = NULL; if (snd_config_get_type(inc) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for Include.1"); + snd_error(UCM, "compound type expected for Include.1"); return -EINVAL; } err = get_string(inc, "File", &file); if (err < 0) { - uc_error("file expected (Include)"); + snd_error(UCM, "file expected (Include)"); return -EINVAL; } err = snd_config_search(inc, "Before", before); if (err < 0 && err != -ENOENT) { - uc_error("before block identifier error"); + snd_error(UCM, "before block identifier error"); return -EINVAL; } err = snd_config_search(inc, "After", after); if (err < 0 && err != -ENOENT) { - uc_error("before block identifier error"); + snd_error(UCM, "before block identifier error"); return -EINVAL; } @@ -144,7 +144,7 @@ static int compound_merge(snd_use_case_mgr_t *uc_mgr, const char *id, int err, array, idx; if (snd_config_get_type(src) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for the merged block"); + snd_error(UCM, "compound type expected for the merged block"); return -EINVAL; } @@ -164,17 +164,17 @@ static int compound_merge(snd_use_case_mgr_t *uc_mgr, const char *id, return snd_config_merge(dst, src, 0); /* merge / append mode */ if (_before && _after) { - uc_error("defined both before and after identifiers in the If or Include block"); + snd_error(UCM, "defined both before and after identifiers in the If or Include block"); return -EINVAL; } array = snd_config_is_array(dst); if (array < 0) { - uc_error("destination configuration node is not a compound"); + snd_error(UCM, "destination configuration node is not a compound"); return array; } if (array && snd_config_is_array(src) <= 0) { - uc_error("source configuration node is not an array"); + snd_error(UCM, "source configuration node is not an array"); return -EINVAL; } @@ -287,12 +287,12 @@ int uc_mgr_evaluate_include(snd_use_case_mgr_t *uc_mgr, int err; if (uc_mgr->conf_format < 3) { - uc_error("in-place include is supported in v3+ syntax"); + snd_error(UCM, "in-place include is supported in v3+ syntax"); return -EINVAL; } if (snd_config_get_type(inc) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for Include"); + snd_error(UCM, "compound type expected for Include"); return -EINVAL; } diff --git a/src/ucm/ucm_local.h b/src/ucm/ucm_local.h index f1e7e3c3..63017335 100644 --- a/src/ucm/ucm_local.h +++ b/src/ucm/ucm_local.h @@ -285,8 +285,6 @@ struct snd_use_case_mgr { char *cdev; }; -#define uc_error SNDERR - #ifdef UC_MGR_DEBUG #define uc_dbg SNDERR #else diff --git a/src/ucm/ucm_regex.c b/src/ucm/ucm_regex.c index dfcab042..1f5b84ce 100644 --- a/src/ucm/ucm_regex.c +++ b/src/ucm/ucm_regex.c @@ -98,24 +98,24 @@ int uc_mgr_define_regex(snd_use_case_mgr_t *uc_mgr, const char *name, int err; if (uc_mgr->conf_format < 3) { - uc_error("define regex is supported in v3+ syntax"); + snd_error(UCM, "define regex is supported in v3+ syntax"); return -EINVAL; } if (snd_config_get_type(eval) != SND_CONFIG_TYPE_COMPOUND) { - uc_error("compound type expected for DefineRegex"); + snd_error(UCM, "compound type expected for DefineRegex"); return -EINVAL; } err = get_string(eval, "String", &string); if (err < 0) { - uc_error("DefineRegex error (String)"); + snd_error(UCM, "DefineRegex error (String)"); return -EINVAL; } err = get_string(eval, "Regex", ®ex_string); if (err < 0) { - uc_error("DefineRegex error (Regex string)"); + snd_error(UCM, "DefineRegex error (Regex string)"); return -EINVAL; } @@ -123,7 +123,7 @@ int uc_mgr_define_regex(snd_use_case_mgr_t *uc_mgr, const char *name, if (err == -ENOENT) { options = REG_EXTENDED; } else if (err < 0) { - uc_error("DefineRegex error (Flags string)"); + snd_error(UCM, "DefineRegex error (Flags string)"); return -EINVAL; } else { while (*flags_string) { @@ -141,7 +141,7 @@ int uc_mgr_define_regex(snd_use_case_mgr_t *uc_mgr, const char *name, options |= REG_NEWLINE; break; default: - uc_error("DefineRegex error (unknown flag '%c')", *flags_string); + snd_error(UCM, "DefineRegex error (unknown flag '%c')", *flags_string); return -EINVAL; } flags_string++; @@ -154,7 +154,7 @@ int uc_mgr_define_regex(snd_use_case_mgr_t *uc_mgr, const char *name, err = regcomp(&re, s, options); free(s); if (err) { - uc_error("Regex '%s' compilation failed (code %d)", s, err); + snd_error(UCM, "Regex '%s' compilation failed (code %d)", s, err); return -EINVAL; } diff --git a/src/ucm/ucm_subs.c b/src/ucm/ucm_subs.c index a3d9c392..639dd7a2 100644 --- a/src/ucm/ucm_subs.c +++ b/src/ucm/ucm_subs.c @@ -178,11 +178,11 @@ static struct ctl_list *get_ctl_list_by_name(snd_use_case_mgr_t *uc_mgr, const c static char *rval_card_number_by_name(snd_use_case_mgr_t *uc_mgr, const char *id) { if (uc_mgr->conf_format < 3) { - uc_error("CardNumberByName substitution is supported in v3+ syntax"); + snd_error(UCM, "CardNumberByName substitution is supported in v3+ syntax"); return NULL; } - uc_error("${CardNumberByName} substitution is obsolete - use ${find-card}!"); + snd_error(UCM, "${CardNumberByName} substitution is obsolete - use ${find-card}!"); return get_card_number(get_ctl_list_by_name(uc_mgr, id)); } @@ -192,11 +192,11 @@ static char *rval_card_id_by_name(snd_use_case_mgr_t *uc_mgr, const char *id) struct ctl_list *ctl_list; if (uc_mgr->conf_format < 3) { - uc_error("CardIdByName substitution is supported in v3+ syntax"); + snd_error(UCM, "CardIdByName substitution is supported in v3+ syntax"); return NULL; } - uc_error("${CardIdByName} substitution is obsolete - use ${find-card}!"); + snd_error(UCM, "${CardIdByName} substitution is obsolete - use ${find-card}!"); ctl_list = get_ctl_list_by_name(uc_mgr, id); if (ctl_list == NULL) @@ -242,19 +242,19 @@ static char *rval_lookup_main(snd_use_case_mgr_t *uc_mgr, int err; if (uc_mgr->conf_format < 4) { - uc_error("Lookups are supported in v4+ syntax"); + snd_error(UCM, "Lookups are supported in v4+ syntax"); return NULL; } err = snd_config_load_string(&config, query, 0); if (err < 0) { - uc_error("The lookup arguments '%s' are invalid", query); + snd_error(UCM, "The lookup arguments '%s' are invalid", query); return NULL; } if (iter->init && iter->init(uc_mgr, iter, config)) goto null; if (snd_config_search(config, "field", &d)) { - uc_error("Lookups require field!"); + snd_error(UCM, "Lookups require field!"); goto null; } if (snd_config_get_string(d, &s)) @@ -266,18 +266,18 @@ static char *rval_lookup_main(snd_use_case_mgr_t *uc_mgr, } } if (iter->fcn == NULL) { - uc_error("Unknown field value '%s'", s); + snd_error(UCM, "Unknown field value '%s'", s); goto null; } if (snd_config_search(config, "regex", &d)) { - uc_error("Lookups require regex!"); + snd_error(UCM, "Lookups require regex!"); goto null; } if (snd_config_get_string(d, &s)) goto null; err = regcomp(&re, s, REG_EXTENDED | REG_ICASE); if (err) { - uc_error("Regex '%s' compilation failed (code %d)", s, err); + snd_error(UCM, "Regex '%s' compilation failed (code %d)", s, err); goto null; } @@ -343,7 +343,7 @@ static char *rval_card_lookup_return(struct lookup_iterate *iter, snd_config_t * snprintf(num, sizeof(num), "%d", snd_ctl_card_info_get_card(iter->info)); return strdup(num); } else { - uc_error("Unknown return type '%s'", s); + snd_error(UCM, "Unknown return type '%s'", s); return NULL; } } @@ -384,7 +384,7 @@ next: if (err < 0) { if (err == -ENOENT) goto next; - uc_error("Unable to obtain PCM info (device %d)", device); + snd_error(UCM, "Unable to obtain PCM info (device %d)", device); return NULL; } return iter; @@ -431,7 +431,7 @@ static int rval_pcm_lookup_init(struct lookup_iterate *iter, else if (strcasecmp(s, "capture") == 0) stream = SND_PCM_STREAM_CAPTURE; else { - uc_error("Unknown stream type '%s'", s); + snd_error(UCM, "Unknown stream type '%s'", s); return -EINVAL; } } @@ -466,24 +466,24 @@ static int rval_device_lookup_init(snd_use_case_mgr_t *uc_mgr, if (snd_config_search(config, "ctl", &d) || snd_config_get_string(d, &s)) { iter->ctl_list = uc_mgr_get_master_ctl(uc_mgr); if (iter->ctl_list == NULL) { - uc_error("Control device is not defined!"); + snd_error(UCM, "Control device is not defined!"); return -EINVAL; } } else { err = uc_mgr_open_ctl(uc_mgr, &iter->ctl_list, s, 1); if (err < 0) { - uc_error("Control device '%s' not found", s); + snd_error(UCM, "Control device '%s' not found", s); return -EINVAL; } } if (snd_config_search(config, "type", &d) || snd_config_get_string(d, &s)) { - uc_error("Missing device type!"); + snd_error(UCM, "Missing device type!"); return -EINVAL; } for (t = types; t->name; t++) if (strcasecmp(t->name, s) == 0) return t->init(iter, config); - uc_error("Device type '%s' is invalid", s); + snd_error(UCM, "Device type '%s' is invalid", s); return -EINVAL; } @@ -531,7 +531,7 @@ static int parse_position(snd_config_t *config, const char *name, ssize_t *pos, *pos = -1; return 0; } - uc_error("Unable to find field '%s'", name); + snd_error(UCM, "Unable to find field '%s'", name); return -1; } if (!snd_config_get_integer(d, &v)) @@ -539,7 +539,7 @@ static int parse_position(snd_config_t *config, const char *name, ssize_t *pos, if (snd_config_get_string(d, &s)) return -1; if (safe_strtol(s, &v)) { - uc_error("Unable to parse position '%s'", s); + snd_error(UCM, "Unable to parse position '%s'", s); return -1; } fin: @@ -555,7 +555,7 @@ static int parse_range(const char *cfg, int *type, ssize_t *pos, ssize_t *size) err = snd_config_load_string(&config, cfg, 0); if (err < 0) { - uc_error("The range arguments '%s' are invalid", cfg); + snd_error(UCM, "The range arguments '%s' are invalid", cfg); return -1; } if (snd_config_search(config, "type", &d)) { @@ -568,7 +568,7 @@ static int parse_range(const char *cfg, int *type, ssize_t *pos, ssize_t *size) } else if (strcasecmp(s, "hex") == 0) { *type = RANGE_TYPE_HEX; } else { - uc_error("Unknown range type '%s'", s); + snd_error(UCM, "Unknown range type '%s'", s); } } *pos = 0; @@ -582,7 +582,7 @@ static int parse_range(const char *cfg, int *type, ssize_t *pos, ssize_t *size) if (*size <= 0) *size = 1; if (*pos < 0) { - uc_error("Invalid start position"); + snd_error(UCM, "Invalid start position"); retval = -1; goto null; } @@ -605,7 +605,7 @@ static char *rval_sysfs_main(snd_use_case_mgr_t *uc_mgr, const char *top_path, c return NULL; if (id[0] == '[') { if (uc_mgr->conf_format < 8) { - uc_error("Sysfs ranges are supported in v8+ syntax"); + snd_error(UCM, "Sysfs ranges are supported in v8+ syntax"); return NULL; } s = strchr(id, ']'); @@ -617,7 +617,7 @@ static char *rval_sysfs_main(snd_use_case_mgr_t *uc_mgr, const char *top_path, c strncpy(link, id + 1, len); link[len] = '\0'; if (parse_range(link, &type, &range_start, &range_size)) { - uc_error("sysfs: cannot parse hex range '%s'", link); + snd_error(UCM, "sysfs: cannot parse hex range '%s'", link); return NULL; } id = s + 1; @@ -633,7 +633,7 @@ static char *rval_sysfs_main(snd_use_case_mgr_t *uc_mgr, const char *top_path, c if (S_ISLNK(sb.st_mode)) { len = readlink(path, link, sizeof(link) - 1); if (len <= 0) { - uc_error("sysfs: cannot read link '%s' (%d)", path, errno); + snd_error(UCM, "sysfs: cannot read link '%s' (%d)", path, errno); return NULL; } link[len] = '\0'; @@ -649,18 +649,18 @@ static char *rval_sysfs_main(snd_use_case_mgr_t *uc_mgr, const char *top_path, c fd = open(path, O_RDONLY); if (fd < 0) { - uc_error("sysfs open failed for '%s' (%d)", path, errno); + snd_error(UCM, "sysfs open failed for '%s' (%d)", path, errno); return NULL; } len = sizeof(path) - 1; if (range_start > 0 && lseek(fd, range_start, SEEK_SET) != range_start) { - uc_error("sysfs seek failed (%d)", errno); + snd_error(UCM, "sysfs seek failed (%d)", errno); close(fd); return NULL; } if (range_size > 0) { if (range_size > len) { - uc_error("sysfs EOB for '%s'", path); + snd_error(UCM, "sysfs EOB for '%s'", path); close(fd); return NULL; } else { @@ -670,7 +670,7 @@ static char *rval_sysfs_main(snd_use_case_mgr_t *uc_mgr, const char *top_path, c len = read(fd, path, len); close(fd); if (len < 0) { - uc_error("sysfs unable to read value '%s' (%d)", path, errno); + snd_error(UCM, "sysfs unable to read value '%s' (%d)", path, errno); return NULL; } if (type == RANGE_TYPE_HEX && range_start >= 0) { @@ -701,7 +701,7 @@ static char *rval_sysfs_card(snd_use_case_mgr_t *uc_mgr, const char *id) char top_path[32], *s; if (uc_mgr->conf_format < 8) { - uc_error("sys-card is supported in v8+ syntax"); + snd_error(UCM, "sys-card is supported in v8+ syntax"); return NULL; } s = get_card_number(uc_mgr_get_master_ctl(uc_mgr)); @@ -716,7 +716,7 @@ static char *rval_var(snd_use_case_mgr_t *uc_mgr, const char *id) bool ignore_not_found = false; if (uc_mgr->conf_format < 3) { - uc_error("variable substitution is supported in v3+ syntax"); + snd_error(UCM, "variable substitution is supported in v3+ syntax"); return NULL; } @@ -755,12 +755,12 @@ static char *rval_eval(snd_use_case_mgr_t *uc_mgr, const char *e) int err; if (uc_mgr->conf_format < 5) { - uc_error("variable evaluation is supported in v5+ syntax"); + snd_error(UCM, "variable evaluation is supported in v5+ syntax"); return NULL; } err = _snd_eval_string(&dst, e, rval_eval_var_cb, uc_mgr); if (err < 0) { - uc_error("unable to evaluate '%s'", e); + snd_error(UCM, "unable to evaluate '%s'", e); return NULL; } err = snd_config_get_ascii(dst, &r); @@ -779,7 +779,7 @@ static int rval_evali(snd_use_case_mgr_t *uc_mgr, snd_config_t *node, const char int err; if (uc_mgr->conf_format < 6) { - uc_error("variable evaluation is supported in v6+ syntax"); + snd_error(UCM, "variable evaluation is supported in v6+ syntax"); return -EINVAL; } err = snd_config_get_id(node, &id); @@ -796,7 +796,7 @@ static int rval_evali(snd_use_case_mgr_t *uc_mgr, snd_config_t *node, const char err = _snd_eval_string(&dst, s + 8, rval_eval_var_cb, uc_mgr); free(s); if (err < 0) { - uc_error("unable to evaluate '%s'", e); + snd_error(UCM, "unable to evaluate '%s'", e); return err; } err = snd_config_set_id(dst, id); @@ -921,9 +921,9 @@ __merr: if (tmp) { strncpy(r, value, tmp + 1 - value); r[tmp + 1 - value] = '\0'; - uc_error("variable '%s' is not known!", r); + snd_error(UCM, "variable '%s' is not known!", r); } else { - uc_error("variable reference '%s' is not complete", value); + snd_error(UCM, "variable reference '%s' is not complete", value); } goto __error; __match2: @@ -941,7 +941,7 @@ __match2: goto __direct_fcn2; tmp = uc_mgr_get_variable(uc_mgr, v2 + 1); if (tmp == NULL) { - uc_error("define '%s' is not reachable in this context!", v2 + 1); + snd_error(UCM, "define '%s' is not reachable in this context!", v2 + 1); rval = NULL; } else { rval = fcn2(uc_mgr, tmp); @@ -962,8 +962,9 @@ __rval: } strncpy(r, value, idsize); r[idsize] = '\0'; - uc_error("variable '%s' is %s in this context!", r, - rval ? "empty" : "not defined"); + snd_error(UCM, "variable '%s' is %s in this context!", r, + rval ? "empty" : "not defined"); + err = -EINVAL; goto __error; } @@ -1016,7 +1017,7 @@ int uc_mgr_substitute_tree(snd_use_case_mgr_t *uc_mgr, snd_config_t *node) return err; err = snd_config_set_id(node, s); if (err < 0) { - uc_error("unable to set substituted id '%s' (old id '%s')", s, id); + snd_error(UCM, "unable to set substituted id '%s' (old id '%s')", s, id); free(s); return err; } diff --git a/src/ucm/utils.c b/src/ucm/utils.c index b37480f3..67d51226 100644 --- a/src/ucm/utils.c +++ b/src/ucm/utils.c @@ -55,7 +55,7 @@ const char *uc_mgr_sysfs_root(void) if (e == NULL) return "/sys"; if (*e == '\0') - uc_error("no sysfs root!"); + snd_error(UCM, "no sysfs root!"); return e; } @@ -69,7 +69,7 @@ struct ctl_list *uc_mgr_get_master_ctl(snd_use_case_mgr_t *uc_mgr) if (ctl_list2->slave) continue; if (ctl_list) { - uc_error("multiple control device names were found!"); + snd_error(UCM, "multiple control device names were found!"); return NULL; } ctl_list = ctl_list2; @@ -298,7 +298,7 @@ int uc_mgr_open_ctl(snd_use_case_mgr_t *uc_mgr, if (err == 0) id = snd_ctl_card_info_get_id(info); if (err < 0 || id == NULL || id[0] == '\0') { - uc_error("control hardware info (%s): %s", device, snd_strerror(err)); + snd_error(UCM, "control hardware info (%s): %s", device, snd_strerror(err)); snd_ctl_close(ctl); return err >= 0 ? -EINVAL : err; } @@ -361,7 +361,7 @@ int uc_mgr_config_load_into(int format, const char *file, snd_config_t *top) if (!fp) { err = -errno; __err_open: - uc_error("could not open configuration file %s", file); + snd_error(UCM, "could not open configuration file %s", file); return err; } err = snd_input_stdio_attach(&in, fp, 1); @@ -372,7 +372,7 @@ int uc_mgr_config_load_into(int format, const char *file, snd_config_t *top) default_paths[1] = NULL; err = _snd_config_load_with_include(top, in, 0, default_paths); if (err < 0) { - uc_error("could not load configuration file %s", file); + snd_error(UCM, "could not load configuration file %s", file); if (in) snd_input_close(in); return err; From 8c575f32e06ef84d1176ef86829b32ee89d06b91 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 15:48:16 +0100 Subject: [PATCH 21/34] include: remove local SNDMSG/SYSMSG defines (no longer used) Signed-off-by: Jaroslav Kysela --- include/local.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/local.h b/include/local.h index a9f8c126..a6996759 100644 --- a/include/local.h +++ b/include/local.h @@ -274,12 +274,8 @@ size_t snd_strlcat(char *dst, const char *src, size_t size); */ #ifndef NDEBUG #define CHECK_SANITY(x) x -#define SNDMSG(args...) snd_lib_check(0, __FILE__, __LINE__, __func__, 0, ##args) -#define SYSMSG(args...) snd_lib_check(0, __FILE__, __LINE__, __func__, errno, ##args) #else #define CHECK_SANITY(x) 0 /* not evaluated */ -#define SNDMSG(args...) /* nop */ -#define SYSMSG(args...) /* nop */ #endif /* From 0432be98f95417328128063e2a842a5bc51d7d46 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 15:58:04 +0100 Subject: [PATCH 22/34] ucm: remove uc_dbg macro and callers Those debug prints are not much useful now. Signed-off-by: Jaroslav Kysela --- src/ucm/parser.c | 10 ++-------- src/ucm/ucm_local.h | 12 ------------ 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/src/ucm/parser.c b/src/ucm/parser.c index 3b90e49b..1bf45d8d 100644 --- a/src/ucm/parser.c +++ b/src/ucm/parser.c @@ -1600,7 +1600,6 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, } if (strcmp(id, "EnableSequence") == 0) { - uc_dbg("EnableSequence"); err = parse_sequence(uc_mgr, &device->enable_list, n); if (err < 0) { snd_error(UCM, "error: failed to parse device enable" @@ -1612,7 +1611,6 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, } if (strcmp(id, "DisableSequence") == 0) { - uc_dbg("DisableSequence"); err = parse_sequence(uc_mgr, &device->disable_list, n); if (err < 0) { snd_error(UCM, "error: failed to parse device disable" @@ -1624,7 +1622,6 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, } if (strcmp(id, "TransitionSequence") == 0) { - uc_dbg("TransitionSequence"); err = parse_transition(uc_mgr, &device->transition_list, n); if (err < 0) { snd_error(UCM, "error: failed to parse transition" @@ -1925,7 +1922,6 @@ static int parse_verb(snd_use_case_mgr_t *uc_mgr, continue; if (strcmp(id, "EnableSequence") == 0) { - uc_dbg("Parse EnableSequence"); err = parse_sequence(uc_mgr, &verb->enable_list, n); if (err < 0) { snd_error(UCM, "error: failed to parse verb enable sequence"); @@ -1935,7 +1931,6 @@ static int parse_verb(snd_use_case_mgr_t *uc_mgr, } if (strcmp(id, "DisableSequence") == 0) { - uc_dbg("Parse DisableSequence"); err = parse_sequence(uc_mgr, &verb->disable_list, n); if (err < 0) { snd_error(UCM, "error: failed to parse verb disable sequence"); @@ -1945,7 +1940,7 @@ static int parse_verb(snd_use_case_mgr_t *uc_mgr, } if (strcmp(id, "TransitionSequence") == 0) { - uc_dbg("Parse TransitionSequence"); + snd_debug(UCM, "Parse TransitionSequence"); err = parse_transition(uc_mgr, &verb->transition_list, n); if (err < 0) { snd_error(UCM, "error: failed to parse transition sequence"); @@ -1955,7 +1950,6 @@ static int parse_verb(snd_use_case_mgr_t *uc_mgr, } if (strcmp(id, "Value") == 0) { - uc_dbg("Parse Value"); err = parse_value(uc_mgr, &verb->value_list, n); if (err < 0) return err; @@ -2271,7 +2265,7 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, } if (!variant) { - uc_dbg("use_case_name %s file '%s'", use_case_name, file); + snd_debug(UCM, "use_case_name %s file '%s'", use_case_name, file); /* do we have both use case name and file ? */ if (!file) { diff --git a/src/ucm/ucm_local.h b/src/ucm/ucm_local.h index 63017335..18b29871 100644 --- a/src/ucm/ucm_local.h +++ b/src/ucm/ucm_local.h @@ -30,12 +30,6 @@ * Jaroslav Kysela */ - - -#if 0 -#define UC_MGR_DEBUG -#endif - #include "local.h" #include #include "use-case.h" @@ -285,12 +279,6 @@ struct snd_use_case_mgr { char *cdev; }; -#ifdef UC_MGR_DEBUG -#define uc_dbg SNDERR -#else -#define uc_dbg(fmt, arg...) do { } while (0) -#endif - void uc_mgr_error(const char *fmt, ...); void uc_mgr_stdout(const char *fmt, ...); From c40faceab5dd75a2140628cc7f567fa0be676c7e Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 16:10:17 +0100 Subject: [PATCH 23/34] configure: bumb version to 1.2.13pre1 (for alsa-utils) Signed-off-by: Jaroslav Kysela --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2a808fa8..c31f7a4e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT(alsa-lib, 1.2.14) +AC_INIT(alsa-lib, 1.2.15pre1) AC_CONFIG_SRCDIR([src/control/control.c]) AC_CONFIG_MACRO_DIR([m4]) From d5f30b72bdfeaa6d1697d288318c11eb642d6c5f Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 16:21:05 +0100 Subject: [PATCH 24/34] error: add missing log_priority/interface functions to header file Signed-off-by: Jaroslav Kysela --- include/error.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/error.h b/include/error.h index 13a9d2bc..faeff8e0 100644 --- a/include/error.h +++ b/include/error.h @@ -91,6 +91,8 @@ void snd_lib_log(int prio, int interface, const char *file, int line, const char void snd_lib_check(int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...); snd_lib_log_handler_t snd_lib_log_set_handler(snd_lib_log_handler_t handler); snd_lib_log_handler_t snd_lib_log_set_local(snd_lib_log_handler_t handler); +const char *snd_lib_log_priority(int prio); +const char *snd_lib_log_interface(int interface); #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95) #define snd_error(interface, ...) snd_lib_log(SND_LOG_ERROR, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows an error log message. */ From 953ce1fd94b856068a0b1bb6b2d8c28d2fedbb02 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 16:31:08 +0100 Subject: [PATCH 25/34] error: make prio/interface output a bit shorter in default log handler Signed-off-by: Jaroslav Kysela --- src/error.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/error.c b/src/error.c index d8b5bb6a..1f4de78e 100644 --- a/src/error.c +++ b/src/error.c @@ -307,7 +307,7 @@ int snd_lib_log_filter(int prio, int interface, const char *configstr) */ static void snd_lib_vlog_default(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg) { - const char *text; + const char *text1, *text2; if (local_log) { local_log(prio, interface, file, line, function, errcode, fmt, arg); @@ -323,13 +323,10 @@ static void snd_lib_vlog_default(int prio, int interface, const char *file, int fprintf(stderr, "ALSA lib %s:%i:(%s) ", file, line, function); - text = snd_lib_log_priority(prio); - if (text) - fprintf(stderr, "[%s] ", text); - - text = snd_lib_log_interface(interface); - if (text) - fprintf(stderr, "[%s] ", text); + text1 = snd_lib_log_priority(prio); + text2 = snd_lib_log_interface(interface); + if (text1 || text2) + fprintf(stderr, "[%s.%s] ", text1 ? text1 : "", text2 ? text2 : ""); vfprintf(stderr, fmt, arg); if (errcode) From f6dce4f9d081d499fe2e0d049f5f2621c93a3cda Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 16:37:36 +0100 Subject: [PATCH 26/34] ucm: remove 'error: ' prefix from error messages (duplication) Signed-off-by: Jaroslav Kysela --- src/ucm/main.c | 33 +++++----- src/ucm/parser.c | 156 +++++++++++++++++++---------------------------- 2 files changed, 78 insertions(+), 111 deletions(-) diff --git a/src/ucm/main.c b/src/ucm/main.c index d054b564..9790565d 100644 --- a/src/ucm/main.c +++ b/src/ucm/main.c @@ -692,13 +692,13 @@ static int run_device_sequence(snd_use_case_mgr_t *uc_mgr, struct use_case_verb snd_trace(UCM, "device sequence '%s/%s': %s", verb->name, name, uc_mgr_enable_str(enable)); if (verb == NULL) { - snd_error(UCM, "error: enadev2 / disdev2 must be executed inside the verb context"); + snd_error(UCM, "enadev2 / disdev2 must be executed inside the verb context"); return -ENOENT; } device = find_device(uc_mgr, verb, name, 0); if (device == NULL) { - snd_error(UCM, "error: unable to find device '%s'\n", name); + snd_error(UCM, "unable to find device '%s'\n", name); return -ENOENT; } @@ -718,7 +718,7 @@ static int run_device_all_sequence(snd_use_case_mgr_t *uc_mgr, struct use_case_v snd_trace(UCM, "disable all devices sequence for '%s'", verb->name); if (verb == NULL) { - snd_error(UCM, "error: disdevall must be executed inside the verb context"); + snd_error(UCM, "disdevall must be executed inside the verb context"); return -ENOENT; } @@ -758,7 +758,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr, int err = 0; if (uc_mgr->sequence_hops > 100) { - snd_error(UCM, "error: too many inner sequences!"); + snd_error(UCM, "too many inner sequences!"); return -EINVAL; } uc_mgr->sequence_hops++; @@ -1500,7 +1500,7 @@ const char *parse_open_variables(snd_use_case_mgr_t *uc_mgr, const char *name) err = snd_config_load_string(&cfg, args, 0); if (err < 0) { - snd_error(UCM, "error: open arguments are not valid (%s)", args); + snd_error(UCM, "open arguments are not valid (%s)", args); goto skip; } @@ -1573,7 +1573,7 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr, if (err < 0) { if (err == -ENXIO && mgr->suppress_nodev_errors) goto _err; - snd_error(UCM, "error: failed to import %s use case configuration %d", + snd_error(UCM, "failed to import %s use case configuration %d", card_name, err); goto _err; @@ -1581,7 +1581,7 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr, err = check_empty_configuration(mgr); if (err < 0) { - snd_error(UCM, "error: failed to import %s (empty configuration)", card_name); + snd_error(UCM, "failed to import %s (empty configuration)", card_name); goto _err; } @@ -1613,7 +1613,7 @@ int snd_use_case_mgr_reload(snd_use_case_mgr_t *uc_mgr) /* reload all use cases */ err = import_master_config(uc_mgr); if (err < 0) { - snd_error(UCM, "error: failed to reload use cases"); + snd_error(UCM, "failed to reload use cases"); pthread_mutex_unlock(&uc_mgr->mutex); return -EINVAL; } @@ -2480,7 +2480,7 @@ static int set_fixedboot_user(snd_use_case_mgr_t *uc_mgr, int err; if (value != NULL && *value) { - snd_error(UCM, "error: wrong value for _fboot (%s)", value); + snd_error(UCM, "wrong value for _fboot (%s)", value); return -EINVAL; } if (list_empty(&uc_mgr->fixedboot_list)) @@ -2500,7 +2500,7 @@ static int set_boot_user(snd_use_case_mgr_t *uc_mgr, int err; if (value != NULL && *value) { - snd_error(UCM, "error: wrong value for _boot (%s)", value); + snd_error(UCM, "wrong value for _boot (%s)", value); return -EINVAL; } if (list_empty(&uc_mgr->boot_list)) @@ -2518,7 +2518,7 @@ static int set_defaults_user(snd_use_case_mgr_t *uc_mgr, const char *value) { if (value != NULL && *value) { - snd_error(UCM, "error: wrong value for _defaults (%s)", value); + snd_error(UCM, "wrong value for _defaults (%s)", value); return -EINVAL; } return set_defaults(uc_mgr, false); @@ -2581,8 +2581,7 @@ static int set_verb_user(snd_use_case_mgr_t *uc_mgr, if (verb) { err = set_verb(uc_mgr, verb, 1); if (err < 0) - snd_error(UCM, "error: failed to initialize new use case: %s", - verb_name); + snd_error(UCM, "failed to initialize new use case: %s", verb_name); } return err; @@ -2634,11 +2633,11 @@ static int switch_device(snd_use_case_mgr_t *uc_mgr, if (uc_mgr->active_verb == NULL) return -ENOENT; if (device_status(uc_mgr, old_device) == 0) { - snd_error(UCM, "error: device %s not enabled", old_device); + snd_error(UCM, "device %s not enabled", old_device); return -EINVAL; } if (device_status(uc_mgr, new_device) != 0) { - snd_error(UCM, "error: device %s already enabled", new_device); + snd_error(UCM, "device %s already enabled", new_device); return -EINVAL; } xold = find_device(uc_mgr, uc_mgr->active_verb, old_device, 1); @@ -2690,11 +2689,11 @@ static int switch_modifier(snd_use_case_mgr_t *uc_mgr, if (uc_mgr->active_verb == NULL) return -ENOENT; if (modifier_status(uc_mgr, old_modifier) == 0) { - snd_error(UCM, "error: modifier %s not enabled", old_modifier); + snd_error(UCM, "modifier %s not enabled", old_modifier); return -EINVAL; } if (modifier_status(uc_mgr, new_modifier) != 0) { - snd_error(UCM, "error: modifier %s already enabled", new_modifier); + snd_error(UCM, "modifier %s already enabled", new_modifier); return -EINVAL; } xold = find_modifier(uc_mgr, uc_mgr->active_verb, old_modifier, 1); diff --git a/src/ucm/parser.c b/src/ucm/parser.c index 1bf45d8d..d46ec87a 100644 --- a/src/ucm/parser.c +++ b/src/ucm/parser.c @@ -75,7 +75,7 @@ int uc_mgr_config_load_file(snd_use_case_mgr_t *uc_mgr, file); err = uc_mgr_config_load(uc_mgr->conf_format, filename, cfg); if (err < 0) { - snd_error(UCM, "error: failed to open file %s: %d", filename, err); + snd_error(UCM, "failed to open file %s: %d", filename, err); return err; } return 0; @@ -237,7 +237,7 @@ static int error_node(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) err = parse_string_substitute3(uc_mgr, cfg, &s); if (err < 0) { - snd_error(UCM, "error: failed to get Error string"); + snd_error(UCM, "failed to get Error string"); return err; } if (!uc_mgr->suppress_nodev_errors) @@ -309,7 +309,7 @@ static int evaluate_regex(snd_use_case_mgr_t *uc_mgr, if (err < 0) return err; if (id[0] == '@') { - snd_error(UCM, "error: value names starting with '@' are reserved for application variables"); + snd_error(UCM, "value names starting with '@' are reserved for application variables"); return -EINVAL; } err = uc_mgr_define_regex(uc_mgr, id, n); @@ -363,7 +363,7 @@ static int evaluate_define(snd_use_case_mgr_t *uc_mgr, return err; if (id[0] == '@') { free(s); - snd_error(UCM, "error: value names starting with '@' are reserved for application variables"); + snd_error(UCM, "value names starting with '@' are reserved for application variables"); return -EINVAL; } err = uc_mgr_set_variable(uc_mgr, id, s); @@ -925,8 +925,7 @@ static int parse_device_list(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, int err; if (dev_list->type != DEVLIST_NONE) { - snd_error(UCM, "error: multiple supported or" - " conflicting device lists"); + snd_error(UCM, "multiple supported or conflicting device lists"); return -EEXIST; } @@ -1033,7 +1032,7 @@ static int parse_component_seq(snd_use_case_mgr_t *uc_mgr, cmpt_seq->device = find_component_dev(uc_mgr, val); if (!cmpt_seq->device) { - snd_error(UCM, "error: Cannot find component device %s", val); + snd_error(UCM, "Cannot find component device %s", val); free(val); return -EINVAL; } @@ -1074,7 +1073,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr, const char *cmd = NULL; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - snd_error(UCM, "error: compound is expected for sequence definition"); + snd_error(UCM, "compound is expected for sequence definition"); return -EINVAL; } @@ -1087,7 +1086,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr, continue; if (idx == 1) { if (snd_config_get_type(n) != SND_CONFIG_TYPE_STRING) { - snd_error(UCM, "error: string type is expected for sequence command"); + snd_error(UCM, "string type is expected for sequence command"); return -EINVAL; } snd_config_get_string(n, &cmd); @@ -1104,7 +1103,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr, curr->type = SEQUENCE_ELEMENT_TYPE_CDEV; err = parse_string_substitute3(uc_mgr, n, &curr->data.cdev); if (err < 0) { - snd_error(UCM, "error: cdev requires a string!"); + snd_error(UCM, "cdev requires a string!"); return err; } continue; @@ -1115,7 +1114,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr, cset: err = parse_string_substitute3(uc_mgr, n, &curr->data.cset); if (err < 0) { - snd_error(UCM, "error: %s requires a string!", cmd); + snd_error(UCM, "%s requires a string!", cmd); return err; } continue; @@ -1129,7 +1128,7 @@ cset: strcmp(cmd, "enadev") == 0, &curr->data.cmpt_seq); if (err < 0) { - snd_error(UCM, "error: %s requires a valid device!", cmd); + snd_error(UCM, "%s requires a valid device!", cmd); return err; } continue; @@ -1145,7 +1144,7 @@ cset: device: err = parse_string_substitute3(uc_mgr, n, &curr->data.device); if (err < 0) { - snd_error(UCM, "error: %s requires a valid device!", cmd); + snd_error(UCM, "%s requires a valid device!", cmd); return err; } continue; @@ -1180,7 +1179,7 @@ device: curr->type = SEQUENCE_ELEMENT_TYPE_SYSSET; err = parse_string_substitute3(uc_mgr, n, &curr->data.sysw); if (err < 0) { - snd_error(UCM, "error: sysw requires a string!"); + snd_error(UCM, "sysw requires a string!"); return err; } continue; @@ -1190,7 +1189,7 @@ device: curr->type = SEQUENCE_ELEMENT_TYPE_SLEEP; err = parse_integer_substitute3(uc_mgr, n, &curr->data.sleep); if (err < 0) { - snd_error(UCM, "error: usleep requires integer!"); + snd_error(UCM, "usleep requires integer!"); return err; } continue; @@ -1200,7 +1199,7 @@ device: curr->type = SEQUENCE_ELEMENT_TYPE_SLEEP; err = parse_integer_substitute3(uc_mgr, n, &curr->data.sleep); if (err < 0) { - snd_error(UCM, "error: msleep requires integer!"); + snd_error(UCM, "msleep requires integer!"); return err; } curr->data.sleep *= 1000L; @@ -1212,7 +1211,7 @@ device: exec: err = parse_string_substitute3(uc_mgr, n, &curr->data.exec); if (err < 0) { - snd_error(UCM, "error: exec requires a string!"); + snd_error(UCM, "exec requires a string!"); return err; } continue; @@ -1227,7 +1226,7 @@ exec: curr->type = SEQUENCE_ELEMENT_TYPE_CFGSAVE; err = parse_string_substitute3(uc_mgr, n, &curr->data.cfgsave); if (err < 0) { - snd_error(UCM, "error: sysw requires a string!"); + snd_error(UCM, "sysw requires a string!"); return err; } continue; @@ -1236,7 +1235,7 @@ exec: if (strcmp(cmd, "comment") == 0) goto skip; - snd_error(UCM, "error: sequence command '%s' is ignored", cmd); + snd_error(UCM, "sequence command '%s' is ignored", cmd); skip: list_del(&curr->list); @@ -1289,7 +1288,7 @@ static int parse_value(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, int err; if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { - snd_error(UCM, "error: compound is expected for value definition"); + snd_error(UCM, "compound is expected for value definition"); return -EINVAL; } @@ -1312,19 +1311,19 @@ static int parse_value(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, case SND_CONFIG_TYPE_REAL: err = snd_config_get_ascii(n, &s); if (err < 0) { - snd_error(UCM, "error: unable to parse value for id '%s': %s!", id, snd_strerror(err)); + snd_error(UCM, "unable to parse value for id '%s': %s!", id, snd_strerror(err)); return err; } break; case SND_CONFIG_TYPE_STRING: err = parse_string_substitute(uc_mgr, n, &s); if (err < 0) { - snd_error(UCM, "error: unable to parse a string for id '%s'!", id); + snd_error(UCM, "unable to parse a string for id '%s'!", id); return err; } break; default: - snd_error(UCM, "error: invalid type %i in Value compound '%s'", type, id); + snd_error(UCM, "invalid type %i in Value compound '%s'", type, id); return -EINVAL; } err = uc_mgr_add_value(base, id, s); @@ -1421,7 +1420,7 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "Comment") == 0) { err = parse_string_substitute3(uc_mgr, n, &modifier->comment); if (err < 0) { - snd_error(UCM, "error: failed to get modifier comment"); + snd_error(UCM, "failed to get modifier comment"); return err; } continue; @@ -1431,9 +1430,7 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr, err = parse_device_list(uc_mgr, &modifier->dev_list, DEVLIST_SUPPORTED, n); if (err < 0) { - snd_error(UCM, "error: failed to parse supported" - " device list"); - + snd_error(UCM, "failed to parse supported device list"); return err; } } @@ -1442,9 +1439,7 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr, err = parse_device_list(uc_mgr, &modifier->dev_list, DEVLIST_CONFLICTING, n); if (err < 0) { - snd_error(UCM, "error: failed to parse conflicting" - " device list"); - + snd_error(UCM, "failed to parse conflicting device list"); return err; } } @@ -1452,9 +1447,7 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "EnableSequence") == 0) { err = parse_sequence(uc_mgr, &modifier->enable_list, n); if (err < 0) { - snd_error(UCM, "error: failed to parse modifier" - " enable sequence"); - + snd_error(UCM, "failed to parse modifier enable sequence"); return err; } continue; @@ -1463,9 +1456,7 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "DisableSequence") == 0) { err = parse_sequence(uc_mgr, &modifier->disable_list, n); if (err < 0) { - snd_error(UCM, "error: failed to parse modifier" - " disable sequence"); - + snd_error(UCM, "failed to parse modifier disable sequence"); return err; } continue; @@ -1474,9 +1465,7 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "TransitionSequence") == 0) { err = parse_transition(uc_mgr, &modifier->transition_list, n); if (err < 0) { - snd_error(UCM, "error: failed to parse transition" - " modifier"); - + snd_error(UCM, "failed to parse transition modifier"); return err; } continue; @@ -1485,7 +1474,7 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "Value") == 0) { err = parse_value(uc_mgr, &modifier->value_list, n); if (err < 0) { - snd_error(UCM, "error: failed to parse Value"); + snd_error(UCM, "failed to parse Value"); return err; } continue; @@ -1571,7 +1560,7 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "Comment") == 0) { err = parse_string_substitute3(uc_mgr, n, &device->comment); if (err < 0) { - snd_error(UCM, "error: failed to get device comment"); + snd_error(UCM, "failed to get device comment"); return err; } continue; @@ -1581,8 +1570,7 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, err = parse_device_list(uc_mgr, &device->dev_list, DEVLIST_SUPPORTED, n); if (err < 0) { - snd_error(UCM, "error: failed to parse supported" - " device list"); + snd_error(UCM, "failed to parse supported device list"); return err; } @@ -1592,8 +1580,7 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, err = parse_device_list(uc_mgr, &device->dev_list, DEVLIST_CONFLICTING, n); if (err < 0) { - snd_error(UCM, "error: failed to parse conflicting" - " device list"); + snd_error(UCM, "failed to parse conflicting device list"); return err; } @@ -1602,8 +1589,7 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "EnableSequence") == 0) { err = parse_sequence(uc_mgr, &device->enable_list, n); if (err < 0) { - snd_error(UCM, "error: failed to parse device enable" - " sequence"); + snd_error(UCM, "failed to parse device enable sequence"); return err; } @@ -1613,8 +1599,7 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "DisableSequence") == 0) { err = parse_sequence(uc_mgr, &device->disable_list, n); if (err < 0) { - snd_error(UCM, "error: failed to parse device disable" - " sequence"); + snd_error(UCM, "failed to parse device disable sequence"); return err; } @@ -1624,8 +1609,7 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "TransitionSequence") == 0) { err = parse_transition(uc_mgr, &device->transition_list, n); if (err < 0) { - snd_error(UCM, "error: failed to parse transition" - " device"); + snd_error(UCM, "failed to parse transition device"); return err; } @@ -1635,7 +1619,7 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "Value") == 0) { err = parse_value(uc_mgr, &device->value_list, n); if (err < 0) { - snd_error(UCM, "error: failed to parse Value"); + snd_error(UCM, "failed to parse Value"); return err; } continue; @@ -1686,7 +1670,7 @@ static int parse_dev_name_list(snd_use_case_mgr_t *uc_mgr, err = parse_string_substitute3(uc_mgr, n, &name2); if (err < 0) { free(name1s); - snd_error(UCM, "error: failed to get target device name for '%s'", name1); + snd_error(UCM, "failed to get target device name for '%s'", name1); return err; } @@ -1798,15 +1782,13 @@ static int verb_dev_list_add(struct use_case_verb *verb, if (list_empty(&device->dev_list.list)) { device->dev_list.type = dst_type; } else { - snd_error(UCM, "error: incompatible device list type ('%s', '%s')", - device->name, src); - + snd_error(UCM, "incompatible device list type ('%s', '%s')", device->name, src); return -EINVAL; } } return uc_mgr_put_to_dev_list(&device->dev_list, src); } - snd_error(UCM, "error: unable to find device '%s'", dst); + snd_error(UCM, "unable to find device '%s'", dst); return -ENOENT; } @@ -1841,7 +1823,7 @@ static int verb_device_management(struct use_case_verb *verb) dev = list_entry(pos, struct ucm_dev_name, list); err = uc_mgr_rename_device(verb, dev->name1, dev->name2); if (err < 0) { - snd_error(UCM, "error: cannot rename device '%s' to '%s'", dev->name1, dev->name2); + snd_error(UCM, "cannot rename device '%s' to '%s'", dev->name1, dev->name2); return err; } } @@ -1851,7 +1833,7 @@ static int verb_device_management(struct use_case_verb *verb) dev = list_entry(pos, struct ucm_dev_name, list); err = uc_mgr_remove_device(verb, dev->name2); if (err < 0) { - snd_error(UCM, "error: cannot remove device '%s'", dev->name2); + snd_error(UCM, "cannot remove device '%s'", dev->name2); return err; } } @@ -1924,7 +1906,7 @@ static int parse_verb(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "EnableSequence") == 0) { err = parse_sequence(uc_mgr, &verb->enable_list, n); if (err < 0) { - snd_error(UCM, "error: failed to parse verb enable sequence"); + snd_error(UCM, "failed to parse verb enable sequence"); return err; } continue; @@ -1933,7 +1915,7 @@ static int parse_verb(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "DisableSequence") == 0) { err = parse_sequence(uc_mgr, &verb->disable_list, n); if (err < 0) { - snd_error(UCM, "error: failed to parse verb disable sequence"); + snd_error(UCM, "failed to parse verb disable sequence"); return err; } continue; @@ -1943,7 +1925,7 @@ static int parse_verb(snd_use_case_mgr_t *uc_mgr, snd_debug(UCM, "Parse TransitionSequence"); err = parse_transition(uc_mgr, &verb->transition_list, n); if (err < 0) { - snd_error(UCM, "error: failed to parse transition sequence"); + snd_error(UCM, "failed to parse transition sequence"); return err; } continue; @@ -2029,9 +2011,7 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "SectionVerb") == 0) { err = parse_verb(uc_mgr, verb, n); if (err < 0) { - snd_error(UCM, "error: %s failed to parse verb", - file); - + snd_error(UCM, "%s failed to parse verb", file); goto _err; } continue; @@ -2042,9 +2022,7 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr, err = parse_compound(uc_mgr, n, parse_device_name, verb, NULL); if (err < 0) { - snd_error(UCM, "error: %s failed to parse device", - file); - + snd_error(UCM, "%s failed to parse device", file); goto _err; } continue; @@ -2055,9 +2033,7 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr, err = parse_compound(uc_mgr, n, parse_modifier_name, verb, NULL); if (err < 0) { - snd_error(UCM, "error: %s failed to parse modifier", - file); - + snd_error(UCM, "%s failed to parse modifier", file); goto _err; } continue; @@ -2067,9 +2043,7 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "RenameDevice") == 0) { err = parse_dev_name_list(uc_mgr, n, &verb->rename_list); if (err < 0) { - snd_error(UCM, "error: %s failed to parse device rename", - file); - + snd_error(UCM, " %s failed to parse device rename", file); goto _err; } continue; @@ -2079,9 +2053,7 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr, if (strcmp(id, "RemoveDevice") == 0) { err = parse_dev_name_list(uc_mgr, n, &verb->remove_list); if (err < 0) { - snd_error(UCM, "error: %s failed to parse device remove", - file); - + snd_error(UCM, "%s failed to parse device remove", file); goto _err; } continue; @@ -2091,7 +2063,7 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr, if (uc_mgr->conf_format > 3 && strcmp(id, "LibraryConfig") == 0) { err = parse_libconfig(uc_mgr, n); if (err < 0) { - snd_error(UCM, "error: failed to parse LibConfig"); + snd_error(UCM, "failed to parse LibConfig"); goto _err; } continue; @@ -2102,14 +2074,14 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr, /* use case verb must have at least 1 device */ if (list_empty(&verb->device_list)) { - snd_error(UCM, "error: no use case device defined", file); + snd_error(UCM, "no use case device defined", file); return -EINVAL; } /* do device rename and delete */ err = verb_device_management(verb); if (err < 0) { - snd_error(UCM, "error: device management error in verb '%s'", verb->name); + snd_error(UCM, "device management error in verb '%s'", verb->name); return err; } @@ -2155,7 +2127,7 @@ static int parse_variant(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, if (_vcomment) { err = parse_string_substitute3(uc_mgr, n, &comment); if (err < 0) { - snd_error(UCM, "error: failed to get Comment"); + snd_error(UCM, "failed to get Comment"); goto __error; } } @@ -2231,7 +2203,7 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, if (strncmp(id, "Comment", 7) == 0) { err = parse_string_substitute3(uc_mgr, n, &comment); if (err < 0) { - snd_error(UCM, "error: failed to get Comment"); + snd_error(UCM, "failed to get Comment"); goto __error; } continue; @@ -2259,7 +2231,7 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, } if (variant && !variant_ok) { - snd_error(UCM, "error: undefined variant '%s'", use_case_name); + snd_error(UCM, "undefined variant '%s'", use_case_name); err = -EINVAL; goto __error; } @@ -2269,7 +2241,7 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, /* do we have both use case name and file ? */ if (!file) { - snd_error(UCM, "error: use case missing file"); + snd_error(UCM, "use case missing file"); err = -EINVAL; goto __error; } @@ -2449,7 +2421,7 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) if (strcmp(id, "Comment") == 0) { err = parse_string_substitute3(uc_mgr, n, &uc_mgr->comment); if (err < 0) { - snd_error(UCM, "error: failed to get master comment"); + snd_error(UCM, "failed to get master comment"); return err; } continue; @@ -2493,7 +2465,7 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) if (strcmp(id, "ValueDefaults") == 0) { err = parse_value(uc_mgr, &uc_mgr->value_list, n); if (err < 0) { - snd_error(UCM, "error: failed to parse ValueDefaults"); + snd_error(UCM, "failed to parse ValueDefaults"); return err; } continue; @@ -2503,7 +2475,7 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg) if (uc_mgr->conf_format > 3 && strcmp(id, "LibraryConfig") == 0) { err = parse_libconfig(uc_mgr, n); if (err < 0) { - snd_error(UCM, "error: failed to parse LibraryConfig"); + snd_error(UCM, "failed to parse LibraryConfig"); return err; } continue; @@ -2779,7 +2751,7 @@ static int parse_toplevel_config(snd_use_case_mgr_t *uc_mgr, if (uc_mgr->conf_format > 3 && strcmp(id, "LibraryConfig") == 0) { err = parse_libconfig(uc_mgr, n); if (err < 0) { - snd_error(UCM, "error: failed to parse LibConfig"); + snd_error(UCM, "failed to parse LibConfig"); return err; } continue; @@ -2821,9 +2793,7 @@ static int load_toplevel_config(snd_use_case_mgr_t *uc_mgr, err = uc_mgr_config_load(uc_mgr->conf_format, filename, cfg); if (err < 0) { - snd_error(UCM, "error: could not parse configuration for card %s", - uc_mgr->card_name); - + snd_error(UCM, "could not parse configuration for card %s", uc_mgr->card_name); goto __error; } @@ -2956,9 +2926,7 @@ int uc_mgr_scan_master_configs(const char **_list[]) err = scandir64(filename, &namelist, filename_filter, SORTFUNC); if (err < 0) { err = -errno; - snd_error(UCM, "error: could not scan directory %s: %s", - filename, strerror(-err)); - + snd_error(UCM, "could not scan directory %s: %s", filename, strerror(-err)); return err; } cnt = err; From bd0ce670c2f2d3eb14f9f5cc153f7112199b96da Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 17:59:12 +0100 Subject: [PATCH 27/34] ucm: fix variant issue where variables or macros are overwritten It is necessary to reset the state logic before each verb variant is parsed. So save the original variable list and macros and restore them before each parser iteration. BugLink: https://github.com/alsa-project/alsa-ucm-conf/pull/633 Signed-off-by: Jaroslav Kysela --- src/ucm/parser.c | 46 ++++++++++++++++++++++++++++++++++++++++++++- src/ucm/ucm_local.h | 4 ++++ src/ucm/utils.c | 33 ++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/src/ucm/parser.c b/src/ucm/parser.c index d46ec87a..7a8c6d39 100644 --- a/src/ucm/parser.c +++ b/src/ucm/parser.c @@ -2250,15 +2250,52 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, err = parse_verb_file(uc_mgr, use_case_name, comment, file); } else { /* parse variants */ + struct list_head orig_variable_list; + snd_config_t *orig_macros = NULL; + int first_iteration = 1; + + /* save original variable list */ + err = uc_mgr_duplicate_variables(&orig_variable_list, &uc_mgr->variable_list); + if (err < 0) + goto __error; + + /* save original macros */ + if (uc_mgr->macros) { + err = snd_config_copy(&orig_macros, uc_mgr->macros); + if (err < 0) + goto __variant_error; + } + snd_config_for_each(i, next, variant) { char *vfile, *vcomment; const char *id; + + /* restore variables and macros for second and later iterations */ + if (!first_iteration) { + uc_mgr_free_value(&uc_mgr->variable_list); + + err = uc_mgr_duplicate_variables(&uc_mgr->variable_list, &orig_variable_list); + if (err < 0) + goto __variant_error; + + if (uc_mgr->macros) { + snd_config_delete(uc_mgr->macros); + uc_mgr->macros = NULL; + } + if (orig_macros) { + err = snd_config_copy(&uc_mgr->macros, orig_macros); + if (err < 0) + goto __variant_error; + } + } + first_iteration = 0; + n = snd_config_iterator_entry(i); if (snd_config_get_id(n, &id) < 0) continue; if (!parse_is_name_safe(id)) { err = -EINVAL; - goto __error; + goto __variant_error; } err = parse_variant(uc_mgr, n, &vfile, &vcomment); if (err < 0) @@ -2270,7 +2307,14 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg, uc_mgr->parse_variant = NULL; free(vfile); free(vcomment); + if (err < 0) + break; } + +__variant_error: + uc_mgr_free_value(&orig_variable_list); + if (orig_macros) + snd_config_delete(orig_macros); } __error: diff --git a/src/ucm/ucm_local.h b/src/ucm/ucm_local.h index 18b29871..5e9b23fb 100644 --- a/src/ucm/ucm_local.h +++ b/src/ucm/ucm_local.h @@ -327,6 +327,8 @@ struct ctl_list *uc_mgr_get_ctl_by_name(snd_use_case_mgr_t *uc_mgr, snd_ctl_t *uc_mgr_get_ctl(snd_use_case_mgr_t *uc_mgr); void uc_mgr_free_ctl_list(snd_use_case_mgr_t *uc_mgr); +void uc_mgr_free_value(struct list_head *base); + int uc_mgr_add_value(struct list_head *base, const char *key, char *val); const char *uc_mgr_get_variable(snd_use_case_mgr_t *uc_mgr, @@ -338,6 +340,8 @@ int uc_mgr_set_variable(snd_use_case_mgr_t *uc_mgr, int uc_mgr_delete_variable(snd_use_case_mgr_t *uc_mgr, const char *name); +int uc_mgr_duplicate_variables(struct list_head *dst, struct list_head *src); + int uc_mgr_get_substituted_value(snd_use_case_mgr_t *uc_mgr, char **_rvalue, const char *value); diff --git a/src/ucm/utils.c b/src/ucm/utils.c index 67d51226..8b591cee 100644 --- a/src/ucm/utils.c +++ b/src/ucm/utils.c @@ -733,6 +733,39 @@ int uc_mgr_delete_variable(snd_use_case_mgr_t *uc_mgr, const char *name) return -ENOENT; } +int uc_mgr_duplicate_variables(struct list_head *dst, struct list_head *src) +{ + struct list_head *pos; + struct ucm_value *var, *new_var; + int err; + + INIT_LIST_HEAD(dst); + + list_for_each(pos, src) { + var = list_entry(pos, struct ucm_value, list); + new_var = calloc(1, sizeof(*new_var)); + if (new_var == NULL) { + err = -ENOMEM; + goto __error; + } + new_var->name = strdup(var->name); + new_var->data = strdup(var->data); + if (new_var->name == NULL || new_var->data == NULL) { + free(new_var->name); + free(new_var->data); + free(new_var); + err = -ENOMEM; + goto __error; + } + list_add_tail(&new_var->list, dst); + } + return 0; + +__error: + uc_mgr_free_value(dst); + return err; +} + void uc_mgr_free_verb(snd_use_case_mgr_t *uc_mgr) { struct list_head *pos, *npos; From 509e77c8696b631a0af460aa541fdb58618991cf Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 20:06:33 +0100 Subject: [PATCH 28/34] pcm route: suppress false positive warning for gcc 8+ Signed-off-by: Jaroslav Kysela --- src/pcm/pcm_route.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index 2fd84e83..29fb51e9 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -325,7 +325,12 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area, #endif zero_end: for (srcidx = 0; srcidx < nsrcs; ++srcidx) { - const char *src = srcs[srcidx]; + const char *src; +#if defined(__GNUC__) && __GNUC__ >= 8 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif + src = srcs[srcidx]; /* Get sample */ goto *get32; @@ -333,6 +338,9 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area, #include "plugin_ops.h" #undef GET32_END after_get: +#if defined(__GNUC__) && __GNUC__ >= 8 +#pragma GCC diagnostic pop +#endif /* Sum */ goto *add; From 18646517f8b1e012db8b4a154fc91c05095f595b Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 20:55:07 +0100 Subject: [PATCH 29/34] test: ucm - remove old syntax configuration files (incomplete anyway) Signed-off-by: Jaroslav Kysela --- test/ucm/TestHDA/Case1.conf | 25 ------------------------- test/ucm/TestHDA/TestHDA.conf | 13 ------------- test/ucm/anothercard/anothercard.conf | 1 - test/ucm/testcard1/testcard1.conf | 0 4 files changed, 39 deletions(-) delete mode 100644 test/ucm/TestHDA/Case1.conf delete mode 100644 test/ucm/TestHDA/TestHDA.conf delete mode 100644 test/ucm/anothercard/anothercard.conf delete mode 100644 test/ucm/testcard1/testcard1.conf diff --git a/test/ucm/TestHDA/Case1.conf b/test/ucm/TestHDA/Case1.conf deleted file mode 100644 index 81b24458..00000000 --- a/test/ucm/TestHDA/Case1.conf +++ /dev/null @@ -1,25 +0,0 @@ -SectionVerb { - EnableSequence [ - exec "Case1 enable seq" - exec "Case1 enable seq 2" - ] - DisableSequence [ - exec "Case2 disable seq" - ] - TransitionVerb."Case2" [ - exec "Case1->Case2 transition seq" - ] - Value { - TestValue1 "123" - } -} - -SectionDevice."Device1".0 { - -} - -SectionModifier."Modifier1".0 { - SupportedDevice [ - "Device1" - ] -} diff --git a/test/ucm/TestHDA/TestHDA.conf b/test/ucm/TestHDA/TestHDA.conf deleted file mode 100644 index 41dd74c8..00000000 --- a/test/ucm/TestHDA/TestHDA.conf +++ /dev/null @@ -1,13 +0,0 @@ -Comment "A test HDA card" - -SectionUseCase."Case1" { - File "Case1.conf" - Comment "Case1 Comment" -} - -SectionDefaults [ - exec "my prg" - msleep 1 - cdev "hw:0" - cset "name='PCM Playback Volume' 50%" -] diff --git a/test/ucm/anothercard/anothercard.conf b/test/ucm/anothercard/anothercard.conf deleted file mode 100644 index 3d9ed7de..00000000 --- a/test/ucm/anothercard/anothercard.conf +++ /dev/null @@ -1 +0,0 @@ -Comment "Another Card" diff --git a/test/ucm/testcard1/testcard1.conf b/test/ucm/testcard1/testcard1.conf deleted file mode 100644 index e69de29b..00000000 From b33d0e4ced06b670093f2e12c4a3c6dd38cb7118 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Fri, 1 Aug 2025 18:02:57 +0200 Subject: [PATCH 30/34] conf/pistachio: fix syntax It was missing closing brackets since its introduction. Closes: https://github.com/alsa-project/alsa-lib/pull/470 Fixes: 4dfa8f08fb83 ("conf/cards: add support for pistachio-card.") Signed-off-by: Olivier Blin Signed-off-by: Jaroslav Kysela --- src/conf/cards/pistachio-card.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conf/cards/pistachio-card.conf b/src/conf/cards/pistachio-card.conf index 59cd920e..f68865eb 100644 --- a/src/conf/cards/pistachio-card.conf +++ b/src/conf/cards/pistachio-card.conf @@ -55,4 +55,5 @@ pistachio-card.pcm.default{ type hw card $CARD device $DEVICE - + } +} From 2b6dedeb74acd5e8adbef5080d62c66507a6af3d Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 21:30:32 +0100 Subject: [PATCH 31/34] doxygen: fix warnings and add missing ALSA_LIBRARY_BUILD define BugLink: https://github.com/alsa-project/alsa-lib/pull/480 Signed-off-by: Jaroslav Kysela --- doc/doxygen.cfg.in | 4 +--- include/asoundef.h | 2 +- include/conf.h | 2 +- include/control.h | 2 +- include/error.h | 6 +++--- include/global.h | 2 +- include/hwdep.h | 2 +- include/mixer.h | 2 +- include/pcm.h | 2 +- include/pcm_extplug.h | 2 +- include/pcm_ioplug.h | 2 +- include/pcm_plugin.h | 24 ++++++++++++++++++++++++ include/rawmidi.h | 4 ++-- include/seq.h | 2 +- include/seq_event.h | 2 +- include/seqmid.h | 2 +- include/timer.h | 2 +- include/ump.h | 2 +- src/error.c | 4 ++++ src/pcm/pcm_hw.c | 2 ++ 20 files changed, 50 insertions(+), 22 deletions(-) diff --git a/doc/doxygen.cfg.in b/doc/doxygen.cfg.in index bcc3a33e..c94f961e 100644 --- a/doc/doxygen.cfg.in +++ b/doc/doxygen.cfg.in @@ -127,7 +127,7 @@ INHERIT_DOCS = YES ENABLED_SECTIONS = "" MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES -PREDEFINED = DOXYGEN PIC "DOC_HIDDEN" \ +PREDEFINED = DOXYGEN PIC "DOC_HIDDEN" "ALSA_LIBRARY_BUILD" \ "ATTRIBUTE_UNUSED=" \ ALSA_PCM_NEW_HW_PARAMS_API \ _POSIX_C_SOURCE \ @@ -140,5 +140,3 @@ TYPEDEF_HIDES_STRUCT = YES # needed in doxygen >= 1.5.4 #INPUT_FILTER = inputfilter #FILTER_SOURCE_FILES = YES - -HTML_TIMESTAMP = NO diff --git a/include/asoundef.h b/include/asoundef.h index 5e158b35..18d5c575 100644 --- a/include/asoundef.h +++ b/include/asoundef.h @@ -32,7 +32,7 @@ #endif #ifndef __ALSA_ASOUNDEF_H -#define __ALSA_ASOUNDEF_H +#define __ALSA_ASOUNDEF_H /**< header include loop protection */ #ifdef __cplusplus extern "C" { diff --git a/include/conf.h b/include/conf.h index 2a6d8296..827396c5 100644 --- a/include/conf.h +++ b/include/conf.h @@ -31,7 +31,7 @@ #endif #ifndef __ALSA_CONF_H -#define __ALSA_CONF_H +#define __ALSA_CONF_H /**< header include loop protection */ #ifdef __cplusplus extern "C" { diff --git a/include/control.h b/include/control.h index e670e6c1..e96cc068 100644 --- a/include/control.h +++ b/include/control.h @@ -32,7 +32,7 @@ #endif #ifndef __ALSA_CONTROL_H -#define __ALSA_CONTROL_H +#define __ALSA_CONTROL_H /**< header include loop protection */ #ifdef __cplusplus extern "C" { diff --git a/include/error.h b/include/error.h index faeff8e0..ce3582bf 100644 --- a/include/error.h +++ b/include/error.h @@ -32,7 +32,7 @@ #endif #ifndef __ALSA_ERROR_H -#define __ALSA_ERROR_H +#define __ALSA_ERROR_H /**< header include loop protection */ #ifdef __cplusplus extern "C" { @@ -54,7 +54,7 @@ const char *snd_strerror(int errnum); #define SND_LOG_INFO 3 /**< info priority level */ #define SND_LOG_DEBUG 4 /**< debug priority level */ #define SND_LOG_TRACE 5 /**< trace priority level */ -#define SND_LOG_LAST SND_LOG_TRACE +#define SND_LOG_LAST SND_LOG_TRACE /**< last known value for priority level */ #define SND_ILOG_CORE 1 /**< core library code */ #define SND_ILOG_CONFIG 2 /**< configuration parsing and operations */ @@ -68,7 +68,7 @@ const char *snd_strerror(int errnum); #define SND_ILOG_UCM 10 /**< UCM API */ #define SND_ILOG_TOPOLOGY 11 /**< topology API */ #define SND_ILOG_ASERVER 12 /**< aserver */ -#define SND_ILOG_LAST SND_ILOG_ASERVER +#define SND_ILOG_LAST SND_ILOG_ASERVER /**< last known value for interface */ /** * \brief Log handler callback. diff --git a/include/global.h b/include/global.h index ae706133..40fe2ca8 100644 --- a/include/global.h +++ b/include/global.h @@ -32,7 +32,7 @@ #endif #ifndef __ALSA_GLOBAL_H_ -#define __ALSA_GLOBAL_H_ +#define __ALSA_GLOBAL_H_ /**< header include loop protection */ #ifdef __cplusplus extern "C" { diff --git a/include/hwdep.h b/include/hwdep.h index 174aa899..cadc60b5 100644 --- a/include/hwdep.h +++ b/include/hwdep.h @@ -32,7 +32,7 @@ #endif #ifndef __ALSA_HWDEP_H -#define __ALSA_HWDEP_H +#define __ALSA_HWDEP_H /**< header include loop protection */ #ifdef __cplusplus extern "C" { diff --git a/include/mixer.h b/include/mixer.h index f9c6026c..329d1faa 100644 --- a/include/mixer.h +++ b/include/mixer.h @@ -32,7 +32,7 @@ #endif #ifndef __ALSA_MIXER_H -#define __ALSA_MIXER_H +#define __ALSA_MIXER_H /**< header include loop protection */ #ifdef __cplusplus extern "C" { diff --git a/include/pcm.h b/include/pcm.h index 74020511..f8c84875 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -33,7 +33,7 @@ #endif #ifndef __ALSA_PCM_H -#define __ALSA_PCM_H +#define __ALSA_PCM_H /**< header include loop protection */ #ifdef __cplusplus extern "C" { diff --git a/include/pcm_extplug.h b/include/pcm_extplug.h index 9049783c..a8239c4c 100644 --- a/include/pcm_extplug.h +++ b/include/pcm_extplug.h @@ -34,7 +34,7 @@ #endif #ifndef __ALSA_PCM_EXTPLUG_H -#define __ALSA_PCM_EXTPLUG_H +#define __ALSA_PCM_EXTPLUG_H /**< header include loop protection */ /** * \defgroup PCM_ExtPlug External Filter plugin SDK diff --git a/include/pcm_ioplug.h b/include/pcm_ioplug.h index c41c5c1f..4777123f 100644 --- a/include/pcm_ioplug.h +++ b/include/pcm_ioplug.h @@ -34,7 +34,7 @@ #endif #ifndef __ALSA_PCM_IOPLUG_H -#define __ALSA_PCM_IOPLUG_H +#define __ALSA_PCM_IOPLUG_H /**< header include loop protection */ /** * \defgroup PCM_IOPlug External I/O plugin SDK diff --git a/include/pcm_plugin.h b/include/pcm_plugin.h index fa95590d..35be5e59 100644 --- a/include/pcm_plugin.h +++ b/include/pcm_plugin.h @@ -202,10 +202,34 @@ int _snd_pcm_ladspa_open(snd_pcm_t **pcmp, const char *name, /* * Jack plugin */ + +/** + * \brief Creates a new Jack PCM + * \param pcmp Returns created PCM handle + * \param name Name of PCM + * \param playback_conf Playback configuration + * \param capture_conf Capture configuration + * \param stream Stream direction + * \param mode PCM open mode + * \retval zero on success otherwise a negative error code + * \warning alsa-lib must be compiled against the JACK library for this plugin to be available + */ int snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name, snd_config_t *playback_conf, snd_config_t *capture_conf, snd_pcm_stream_t stream, int mode); + +/** + * \brief Creates a new Jack PCM (internal) + * \param pcmp Returns created PCM handle + * \param name Name of PCM + * \param root Root configuration node + * \param conf Configuration for this PCM + * \param stream Stream direction + * \param mode PCM open mode + * \retval zero on success otherwise a negative error code + * \warning alsa-lib must be compiled against the JACK library for this plugin to be available + */ int _snd_pcm_jack_open(snd_pcm_t **pcmp, const char *name, snd_config_t *root, snd_config_t *conf, snd_pcm_stream_t stream, int mode); diff --git a/include/rawmidi.h b/include/rawmidi.h index 554e706f..8031e1ed 100644 --- a/include/rawmidi.h +++ b/include/rawmidi.h @@ -32,7 +32,7 @@ #endif #ifndef __ALSA_RAWMIDI_H -#define __ALSA_RAWMIDI_H +#define __ALSA_RAWMIDI_H /**< header include loop protection */ #ifdef __cplusplus extern "C" { @@ -103,7 +103,7 @@ typedef enum _snd_rawmidi_read_mode { #define SND_RAWMIDI_INFO_UMP 0x00000008 /**< rawmidi is UMP */ #define SND_RAWMIDI_INFO_STREAM_INACTIVE 0x00000010 /**< the selected substream is inactive */ #ifndef SNDRV_RAWMIDI_INFO_STREAM_INACTIVE -#define SNDRV_RAWMIDI_INFO_STREAM_INACTIVE SND_RAWMIDI_INFO_STREAM_INACTIVE /* only for compatibility */ +#define SNDRV_RAWMIDI_INFO_STREAM_INACTIVE SND_RAWMIDI_INFO_STREAM_INACTIVE /**< compatibility alias for SND_RAWMIDI_INFO_STREAM_INACTIVE */ #endif int snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi, diff --git a/include/seq.h b/include/seq.h index 686f69dd..ece42cca 100644 --- a/include/seq.h +++ b/include/seq.h @@ -33,7 +33,7 @@ #endif #ifndef __ALSA_SEQ_H -#define __ALSA_SEQ_H +#define __ALSA_SEQ_H /**< header include loop protection */ #ifdef __cplusplus extern "C" { diff --git a/include/seq_event.h b/include/seq_event.h index 268578b8..c4054c9f 100644 --- a/include/seq_event.h +++ b/include/seq_event.h @@ -32,7 +32,7 @@ #endif #ifndef __ALSA_SEQ_EVENT_H -#define __ALSA_SEQ_EVENT_H +#define __ALSA_SEQ_EVENT_H /**< header include loop protection */ /** * \defgroup SeqEvents Sequencer Event Definitions diff --git a/include/seqmid.h b/include/seqmid.h index 1df03bad..c93428f8 100644 --- a/include/seqmid.h +++ b/include/seqmid.h @@ -32,7 +32,7 @@ #endif #ifndef __ALSA_SEQMID_H -#define __ALSA_SEQMID_H +#define __ALSA_SEQMID_H /**< header include loop protection */ #ifdef __cplusplus extern "C" { diff --git a/include/timer.h b/include/timer.h index 7a41331a..42e1942e 100644 --- a/include/timer.h +++ b/include/timer.h @@ -32,7 +32,7 @@ #endif #ifndef __ALSA_TIMER_H -#define __ALSA_TIMER_H +#define __ALSA_TIMER_H /**< header include loop protection */ #ifdef __cplusplus extern "C" { diff --git a/include/ump.h b/include/ump.h index d19ab557..54144e70 100644 --- a/include/ump.h +++ b/include/ump.h @@ -13,7 +13,7 @@ #endif #ifndef __ALSA_UMP_H -#define __ALSA_UMP_H +#define __ALSA_UMP_H /**< header include loop protection */ #ifdef __cplusplus extern "C" { diff --git a/src/error.c b/src/error.c index 1f4de78e..e6ed6abb 100644 --- a/src/error.c +++ b/src/error.c @@ -419,7 +419,9 @@ snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func local_error = func; return old; } +#ifndef DOC_HIDDEN link_warning(snd_lib_error_set_local, "Warning: snd_lib_error_set_local is deprecated, use snd_lib_log_set_local"); +#endif /** * \brief The default error handler function. @@ -448,7 +450,9 @@ static void snd_lib_error_default(const char *file, int line, const char *functi * For internal use only. */ snd_lib_error_handler_t snd_lib_error = snd_lib_error_default; +#ifndef DOC_HIDDEN link_warning(snd_lib_error, "Warning: snd_lib_error is deprecated, use snd_log interface"); +#endif /** * \brief Sets the error handler. diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index e4dc9085..efd838d3 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -379,8 +379,10 @@ static int snd_pcm_hw_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) return 0; } +#ifndef DOC_HIDDEN #define hw_param_mask(params,var) \ &((params)->masks[(var) - SND_PCM_HW_PARAM_FIRST_MASK]) +#endif static int hw_params_call(snd_pcm_hw_t *pcm_hw, snd_pcm_hw_params_t *params) { From ea0a075c408a7905a9ee89b76e55f27eec119be7 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 21:51:43 +0100 Subject: [PATCH 32/34] ucm: add missing stdbool.h include to ucm_local.h Signed-off-by: Jaroslav Kysela --- src/ucm/ucm_local.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ucm/ucm_local.h b/src/ucm/ucm_local.h index 5e9b23fb..bf7bc392 100644 --- a/src/ucm/ucm_local.h +++ b/src/ucm/ucm_local.h @@ -32,6 +32,7 @@ #include "local.h" #include +#include #include "use-case.h" #define SYNTAX_VERSION_MAX 8 From f77ab152b88f725b812997f02d91c616b5437ce8 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 7 Nov 2025 21:52:31 +0100 Subject: [PATCH 33/34] doc: add missing include pcm_plugin.h to source files Signed-off-by: Jaroslav Kysela --- doc/doxygen.cfg.in | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/doxygen.cfg.in b/doc/doxygen.cfg.in index c94f961e..753a4cb9 100644 --- a/doc/doxygen.cfg.in +++ b/doc/doxygen.cfg.in @@ -16,6 +16,7 @@ INPUT = @top_srcdir@/doc/index.doxygen \ @top_srcdir@/include/conf.h \ @top_srcdir@/include/control.h \ @top_srcdir@/include/pcm.h \ + @top_srcdir@/include/pcm_plugin.h \ @top_srcdir@/include/rawmidi.h \ @top_srcdir@/include/ump.h \ @top_srcdir@/include/ump_msg.h \ From 41039b49ad3e20506134864028c77aeaba4c0d51 Mon Sep 17 00:00:00 2001 From: qaqland Date: Mon, 15 Sep 2025 14:01:18 +0800 Subject: [PATCH 34/34] snd_tlv_convert_to_dB: Fix mute handling for MINMAX_MUTE type Ensure the SND_CTL_TLV_DB_GAIN_MUTE value is returned when the calculated gain equals the minimum dB value for the SNDRV_CTL_TLVT_DB_MINMAX_MUTE type. The previous check based solely on the volume value could miss cases where the linear calculation resulted in the minimum gain. Closes: https://github.com/alsa-project/alsa-lib/pull/478 Signed-off-by: qaqland Signed-off-by: Jaroslav Kysela --- src/control/tlv.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/control/tlv.c b/src/control/tlv.c index cc60703d..271da984 100644 --- a/src/control/tlv.c +++ b/src/control/tlv.c @@ -246,16 +246,17 @@ int snd_tlv_convert_to_dB(unsigned int *tlv, long rangemin, long rangemax, int mindb, maxdb; mindb = tlv[SNDRV_CTL_TLVO_DB_MINMAX_MIN]; maxdb = tlv[SNDRV_CTL_TLVO_DB_MINMAX_MAX]; - if (volume <= rangemin || rangemax <= rangemin) { - if (type == SND_CTL_TLVT_DB_MINMAX_MUTE) - *db_gain = SND_CTL_TLV_DB_GAIN_MUTE; - else - *db_gain = mindb; - } else if (volume >= rangemax) - *db_gain = maxdb; + if (rangemax <= rangemin) + *db_gain = mindb; else *db_gain = (maxdb - mindb) * (volume - rangemin) / (rangemax - rangemin) + mindb; + if (*db_gain < mindb) + *db_gain = mindb; + if (*db_gain > maxdb) + *db_gain = maxdb; + if (type == SND_CTL_TLVT_DB_MINMAX_MUTE && *db_gain == mindb) + *db_gain = SND_CTL_TLV_DB_GAIN_MUTE; return 0; } #ifndef HAVE_SOFT_FLOAT