| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | #include <stdlib.h> |
|---|
| 13 | #include <pthread.h> |
|---|
| 14 | #include <iostream> |
|---|
| 15 | #include <alsa/asoundlib.h> |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | void call_snd_pcm_open(const char * name) { |
|---|
| 19 | int err; |
|---|
| 20 | snd_pcm_t *playback_handle; |
|---|
| 21 | if ((err = snd_pcm_open (&playback_handle, name, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { |
|---|
| 22 | fprintf (stderr, "cannot open audio device %s (%s)\n", |
|---|
| 23 | name, |
|---|
| 24 | snd_strerror (err)); |
|---|
| 25 | } |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | void * threadWork(void *arg) { |
|---|
| 29 | std::cerr << "Thread : Entering thread Test::run" << std::endl; |
|---|
| 30 | std::cerr << "Thread : call_snd_pcm_opening Pa_Intialize"<< std::endl; |
|---|
| 31 | |
|---|
| 32 | call_snd_pcm_open("pulse"); |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | std::cerr << "Thread : FINISHED"<< std::endl; |
|---|
| 64 | |
|---|
| 65 | return NULL; |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | int main() { |
|---|
| 70 | std::cerr << "****************************************"<< std::endl; |
|---|
| 71 | std::cerr << "* ALSA TEST BUG *"<< std::endl; |
|---|
| 72 | std::cerr << "****************************************"<< std::endl; |
|---|
| 73 | std::cerr << "Main thread : starting thread"<< std::endl; |
|---|
| 74 | pthread_attr_t attr; |
|---|
| 75 | pthread_attr_init(&attr); |
|---|
| 76 | pthread_t threadid; |
|---|
| 77 | |
|---|
| 78 | pthread_create( &threadid, &attr, threadWork, NULL); |
|---|
| 79 | |
|---|
| 80 | std::cerr << "Main thread : sleeping 5 secs"<< std::endl; |
|---|
| 81 | |
|---|
| 82 | sleep(5); |
|---|
| 83 | |
|---|
| 84 | std::cerr << "****************************************"<< std::endl; |
|---|
| 85 | std::cerr << "* ALSA TEST BUG TERMINATED - no problem*"<< std::endl; |
|---|
| 86 | std::cerr << "****************************************"<< std::endl; |
|---|
| 87 | |
|---|
| 88 | return EXIT_SUCCESS; |
|---|
| 89 | } |
|---|