diff options
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/s_audio.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/src/s_audio.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/apps/plugins/pdbox/PDa/src/s_audio.c b/apps/plugins/pdbox/PDa/src/s_audio.c index 5f27d98671..61d1caa583 100644 --- a/apps/plugins/pdbox/PDa/src/s_audio.c +++ b/apps/plugins/pdbox/PDa/src/s_audio.c | |||
@@ -6,6 +6,13 @@ | |||
6 | audio settings from argparse routine and from dialog window. | 6 | audio settings from argparse routine and from dialog window. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #ifdef ROCKBOX | ||
10 | #include "plugin.h" | ||
11 | #include "pdbox.h" | ||
12 | #include "m_pd.h" | ||
13 | #include "s_stuff.h" | ||
14 | #define snprintf rb->snprintf | ||
15 | #else /* ROCKBOX */ | ||
9 | #include "m_pd.h" | 16 | #include "m_pd.h" |
10 | #include "s_stuff.h" | 17 | #include "s_stuff.h" |
11 | #include <stdio.h> | 18 | #include <stdio.h> |
@@ -17,6 +24,7 @@ | |||
17 | #include <stdlib.h> | 24 | #include <stdlib.h> |
18 | #include <string.h> | 25 | #include <string.h> |
19 | #include <errno.h> | 26 | #include <errno.h> |
27 | #endif /* ROCKBOX */ | ||
20 | 28 | ||
21 | #define SYS_DEFAULTCH 2 | 29 | #define SYS_DEFAULTCH 2 |
22 | #define SYS_MAXCH 100 | 30 | #define SYS_MAXCH 100 |
@@ -116,7 +124,11 @@ static void sys_save_audio_params( | |||
116 | void oss_init(void); | 124 | void oss_init(void); |
117 | #endif | 125 | #endif |
118 | 126 | ||
127 | #ifdef ROCKBOX | ||
128 | static void pd_audio_init(void) | ||
129 | #else | ||
119 | static void audio_init( void) | 130 | static void audio_init( void) |
131 | #endif | ||
120 | { | 132 | { |
121 | static int initted = 0; | 133 | static int initted = 0; |
122 | if (initted) | 134 | if (initted) |
@@ -131,7 +143,9 @@ static void audio_init( void) | |||
131 | 143 | ||
132 | static void sys_setchsr(int chin, int chout, int sr) | 144 | static void sys_setchsr(int chin, int chout, int sr) |
133 | { | 145 | { |
146 | #ifndef ROCKBOX | ||
134 | int nblk; | 147 | int nblk; |
148 | #endif | ||
135 | int inbytes = (chin ? chin : 2) * (DEFDACBLKSIZE*sizeof(float)); | 149 | int inbytes = (chin ? chin : 2) * (DEFDACBLKSIZE*sizeof(float)); |
136 | int outbytes = (chout ? chout : 2) * (DEFDACBLKSIZE*sizeof(float)); | 150 | int outbytes = (chout ? chout : 2) * (DEFDACBLKSIZE*sizeof(float)); |
137 | 151 | ||
@@ -144,12 +158,20 @@ static void sys_setchsr(int chin, int chout, int sr) | |||
144 | 158 | ||
145 | if (sys_soundin) | 159 | if (sys_soundin) |
146 | free(sys_soundin); | 160 | free(sys_soundin); |
161 | #ifdef ROCKBOX | ||
162 | sys_soundin = (t_sample*) malloc(inbytes); | ||
163 | #else | ||
147 | sys_soundin = (t_float *)malloc(inbytes); | 164 | sys_soundin = (t_float *)malloc(inbytes); |
165 | #endif | ||
148 | memset(sys_soundin, 0, inbytes); | 166 | memset(sys_soundin, 0, inbytes); |
149 | 167 | ||
150 | if (sys_soundout) | 168 | if (sys_soundout) |
151 | free(sys_soundout); | 169 | free(sys_soundout); |
170 | #ifdef ROCKBOX | ||
171 | sys_soundout = (t_sample*) malloc(outbytes); | ||
172 | #else | ||
152 | sys_soundout = (t_float *)malloc(outbytes); | 173 | sys_soundout = (t_float *)malloc(outbytes); |
174 | #endif | ||
153 | memset(sys_soundout, 0, outbytes); | 175 | memset(sys_soundout, 0, outbytes); |
154 | 176 | ||
155 | if (sys_verbose) | 177 | if (sys_verbose) |
@@ -169,12 +191,20 @@ void sys_open_audio(int naudioindev, int *audioindev, int nchindev, | |||
169 | int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev, | 191 | int *chindev, int naudiooutdev, int *audiooutdev, int nchoutdev, |
170 | int *choutdev, int rate, int advance, int enable) | 192 | int *choutdev, int rate, int advance, int enable) |
171 | { | 193 | { |
194 | #ifdef ROCKBOX | ||
195 | int i; | ||
196 | #else | ||
172 | int i, *ip; | 197 | int i, *ip; |
198 | #endif | ||
173 | int defaultchannels = SYS_DEFAULTCH; | 199 | int defaultchannels = SYS_DEFAULTCH; |
174 | int inchans, outchans; | 200 | int inchans, outchans; |
175 | if (rate < 1) | 201 | if (rate < 1) |
176 | rate = SYS_DEFAULTSRATE; | 202 | rate = SYS_DEFAULTSRATE; |
203 | #ifdef ROCKBOX | ||
204 | pd_audio_init(); | ||
205 | #else | ||
177 | audio_init(); | 206 | audio_init(); |
207 | #endif | ||
178 | /* Since the channel vector might be longer than the | 208 | /* Since the channel vector might be longer than the |
179 | audio device vector, or vice versa, we fill the shorter one | 209 | audio device vector, or vice versa, we fill the shorter one |
180 | in to match the longer one. Also, if both are empty, we fill in | 210 | in to match the longer one. Also, if both are empty, we fill in |
@@ -330,6 +360,11 @@ else | |||
330 | naudiooutdev, audiooutdev, nchoutdev, choutdev, rate); | 360 | naudiooutdev, audiooutdev, nchoutdev, choutdev, rate); |
331 | else | 361 | else |
332 | #endif | 362 | #endif |
363 | #ifdef USEAPI_ROCKBOX | ||
364 | if (sys_audioapi == API_ROCKBOX) | ||
365 | rockbox_open_audio(rate); | ||
366 | else | ||
367 | #endif | ||
333 | post("unknown audio API specified"); | 368 | post("unknown audio API specified"); |
334 | } | 369 | } |
335 | sys_save_audio_params(naudioindev, audioindev, chindev, | 370 | sys_save_audio_params(naudioindev, audioindev, chindev, |
@@ -337,7 +372,9 @@ else | |||
337 | if (sys_inchannels == 0 && sys_outchannels == 0) | 372 | if (sys_inchannels == 0 && sys_outchannels == 0) |
338 | enable = 0; | 373 | enable = 0; |
339 | audio_state = enable; | 374 | audio_state = enable; |
375 | #ifndef ROCKBOX | ||
340 | sys_vgui("set pd_whichapi %d\n", (audio_isopen() ? sys_audioapi : 0)); | 376 | sys_vgui("set pd_whichapi %d\n", (audio_isopen() ? sys_audioapi : 0)); |
377 | #endif | ||
341 | sched_set_using_dacs(enable); | 378 | sched_set_using_dacs(enable); |
342 | } | 379 | } |
343 | 380 | ||
@@ -370,6 +407,11 @@ void sys_close_audio(void) | |||
370 | mmio_close_audio(); | 407 | mmio_close_audio(); |
371 | else | 408 | else |
372 | #endif | 409 | #endif |
410 | #ifdef USEAPI_ROCKBOX | ||
411 | if (sys_audioapi == API_ROCKBOX) | ||
412 | rockbox_close_audio(); | ||
413 | else | ||
414 | #endif | ||
373 | post("sys_close_audio: unknown API %d", sys_audioapi); | 415 | post("sys_close_audio: unknown API %d", sys_audioapi); |
374 | sys_inchannels = sys_outchannels = 0; | 416 | sys_inchannels = sys_outchannels = 0; |
375 | } | 417 | } |
@@ -435,6 +477,11 @@ int sys_send_dacs(void) | |||
435 | return (mmio_send_dacs()); | 477 | return (mmio_send_dacs()); |
436 | else | 478 | else |
437 | #endif | 479 | #endif |
480 | #ifdef USEAPI_ROCKBOX | ||
481 | if (sys_audioapi == API_ROCKBOX) | ||
482 | return (rockbox_send_dacs()); | ||
483 | else | ||
484 | #endif | ||
438 | post("unknown API"); | 485 | post("unknown API"); |
439 | return (0); | 486 | return (0); |
440 | } | 487 | } |
@@ -482,11 +529,17 @@ void sys_reportidle(void) | |||
482 | #define MAXNDEV 20 | 529 | #define MAXNDEV 20 |
483 | #define DEVDESCSIZE 80 | 530 | #define DEVDESCSIZE 80 |
484 | 531 | ||
532 | #ifndef ROCKBOX | ||
485 | static void audio_getdevs(char *indevlist, int *nindevs, | 533 | static void audio_getdevs(char *indevlist, int *nindevs, |
486 | char *outdevlist, int *noutdevs, int *canmulti, | 534 | char *outdevlist, int *noutdevs, int *canmulti, |
487 | int maxndev, int devdescsize) | 535 | int maxndev, int devdescsize) |
488 | { | 536 | { |
537 | #ifdef ROCKBOX | ||
538 | (void) maxndev; | ||
539 | pd_audio_init(); | ||
540 | #else | ||
489 | audio_init(); | 541 | audio_init(); |
542 | #endif /* ROCKBOX */ | ||
490 | #ifdef USEAPI_OSS | 543 | #ifdef USEAPI_OSS |
491 | if (sys_audioapi == API_OSS) | 544 | if (sys_audioapi == API_OSS) |
492 | { | 545 | { |
@@ -519,6 +572,13 @@ static void audio_getdevs(char *indevlist, int *nindevs, | |||
519 | } | 572 | } |
520 | else | 573 | else |
521 | #endif | 574 | #endif |
575 | #ifdef USEAPI_ROCKBOX | ||
576 | if (sys_audioapi == API_ROCKBOX) | ||
577 | { | ||
578 | /* Rockbox devices are known in advance. (?) */ | ||
579 | } | ||
580 | else | ||
581 | #endif | ||
522 | { | 582 | { |
523 | /* this shouldn't happen once all the above get filled in. */ | 583 | /* this shouldn't happen once all the above get filled in. */ |
524 | int i; | 584 | int i; |
@@ -531,6 +591,7 @@ static void audio_getdevs(char *indevlist, int *nindevs, | |||
531 | *canmulti = 0; | 591 | *canmulti = 0; |
532 | } | 592 | } |
533 | } | 593 | } |
594 | #endif | ||
534 | 595 | ||
535 | #ifdef MSW | 596 | #ifdef MSW |
536 | #define DEVONSET 0 /* microsoft device list starts at 0 (the "mapper"). */ | 597 | #define DEVONSET 0 /* microsoft device list starts at 0 (the "mapper"). */ |
@@ -538,6 +599,7 @@ static void audio_getdevs(char *indevlist, int *nindevs, | |||
538 | #define DEVONSET 1 /* To agree with command line flags, normally start at 1 */ | 599 | #define DEVONSET 1 /* To agree with command line flags, normally start at 1 */ |
539 | #endif | 600 | #endif |
540 | 601 | ||
602 | #ifndef ROCKBOX | ||
541 | static void sys_listaudiodevs(void ) | 603 | static void sys_listaudiodevs(void ) |
542 | { | 604 | { |
543 | char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE]; | 605 | char indevlist[MAXNDEV*DEVDESCSIZE], outdevlist[MAXNDEV*DEVDESCSIZE]; |
@@ -564,8 +626,10 @@ static void sys_listaudiodevs(void ) | |||
564 | } | 626 | } |
565 | post("API number %d\n", sys_audioapi); | 627 | post("API number %d\n", sys_audioapi); |
566 | } | 628 | } |
629 | #endif | ||
567 | 630 | ||
568 | /* start an audio settings dialog window */ | 631 | /* start an audio settings dialog window */ |
632 | #ifndef ROCKBOX | ||
569 | void glob_audio_properties(t_pd *dummy, t_floatarg flongform) | 633 | void glob_audio_properties(t_pd *dummy, t_floatarg flongform) |
570 | { | 634 | { |
571 | char buf[1024 + 2 * MAXNDEV*(DEVDESCSIZE+4)]; | 635 | char buf[1024 + 2 * MAXNDEV*(DEVDESCSIZE+4)]; |
@@ -645,8 +709,10 @@ void glob_audio_properties(t_pd *dummy, t_floatarg flongform) | |||
645 | gfxstub_deleteforkey(0); | 709 | gfxstub_deleteforkey(0); |
646 | gfxstub_new(&glob_pdobject, glob_audio_properties, buf); | 710 | gfxstub_new(&glob_pdobject, glob_audio_properties, buf); |
647 | } | 711 | } |
712 | #endif | ||
648 | 713 | ||
649 | /* new values from dialog window */ | 714 | /* new values from dialog window */ |
715 | #ifndef ROCKBOX | ||
650 | void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv) | 716 | void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv) |
651 | { | 717 | { |
652 | int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV]; | 718 | int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV]; |
@@ -696,6 +762,7 @@ void glob_audio_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv) | |||
696 | noutdev, newaudiooutdev, noutdev, newaudiooutchan, | 762 | noutdev, newaudiooutdev, noutdev, newaudiooutchan, |
697 | newrate, newadvance, 1); | 763 | newrate, newadvance, 1); |
698 | } | 764 | } |
765 | #endif | ||
699 | 766 | ||
700 | void sys_listdevs(void ) | 767 | void sys_listdevs(void ) |
701 | { | 768 | { |
@@ -724,6 +791,13 @@ void sys_listdevs(void ) | |||
724 | sys_listaudiodevs(); | 791 | sys_listaudiodevs(); |
725 | else | 792 | else |
726 | #endif | 793 | #endif |
794 | #ifdef USEAPI_ROCKBOX | ||
795 | if (sys_audioapi == API_ROCKBOX) | ||
796 | { | ||
797 | /* Nothing to list, IMO. */ | ||
798 | } | ||
799 | else | ||
800 | #endif | ||
727 | post("unknown API"); | 801 | post("unknown API"); |
728 | 802 | ||
729 | sys_listmididevs(); | 803 | sys_listmididevs(); |
@@ -746,9 +820,11 @@ void sys_set_audio_api(int which) | |||
746 | post("sys_audioapi %d", sys_audioapi); | 820 | post("sys_audioapi %d", sys_audioapi); |
747 | } | 821 | } |
748 | 822 | ||
823 | #ifndef ROCKBOX | ||
749 | void glob_audio_setapi(void *dummy, t_floatarg f) | 824 | void glob_audio_setapi(void *dummy, t_floatarg f) |
750 | { | 825 | { |
751 | int newapi = f; | 826 | int newapi = f; |
827 | |||
752 | if (newapi) | 828 | if (newapi) |
753 | { | 829 | { |
754 | if (newapi == sys_audioapi) | 830 | if (newapi == sys_audioapi) |
@@ -775,6 +851,7 @@ void glob_audio_setapi(void *dummy, t_floatarg f) | |||
775 | sched_set_using_dacs(0); | 851 | sched_set_using_dacs(0); |
776 | } | 852 | } |
777 | } | 853 | } |
854 | #endif | ||
778 | 855 | ||
779 | /* start or stop the audio hardware */ | 856 | /* start or stop the audio hardware */ |
780 | void sys_set_audio_state(int onoff) | 857 | void sys_set_audio_state(int onoff) |
@@ -842,6 +919,10 @@ void alsa_printstate( void); | |||
842 | void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv) | 919 | void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv) |
843 | { | 920 | { |
844 | t_symbol *arg = atom_getsymbolarg(0, argc, argv); | 921 | t_symbol *arg = atom_getsymbolarg(0, argc, argv); |
922 | #ifdef ROCKBOX | ||
923 | (void) dummy; | ||
924 | (void) s; | ||
925 | #endif | ||
845 | if (arg == gensym("restart")) | 926 | if (arg == gensym("restart")) |
846 | { | 927 | { |
847 | int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV]; | 928 | int naudioindev, audioindev[MAXAUDIOINDEV], chindev[MAXAUDIOINDEV]; |