| static void *polling_thread(void *p) | static void *polling_thread(void *p) | ||||
| { | { | ||||
| (void)p; // unused | |||||
| while (1) { | while (1) { | ||||
| int a_stop_is_required = 0; | int a_stop_is_required = 0; | ||||
| static void *say_thread(void *p) | static void *say_thread(void *p) | ||||
| { | { | ||||
| (void)p; // unused | |||||
| // announce that thread is started | // announce that thread is started | ||||
| sem_post(&my_sem_stop_is_acknowledged); | sem_post(&my_sem_stop_is_acknowledged); | ||||
| return ix - start; | return ix - start; | ||||
| } | } | ||||
| static int SetHeadIntonation(TUNE *tune, int syl_ix, int end_ix, int control) | |||||
| static int SetHeadIntonation(TUNE *tune, int syl_ix, int end_ix) | |||||
| { | { | ||||
| int stress; | int stress; | ||||
| SYLLABLE *syl; | SYLLABLE *syl; | ||||
| if (option_tone_flags & OPTION_EMPHASIZE_PENULTIMATE) | if (option_tone_flags & OPTION_EMPHASIZE_PENULTIMATE) | ||||
| tone_posn = tone_posn2; // put tone on the penultimate stressed word | tone_posn = tone_posn2; // put tone on the penultimate stressed word | ||||
| ix = SetHeadIntonation(tune, ix, tone_posn, 0); | |||||
| ix = SetHeadIntonation(tune, ix, tone_posn); | |||||
| if (no_tonic) | if (no_tonic) | ||||
| return 0; | return 0; | ||||
| return tone_pitch_env; | return tone_pitch_env; | ||||
| } | } | ||||
| static void CalcPitches_Tone(Translator *tr, int clause_tone) | |||||
| static void CalcPitches_Tone(Translator *tr) | |||||
| { | { | ||||
| // clause_tone: 0=. 1=, 2=?, 3=! 4=none | |||||
| PHONEME_LIST *p; | PHONEME_LIST *p; | ||||
| int ix; | int ix; | ||||
| int count_stressed = 0; | int count_stressed = 0; | ||||
| return; // nothing to do | return; // nothing to do | ||||
| if (tr->langopts.tone_language == 1) { | if (tr->langopts.tone_language == 1) { | ||||
| CalcPitches_Tone(tr, clause_type); | |||||
| CalcPitches_Tone(tr); | |||||
| return; | return; | ||||
| } | } | ||||
| /* | /* | ||||
| * Tolerance to missing diphones (always active so this is ignored) | * Tolerance to missing diphones (always active so this is ignored) | ||||
| */ | */ | ||||
| static inline void setNoError_MBR(int no_error) { | |||||
| static inline void setNoError_MBR(int no_error) | |||||
| { | |||||
| (void)no_error; // unused | |||||
| } | } | ||||
| #ifdef __cplusplus | #ifdef __cplusplus |
| extern int n_ph_list2; | extern int n_ph_list2; | ||||
| extern PHONEME_LIST2 ph_list2[N_PHONEME_LIST]; // first stage of text->phonemes | extern PHONEME_LIST2 ph_list2[N_PHONEME_LIST]; // first stage of text->phonemes | ||||
| static int SubstitutePhonemes(Translator *tr, PHONEME_LIST *plist_out) | |||||
| static int SubstitutePhonemes(PHONEME_LIST *plist_out) | |||||
| { | { | ||||
| // Copy the phonemes list and perform any substitutions that are required for the | // Copy the phonemes list and perform any substitutions that are required for the | ||||
| // current voice | // current voice | ||||
| } | } | ||||
| } | } | ||||
| n_ph_list3 = SubstitutePhonemes(tr, ph_list3) - 2; | |||||
| n_ph_list3 = SubstitutePhonemes(ph_list3) - 2; | |||||
| for (j = 0; (j < n_ph_list3) && (ix < N_PHONEME_LIST-3);) { | for (j = 0; (j < n_ph_list3) && (ix < N_PHONEME_LIST-3);) { | ||||
| if (ph_list3[j].sourceix) { | if (ph_list3[j].sourceix) { |
| return -1; | return -1; | ||||
| } | } | ||||
| wave_set_callback_is_output_enabled(fifo_is_command_enabled); | wave_set_callback_is_output_enabled(fifo_is_command_enabled); | ||||
| my_audio = wave_open("alsa"); | |||||
| my_audio = wave_open(); | |||||
| event_init(); | event_init(); | ||||
| } | } | ||||
| } | } | ||||
| return a_wave_can_be_played == 0; // 1 = stop synthesis, -1 = error | return a_wave_can_be_played == 0; // 1 = stop synthesis, -1 = error | ||||
| } | } | ||||
| static int create_events(short *outbuf, int length, espeak_EVENT *event, uint32_t the_write_pos) | |||||
| static int create_events(short *outbuf, int length, espeak_EVENT *event_list, uint32_t the_write_pos) | |||||
| { | { | ||||
| int finished; | int finished; | ||||
| int i = 0; | int i = 0; | ||||
| length = (out_ptr - outbuf)/2; | length = (out_ptr - outbuf)/2; | ||||
| count_samples += length; | count_samples += length; | ||||
| event_list[event_list_ix].type = espeakEVENT_LIST_TERMINATED; // indicates end of event list | event_list[event_list_ix].type = espeakEVENT_LIST_TERMINATED; // indicates end of event list | ||||
| event_list[event_list_ix].unique_identifier = my_unique_identifier; | |||||
| event_list[event_list_ix].unique_identifier = unique_identifier; | |||||
| event_list[event_list_ix].user_data = my_user_data; | event_list[event_list_ix].user_data = my_user_data; | ||||
| count_buffers++; | count_buffers++; | ||||
| unsigned int position, espeak_POSITION_TYPE position_type, | unsigned int position, espeak_POSITION_TYPE position_type, | ||||
| unsigned int end_position, unsigned int flags, void *user_data) | unsigned int end_position, unsigned int flags, void *user_data) | ||||
| { | { | ||||
| (void)size; // unused | |||||
| espeak_ERROR aStatus; | espeak_ERROR aStatus; | ||||
| InitText(flags); | InitText(flags); | ||||
| const char *index_mark, unsigned int end_position, | const char *index_mark, unsigned int end_position, | ||||
| unsigned int flags, void *user_data) | unsigned int flags, void *user_data) | ||||
| { | { | ||||
| (void)size; // unused | |||||
| espeak_ERROR aStatus; | espeak_ERROR aStatus; | ||||
| InitText(flags); | InitText(flags); |
| return word; | return word; | ||||
| } | } | ||||
| static int CheckDottedAbbrev(char *word1, WORD_TAB *wtab) | |||||
| static int CheckDottedAbbrev(char *word1) | |||||
| { | { | ||||
| int wc; | int wc; | ||||
| int count = 0; | int count = 0; | ||||
| if ((word_length == 1) && (dictionary_skipwords == 0)) { | if ((word_length == 1) && (dictionary_skipwords == 0)) { | ||||
| // is this a series of single letters separated by dots? | // is this a series of single letters separated by dots? | ||||
| if (CheckDottedAbbrev(word1, wtab)) { | |||||
| if (CheckDottedAbbrev(word1)) { | |||||
| dictionary_flags[0] = 0; | dictionary_flags[0] = 0; | ||||
| dictionary_flags[1] = 0; | dictionary_flags[1] = 0; | ||||
| spell_word = 1; | spell_word = 1; |
| &tone_pts[8], &tone_pts[9]); | &tone_pts[8], &tone_pts[9]); | ||||
| } | } | ||||
| static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname, const char *leafname) | |||||
| static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname) | |||||
| { | { | ||||
| // Read a Voice file, allocate a VOICE_DATA and set data from the | // Read a Voice file, allocate a VOICE_DATA and set data from the | ||||
| // file's language, gender, name lines | // file's language, gender, name lines | ||||
| voice->freqadd[formant] = freqadd; | voice->freqadd[formant] = freqadd; | ||||
| } | } | ||||
| static void PhonemeReplacement(int type, char *p) | |||||
| static void PhonemeReplacement(char *p) | |||||
| { | { | ||||
| int n; | int n; | ||||
| int phon; | int phon; | ||||
| SelectPhonemeTableName(phonemes_name); | SelectPhonemeTableName(phonemes_name); | ||||
| phonemes_set = 1; | phonemes_set = 1; | ||||
| } | } | ||||
| PhonemeReplacement(key, p); | |||||
| PhonemeReplacement(p); | |||||
| break; | break; | ||||
| case V_WORDGAP: // words | case V_WORDGAP: // words | ||||
| sscanf(p, "%d %d", &langopts->word_gap, &langopts->vowel_pause); | sscanf(p, "%d %d", &langopts->word_gap, &langopts->vowel_pause); | ||||
| continue; | continue; | ||||
| // pass voice file name within the voices directory | // pass voice file name within the voices directory | ||||
| voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, FindFileData.cFileName); | |||||
| voice_data = ReadVoiceFile(f_voice, fname+len_path_voices); | |||||
| fclose(f_voice); | fclose(f_voice); | ||||
| if (voice_data != NULL) | if (voice_data != NULL) | ||||
| continue; | continue; | ||||
| // pass voice file name within the voices directory | // pass voice file name within the voices directory | ||||
| voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, ent->d_name); | |||||
| voice_data = ReadVoiceFile(f_voice, fname+len_path_voices); | |||||
| fclose(f_voice); | fclose(f_voice); | ||||
| if (voice_data != NULL) | if (voice_data != NULL) |
| // wave.cpp (this file) | // wave.cpp (this file) | ||||
| int wave_port_init(int); | int wave_port_init(int); | ||||
| void *wave_port_open(const char *the_api); | |||||
| void *wave_port_open(); | |||||
| size_t wave_port_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize); | size_t wave_port_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize); | ||||
| int wave_port_close(void *theHandler); | int wave_port_close(void *theHandler); | ||||
| int wave_port_is_busy(void *theHandler); | int wave_port_is_busy(void *theHandler); | ||||
| // wave_pulse.cpp | // wave_pulse.cpp | ||||
| int is_pulse_running(); | int is_pulse_running(); | ||||
| int wave_pulse_init(int); | int wave_pulse_init(int); | ||||
| void *wave_pulse_open(const char *the_api); | |||||
| void *wave_pulse_open(); | |||||
| size_t wave_pulse_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize); | size_t wave_pulse_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize); | ||||
| int wave_pulse_close(void *theHandler); | int wave_pulse_close(void *theHandler); | ||||
| int wave_pulse_is_busy(void *theHandler); | int wave_pulse_is_busy(void *theHandler); | ||||
| return wave_port_init(srate); | return wave_port_init(srate); | ||||
| } | } | ||||
| void *wave_open(const char *the_api) | |||||
| void *wave_open() | |||||
| { | { | ||||
| if (pulse_running) | if (pulse_running) | ||||
| return wave_pulse_open(the_api); | |||||
| return wave_pulse_open(); | |||||
| else | else | ||||
| return wave_port_open(the_api); | |||||
| return wave_port_open(); | |||||
| } | } | ||||
| size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize) | size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize) | ||||
| PaStreamCallbackFlags flags, void *userData) | PaStreamCallbackFlags flags, void *userData) | ||||
| #endif | #endif | ||||
| { | { | ||||
| (void)inputBuffer; // unused | |||||
| (void)outTime; // unused | |||||
| (void)userData; // unused | |||||
| int aResult = 0; // paContinue | int aResult = 0; // paContinue | ||||
| char *aWrite = myWrite; | char *aWrite = myWrite; | ||||
| size_t n = out_channels*sizeof(uint16_t)*framesPerBuffer; | size_t n = out_channels*sizeof(uint16_t)*framesPerBuffer; | ||||
| void wave_flush(void *theHandler) | void wave_flush(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| if (my_stream_could_start) | if (my_stream_could_start) | ||||
| start_stream(); | start_stream(); | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| static void select_device(const char *the_api) | |||||
| static void select_device() | |||||
| { | { | ||||
| #if (USE_PORTAUDIO == 19) | #if (USE_PORTAUDIO == 19) | ||||
| int numDevices = Pa_GetDeviceCount(); | int numDevices = Pa_GetDeviceCount(); | ||||
| return err == paNoError; | return err == paNoError; | ||||
| } | } | ||||
| void *wave_open(const char *the_api) | |||||
| void *wave_open() | |||||
| { | { | ||||
| static int once = 0; | static int once = 0; | ||||
| if (!once) { | if (!once) { | ||||
| select_device("alsa"); | |||||
| select_device(); | |||||
| once = 1; | once = 1; | ||||
| } | } | ||||
| return (void *)1; | return (void *)1; | ||||
| size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize) | size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| size_t bytes_written = 0; | size_t bytes_written = 0; | ||||
| // space in ringbuffer for the sample needed: 1x mono channel but 2x for 1 stereo channel | // space in ringbuffer for the sample needed: 1x mono channel but 2x for 1 stereo channel | ||||
| size_t bytes_to_write = (out_channels == 1) ? theSize : theSize*2; | size_t bytes_to_write = (out_channels == 1) ? theSize : theSize*2; | ||||
| int wave_close(void *theHandler) | int wave_close(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| static int aStopStreamCount = 0; | static int aStopStreamCount = 0; | ||||
| #if (USE_PORTAUDIO == 19) | #if (USE_PORTAUDIO == 19) | ||||
| int wave_is_busy(void *theHandler) | int wave_is_busy(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| PaError active = 0; | PaError active = 0; | ||||
| if (pa_stream) { | if (pa_stream) { | ||||
| uint32_t wave_get_read_position(void *theHandler) | uint32_t wave_get_read_position(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return myReadPosition; | return myReadPosition; | ||||
| } | } | ||||
| uint32_t wave_get_write_position(void *theHandler) | uint32_t wave_get_write_position(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return myWritePosition; | return myWritePosition; | ||||
| } | } | ||||
| int wave_init(int srate) | int wave_init(int srate) | ||||
| { | { | ||||
| (void)srate; // unused | |||||
| return 1; | return 1; | ||||
| } | } | ||||
| void *wave_open(const char *the_api) | |||||
| void *wave_open() | |||||
| { | { | ||||
| return (void *)1; | return (void *)1; | ||||
| } | } | ||||
| size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize) | size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| (void)theMono16BitsWaveBuffer; // unused | |||||
| return theSize; | return theSize; | ||||
| } | } | ||||
| int wave_close(void *theHandler) | int wave_close(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| int wave_is_busy(void *theHandler) | int wave_is_busy(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| uint32_t wave_get_read_position(void *theHandler) | uint32_t wave_get_read_position(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| uint32_t wave_get_write_position(void *theHandler) | uint32_t wave_get_write_position(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| void wave_flush(void *theHandler) | void wave_flush(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| } | } | ||||
| typedef int (t_wave_callback)(void); | typedef int (t_wave_callback)(void); | ||||
| void wave_set_callback_is_output_enabled(t_wave_callback *cb) | void wave_set_callback_is_output_enabled(t_wave_callback *cb) | ||||
| { | { | ||||
| (void)cb; // unused | |||||
| } | } | ||||
| extern void *wave_test_get_write_buffer() | extern void *wave_test_get_write_buffer() | ||||
| int wave_get_remaining_time(uint32_t sample, uint32_t *time) | int wave_get_remaining_time(uint32_t sample, uint32_t *time) | ||||
| { | { | ||||
| (void)sample; // unused | |||||
| if (!time) return -1; | if (!time) return -1; | ||||
| *time = (uint32_t)0; | *time = (uint32_t)0; | ||||
| return 0; | return 0; |
| extern int option_device_number; | extern int option_device_number; | ||||
| extern int wave_init(int samplerate); | extern int wave_init(int samplerate); | ||||
| extern void *wave_open(const char *the_api); | |||||
| extern void *wave_open(); | |||||
| extern size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize); | extern size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize); | ||||
| extern int wave_close(void *theHandler); | extern int wave_close(void *theHandler); |
| static void subscribe_cb(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata) | static void subscribe_cb(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata) | ||||
| { | { | ||||
| (void)userdata; // unused | |||||
| assert(c); | assert(c); | ||||
| if (!stream || | if (!stream || | ||||
| static void context_state_cb(pa_context *c, void *userdata) | static void context_state_cb(pa_context *c, void *userdata) | ||||
| { | { | ||||
| (void)userdata; // unused | |||||
| assert(c); | assert(c); | ||||
| switch (pa_context_get_state(c)) | switch (pa_context_get_state(c)) | ||||
| static void stream_state_cb(pa_stream *s, void *userdata) | static void stream_state_cb(pa_stream *s, void *userdata) | ||||
| { | { | ||||
| (void)userdata; // unused | |||||
| assert(s); | assert(s); | ||||
| switch (pa_stream_get_state(s)) | switch (pa_stream_get_state(s)) | ||||
| static void stream_request_cb(pa_stream *s, size_t length, void *userdata) | static void stream_request_cb(pa_stream *s, size_t length, void *userdata) | ||||
| { | { | ||||
| (void)length; // unused | |||||
| (void)userdata; // unused | |||||
| assert(s); | assert(s); | ||||
| pa_threaded_mainloop_signal(mainloop, 0); | pa_threaded_mainloop_signal(mainloop, 0); | ||||
| static void stream_latency_update_cb(pa_stream *s, void *userdata) | static void stream_latency_update_cb(pa_stream *s, void *userdata) | ||||
| { | { | ||||
| (void)userdata; // unused | |||||
| assert(s); | assert(s); | ||||
| pa_threaded_mainloop_signal(mainloop, 0); | pa_threaded_mainloop_signal(mainloop, 0); | ||||
| void wave_flush(void *theHandler) | void wave_flush(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| } | } | ||||
| void wave_set_callback_is_output_enabled(t_wave_callback *cb) | void wave_set_callback_is_output_enabled(t_wave_callback *cb) | ||||
| return pulse_open() == PULSE_OK; | return pulse_open() == PULSE_OK; | ||||
| } | } | ||||
| void *wave_open(const char *the_api) | |||||
| void *wave_open() | |||||
| { | { | ||||
| return (void *)1; | return (void *)1; | ||||
| } | } | ||||
| size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize) | size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| size_t bytes_to_write = theSize; | size_t bytes_to_write = theSize; | ||||
| char *aBuffer = theMono16BitsWaveBuffer; | char *aBuffer = theMono16BitsWaveBuffer; | ||||
| int wave_close(void *theHandler) | int wave_close(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| static int aStopStreamCount = 0; | static int aStopStreamCount = 0; | ||||
| // Avoid race condition by making sure this function only | // Avoid race condition by making sure this function only | ||||
| int wave_is_busy(void *theHandler) | int wave_is_busy(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| pa_timing_info a_timing_info; | pa_timing_info a_timing_info; | ||||
| int active = pulse_playing(&a_timing_info); | int active = pulse_playing(&a_timing_info); | ||||
| return active; | return active; | ||||
| uint32_t wave_get_read_position(void *theHandler) | uint32_t wave_get_read_position(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| pa_timing_info a_timing_info; | pa_timing_info a_timing_info; | ||||
| pulse_playing(&a_timing_info); | pulse_playing(&a_timing_info); | ||||
| return a_timing_info.read_index; | return a_timing_info.read_index; | ||||
| uint32_t wave_get_write_position(void *theHandler) | uint32_t wave_get_write_position(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| pa_timing_info a_timing_info; | pa_timing_info a_timing_info; | ||||
| pulse_playing(&a_timing_info); | pulse_playing(&a_timing_info); | ||||
| return a_timing_info.write_index; | return a_timing_info.write_index; | ||||
| int wave_init(int srate) | int wave_init(int srate) | ||||
| { | { | ||||
| (void)srate; // unused | |||||
| return 1; | return 1; | ||||
| } | } | ||||
| void *wave_open(const char *the_api) | |||||
| void *wave_open() | |||||
| { | { | ||||
| return (void *)1; | return (void *)1; | ||||
| } | } | ||||
| size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize) | size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| (void)theMono16BitsWaveBuffer; // unused | |||||
| return theSize; | return theSize; | ||||
| } | } | ||||
| int wave_close(void *theHandler) | int wave_close(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| int wave_is_busy(void *theHandler) | int wave_is_busy(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| uint32_t wave_get_read_position(void *theHandler) | uint32_t wave_get_read_position(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| uint32_t wave_get_write_position(void *theHandler) | uint32_t wave_get_write_position(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| void wave_flush(void *theHandler) | void wave_flush(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| } | } | ||||
| typedef int (t_wave_callback)(void); | typedef int (t_wave_callback)(void); | ||||
| void wave_set_callback_is_output_enabled(t_wave_callback *cb) | void wave_set_callback_is_output_enabled(t_wave_callback *cb) | ||||
| { | { | ||||
| (void)cb; // unused | |||||
| } | } | ||||
| extern void *wave_test_get_write_buffer() | extern void *wave_test_get_write_buffer() | ||||
| int wave_get_remaining_time(uint32_t sample, uint32_t *time) | int wave_get_remaining_time(uint32_t sample, uint32_t *time) | ||||
| { | { | ||||
| (void)sample; // unused | |||||
| if (!time) return -1; | if (!time) return -1; | ||||
| *time = (uint32_t)0; | *time = (uint32_t)0; | ||||
| return 0; | return 0; |
| // | // | ||||
| // DESCRIPTION: | // DESCRIPTION: | ||||
| // | // | ||||
| // opens the audio subsystem given a specific API (e.g., "alsa", | |||||
| // "oss", ...). We ignore the_api and just return the sun_audio_fd we | |||||
| // opens the audio subsystem. We just return the sun_audio_fd we | |||||
| // opened in wave_init. This return value will be passed in as the | // opened in wave_init. This return value will be passed in as the | ||||
| // theHandler parameter in all other methods. | // theHandler parameter in all other methods. | ||||
| // | // | ||||
| // PARAMETERS: | |||||
| // | |||||
| // the_api: "alsa", "oss" (ignored) | |||||
| // | |||||
| // GLOBALS USED/MODIFIED: | // GLOBALS USED/MODIFIED: | ||||
| // | // | ||||
| // sun_audio_fd: used as return value | // sun_audio_fd: used as return value | ||||
| // sun_audio_fd opened in wave_init, which is passed in as theHandler | // sun_audio_fd opened in wave_init, which is passed in as theHandler | ||||
| // parameter in all other methods | // parameter in all other methods | ||||
| // | // | ||||
| void *wave_open(const char *the_api) | |||||
| void *wave_open() | |||||
| { | { | ||||
| return (void *)sun_audio_fd; | return (void *)sun_audio_fd; | ||||
| } | } | ||||
| // | // | ||||
| int wave_is_busy(void *theHandler) | int wave_is_busy(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| uint32_t time; | uint32_t time; | ||||
| if (total_samples_sent >= 1) | if (total_samples_sent >= 1) | ||||
| wave_get_remaining_time(total_samples_sent - 1, &time); | wave_get_remaining_time(total_samples_sent - 1, &time); | ||||
| // | // | ||||
| void wave_flush(void *theHandler) | void wave_flush(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| } | } | ||||
| // wave_set_callback_is_output_enabled | // wave_set_callback_is_output_enabled | ||||
| // | // | ||||
| uint32_t wave_get_write_position(void *theHandler) | uint32_t wave_get_write_position(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return total_samples_sent; | return total_samples_sent; | ||||
| } | } | ||||
| int wave_init(int srate) | int wave_init(int srate) | ||||
| { | { | ||||
| (void)srate; // unused | |||||
| return 1; | return 1; | ||||
| } | } | ||||
| void *wave_open(const char *the_api) | |||||
| void *wave_open() | |||||
| { | { | ||||
| return (void *)1; | return (void *)1; | ||||
| } | } | ||||
| size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize) | size_t wave_write(void *theHandler, char *theMono16BitsWaveBuffer, size_t theSize) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| (void)theMono16BitsWaveBuffer; // unused | |||||
| return theSize; | return theSize; | ||||
| } | } | ||||
| int wave_close(void *theHandler) | int wave_close(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| int wave_is_busy(void *theHandler) | int wave_is_busy(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| uint32_t wave_get_read_position(void *theHandler) | uint32_t wave_get_read_position(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| uint32_t wave_get_write_position(void *theHandler) | uint32_t wave_get_write_position(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| void wave_flush(void *theHandler) | void wave_flush(void *theHandler) | ||||
| { | { | ||||
| (void)theHandler; // unused | |||||
| } | } | ||||
| typedef int (t_wave_callback)(void); | typedef int (t_wave_callback)(void); | ||||
| void wave_set_callback_is_output_enabled(t_wave_callback *cb) | void wave_set_callback_is_output_enabled(t_wave_callback *cb) | ||||
| { | { | ||||
| (void)cb; // unused | |||||
| } | } | ||||
| extern void *wave_test_get_write_buffer() | extern void *wave_test_get_write_buffer() | ||||
| int wave_get_remaining_time(uint32_t sample, uint32_t *time) | int wave_get_remaining_time(uint32_t sample, uint32_t *time) | ||||
| { | { | ||||
| (void)sample; // unused | |||||
| if (!time) return -1; | if (!time) return -1; | ||||
| *time = (uint32_t)0; | *time = (uint32_t)0; | ||||
| return 0; | return 0; |
| PaStreamCallbackFlags flags, void *userData) | PaStreamCallbackFlags flags, void *userData) | ||||
| #endif | #endif | ||||
| { | { | ||||
| (void)inputBuffer; // unused | |||||
| (void)outTime; // unused | |||||
| (void)userData; // unused | |||||
| int ix; | int ix; | ||||
| int result; | int result; | ||||
| unsigned char *p; | unsigned char *p; |
| static void init_path(char *argv0, char *path_specified) | static void init_path(char *argv0, char *path_specified) | ||||
| { | { | ||||
| (void)argv0; // unused (except with PLATFORM_WINDOWS) | |||||
| if (path_specified) { | if (path_specified) { | ||||
| sprintf(path_home, "%s/espeak-data", path_specified); | sprintf(path_home, "%s/espeak-data", path_specified); | ||||
| return; | return; |