1
1
/*
2
2
* libalsa output driver. This file is part of Shairport.
3
3
* Copyright (c) Muffinman, Skaman 2013
4
- * Copyright (c) Mike Brady 2014 -- 2022
4
+ * Copyright (c) Mike Brady 2014 -- 2024
5
5
* All rights reserved.
6
6
*
7
7
* Permission is hereby granted, free of charge, to any person
@@ -146,6 +146,7 @@ long alsa_mix_minv, alsa_mix_maxv;
146
146
long alsa_mix_mindb , alsa_mix_maxdb ;
147
147
148
148
char * alsa_out_dev = "default" ;
149
+ char * hw_alsa_out_dev = NULL ;
149
150
char * alsa_mix_dev = NULL ;
150
151
char * alsa_mix_ctrl = NULL ;
151
152
int alsa_mix_index = 0 ;
@@ -291,7 +292,12 @@ static void help(void) {
291
292
debug (2 , "error %d executing a script to list alsa hardware device names" , r );
292
293
}
293
294
294
- void set_alsa_out_dev (char * dev ) { alsa_out_dev = dev ; } // ugh -- not static!
295
+ void set_alsa_out_dev (char * dev ) {
296
+ alsa_out_dev = dev ;
297
+ if (hw_alsa_out_dev != NULL )
298
+ free (hw_alsa_out_dev );
299
+ hw_alsa_out_dev = str_replace (alsa_out_dev , "hdmi:" , "hw:" );
300
+ } // ugh -- not static!
295
301
296
302
// assuming pthread cancellation is disabled
297
303
// returns zero of all is okay, a Unx error code if there's a problem
@@ -902,7 +908,7 @@ static int prepare_mixer() {
902
908
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE , & oldState ); // make this un-cancellable
903
909
904
910
if (alsa_mix_dev == NULL )
905
- alsa_mix_dev = alsa_out_dev ;
911
+ alsa_mix_dev = hw_alsa_out_dev ;
906
912
907
913
// Now, start trying to initialise the alsa device with the settings
908
914
// obtained
@@ -1355,11 +1361,19 @@ static int init(int argc, char **argv) {
1355
1361
}
1356
1362
1357
1363
debug (1 , "alsa: output device name is \"%s\"." , alsa_out_dev );
1358
-
1364
+
1365
+
1366
+ // now, we need a version of the alsa_out_dev that substitutes "hw:" for "hdmi" if it's
1367
+ // there. It seems hw:1 would be a valid devcie name where hdmi:1 would not
1368
+
1369
+ if (alsa_out_dev != NULL )
1370
+ hw_alsa_out_dev = str_replace (alsa_out_dev , "hdmi:" , "hw:" );
1371
+
1359
1372
// so, now, if the option to keep the DAC running has been selected, start a
1360
1373
// thread to monitor the
1361
1374
// length of the queue
1362
1375
// if the queue gets too short, stuff it with silence
1376
+
1363
1377
1364
1378
pthread_create (& alsa_buffer_monitor_thread , NULL , & alsa_buffer_monitor_thread_code , NULL );
1365
1379
@@ -1376,6 +1390,8 @@ static void deinit(void) {
1376
1390
debug (3 , "Join buffer monitor thread." );
1377
1391
pthread_join (alsa_buffer_monitor_thread , NULL );
1378
1392
pthread_setcancelstate (oldState , NULL );
1393
+ if (hw_alsa_out_dev != NULL )
1394
+ free (hw_alsa_out_dev );
1379
1395
}
1380
1396
1381
1397
static int set_mute_state () {
0 commit comments