Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: remove HDMI audio, revert playback buffer, strip codec verbs

Restore audio_init to match original working state:
- Remove HDMI PCM open (exhausts HDA controller streams, blocks capture)
- Revert playback buffer from 6 periods back to 3 (original value)
- Remove HDA codec verb section (not in original working code)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+5 -58
+5 -58
fedac/native/src/audio.c
··· 783 783 snd_pcm_uframes_t period = AUDIO_PERIOD_SIZE; 784 784 snd_pcm_hw_params_set_period_size_near(pcm, params, &period, 0); 785 785 786 - snd_pcm_uframes_t buffer_size = AUDIO_PERIOD_SIZE * 6; // 6 periods for better underrun tolerance 786 + snd_pcm_uframes_t buffer_size = AUDIO_PERIOD_SIZE * 3; // 3 periods (~3ms total at 192kHz) 787 787 snd_pcm_hw_params_set_buffer_size_near(pcm, params, &buffer_size); 788 788 789 789 err = snd_pcm_hw_params(pcm, params); ··· 867 867 fprintf(stderr, "[audio] Cannot open mixer\n"); 868 868 } 869 869 870 - // Force-unmute via HDA codec verbs (bypasses ALSA mixer abstraction) 871 - // ALC257: Node 0x14 = Speaker, Node 0x21 = HP Out 872 - // Pin Widget Control verb (0x707) with OUT enabled (0x40) 873 - // Amp Gain/Mute verb: 0x3 = set output amp, 0xb0 = unmute + gain 874 - { 875 - FILE *codec = fopen("/proc/asound/card0/codec#0", "r"); 876 - if (codec) { 877 - fprintf(stderr, "[audio] HDA codec found, sending unmute verbs\n"); 878 - fclose(codec); 879 - // Write verbs to hwdep (if available) — fallback: use sysfs 880 - char verb_path[128]; 881 - snprintf(verb_path, sizeof(verb_path), "/sys/class/sound/hwC0D0/init_pin_configs"); 882 - if (access(verb_path, F_OK) == 0) 883 - fprintf(stderr, "[audio] HDA sysfs: %s\n", verb_path); 884 - } 885 - } 886 - 887 870 // Read initial system volume 888 871 audio->system_volume = read_system_volume_card(card_idx); 889 872 fprintf(stderr, "[audio] System volume: %d%%\n", audio->system_volume); 890 873 891 - // Try to open HDMI audio device (non-blocking, best-effort) 892 - { 893 - // Intel HDA HDMI subdevices: device 3, 7, 8 on card 0 or 1 894 - const char *hdmi_devs[] = { 895 - "hdmi:0,0", "hdmi:0,1", "hdmi:0,2", "hdmi:0,3", 896 - "hdmi:1,0", "hdmi:1,1", 897 - "plughw:0,3", "plughw:0,7", "plughw:0,8", 898 - "plughw:1,3", "plughw:1,7", 899 - NULL 900 - }; 901 - for (int hi = 0; hdmi_devs[hi] && !audio->hdmi_pcm; hi++) { 902 - snd_pcm_t *hpcm = NULL; 903 - if (snd_pcm_open(&hpcm, hdmi_devs[hi], SND_PCM_STREAM_PLAYBACK, 904 - SND_PCM_NONBLOCK) != 0) continue; 905 - snd_pcm_hw_params_t *hp; 906 - snd_pcm_hw_params_alloca(&hp); 907 - if (snd_pcm_hw_params_any(hpcm, hp) < 0 || 908 - snd_pcm_hw_params_set_access(hpcm, hp, SND_PCM_ACCESS_RW_INTERLEAVED) < 0 || 909 - snd_pcm_hw_params_set_format(hpcm, hp, SND_PCM_FORMAT_S16_LE) < 0 || 910 - snd_pcm_hw_params_set_channels(hpcm, hp, 2) < 0) { 911 - snd_pcm_close(hpcm); continue; 912 - } 913 - unsigned int hrate = 48000; 914 - snd_pcm_hw_params_set_rate_near(hpcm, hp, &hrate, NULL); 915 - snd_pcm_uframes_t hperiod = 512; 916 - snd_pcm_hw_params_set_period_size_near(hpcm, hp, &hperiod, NULL); 917 - if (snd_pcm_hw_params(hpcm, hp) < 0) { snd_pcm_close(hpcm); continue; } 918 - snd_pcm_prepare(hpcm); 919 - audio->hdmi_pcm = hpcm; 920 - audio->hdmi_rate = hrate; 921 - audio->hdmi_period_size = (int)hperiod; 922 - // Downsample ratio: every N primary samples → 1 HDMI sample 923 - audio->hdmi_downsample_n = (int)((double)rate / hrate + 0.5); 924 - if (audio->hdmi_downsample_n < 1) audio->hdmi_downsample_n = 1; 925 - fprintf(stderr, "[audio] HDMI audio: %s @ %uHz, downsample 1/%d\n", 926 - hdmi_devs[hi], hrate, audio->hdmi_downsample_n); 927 - } 928 - if (!audio->hdmi_pcm) 929 - fprintf(stderr, "[audio] No HDMI audio device\n"); 930 - } 874 + // HDMI audio disabled — opening HDMI PCM streams on the same HDA controller 875 + // can exhaust controller streams and cause EIO on capture. 876 + audio->hdmi_pcm = NULL; 877 + fprintf(stderr, "[audio] HDMI audio: disabled\n"); 931 878 932 879 // Start audio thread 933 880 audio->running = 1;