Revert "Fix pulse audio output driver in daemon mode."
This reverts commit 8045e00d4f.
Now, pulseaudio can be initialised at startup, thus detecting connection
errors early.
Conflicts:
audio_pulse.c
This commit is contained in:
+21
-20
@@ -35,9 +35,6 @@
|
||||
|
||||
static pa_simple *pa_dev = NULL;
|
||||
static int pa_error;
|
||||
static const char *pa_server = NULL;
|
||||
static const char *pa_sink = NULL;
|
||||
static const char *pa_appname = NULL;
|
||||
|
||||
static void help(void) {
|
||||
printf(" -a server set the server name\n"
|
||||
@@ -48,8 +45,10 @@ static void help(void) {
|
||||
}
|
||||
|
||||
static int init(int argc, char **argv) {
|
||||
pa_appname = config.apname;
|
||||
|
||||
char *pa_server = NULL;
|
||||
char *pa_sink = NULL;
|
||||
char *pa_appname = config.apname;
|
||||
|
||||
optind = 1; // optind=0 is equivalent to optind=1 plus special behaviour
|
||||
argv--; // so we shift the arguments to satisfy getopt()
|
||||
argc++;
|
||||
@@ -77,16 +76,9 @@ static int init(int argc, char **argv) {
|
||||
if (optind < argc)
|
||||
die("Invalid audio argument: %s", argv[optind]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void deinit(void) {
|
||||
}
|
||||
|
||||
static void start(int sample_rate) {
|
||||
const pa_sample_spec ss = {
|
||||
static const pa_sample_spec ss = {
|
||||
.format = PA_SAMPLE_S16LE,
|
||||
.rate = sample_rate,
|
||||
.rate = 44100,
|
||||
.channels = 2
|
||||
};
|
||||
|
||||
@@ -100,20 +92,29 @@ static void start(int sample_rate) {
|
||||
|
||||
if (!pa_dev)
|
||||
die("Could not connect to pulseaudio server: %s", pa_strerror(pa_error));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void deinit(void) {
|
||||
if (pa_dev)
|
||||
pa_simple_free(pa_dev);
|
||||
pa_dev = NULL;
|
||||
}
|
||||
|
||||
static void start(int sample_rate) {
|
||||
if (sample_rate != 44100)
|
||||
die("unexpected sample rate!");
|
||||
}
|
||||
|
||||
static void play(short buf[], int samples) {
|
||||
if( pa_simple_write(pa_dev, (char *)buf, (size_t)samples * 4, &pa_error) < 0 )
|
||||
warn("pa_simple_write() failed: %s\n", pa_strerror(pa_error));
|
||||
fprintf(stderr, __FILE__": pa_simple_write() failed: %s\n", pa_strerror(pa_error));
|
||||
}
|
||||
|
||||
static void stop(void) {
|
||||
if (pa_simple_drain(pa_dev, &pa_error) < 0)
|
||||
warn("pa_simple_drain() failed: %s\n", pa_strerror(pa_error));
|
||||
|
||||
if (pa_dev)
|
||||
pa_simple_free(pa_dev);
|
||||
pa_dev = NULL;
|
||||
fprintf(stderr, __FILE__": pa_simple_drain() failed: %s\n", pa_strerror(pa_error));
|
||||
}
|
||||
|
||||
audio_output audio_pulse = {
|
||||
|
||||
Reference in New Issue
Block a user