comparison src/audio/android/SDL_androidaudio.c @ 4724:d86332c0fb9b

Working on the sound system
author Paul Hunkin <paul@bieh.net>
date Sat, 14 Aug 2010 12:35:21 +1200
parents 79aa6c61f33b
children 58b6bb4a45e9
comparison
equal deleted inserted replaced
4723:74da47b2f5b7 4724:d86332c0fb9b
27 27
28 #include "SDL_audio.h" 28 #include "SDL_audio.h"
29 #include "../SDL_audio_c.h" 29 #include "../SDL_audio_c.h"
30 #include "SDL_androidaudio.h" 30 #include "SDL_androidaudio.h"
31 31
32 extern void Android_UpdateAudioBuffer(unsigned char *buf, int len);
33
32 #include <android/log.h> 34 #include <android/log.h>
33 35
34 static int 36 static int
35 AndroidAUD_OpenDevice(_THIS, const char *devname, int iscapture) 37 AndroidAUD_OpenDevice(_THIS, const char *devname, int iscapture)
36 { 38 {
39 SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
40 int valid_datatype = 0;
41
37 //TODO: Sample rates etc 42 //TODO: Sample rates etc
38 __android_log_print(ANDROID_LOG_INFO, "SDL", "AndroidAudio Open\n"); 43 __android_log_print(ANDROID_LOG_INFO, "SDL", "AndroidAudio Open\n");
44
45 this->hidden = SDL_malloc(sizeof(*(this->hidden)));
46 if (!this->hidden) {
47 SDL_OutOfMemory();
48 return 0;
49 }
50 SDL_memset(this->hidden, 0, (sizeof *this->hidden));
51
52 while ((!valid_datatype) && (test_format)) {
53 this->spec.format = test_format;
54 switch (test_format) {
55 case AUDIO_S8:
56 /*case AUDIO_S16LSB: */
57 valid_datatype = 1;
58 break;
59 default:
60 test_format = SDL_NextAudioFormat();
61 break;
62 }
63 }
39 64
40 return 1; 65 return 1;
41 } 66 }
42 67
43 static void 68 static void
44 AndroidAUD_PlayDevice(_THIS) 69 AndroidAUD_PlayDevice(_THIS)
45 { 70 {
46 __android_log_print(ANDROID_LOG_INFO, "SDL", "AndroidAudio Play\n"); 71 __android_log_print(ANDROID_LOG_INFO, "SDL", "AndroidAudio Play\n");
47 72
48
49 73
50 //playGenericSound(this->hidden->mixbuf, this->hidden->mixlen); 74 //playGenericSound(this->hidden->mixbuf, this->hidden->mixlen);
51 75
52 #if 0 76 #if 0
53 // sound->data = this->hidden->mixbuf;/* pointer to raw audio data */ 77
54 // sound->len = this->hidden->mixlen; /* size of raw data pointed to above */
55 // sound->rate = 22050; /* sample rate = 22050Hz */ 78 // sound->rate = 22050; /* sample rate = 22050Hz */
56 // sound->vol = 127; /* volume [0..127] for [min..max] */ 79 // sound->vol = 127; /* volume [0..127] for [min..max] */
57 // sound->pan = 64; /* balance [0..127] for [left..right] */ 80 // sound->pan = 64; /* balance [0..127] for [left..right] */
58 // sound->format = 0; /* 0 for 16-bit, 1 for 8-bit */ 81 // sound->format = 0; /* 0 for 16-bit, 1 for 8-bit */
59 // playSound(sound); 82 // playSound(sound);
62 85
63 86
64 static Uint8 * 87 static Uint8 *
65 AndroidAUD_GetDeviceBuf(_THIS) 88 AndroidAUD_GetDeviceBuf(_THIS)
66 { 89 {
90 //__android_log_print(ANDROID_LOG_INFO, "SDL", "****** get device buf\n");
91
92
93 // sound->data = this->hidden->mixbuf;/* pointer to raw audio data */
94 // sound->len = this->hidden->mixlen; /* size of raw data pointed to above */
95
96
97 Android_UpdateAudioBuffer(this->hidden->mixbuf, this->hidden->mixlen);
98
67 return this->hidden->mixbuf; /* is this right? */ 99 return this->hidden->mixbuf; /* is this right? */
68 } 100 }
69 101
70 static void 102 static void
71 AndroidAUD_WaitDevice(_THIS) 103 AndroidAUD_WaitDevice(_THIS)
72 { 104 {
73 /* stub */ 105 /* stub */
106 __android_log_print(ANDROID_LOG_INFO, "SDL", "****** wait device buf\n");
74 } 107 }
75 108
76 static void 109 static void
77 AndroidAUD_CloseDevice(_THIS) 110 AndroidAUD_CloseDevice(_THIS)
78 { 111 {
79 /* stub */ 112 /* stub */
113 __android_log_print(ANDROID_LOG_INFO, "SDL", "****** close device buf\n");
80 } 114 }
81 115
82 static int 116 static int
83 AndroidAUD_Init(SDL_AudioDriverImpl * impl) 117 AndroidAUD_Init(SDL_AudioDriverImpl * impl)
84 { 118 {