git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4587 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.9.8
| @@ -165,14 +165,14 @@ int JackAudioAdapter::Open() | |||||
| fPlaybackPortList = new jack_port_t*[fAudioAdapter->GetOutputs()]; | fPlaybackPortList = new jack_port_t*[fAudioAdapter->GetOutputs()]; | ||||
| for (int i = 0; i < fAudioAdapter->GetInputs(); i++) { | for (int i = 0; i < fAudioAdapter->GetInputs(); i++) { | ||||
| sprintf(name, "capture_%d", i + 1); | |||||
| snprintf(name, sizeof(name), "capture_%d", i + 1); | |||||
| if ((fCapturePortList[i] = jack_port_register(fClient, name, JACK_DEFAULT_AUDIO_TYPE, CaptureDriverFlags, 0)) == NULL) { | if ((fCapturePortList[i] = jack_port_register(fClient, name, JACK_DEFAULT_AUDIO_TYPE, CaptureDriverFlags, 0)) == NULL) { | ||||
| goto fail; | goto fail; | ||||
| } | } | ||||
| } | } | ||||
| for (int i = 0; i < fAudioAdapter->GetOutputs(); i++) { | for (int i = 0; i < fAudioAdapter->GetOutputs(); i++) { | ||||
| sprintf(name, "playback_%d", i + 1); | |||||
| snprintf(name, sizeof(name), "playback_%d", i + 1); | |||||
| if ((fPlaybackPortList[i] = jack_port_register(fClient, name, JACK_DEFAULT_AUDIO_TYPE, PlaybackDriverFlags, 0)) == NULL) { | if ((fPlaybackPortList[i] = jack_port_register(fClient, name, JACK_DEFAULT_AUDIO_TYPE, PlaybackDriverFlags, 0)) == NULL) { | ||||
| goto fail; | goto fail; | ||||
| } | } | ||||
| @@ -90,7 +90,7 @@ int JackDebugClient::Open(const char* server_name, const char* name, int uuid, j | |||||
| /* Convert it to local time representation. */ | /* Convert it to local time representation. */ | ||||
| loctime = localtime (&curtime); | loctime = localtime (&curtime); | ||||
| strftime (buffer, 256, "%I-%M", loctime); | strftime (buffer, 256, "%I-%M", loctime); | ||||
| sprintf(provstr, "JackClientDebug-%s-%s.log", name, buffer); | |||||
| snprintf(provstr, sizeof(provstr), "JackClientDebug-%s-%s.log", name, buffer); | |||||
| fStream = new ofstream(provstr, ios_base::ate); | fStream = new ofstream(provstr, ios_base::ate); | ||||
| if (fStream->is_open()) { | if (fStream->is_open()) { | ||||
| if (res == -1) { | if (res == -1) { | ||||
| @@ -266,7 +266,7 @@ jackctl_parse_driver_params(jackctl_driver *driver_ptr, int argc, char* argv[]) | |||||
| options_ptr = options; | options_ptr = options; | ||||
| for (i = 0; i < desc->nparams; i++) { | for (i = 0; i < desc->nparams; i++) { | ||||
| sprintf (options_ptr, "%c::", desc->params[i].character); | |||||
| sprintf(options_ptr, "%c::", desc->params[i].character); | |||||
| options_ptr += 3; | options_ptr += 3; | ||||
| long_options[i].name = desc->params[i].name; | long_options[i].name = desc->params[i].name; | ||||
| long_options[i].flag = NULL; | long_options[i].flag = NULL; | ||||
| @@ -410,8 +410,9 @@ jack_get_descriptor (JSList * drivers, const char* sofile, const char* symbol) | |||||
| #endif | #endif | ||||
| } | } | ||||
| filename = (char*)malloc(strlen (driver_dir) + 1 + strlen(sofile) + 1); | |||||
| sprintf (filename, "%s/%s", driver_dir, sofile); | |||||
| int len = strlen(driver_dir) + 1 + strlen(sofile) + 1; | |||||
| filename = (char*)malloc(len); | |||||
| snprintf(filename, len, "%s/%s", driver_dir, sofile); | |||||
| if ((dlhandle = LoadDriverModule(filename)) == NULL) { | if ((dlhandle = LoadDriverModule(filename)) == NULL) { | ||||
| #ifdef WIN32 | #ifdef WIN32 | ||||
| @@ -495,15 +496,16 @@ static bool check_symbol(const char* sofile, const char* symbol) | |||||
| } else { | } else { | ||||
| GetCurrentDirectory(512, temp_driver_dir1); | GetCurrentDirectory(512, temp_driver_dir1); | ||||
| } | } | ||||
| sprintf(temp_driver_dir2, "%s/%s", temp_driver_dir1, ADDON_DIR); | |||||
| snprintf(temp_driver_dir2, sizeof(temp_driver_dir2), "%s/%s", temp_driver_dir1, ADDON_DIR); | |||||
| driver_dir = temp_driver_dir2; | driver_dir = temp_driver_dir2; | ||||
| #else | #else | ||||
| driver_dir = ADDON_DIR; | driver_dir = ADDON_DIR; | ||||
| #endif | #endif | ||||
| } | } | ||||
| char* filename = (char*)malloc(strlen (driver_dir) + 1 + strlen(sofile) + 1); | |||||
| sprintf (filename, "%s/%s", driver_dir, sofile); | |||||
| int len = strlen(driver_dir) + 1 + strlen(sofile) + 1; | |||||
| char* filename = (char*)malloc(len); | |||||
| snprintf(filename, len, "%s/%s", driver_dir, sofile); | |||||
| if ((dlhandle = LoadDriverModule(filename)) == NULL) { | if ((dlhandle = LoadDriverModule(filename)) == NULL) { | ||||
| #ifdef WIN32 | #ifdef WIN32 | ||||
| @@ -549,7 +551,7 @@ jack_drivers_load (JSList * drivers) { | |||||
| driver_dir = driver_dir_storage; | driver_dir = driver_dir_storage; | ||||
| } | } | ||||
| sprintf(dll_filename, "%s/*.dll", driver_dir); | |||||
| snprintf(dll_filename, sizeof(dll_filename), "%s/*.dll", driver_dir); | |||||
| file = (HANDLE )FindFirstFile(dll_filename, &filedata); | file = (HANDLE )FindFirstFile(dll_filename, &filedata); | ||||
| @@ -694,7 +696,7 @@ jack_internals_load (JSList * internals) { | |||||
| driver_dir = driver_dir_storage; | driver_dir = driver_dir_storage; | ||||
| } | } | ||||
| sprintf(dll_filename, "%s/*.dll", driver_dir); | |||||
| snprintf(dll_filename, sizeof(dll_filename), "%s/*.dll", driver_dir); | |||||
| file = (HANDLE )FindFirstFile(dll_filename, &filedata); | file = (HANDLE )FindFirstFile(dll_filename, &filedata); | ||||
| @@ -52,8 +52,8 @@ void JackGlobals::CheckContext(const char* name) | |||||
| curtime = time (NULL); | curtime = time (NULL); | ||||
| /* Convert it to local time representation. */ | /* Convert it to local time representation. */ | ||||
| loctime = localtime (&curtime); | loctime = localtime (&curtime); | ||||
| strftime (buffer, 256, "%I-%M", loctime); | |||||
| sprintf(provstr, "JackAPICall-%s.log", buffer); | |||||
| strftime(buffer, 256, "%I-%M", loctime); | |||||
| sprintnf(provstr, sizeof(provstr), "JackAPICall-%s.log", buffer); | |||||
| JackGlobals::fStream = new std::ofstream(provstr, std::ios_base::ate); | JackGlobals::fStream = new std::ofstream(provstr, std::ios_base::ate); | ||||
| JackGlobals::fStream->is_open(); | JackGlobals::fStream->is_open(); | ||||
| } | } | ||||
| @@ -176,7 +176,7 @@ namespace Jack | |||||
| //audio | //audio | ||||
| for (i = 0; i < fParams.fSendAudioChannels; i++) { | for (i = 0; i < fParams.fSendAudioChannels; i++) { | ||||
| sprintf(name, "to_slave_%d", i+1); | |||||
| snprintf(name, sizeof(name), "to_slave_%d", i+1); | |||||
| if ((fAudioCapturePorts[i] = jack_port_register(fJackClient, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput | JackPortIsTerminal, 0)) == NULL) | if ((fAudioCapturePorts[i] = jack_port_register(fJackClient, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput | JackPortIsTerminal, 0)) == NULL) | ||||
| return -1; | return -1; | ||||
| //port latency | //port latency | ||||
| @@ -185,7 +185,7 @@ namespace Jack | |||||
| } | } | ||||
| for (i = 0; i < fParams.fReturnAudioChannels; i++) { | for (i = 0; i < fParams.fReturnAudioChannels; i++) { | ||||
| sprintf(name, "from_slave_%d", i+1); | |||||
| snprintf(name, sizeof(name), "from_slave_%d", i+1); | |||||
| if ((fAudioPlaybackPorts[i] = jack_port_register(fJackClient, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput | JackPortIsTerminal, 0)) == NULL) | if ((fAudioPlaybackPorts[i] = jack_port_register(fJackClient, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput | JackPortIsTerminal, 0)) == NULL) | ||||
| return -1; | return -1; | ||||
| //port latency | //port latency | ||||
| @@ -195,7 +195,7 @@ namespace Jack | |||||
| //midi | //midi | ||||
| for (i = 0; i < fParams.fSendMidiChannels; i++) { | for (i = 0; i < fParams.fSendMidiChannels; i++) { | ||||
| sprintf(name, "midi_to_slave_%d", i+1); | |||||
| snprintf(name, sizeof(name), "midi_to_slave_%d", i+1); | |||||
| if ((fMidiCapturePorts[i] = jack_port_register(fJackClient, name, JACK_DEFAULT_MIDI_TYPE, JackPortIsInput | JackPortIsTerminal, 0)) == NULL) | if ((fMidiCapturePorts[i] = jack_port_register(fJackClient, name, JACK_DEFAULT_MIDI_TYPE, JackPortIsInput | JackPortIsTerminal, 0)) == NULL) | ||||
| return -1; | return -1; | ||||
| //port latency | //port latency | ||||
| @@ -204,7 +204,7 @@ namespace Jack | |||||
| } | } | ||||
| for (i = 0; i < fParams.fReturnMidiChannels; i++) { | for (i = 0; i < fParams.fReturnMidiChannels; i++) { | ||||
| sprintf(name, "midi_from_slave_%d", i+1); | |||||
| snprintf(name, sizeof(name), "midi_from_slave_%d", i+1); | |||||
| if ((fMidiPlaybackPorts[i] = jack_port_register(fJackClient, name, JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput | JackPortIsTerminal, 0)) == NULL) | if ((fMidiPlaybackPorts[i] = jack_port_register(fJackClient, name, JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput | JackPortIsTerminal, 0)) == NULL) | ||||
| return -1; | return -1; | ||||
| //port latency | //port latency | ||||
| @@ -779,7 +779,8 @@ namespace Jack | |||||
| jack_info("Takes physical %d outputs for client", params.fReturnAudioChannels); | jack_info("Takes physical %d outputs for client", params.fReturnAudioChannels); | ||||
| } | } | ||||
| SetSlaveName(params); | |||||
| // Rename done in jack_client_open if needed ? | |||||
| //SetSlaveName(params); | |||||
| //create a new master and add it to the list | //create a new master and add it to the list | ||||
| JackNetMaster* master = new JackNetMaster(fSocket, params, fMulticastIP); | JackNetMaster* master = new JackNetMaster(fSocket, params, fMulticastIP); | ||||
| @@ -798,7 +799,7 @@ namespace Jack | |||||
| master_list_it_t it; | master_list_it_t it; | ||||
| for (it = fMasterList.begin(); it != fMasterList.end(); it++) { | for (it = fMasterList.begin(); it != fMasterList.end(); it++) { | ||||
| if (strcmp((*it)->fParams.fName, params.fName) == 0) { | if (strcmp((*it)->fParams.fName, params.fName) == 0) { | ||||
| sprintf(params.fName, "%s-%u", params.fName, params.fID); | |||||
| snprintf(params.fName, sizeof(params.fName), "%s-%u", params.fName, params.fID); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -574,7 +574,7 @@ enum_alsa_devices() | |||||
| while(snd_card_next(&card_no) >= 0 && card_no >= 0) | while(snd_card_next(&card_no) >= 0 && card_no >= 0) | ||||
| { | { | ||||
| sprintf(card_id, "hw:%d", card_no); | |||||
| snprintf(card_id, sizeof(card_id), "hw:%d", card_no); | |||||
| if (snd_ctl_open(&handle, card_id, 0) >= 0 && | if (snd_ctl_open(&handle, card_id, 0) >= 0 && | ||||
| snd_ctl_card_info(handle, info) >= 0) | snd_ctl_card_info(handle, info) >= 0) | ||||
| @@ -585,7 +585,7 @@ enum_alsa_devices() | |||||
| while (snd_ctl_pcm_next_device(handle, &device_no) >= 0 && device_no != -1) | while (snd_ctl_pcm_next_device(handle, &device_no) >= 0 && device_no != -1) | ||||
| { | { | ||||
| sprintf(device_id, "%s,%d", card_id, device_no); | |||||
| snprintf(device_id, sizeof(device_id), "%s,%d", card_id, device_no); | |||||
| snd_pcm_info_set_device(pcminfo_capture, device_no); | snd_pcm_info_set_device(pcminfo_capture, device_no); | ||||
| snd_pcm_info_set_subdevice(pcminfo_capture, 0); | snd_pcm_info_set_subdevice(pcminfo_capture, 0); | ||||
| @@ -28,11 +28,11 @@ namespace Jack | |||||
| mach_port_t JackMachSemaphore::fBootPort = 0; | mach_port_t JackMachSemaphore::fBootPort = 0; | ||||
| void JackMachSemaphore::BuildName(const char* client_name, const char* server_name, char* res) | |||||
| void JackMachSemaphore::BuildName(const char* client_name, const char* server_name, char* res, int size) | |||||
| { | { | ||||
| char ext_client_name[JACK_CLIENT_NAME_SIZE + 1]; | char ext_client_name[JACK_CLIENT_NAME_SIZE + 1]; | ||||
| JackTools::RewriteName(client_name, ext_client_name); | JackTools::RewriteName(client_name, ext_client_name); | ||||
| sprintf(res, "jack_mach_sem.%d_%s_%s", JackTools::GetUID(), server_name, ext_client_name); | |||||
| snprintf(res, size, "jack_mach_sem.%d_%s_%s", JackTools::GetUID(), server_name, ext_client_name); | |||||
| } | } | ||||
| bool JackMachSemaphore::Signal() | bool JackMachSemaphore::Signal() | ||||
| @@ -105,7 +105,7 @@ bool JackMachSemaphore::TimedWait(long usec) | |||||
| // Server side : publish the semaphore in the global namespace | // Server side : publish the semaphore in the global namespace | ||||
| bool JackMachSemaphore::Allocate(const char* name, const char* server_name, int value) | bool JackMachSemaphore::Allocate(const char* name, const char* server_name, int value) | ||||
| { | { | ||||
| BuildName(name, server_name, fName); | |||||
| BuildName(name, server_name, fName, sizeof(fName)); | |||||
| mach_port_t task = mach_task_self(); | mach_port_t task = mach_task_self(); | ||||
| kern_return_t res; | kern_return_t res; | ||||
| @@ -149,7 +149,7 @@ bool JackMachSemaphore::Allocate(const char* name, const char* server_name, int | |||||
| // Client side : get the published semaphore from server | // Client side : get the published semaphore from server | ||||
| bool JackMachSemaphore::ConnectInput(const char* name, const char* server_name) | bool JackMachSemaphore::ConnectInput(const char* name, const char* server_name) | ||||
| { | { | ||||
| BuildName(name, server_name, fName); | |||||
| BuildName(name, server_name, fName, sizeof(fName)); | |||||
| kern_return_t res; | kern_return_t res; | ||||
| // Temporary... A REVOIR | // Temporary... A REVOIR | ||||
| @@ -12,7 +12,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
| You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
| along with this program; if not, write to the Free Software | |||||
| along with this program; if not, write to the Free Software | |||||
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
| */ | */ | ||||
| @@ -43,7 +43,7 @@ class SERVER_EXPORT JackMachSemaphore : public detail::JackSynchro | |||||
| protected: | protected: | ||||
| void BuildName(const char* name, const char* server_name, char* res); | |||||
| void BuildName(const char* name, const char* server_name, char* res, int size); | |||||
| public: | public: | ||||
| @@ -40,7 +40,7 @@ JackCoreMidiOutputPort::JackCoreMidiOutputPort(double time_ratio, | |||||
| std::auto_ptr<JackMidiAsyncQueue> thread_queue_ptr(thread_queue); | std::auto_ptr<JackMidiAsyncQueue> thread_queue_ptr(thread_queue); | ||||
| thread = new JackThread(this); | thread = new JackThread(this); | ||||
| std::auto_ptr<JackThread> thread_ptr(thread); | std::auto_ptr<JackThread> thread_ptr(thread); | ||||
| sprintf(semaphore_name, "coremidi_%p", this); | |||||
| snprintf(semaphore_name, sizeof(semaphore_name), "coremidi_%p", this); | |||||
| thread_queue_semaphore = sem_open(semaphore_name, O_CREAT, 0777, 0); | thread_queue_semaphore = sem_open(semaphore_name, O_CREAT, 0777, 0); | ||||
| if (thread_queue_semaphore == (sem_t *) SEM_FAILED) { | if (thread_queue_semaphore == (sem_t *) SEM_FAILED) { | ||||
| throw std::runtime_error(strerror(errno)); | throw std::runtime_error(strerror(errno)); | ||||
| @@ -28,11 +28,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||||
| namespace Jack | namespace Jack | ||||
| { | { | ||||
| void JackPosixSemaphore::BuildName(const char* client_name, const char* server_name, char* res) | |||||
| void JackPosixSemaphore::BuildName(const char* client_name, const char* server_name, char* res, int size) | |||||
| { | { | ||||
| char ext_client_name[JACK_CLIENT_NAME_SIZE + 1]; | char ext_client_name[JACK_CLIENT_NAME_SIZE + 1]; | ||||
| JackTools::RewriteName(client_name, ext_client_name); | JackTools::RewriteName(client_name, ext_client_name); | ||||
| sprintf(res, "jack_sem.%d_%s_%s", JackTools::GetUID(), server_name, ext_client_name); | |||||
| snprintf(res, size, "jack_sem.%d_%s_%s", JackTools::GetUID(), server_name, ext_client_name); | |||||
| } | } | ||||
| bool JackPosixSemaphore::Signal() | bool JackPosixSemaphore::Signal() | ||||
| @@ -140,7 +140,7 @@ bool JackPosixSemaphore::TimedWait(long usec) | |||||
| // Server side : publish the semaphore in the global namespace | // Server side : publish the semaphore in the global namespace | ||||
| bool JackPosixSemaphore::Allocate(const char* name, const char* server_name, int value) | bool JackPosixSemaphore::Allocate(const char* name, const char* server_name, int value) | ||||
| { | { | ||||
| BuildName(name, server_name, fName); | |||||
| BuildName(name, server_name, fName, sizeof(fName)); | |||||
| jack_log("JackPosixSemaphore::Allocate name = %s val = %ld", fName, value); | jack_log("JackPosixSemaphore::Allocate name = %s val = %ld", fName, value); | ||||
| if ((fSemaphore = sem_open(fName, O_CREAT, 0777, value)) == (sem_t*)SEM_FAILED) { | if ((fSemaphore = sem_open(fName, O_CREAT, 0777, value)) == (sem_t*)SEM_FAILED) { | ||||
| @@ -154,7 +154,7 @@ bool JackPosixSemaphore::Allocate(const char* name, const char* server_name, int | |||||
| // Client side : get the published semaphore from server | // Client side : get the published semaphore from server | ||||
| bool JackPosixSemaphore::ConnectInput(const char* name, const char* server_name) | bool JackPosixSemaphore::ConnectInput(const char* name, const char* server_name) | ||||
| { | { | ||||
| BuildName(name, server_name, fName); | |||||
| BuildName(name, server_name, fName, sizeof(fName)); | |||||
| jack_log("JackPosixSemaphore::Connect name = %s", fName); | jack_log("JackPosixSemaphore::Connect name = %s", fName); | ||||
| // Temporary... | // Temporary... | ||||
| @@ -12,7 +12,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
| You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
| along with this program; if not, write to the Free Software | |||||
| along with this program; if not, write to the Free Software | |||||
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
| */ | */ | ||||
| @@ -42,7 +42,7 @@ class SERVER_EXPORT JackPosixSemaphore : public detail::JackSynchro | |||||
| protected: | protected: | ||||
| void BuildName(const char* name, const char* server_name, char* res); | |||||
| void BuildName(const char* name, const char* server_name, char* res, int size); | |||||
| public: | public: | ||||
| @@ -1,20 +1,20 @@ | |||||
| /* | /* | ||||
| Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
| This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
| the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
| (at your option) any later version. | (at your option) any later version. | ||||
| This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
| GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
| You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
| along with this program; if not, write to the Free Software | along with this program; if not, write to the Free Software | ||||
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
| */ | */ | ||||
| @@ -29,9 +29,9 @@ | |||||
| namespace Jack | namespace Jack | ||||
| { | { | ||||
| void JackWinEvent::BuildName(const char* name, const char* server_name, char* res) | |||||
| void JackWinEvent::BuildName(const char* name, const char* server_name, char* res, int size) | |||||
| { | { | ||||
| sprintf(res, "jack_pipe.%s_%s", server_name, name); | |||||
| snprintf(res, size, "jack_pipe.%s_%s", server_name, name); | |||||
| } | } | ||||
| bool JackWinEvent::Signal() | bool JackWinEvent::Signal() | ||||
| @@ -89,7 +89,7 @@ bool JackWinEvent::TimedWait(long usec) | |||||
| // Client side : get the published semaphore from server | // Client side : get the published semaphore from server | ||||
| bool JackWinEvent::ConnectInput(const char* name, const char* server_name) | bool JackWinEvent::ConnectInput(const char* name, const char* server_name) | ||||
| { | { | ||||
| BuildName(name, server_name, fName); | |||||
| BuildName(name, server_name, fName, sizeof(fName)); | |||||
| jack_log("JackWinEvent::Connect %s", fName); | jack_log("JackWinEvent::Connect %s", fName); | ||||
| // Temporary... | // Temporary... | ||||
| @@ -130,7 +130,7 @@ bool JackWinEvent::Disconnect() | |||||
| bool JackWinEvent::Allocate(const char* name, const char* server_name, int value) | bool JackWinEvent::Allocate(const char* name, const char* server_name, int value) | ||||
| { | { | ||||
| BuildName(name, server_name, fName); | |||||
| BuildName(name, server_name, fName, sizeof(fName)); | |||||
| jack_log("JackWinEvent::Allocate name = %s val = %ld", fName, value); | jack_log("JackWinEvent::Allocate name = %s val = %ld", fName, value); | ||||
| /* create an auto reset event */ | /* create an auto reset event */ | ||||
| @@ -1,20 +1,20 @@ | |||||
| /* | /* | ||||
| Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
| This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
| the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
| (at your option) any later version. | (at your option) any later version. | ||||
| This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
| GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
| You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
| along with this program; if not, write to the Free Software | along with this program; if not, write to the Free Software | ||||
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
| */ | */ | ||||
| #ifndef __JackWinEvent__ | #ifndef __JackWinEvent__ | ||||
| @@ -41,7 +41,7 @@ class JackWinEvent : public JackSynchro | |||||
| protected: | protected: | ||||
| void BuildName(const char* name, const char* server_name, char* res); | |||||
| void BuildName(const char* name, const char* server_name, char* res, int size); | |||||
| public: | public: | ||||
| @@ -1,20 +1,20 @@ | |||||
| /* | /* | ||||
| Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
| This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
| the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
| (at your option) any later version. | (at your option) any later version. | ||||
| This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
| GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
| You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
| along with this program; if not, write to the Free Software | along with this program; if not, write to the Free Software | ||||
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
| */ | */ | ||||
| @@ -54,7 +54,7 @@ int JackWinNamedPipe::Write(void* data, int len) | |||||
| int JackWinNamedPipeClient::Connect(const char* dir, int which) | int JackWinNamedPipeClient::Connect(const char* dir, int which) | ||||
| { | { | ||||
| sprintf(fName, "\\\\.\\pipe\\%s_jack_%d", dir, which); | |||||
| snprintf(fName, sizeof(fName), "\\\\.\\pipe\\%s_jack_%d", dir, which); | |||||
| jack_log("Connect: fName %s", fName); | jack_log("Connect: fName %s", fName); | ||||
| fNamedPipe = CreateFile(fName, // pipe name | fNamedPipe = CreateFile(fName, // pipe name | ||||
| @@ -76,7 +76,7 @@ int JackWinNamedPipeClient::Connect(const char* dir, int which) | |||||
| int JackWinNamedPipeClient::Connect(const char* dir, const char* name, int which) | int JackWinNamedPipeClient::Connect(const char* dir, const char* name, int which) | ||||
| { | { | ||||
| sprintf(fName, "\\\\.\\pipe\\%s_jack_%s_%d", dir, name, which); | |||||
| snprintf(fName, sizeof(fName), "\\\\.\\pipe\\%s_jack_%s_%d", dir, name, which); | |||||
| jack_log("Connect: fName %s", fName); | jack_log("Connect: fName %s", fName); | ||||
| fNamedPipe = CreateFile(fName, // pipe name | fNamedPipe = CreateFile(fName, // pipe name | ||||
| @@ -226,7 +226,7 @@ int JackWinAsyncNamedPipeClient::Write(void* data, int len) | |||||
| int JackWinNamedPipeServer::Bind(const char* dir, int which) | int JackWinNamedPipeServer::Bind(const char* dir, int which) | ||||
| { | { | ||||
| sprintf(fName, "\\\\.\\pipe\\%s_jack_%d", dir, which); | |||||
| snprintf(fName, sizeof(fName), "\\\\.\\pipe\\%s_jack_%d", dir, which); | |||||
| jack_log("Bind: fName %s", fName); | jack_log("Bind: fName %s", fName); | ||||
| if ((fNamedPipe = CreateNamedPipe(fName, | if ((fNamedPipe = CreateNamedPipe(fName, | ||||
| @@ -248,7 +248,7 @@ int JackWinNamedPipeServer::Bind(const char* dir, int which) | |||||
| int JackWinNamedPipeServer::Bind(const char* dir, const char* name, int which) | int JackWinNamedPipeServer::Bind(const char* dir, const char* name, int which) | ||||
| { | { | ||||
| sprintf(fName, "\\\\.\\pipe\\%s_jack_%s_%d", dir, name, which); | |||||
| snprintf(fName, sizeof(fName), "\\\\.\\pipe\\%s_jack_%s_%d", dir, name, which); | |||||
| jack_log("Bind: fName %s", fName); | jack_log("Bind: fName %s", fName); | ||||
| if ((fNamedPipe = CreateNamedPipe(fName, | if ((fNamedPipe = CreateNamedPipe(fName, | ||||
| @@ -322,7 +322,7 @@ int JackWinNamedPipeServer::Close() | |||||
| int JackWinAsyncNamedPipeServer::Bind(const char* dir, int which) | int JackWinAsyncNamedPipeServer::Bind(const char* dir, int which) | ||||
| { | { | ||||
| sprintf(fName, "\\\\.\\pipe\\%s_jack_%d", dir, which); | |||||
| snprintf(fName, sizeof(fName), "\\\\.\\pipe\\%s_jack_%d", dir, which); | |||||
| jack_log("Bind: fName %s", fName); | jack_log("Bind: fName %s", fName); | ||||
| if ((fNamedPipe = CreateNamedPipe(fName, | if ((fNamedPipe = CreateNamedPipe(fName, | ||||
| @@ -344,7 +344,7 @@ int JackWinAsyncNamedPipeServer::Bind(const char* dir, int which) | |||||
| int JackWinAsyncNamedPipeServer::Bind(const char* dir, const char* name, int which) | int JackWinAsyncNamedPipeServer::Bind(const char* dir, const char* name, int which) | ||||
| { | { | ||||
| sprintf(fName, "\\\\.\\pipe\\%s_jack_%s_%d", dir, name, which); | |||||
| snprintf(fName, sizeof(fName), "\\\\.\\pipe\\%s_jack_%s_%d", dir, name, which); | |||||
| jack_log("Bind: fName %s", fName); | jack_log("Bind: fName %s", fName); | ||||
| if ((fNamedPipe = CreateNamedPipe(fName, | if ((fNamedPipe = CreateNamedPipe(fName, | ||||
| @@ -1,20 +1,20 @@ | |||||
| /* | /* | ||||
| Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
| This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
| the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
| (at your option) any later version. | (at your option) any later version. | ||||
| This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
| GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
| You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
| along with this program; if not, write to the Free Software | along with this program; if not, write to the Free Software | ||||
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
| */ | */ | ||||
| #include "JackWinSemaphore.h" | #include "JackWinSemaphore.h" | ||||
| @@ -26,11 +26,11 @@ | |||||
| namespace Jack | namespace Jack | ||||
| { | { | ||||
| void JackWinSemaphore::BuildName(const char* client_name, const char* server_name, char* res) | |||||
| void JackWinSemaphore::BuildName(const char* client_name, const char* server_name, char* res, int size) | |||||
| { | { | ||||
| char ext_client_name[JACK_CLIENT_NAME_SIZE + 1]; | char ext_client_name[JACK_CLIENT_NAME_SIZE + 1]; | ||||
| JackTools::RewriteName(client_name, ext_client_name); | JackTools::RewriteName(client_name, ext_client_name); | ||||
| sprintf(res, "jack_pipe.%s_%s", server_name, ext_client_name); | |||||
| snprintf(res, size, "jack_pipe.%s_%s", server_name, ext_client_name); | |||||
| } | } | ||||
| bool JackWinSemaphore::Signal() | bool JackWinSemaphore::Signal() | ||||
| @@ -88,7 +88,7 @@ bool JackWinSemaphore::TimedWait(long usec) | |||||
| // Client side : get the published semaphore from server | // Client side : get the published semaphore from server | ||||
| bool JackWinSemaphore::ConnectInput(const char* name, const char* server_name) | bool JackWinSemaphore::ConnectInput(const char* name, const char* server_name) | ||||
| { | { | ||||
| BuildName(name, server_name, fName); | |||||
| BuildName(name, server_name, fName, sizeof(fName)); | |||||
| jack_log("JackWinSemaphore::Connect %s", fName); | jack_log("JackWinSemaphore::Connect %s", fName); | ||||
| // Temporary... | // Temporary... | ||||
| @@ -129,7 +129,7 @@ bool JackWinSemaphore::Disconnect() | |||||
| bool JackWinSemaphore::Allocate(const char* name, const char* server_name, int value) | bool JackWinSemaphore::Allocate(const char* name, const char* server_name, int value) | ||||
| { | { | ||||
| BuildName(name, server_name, fName); | |||||
| BuildName(name, server_name, fName, sizeof(fName)); | |||||
| jack_log("JackWinSemaphore::Allocate name = %s val = %ld", fName, value); | jack_log("JackWinSemaphore::Allocate name = %s val = %ld", fName, value); | ||||
| if ((fSemaphore = CreateSemaphore(NULL, value, 32767, fName)) == NULL) { | if ((fSemaphore = CreateSemaphore(NULL, value, 32767, fName)) == NULL) { | ||||
| @@ -137,7 +137,7 @@ bool JackWinSemaphore::Allocate(const char* name, const char* server_name, int v | |||||
| return false; | return false; | ||||
| } else if (GetLastError() == ERROR_ALREADY_EXISTS) { | } else if (GetLastError() == ERROR_ALREADY_EXISTS) { | ||||
| jack_error("Allocate: named semaphore already exist name = %s", fName); | jack_error("Allocate: named semaphore already exist name = %s", fName); | ||||
| // Try to open it | |||||
| // Try to open it | |||||
| fSemaphore = OpenSemaphore(SEMAPHORE_ALL_ACCESS, FALSE, fName); | fSemaphore = OpenSemaphore(SEMAPHORE_ALL_ACCESS, FALSE, fName); | ||||
| return (fSemaphore != NULL); | return (fSemaphore != NULL); | ||||
| } else { | } else { | ||||
| @@ -1,20 +1,20 @@ | |||||
| /* | /* | ||||
| Copyright (C) 2004-2008 Grame | Copyright (C) 2004-2008 Grame | ||||
| This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | ||||
| the Free Software Foundation; either version 2.1 of the License, or | the Free Software Foundation; either version 2.1 of the License, or | ||||
| (at your option) any later version. | (at your option) any later version. | ||||
| This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
| GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | ||||
| You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | ||||
| along with this program; if not, write to the Free Software | along with this program; if not, write to the Free Software | ||||
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
| */ | */ | ||||
| @@ -41,7 +41,7 @@ class JackWinSemaphore : public detail::JackSynchro | |||||
| protected: | protected: | ||||
| void BuildName(const char* name, const char* server_name, char* res); | |||||
| void BuildName(const char* name, const char* server_name, char* res, int size); | |||||
| public: | public: | ||||