aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/alsa/alsa-api-mixer.c4
-rw-r--r--plugins/alsa/alsa-bluez.c2
-rw-r--r--plugins/alsa/alsa-bluez.h2
-rw-r--r--plugins/alsa/alsa-core-pcm.c80
-rw-r--r--plugins/alsa/alsa-ringbuf.c2
-rw-r--r--plugins/alsa/alsa-ringbuf.h2
6 files changed, 41 insertions, 51 deletions
diff --git a/plugins/alsa/alsa-api-mixer.c b/plugins/alsa/alsa-api-mixer.c
index f8222df..171046b 100644
--- a/plugins/alsa/alsa-api-mixer.c
+++ b/plugins/alsa/alsa-api-mixer.c
@@ -664,8 +664,8 @@ static void MixerBluezAlsaDevVerb(AFB_ReqT request) {
}
parsed:
- printf("%s: interface %s, device %s, profile %s\n", __func__, interface, device, profile);
- error = alsa_bluez_set_device(interface, device, profile);
+ AFB_ApiNotice(mixer->api, "%s: interface %s, device %s, profile %s\n", __func__, interface, device, profile);
+ error = alsa_bluez_set_remote_device(interface, device, profile);
if (error) {
AFB_ReqFailF(request,
"runtime error",
diff --git a/plugins/alsa/alsa-bluez.c b/plugins/alsa/alsa-bluez.c
index 53612df..080c3c8 100644
--- a/plugins/alsa/alsa-bluez.c
+++ b/plugins/alsa/alsa-bluez.c
@@ -61,7 +61,7 @@ failed:
return;
}
-int alsa_bluez_set_device(const char * interface, const char * device, const char * profile) {
+int alsa_bluez_set_remote_device(const char * interface, const char * device, const char * profile) {
if (!bluealsa_proxy_set_remote_device)
return -1;
diff --git a/plugins/alsa/alsa-bluez.h b/plugins/alsa/alsa-bluez.h
index 85d153a..c288d38 100644
--- a/plugins/alsa/alsa-bluez.h
+++ b/plugins/alsa/alsa-bluez.h
@@ -24,6 +24,6 @@
#include <alsa/asoundlib.h>
extern void alsa_bluez_init();
-extern int alsa_bluez_set_device(const char * interface, const char * device, const char * profile);
+extern int alsa_bluez_set_remote_device(const char * interface, const char * device, const char * profile);
#endif /* __INC_ALSA_BLUEZ_H */
diff --git a/plugins/alsa/alsa-core-pcm.c b/plugins/alsa/alsa-core-pcm.c
index f41aed0..25872ae 100644
--- a/plugins/alsa/alsa-core-pcm.c
+++ b/plugins/alsa/alsa-core-pcm.c
@@ -165,7 +165,7 @@ PUBLIC int AlsaPcmConf(SoftMixerT *mixer, AlsaPcmCtlT *pcm, int mode) {
error = snd_pcm_hw_params_get_buffer_time_max(pxmHwParams, &buffer_time, 0);
- printf("HW_BUFFER_TIME MAX is %d\n", buffer_time);
+ AFB_ApiInfo(mixer->api, "HW_BUFFER_TIME MAX is %d\n", buffer_time);
if (buffer_time > 500000)
buffer_time = 500000;
@@ -178,11 +178,11 @@ PUBLIC int AlsaPcmConf(SoftMixerT *mixer, AlsaPcmCtlT *pcm, int mode) {
}
if (period_time > 0) {
- printf("SET PERIOD TIME to %d\n", period_time);
+ AFB_ApiInfo(mixer->api, "SET PERIOD TIME to %d", period_time);
error = snd_pcm_hw_params_set_period_time_near(pcm->handle, pxmHwParams, &period_time, 0);
}
else {
- printf("SET PERIOD SIZE\n");
+ AFB_ApiInfo(mixer->api, "SET PERIOD SIZE...");
error = snd_pcm_hw_params_set_period_size_near(pcm->handle, pxmHwParams, &period_frames, 0);
}
@@ -194,10 +194,10 @@ PUBLIC int AlsaPcmConf(SoftMixerT *mixer, AlsaPcmCtlT *pcm, int mode) {
}
if (buffer_time > 0) {
- printf("SET BUFFER TIME to %d\n", buffer_time);
+ AFB_ApiInfo(mixer->api, "SET BUFFER TIME to %d", buffer_time);
error = snd_pcm_hw_params_set_buffer_time_near(pcm->handle, pxmHwParams, &buffer_time, 0);
} else {
- printf("SET BUFFER SIZE\n");
+ AFB_ApiInfo(mixer->api, "SET BUFFER SIZE...");
error = snd_pcm_hw_params_set_buffer_size_near(pcm->handle, pxmHwParams, &buffer_frames);
}
@@ -285,7 +285,7 @@ PUBLIC int AlsaPcmConf(SoftMixerT *mixer, AlsaPcmCtlT *pcm, int mode) {
if (start_threshold > n/2)
start_threshold = n/2;
- printf("CALCULATED START THRESHOLD: %ld\n", start_threshold);
+ AFB_ApiInfo(mixer->api, "CALCULATED START THRESHOLD: %ld", start_threshold);
if (mode == SND_PCM_STREAM_PLAYBACK) {
start_threshold = 1;
@@ -353,24 +353,14 @@ STATIC int AlsaPcmReadCB( struct pollfd * pfd, AlsaPcmCopyHandleT * pcmCopyHandl
goto ExitOnSuccess;
}
- pthread_mutex_lock(&pcmCopyHandle->mutex);
- snd_pcm_sframes_t availInBuf = alsa_ringbuf_frames_free(rbuf);
- pthread_mutex_unlock(&pcmCopyHandle->mutex);
-
- /* we get too much data, take what we can now,
- * hopefully we will have more luck next time */
-
- if (availIn > availInBuf) {
-// printf("INCOMING BUFFER TOO SMALL !\n");
- availIn = availInBuf;
- }
-
while (true) {
+ snd_pcm_sframes_t nbRead;
+
pthread_mutex_lock(&pcmCopyHandle->mutex);
- snd_pcm_sframes_t r = alsa_ringbuf_frames_free(rbuf);
+ snd_pcm_sframes_t remain = alsa_ringbuf_frames_remain_capacity(rbuf);
- if (r <= 0) {
+ if (remain <= 0) {
pthread_mutex_unlock(&pcmCopyHandle->mutex);
// Wake up the reader, in case it is sleeping,
// that lets it an opportunity to pop something.
@@ -378,33 +368,33 @@ STATIC int AlsaPcmReadCB( struct pollfd * pfd, AlsaPcmCopyHandleT * pcmCopyHandl
break;
}
- if (r < availIn)
- r = availIn;
+ if (remain < availIn)
+ remain = availIn;
- char buf[r*pcmCopyHandle->frame_size];
+ char buf[remain*pcmCopyHandle->frame_size];
pthread_mutex_unlock(&pcmCopyHandle->mutex);
- r = snd_pcm_readi(pcmIn, buf, r);
+ nbRead = snd_pcm_readi(pcmIn, buf, remain);
- if (r == 0) {
+ if (nbRead == 0) {
break;
}
- if (r < 0) {
- if (r == -EPIPE) {
- err = xrun(pcmIn, (int)r);
+ if (nbRead < 0) {
+ if (nbRead== -EPIPE) {
+ err = xrun(pcmIn, (int)nbRead);
AFB_ApiDebug(pcmCopyHandle->api, "read EPIPE (%d), recov %d", ++pcmCopyHandle->read_err_count, err);
goto ExitOnSuccess;
- } else if (r == -ESTRPIPE) {
+ } else if (nbRead== -ESTRPIPE) {
AFB_ApiDebug(pcmCopyHandle->api, "read ESTRPIPE");
- if ((err = suspend(pcmIn, (int)r)) < 0)
+ if ((err = suspend(pcmIn, (int)nbRead)) < 0)
goto ExitOnSuccess;
- r = 0;
+ nbRead = 0;
} else {
goto ExitOnSuccess;
}
}
pthread_mutex_lock(&pcmCopyHandle->mutex);
- alsa_ringbuf_frames_push(rbuf, buf, r);
+ alsa_ringbuf_frames_push(rbuf, buf, nbRead);
snd_pcm_uframes_t used = alsa_ringbuf_frames_used(rbuf);
pthread_mutex_unlock(&pcmCopyHandle->mutex);
@@ -414,7 +404,7 @@ STATIC int AlsaPcmReadCB( struct pollfd * pfd, AlsaPcmCopyHandleT * pcmCopyHandl
sem_post(&pcmCopyHandle->sem);
}
- availIn -= r;
+ availIn -= nbRead;
// completed, we have read everything
if (availIn <= 0) {
@@ -576,7 +566,7 @@ static void *writeThreadEntry(void *handle) {
sem_wait(&pcmCopyHandle->sem);
while (true) {
- snd_pcm_sframes_t r;
+ snd_pcm_sframes_t used, nbWritten;
snd_pcm_sframes_t availOut = snd_pcm_avail(pcmOut);
if (availOut < 0) {
@@ -599,27 +589,27 @@ static void *writeThreadEntry(void *handle) {
}
pthread_mutex_lock(&pcmCopyHandle->mutex);
- r = alsa_ringbuf_frames_used(rbuf);
- if (r <= 0) {
+ used = alsa_ringbuf_frames_used(rbuf);
+ if (used <= 0) {
pthread_mutex_unlock(&pcmCopyHandle->mutex);
break; // will wait again
}
- if (r > availOut)
- r = availOut;
+ if (used > availOut)
+ used = availOut;
- char buf[r*pcmCopyHandle->frame_size];
- alsa_ringbuf_frames_pop(rbuf, buf, r);
+ char buf[used*pcmCopyHandle->frame_size];
+ alsa_ringbuf_frames_pop(rbuf, buf, used);
pthread_mutex_unlock(&pcmCopyHandle->mutex);
- r = snd_pcm_writei( pcmOut, buf, r);
- if (r <= 0) {
- if (r == -EPIPE) {
- int err = xrun(pcmOut, (int)r);
+ nbWritten = snd_pcm_writei( pcmOut, buf, used);
+ if (nbWritten <= 0) {
+ if (nbWritten == -EPIPE) {
+ int err = xrun(pcmOut, (int)nbWritten);
AFB_ApiDebug(pcmCopyHandle->api, "XXX write EPIPE (%d), recov %d", ++pcmCopyHandle->write_err_count , err);
continue;
- } else if (r == -ESTRPIPE) {
+ } else if (nbWritten == -ESTRPIPE) {
AFB_ApiDebug(pcmCopyHandle->api, "XXX write ESTRPIPE");
break;
}
diff --git a/plugins/alsa/alsa-ringbuf.c b/plugins/alsa/alsa-ringbuf.c
index 2d77e4c..476222c 100644
--- a/plugins/alsa/alsa-ringbuf.c
+++ b/plugins/alsa/alsa-ringbuf.c
@@ -25,7 +25,7 @@ snd_pcm_uframes_t alsa_ringbuf_capacity(const alsa_ringbuf_t *rb) {
return ringbuf_capacity(rb->rbuf)/rb->frameSize;
}
-snd_pcm_uframes_t alsa_ringbuf_frames_free(const alsa_ringbuf_t *rb) {
+snd_pcm_uframes_t alsa_ringbuf_frames_remain_capacity(const alsa_ringbuf_t *rb) {
return ringbuf_bytes_free(rb->rbuf)/rb->frameSize;
}
diff --git a/plugins/alsa/alsa-ringbuf.h b/plugins/alsa/alsa-ringbuf.h
index 5ecc7fe..4ab709c 100644
--- a/plugins/alsa/alsa-ringbuf.h
+++ b/plugins/alsa/alsa-ringbuf.h
@@ -16,7 +16,7 @@ extern snd_pcm_uframes_t alsa_ringbuf_buffer_size(const alsa_ringbuf_t *rb);
extern void alsa_ringbuf_free(alsa_ringbuf_t *rb);
extern void alsa_ringbuf_reset(alsa_ringbuf_t *rb);
extern snd_pcm_uframes_t alsa_ringbuf_capacity(const alsa_ringbuf_t *rb);
-extern snd_pcm_uframes_t alsa_ringbuf_frames_free(const alsa_ringbuf_t *rb);
+extern snd_pcm_uframes_t alsa_ringbuf_frames_remain_capacity(const alsa_ringbuf_t *rb);
extern snd_pcm_uframes_t alsa_ringbuf_frames_used(const alsa_ringbuf_t *rb);
extern bool alsa_ringbuf_is_full(const alsa_ringbuf_t *rb);
extern bool alsa_ringbuf_is_empty(const alsa_ringbuf_t *rb);
* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */