Changeset 45:ae98e6b0f3f4 in roaraudio for roard/sample.c
- Timestamp:
- 06/22/08 16:30:55 (16 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/sample.c
r44 r45 13 13 14 14 15 int samples_free (void); 16 int samples_new (void); 17 int samples_delete (int id); 18 int samples_set_name (int id, char * name); 15 int samples_free (void) { 16 int i; 17 18 for (i = 0; i < ROAR_SAMPLES_MAX; i++) 19 if ( g_samples[i] != NULL ) 20 samples_delete(i); 21 22 return 0; 23 } 24 25 int samples_new (void) { 26 struct roar_sample * c = malloc(sizeof(struct roar_sample)); 27 int i; 28 29 if ( c == NULL ) 30 return -1; 31 32 c->name[0] = 0; 33 c->data = NULL; 34 35 for (i = 0; i < ROAR_SAMPLES_MAX; i++) { 36 if ( g_samples[i] == NULL ) { 37 g_samples[i] = c; 38 return i; 39 } 40 } 41 42 free(c); 43 44 return -1; 45 } 46 47 int samples_delete (int id) { 48 struct roar_sample * c = g_samples[id]; 49 50 if ( c == NULL ) 51 return -1; 52 53 if (c->data != NULL ) 54 roar_buffer_free(c->data); 55 56 free(c); 57 58 g_samples[id] = NULL; 59 60 return 0; 61 } 62 63 int samples_set_name (int id, char * name) { 64 struct roar_sample * c = g_samples[id]; 65 66 if ( c == NULL ) 67 return -1; 68 69 strncpy(c->name, name, ROAR_BUFFER_NAME-1); 70 71 c->name[ROAR_BUFFER_NAME-1] = 0; 72 73 return 0; 74 } 19 75 20 76 //ll
Note: See TracChangeset
for help on using the changeset viewer.