Advertisement
JetForMe

Untitled

Nov 22nd, 2014
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. /**
  2.     sudo apt-get install libasound-dev
  3.    
  4.     g++ -I/usr/include/alsa -lasound main.cpp -o radio
  5. */
  6.  
  7. #include <cstdio>
  8.  
  9. #include <alsa/asoundlib.h>
  10.  
  11.  
  12. int
  13. main(int inArgC, const char** inArgs)
  14. {
  15.     std::printf("Hello world\n");
  16.    
  17.     snd_pcm_t*              pcm = NULL;
  18.     char* pcmName = ::strdup("plughw:0,0");
  19.     snd_pcm_stream_t        stream = SND_PCM_STREAM_PLAYBACK;
  20.     int result = snd_pcm_open(&pcm, pcmName, stream, 0);
  21.     if (result < 0)
  22.     {
  23.         std::fprintf(stderr, "Error opening PCM device %s: %d\n", pcmName, result);
  24.         return -1;
  25.     }
  26.    
  27.     return 0;
  28. }
  29.  
  30.  
  31. -----------
  32.  
  33. $ g++ -lasound main.cpp -o radio
  34. /tmp/cckzNJjH.o: In function `main':
  35. main.cpp:(.text+0x4a): undefined reference to `snd_pcm_open'
  36. collect2: error: ld returned 1 exit status
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement